[PATCH] D140164: [clang/Lexer] Enhance `Lexer::getImmediateMacroNameForDiagnostics` to return a result from non-file buffers
Argyrios Kyrtzidis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 15 15:31:37 PST 2022
akyrtzi updated this revision to Diff 483370.
akyrtzi added a comment.
Adjust code comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140164/new/
https://reviews.llvm.org/D140164
Files:
clang/lib/Lex/Lexer.cpp
clang/test/Modules/build-fail-notes.m
clang/test/Modules/epic-fail.m
Index: clang/test/Modules/epic-fail.m
===================================================================
--- clang/test/Modules/epic-fail.m
+++ clang/test/Modules/epic-fail.m
@@ -6,7 +6,7 @@
// CHECK: While building module 'Module' imported from
// CHECK: error: expected ';' after top level declarator
-// CHECK: note: expanded from here
+// CHECK: note: expanded from macro 'getModuleVersion'
// CHECK: fatal error: could not build module 'Module'
// CHECK: While building module 'DependsOnModule' imported from
// CHECK: fatal error: could not build module 'Module'
Index: clang/test/Modules/build-fail-notes.m
===================================================================
--- clang/test/Modules/build-fail-notes.m
+++ clang/test/Modules/build-fail-notes.m
@@ -6,7 +6,7 @@
// CHECK: While building module 'DependsOnModule' imported from
// CHECK: While building module 'Module' imported from
// CHECK: error: expected ';' after top level declarator
-// CHECK: note: expanded from here
+// CHECK: note: expanded from macro 'getModuleVersion'
// CHECK: fatal error: could not build module 'Module'
// CHECK: fatal error: could not build module 'DependsOnModule'
// CHECK-NOT: error:
@@ -24,7 +24,7 @@
// CHECK-SDIAG: Module.h:9:13: error: expected ';' after top level declarator
// CHECK-SDIAG: build-fail-notes.m:4:9: note: while building module 'DependsOnModule' imported from
// CHECK-SDIAG: DependsOnModule.h:1:10: note: while building module 'Module' imported from
-// CHECK-SDIAG: note: expanded from here
+// CHECK-SDIAG: note: expanded from macro 'getModuleVersion'
// CHECK-SDIAG: warning: umbrella header for module 'Module' does not include header 'NotInModule.h' [-Wincomplete-umbrella]
// CHECK-SDIAG: DependsOnModule.h:1:10: fatal: could not build module 'Module'
// CHECK-SDIAG: build-fail-notes.m:4:9: note: while building module 'DependsOnModule' imported from
Index: clang/lib/Lex/Lexer.cpp
===================================================================
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1047,9 +1047,11 @@
while (SM.isMacroArgExpansion(Loc))
Loc = SM.getImmediateExpansionRange(Loc).getBegin();
- // If the macro's spelling has no FileID, then it's actually a token paste
- // or stringization (or similar) and not a macro at all.
- if (!SM.getFileEntryForID(SM.getFileID(SM.getSpellingLoc(Loc))))
+ // If the macro's spelling isn't FileID or from scratch space, then it's
+ // actually a token paste or stringization (or similar) and not a macro at
+ // all.
+ SourceLocation SpellLoc = SM.getSpellingLoc(Loc);
+ if (!SpellLoc.isFileID() || SM.isWrittenInScratchSpace(SpellLoc))
return {};
// Find the spelling location of the start of the non-argument expansion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140164.483370.patch
Type: text/x-patch
Size: 2769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221215/d785b33d/attachment.bin>
More information about the cfe-commits
mailing list