[cfe-commits] r69750 - in /cfe/trunk: lib/Lex/TokenConcatenation.cpp test/Preprocessor/output_paste_avoid.c
Chris Lattner
sabre at nondot.org
Tue Apr 21 16:28:41 PDT 2009
Author: lattner
Date: Tue Apr 21 18:28:41 2009
New Revision: 69750
URL: http://llvm.org/viewvc/llvm-project?rev=69750&view=rev
Log:
apply Eli's patch to fix PR4008, with a testcase. Thanks Eli!
Modified:
cfe/trunk/lib/Lex/TokenConcatenation.cpp
cfe/trunk/test/Preprocessor/output_paste_avoid.c
Modified: cfe/trunk/lib/Lex/TokenConcatenation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenConcatenation.cpp?rev=69750&r1=69749&r2=69750&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenConcatenation.cpp (original)
+++ cfe/trunk/lib/Lex/TokenConcatenation.cpp Tue Apr 21 18:28:41 2009
@@ -126,6 +126,14 @@
/// don't want to track enough to tell "x.." from "...".
bool TokenConcatenation::AvoidConcat(const Token &PrevTok,
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();
if (PrevTok.getIdentifierInfo()) // Language keyword or named operator.
PrevKind = tok::identifier;
Modified: cfe/trunk/test/Preprocessor/output_paste_avoid.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/output_paste_avoid.c?rev=69750&r1=69749&r2=69750&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/output_paste_avoid.c (original)
+++ cfe/trunk/test/Preprocessor/output_paste_avoid.c Tue Apr 21 18:28:41 2009
@@ -1,18 +1,23 @@
-// RUN: clang-cc -E %s | grep '+ + - - + + = = =' &&
-// RUN: clang-cc -E %s | not grep -F '...' &&
-// RUN: clang-cc -E %s | not grep -F 'L"str"'
-
+// RUN: clang-cc -E %s -o %t &&
// This should print as ".. ." to avoid turning into ...
+// RUN: grep -F 'A: . . .' %t &&
#define y(a) ..a
-y(.)
+A: y(.)
+
+// RUN: grep -F 'C: .. .' %t &&
+#define DOT .
+C: ..DOT
+
+// RUN: grep -F 'D: + + - - + + = = =' %t &&
#define PLUS +
#define EMPTY
#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"
#define test(x) L#x
-test(str)
+E: test(str)
More information about the cfe-commits
mailing list