summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-02-24 20:50:36 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-02-24 20:50:36 +0000
commit5b2f7c5f604da111060cec778e59c89e017ac1e4 (patch)
tree3f8a6ab819b3c20ad75c7a98df3a0778db03162d /clang/lib/Frontend/PrintPreprocessedOutput.cpp
parentdec2c8657ef3195ec7494fe13ab912d5cdb23fcb (diff)
downloadbcm5719-llvm-5b2f7c5f604da111060cec778e59c89e017ac1e4.tar.gz
bcm5719-llvm-5b2f7c5f604da111060cec778e59c89e017ac1e4.zip
If preprocessing results in a token with leading whitespace that was expanded
from a macro in column 0, ensure that we print whitespace before it in the -E output. Patch by Harald van Dijk! llvm-svn: 202070
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r--clang/lib/Frontend/PrintPreprocessedOutput.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index fd470ec5fdb..489227d9d7e 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -521,6 +521,13 @@ bool PrintPPOutputPPCallbacks::HandleFirstTokOnLine(Token &Tok) {
// indented for easy reading.
unsigned ColNo = SM.getExpansionColumnNumber(Tok.getLocation());
+ // The first token on a line can have a column number of 1, yet still expect
+ // leading white space, if a macro expansion in column 1 starts with an empty
+ // macro argument, or an empty nested macro expansion. In this case, move the
+ // token to column 2.
+ if (ColNo == 1 && Tok.hasLeadingSpace())
+ ColNo = 2;
+
// This hack prevents stuff like:
// #define HASH #
// HASH define foo bar
OpenPOWER on IntegriCloud