[PATCH] D153914: [clang-cl] Enable concatenation of predefined identifiers
Richard Dzenis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 14 06:33:23 PDT 2023
RIscRIpt updated this revision to Diff 540395.
RIscRIpt added a comment.
Addressed review comments.
In D153914#4497696 <https://reviews.llvm.org/D153914#4497696>, @aaron.ballman wrote:
> Sema seems like the wrong place to perform such concatenations, but given that adjacent string literals are concatenated during phase 6...
I agree, but I couldn't come up with anything better (having limited knowledge about Clang).
Other possible //ugly// solution: make actual concatenation in `StringLiteralParser`, but this would require either of:
1. Pass `Decl*` into `StringLiteralParser` - this requires dependency (and linkage) of Lex with AST.
2. Pre-calculate function names for all possible types of tokens (`__FUNCTION__`, `__FUNCDNAME__`, etc.) in `ActOnStringLiteral` and pass into `StringLiteralParser`
3. Find other way of obtaining __current__ function name in Lex.
One may wish to expand these macros during phase (4), but these macros are predefined identifiers in non-MSVC compilers, and MSVC don't expand them as macros (`-E` compiler flag); and we don't have knowledge about AST (not to mention the function name) during phase (4).
In D153914#4497696 <https://reviews.llvm.org/D153914#4497696>, @aaron.ballman wrote:
> I'm not certain it's actually observable.
I didn't understand this part.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153914/new/
https://reviews.llvm.org/D153914
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TokenKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/ms_predefined_expr.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153914.540395.patch
Type: text/x-patch
Size: 17148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230714/5c11ab9a/attachment.bin>
More information about the cfe-commits
mailing list