PR4288: Make -dD (dump macros with preprocessed source) play nicely with

# line directives.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72724 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman 2009-06-02 07:55:39 +00:00
Родитель 354e53da65
Коммит 3e753e279d
2 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -87,6 +87,7 @@ public:
private:
unsigned CurLine;
bool EmittedTokensOnThisLine;
bool EmittedMacroOnThisLine;
SrcMgr::CharacteristicKind FileType;
llvm::SmallString<512> CurFilename;
bool Initialized;
@ -100,6 +101,7 @@ public:
CurLine = 0;
CurFilename += "<uninit>";
EmittedTokensOnThisLine = false;
EmittedMacroOnThisLine = false;
FileType = SrcMgr::C_User;
Initialized = false;
}
@ -130,9 +132,10 @@ public:
void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
const char *Extra,
unsigned ExtraLen) {
if (EmittedTokensOnThisLine) {
if (EmittedTokensOnThisLine || EmittedMacroOnThisLine) {
OS << '\n';
EmittedTokensOnThisLine = false;
EmittedMacroOnThisLine = false;
}
OS << '#' << ' ' << LineNo << ' ' << '"';
@ -161,11 +164,12 @@ bool PrintPPOutputPPCallbacks::MoveToLine(SourceLocation Loc) {
CurLine = LineNo;
if (!EmittedTokensOnThisLine)
if (!EmittedTokensOnThisLine && !EmittedMacroOnThisLine)
return true;
OS << '\n';
EmittedTokensOnThisLine = false;
EmittedMacroOnThisLine = false;
return true;
}
@ -260,6 +264,7 @@ void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II,
MoveToLine(MI->getDefinitionLoc());
PrintMacroDefinition(*II, *MI, PP, OS);
EmittedMacroOnThisLine = true;
}

Просмотреть файл

@ -0,0 +1,13 @@
// RUN: clang-cc -E -dD < %s | grep stdin | grep -v define
#define A A
/* 1
* 2
* 3
* 4
* 5
* 6
* 7
* 8
*/
#define B B