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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits