[PATCH] D55782: Fix isInSystemMacro to handle pasted token

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 28 11:05:57 PST 2019


rsmith added inline comments.


================
Comment at: include/clang/Basic/SourceManager.h:1458-1460
+	    // 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.
+            isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc))));
----------------
I think this also matches things like:

```
// system header
#define BAR FOO

// user code
#define FOO x
BAR
```

... where the location of `x` token produced by the `BAR` macro will now be considered to be in a system macro. Can you make this more targeted? (Maybe we could change the `SLocEntry` for the token-paste scratch buffer to be considered a system header if the `##` token is in a system macro -- that'll need the preprocessor to store two `ScratchBuffer`s, one for system headers and one for user code, but that seems acceptable.)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55782/new/

https://reviews.llvm.org/D55782





More information about the cfe-commits mailing list