r202068 - If the first token in a macro that appears at the start of a line expands to
Richard Smith
richard-llvm at metafoo.co.uk
Mon Feb 24 12:45:01 PST 2014
Author: rsmith
Date: Mon Feb 24 14:45:00 2014
New Revision: 202068
URL: http://llvm.org/viewvc/llvm-project?rev=202068&view=rev
Log:
If the first token in a macro that appears at the start of a line expands to
nothing, be sure to inform the *next* token expanded from the macro that it is
now at the start of a line. Patch by Harald van Dijk!
Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Preprocessor/macro_expand_empty.c
Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=202068&r1=202067&r2=202068&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Mon Feb 24 14:45:00 2014
@@ -474,6 +474,7 @@ bool TokenLexer::Lex(Token &Tok) {
} else {
// If this is not the first token, we may still need to pass through
// leading whitespace if we've expanded a macro.
+ if (AtStartOfLine) Tok.setFlag(Token::StartOfLine);
if (HasLeadingSpace) Tok.setFlag(Token::LeadingSpace);
}
AtStartOfLine = false;
Modified: cfe/trunk/test/Preprocessor/macro_expand_empty.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_expand_empty.c?rev=202068&r1=202067&r2=202068&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/macro_expand_empty.c (original)
+++ cfe/trunk/test/Preprocessor/macro_expand_empty.c Mon Feb 24 14:45:00 2014
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
+
// Check that this doesn't crash
#define IDENTITY1(x) x
@@ -12,3 +13,9 @@
#define IDENTITY9(x) IDENTITY8(x) IDENTITY8(x) IDENTITY8(x) IDENTITY8(x)
#define IDENTITY0(x) IDENTITY9(x) IDENTITY9(x) IDENTITY9(x) IDENTITY9(x)
IDENTITY0()
+
+#define FOO() BAR() second
+#define BAR()
+first // CHECK: {{^}}first{{$}}
+FOO() // CHECK: second
+third // CHECK: {{^}}third{{$}}
More information about the cfe-commits
mailing list