Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Handle general CV-qualifier case for new expressions with the Use Auto Transform #15618

Open Quuxplusone opened 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR15618
Status NEW
Importance P enhancement
Reported by Edwin Vane (edwin.vane@intel.com)
Reported on 2013-03-28 11:19:30 -0700
Last modified on 2018-11-10 04:08:38 -0800
Version unspecified
Hardware All All
CC alexfh@google.com, development@jonas-toth.eu, djasper@google.com, edwin.vane@intel.com, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Currently, the Use Auto Transform will only transform a statement like:

MyType *a = new MyType();
=>
auto a = new MyType();
MyType * const b = new MyType();
=>
const auto b = new MyType();

if type of the variable declaration is exactly the same as the type returned by
the new expression and the pointee type is not CV-qualified. However, there are
several other cases that could be handled:

const MyType *a = new MyType();
=>
const auto *a = new MyType();
const MyType * const b = new MyType();
=>
const auto * const b = new MyType();
const MyType *a = new const MyType();
=>
auto c = new const MyType();

etc...

The currently can't be handled because clang doesn't provide enough source
location information as part of the TypeLoc. In particular, CV-qualifiers are
not considered as part of the TypeLoc. If one were to re-write the entire
declaration specifier there are two problems:
1) While clang provides the start of the declaration, it doesn't provide the
end of the declaration specifier. The start of the initializer is not good
enough because then we have to worry about the initialization style.
2) The type specifier is not the only thing to worry about in the declaration
specifier: attributes and storage class specifiers are also a concern for
variable declarations.
Quuxplusone commented 9 years ago

The transform has been migrated to clang-tidy (http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html). The request still seems relevant.

Quuxplusone commented 5 years ago

This will be partially addressed by the const-transformations coming with https://reviews.llvm.org/D45444