Skip to content
Snippets Groups Projects
Commit e1614bb0 authored by Chris Lattner's avatar Chris Lattner
Browse files

apply Eli's patch to fix PR4008, with a testcase. Thanks Eli!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69750 91177308-0d34-0410-b5e6-96231b3b80d8
parent 914d3db2
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,14 @@ static char GetFirstChar(Preprocessor &PP, const Token &Tok) { ...@@ -126,6 +126,14 @@ static char GetFirstChar(Preprocessor &PP, const Token &Tok) {
/// don't want to track enough to tell "x.." from "...". /// don't want to track enough to tell "x.." from "...".
bool TokenConcatenation::AvoidConcat(const Token &PrevTok, bool TokenConcatenation::AvoidConcat(const Token &PrevTok,
const Token &Tok) const { const Token &Tok) const {
// 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
// were an issue, the tokens would have been lexed differently.
if (PrevTok.getLocation().isFileID() && Tok.getLocation().isFileID() &&
PrevTok.getLocation().getFileLocWithOffset(PrevTok.getLength()) ==
Tok.getLocation())
return false;
tok::TokenKind PrevKind = PrevTok.getKind(); tok::TokenKind PrevKind = PrevTok.getKind();
if (PrevTok.getIdentifierInfo()) // Language keyword or named operator. if (PrevTok.getIdentifierInfo()) // Language keyword or named operator.
PrevKind = tok::identifier; PrevKind = tok::identifier;
......
// RUN: clang-cc -E %s | grep '+ + - - + + = = =' && // RUN: clang-cc -E %s -o %t &&
// RUN: clang-cc -E %s | not grep -F '...' &&
// RUN: clang-cc -E %s | not grep -F 'L"str"'
// This should print as ".. ." to avoid turning into ... // This should print as ".. ." to avoid turning into ...
// RUN: grep -F 'A: . . .' %t &&
#define y(a) ..a #define y(a) ..a
y(.) A: y(.)
// RUN: grep -F 'C: .. .' %t &&
#define DOT .
C: ..DOT
// RUN: grep -F 'D: + + - - + + = = =' %t &&
#define PLUS + #define PLUS +
#define EMPTY #define EMPTY
#define f(x) =x= #define f(x) =x=
+PLUS -EMPTY- PLUS+ f(=) D: +PLUS -EMPTY- PLUS+ f(=)
// RUN: grep -F 'E: L "str"' %t
// Should expand to L "str" not L"str" // Should expand to L "str" not L"str"
#define test(x) L#x #define test(x) L#x
test(str) E: test(str)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment