forked from OSchip/llvm-project
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
This commit is contained in:
parent
dec2c8657e
commit
5b2f7c5f60
|
@ -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
|
||||
|
|
|
@ -17,5 +17,5 @@ IDENTITY0()
|
|||
#define FOO() BAR() second
|
||||
#define BAR()
|
||||
first // CHECK: {{^}}first{{$}}
|
||||
FOO() // CHECK: second
|
||||
FOO() // CHECK: {{^}} second{{$}}
|
||||
third // CHECK: {{^}}third{{$}}
|
||||
|
|
Loading…
Reference in New Issue