aaron.ballman added inline comments.

================
Comment at: clang/test/FixIt/fixit-const-var-init.cpp:24
+
+template <> constexpr float d<int, float>; // expected-error {{must be 
initialized by a constant expression}}
+// CHECK: fix-it:"{{.*}}":{24:42-24:42}:" = 0.0"
----------------
v1nh1shungry wrote:
> aaron.ballman wrote:
> > I'd like to see some additional test coverage for more complicated 
> > declarators:
> > ```
> > void (* const func)(int, int);
> > const int var [[clang::annotate("")]];
> > ```
> One more question: I just did the second test
> 
> ```
> const int var [[clang::annotate("")]];
> ```
> 
> and it inserted the fix hint after the identifier.
> 
> Is this the expected behavior of `getEndLoc()`?
@erichkeane and I talked about this off-list because it's a bit of an academic 
question as to whether an attribute is "part" of a declaration or not. We 
ultimately decided that we think it's best for the attribute to *not* be 
considered part of the source range of the variable declaration; they are 
wholly separate AST nodes.

So based on that, we think you will need some changes to SemaInit.cpp after 
all. And you'll have to use `SourceManager::isBeforeInTranslationUnit()` to 
determine if the begin source location of the attribute is after the end source 
location of the variable or not (because the attribute could go before the type 
information or after the variable name).

There's another test case to consider that hopefully will Just Work with this 
design, but is worth testing explicitly:
```
void (* const func [[clang::annotate("test")]])(int, int);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139705/new/

https://reviews.llvm.org/D139705

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to