summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-02-24 20:45:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-02-24 20:45:00 +0000
commitf2baa70396a9071b859a9616c2017c8286aff4cc (patch)
treed310872ddcf81e1c2c129d4c6c88aa92380e6909 /clang
parent9611d23d6379eafb9c3fd4d3a878460ff05733d0 (diff)
downloadbcm5719-llvm-f2baa70396a9071b859a9616c2017c8286aff4cc.tar.gz
bcm5719-llvm-f2baa70396a9071b859a9616c2017c8286aff4cc.zip
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! llvm-svn: 202068
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/TokenLexer.cpp1
-rw-r--r--clang/test/Preprocessor/macro_expand_empty.c9
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index 316fba76ccd..40e9707b7b8 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/lib/Lex/TokenLexer.cpp
@@ -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;
diff --git a/clang/test/Preprocessor/macro_expand_empty.c b/clang/test/Preprocessor/macro_expand_empty.c
index 3fb6394dc9e..c3fc4f2964e 100644
--- a/clang/test/Preprocessor/macro_expand_empty.c
+++ b/clang/test/Preprocessor/macro_expand_empty.c
@@ -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{{$}}
OpenPOWER on IntegriCloud