[PATCH] D116793: [AST] Add more source information for DecltypeTypeLoc.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 6 23:42:44 PST 2022


hokein added inline comments.


================
Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1012
+    // token doesn't have it.
+    DS.setTypeofParensRange(SourceRange(SourceLocation(), EndLoc));
     ConsumeAnnotationToken();
----------------
This is unfortunate for a common case `decltype(expression) a;`, the `ParseDecltypeSpecifier` is called twice to parse the decltype specifier: 

- first time, we parse the raw decltype token, and we annotate that (the `DS` was created locally, and then was thrown away)
- second time, we parsed the annotated decltype, and set another `DS`, at this point, we lost the LParen information :(

One way to fix that is to add a new field `SourceLocation` in `Token` class (there is 4-bytes padding size left, so it won't increase its size), but I'm a little worried, it seems like an overkill to just fix this issue. 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116793



More information about the cfe-commits mailing list