Author: serge_sans_paille Date: Thu May 16 05:40:00 2019 New Revision: 360885
URL: http://llvm.org/viewvc/llvm-project?rev=360885&view=rev Log: 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 Modified: cfe/trunk/include/clang/Basic/SourceManager.h cfe/trunk/test/Misc/no-warn-in-system-macro.c Modified: cfe/trunk/include/clang/Basic/SourceManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=360885&r1=360884&r2=360885&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceManager.h (original) +++ cfe/trunk/include/clang/Basic/SourceManager.h Thu May 16 05:40:00 2019 @@ -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)); } Modified: cfe/trunk/test/Misc/no-warn-in-system-macro.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/no-warn-in-system-macro.c?rev=360885&r1=360884&r2=360885&view=diff ============================================================================== --- cfe/trunk/test/Misc/no-warn-in-system-macro.c (original) +++ cfe/trunk/test/Misc/no-warn-in-system-macro.c Thu May 16 05:40:00 2019 @@ -3,11 +3,16 @@ #include <no-warn-in-system-macro.c.inc> +#define MACRO(x) x + int main(void) { double foo = 1.0; if (isnan(foo)) return 1; - return 0; + + MACRO(isnan(foo)); + + return 0; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits