зеркало из https://github.com/microsoft/clang-1.git
[Preprocessor] When checking if we can concatenate two tokens, check
if they were already concatenated in source using the spelling locations even if they came from a macro expansion. This fixes an issue where a GUID passed as macro argument ends up malformed after preprocessing because we added spaces inside it. rdar://13016645 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173826 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a16355c318
Коммит
fcf896078e
|
@ -156,9 +156,10 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok,
|
||||||
// First, check to see if the tokens were directly adjacent in the original
|
// First, check to see if the tokens were directly adjacent in the original
|
||||||
// source. If they were, it must be okay to stick them together: if there
|
// source. If they were, it must be okay to stick them together: if there
|
||||||
// were an issue, the tokens would have been lexed differently.
|
// were an issue, the tokens would have been lexed differently.
|
||||||
if (PrevTok.getLocation().isFileID() && Tok.getLocation().isFileID() &&
|
SourceManager &SM = PP.getSourceManager();
|
||||||
PrevTok.getLocation().getLocWithOffset(PrevTok.getLength()) ==
|
SourceLocation PrevSpellLoc = SM.getSpellingLoc(PrevTok.getLocation());
|
||||||
Tok.getLocation())
|
SourceLocation SpellLoc = SM.getSpellingLoc(Tok.getLocation());
|
||||||
|
if (PrevSpellLoc.getLocWithOffset(PrevTok.getLength()) == SpellLoc)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
tok::TokenKind PrevKind = PrevTok.getKind();
|
tok::TokenKind PrevKind = PrevTok.getKind();
|
||||||
|
|
|
@ -31,3 +31,9 @@ E: test(str)
|
||||||
#define equal =
|
#define equal =
|
||||||
F: >>equal
|
F: >>equal
|
||||||
// CHECK: F: >> =
|
// CHECK: F: >> =
|
||||||
|
|
||||||
|
// Make sure we don't introduce spaces in the guid because we try to avoid
|
||||||
|
// pasting '-' to a numeric constant.
|
||||||
|
#define TYPEDEF(guid) typedef [uuid(guid)]
|
||||||
|
TYPEDEF(66504301-BE0F-101A-8BBB-00AA00300CAB) long OLE_COLOR;
|
||||||
|
// CHECK: typedef [uuid(66504301-BE0F-101A-8BBB-00AA00300CAB)] long OLE_COLOR;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче