summaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorSerge Guelton <sguelton@redhat.com>2019-05-16 12:40:00 +0000
committerSerge Guelton <sguelton@redhat.com>2019-05-16 12:40:00 +0000
commiteffb4994daa210879cc375c55141296e93b27534 (patch)
treeffc1e6fb71556473a2da7a482c397504376334f0 /include/clang/Basic/SourceManager.h
parentc0478341937c33b16056e9ce28d6134afbd91693 (diff)
downloadclang-effb4994daa210879cc375c55141296e93b27534.tar.gz
Fix isInSystemMacro in presence of macro and pasted token
When a warning is raised from the expansion of a system macro that involves pasted token, there was still situations were they were not skipped, as showcased by this issue: https://bugzilla.redhat.com/show_bug.cgi?id=1472437 Differential Revision: https://reviews.llvm.org/D59413 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 484889ea54..388fc1c1f8 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -1466,8 +1466,13 @@ public:
// This happens when the macro is the result of a paste, in that case
// its spelling is the scratch memory, so we take the parent context.
- if (isWrittenInScratchSpace(getSpellingLoc(loc)))
- return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+ // There can be several level of token pasting.
+ if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+ do {
+ loc = getImmediateMacroCallerLoc(loc);
+ } while (isWrittenInScratchSpace(getSpellingLoc(loc)));
+ return isInSystemMacro(loc);
+ }
return isInSystemHeader(getSpellingLoc(loc));
}