fix PR3798 by ignoring all diagnostics generated while repreprocessing a file in rewrite macros.
llvm-svn: 66961
This commit is contained in:
parent
8bd06d8e1b
commit
e07ea35817
|
@ -197,6 +197,9 @@ public:
|
|||
~Preprocessor();
|
||||
|
||||
Diagnostic &getDiagnostics() const { return *Diags; }
|
||||
void setDiagnostics(Diagnostic &D) { Diags = &D; }
|
||||
|
||||
|
||||
const LangOptions &getLangOptions() const { return Features; }
|
||||
TargetInfo &getTargetInfo() const { return Target; }
|
||||
FileManager &getFileManager() const { return FileMgr; }
|
||||
|
|
|
@ -424,6 +424,17 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// IgnoringDiagClient - This is a diagnostic client that just ignores all
|
||||
/// diags.
|
||||
class IgnoringDiagClient : public DiagnosticClient {
|
||||
void HandleDiagnostic(Diagnostic::Level DiagLevel,
|
||||
const DiagnosticInfo &Info) {
|
||||
// Just ignore it.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// HighlightMacros - This uses the macro table state from the end of the
|
||||
/// file, to re-expand macros and insert (into the HTML) information about the
|
||||
/// macro expansions. This won't be perfectly perfect, but it will be
|
||||
|
@ -466,6 +477,14 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
|
|||
if (Tok.is(tok::eof)) break;
|
||||
}
|
||||
|
||||
// Temporarily change the diagnostics object so that we ignore any generated
|
||||
// diagnostics from this pass.
|
||||
IgnoringDiagClient TmpDC;
|
||||
Diagnostic TmpDiags(&TmpDC);
|
||||
|
||||
Diagnostic *OldDiags = &PP.getDiagnostics();
|
||||
PP.setDiagnostics(TmpDiags);
|
||||
|
||||
// Inform the preprocessor that we don't want comments.
|
||||
PP.SetCommentRetentionState(false, false);
|
||||
|
||||
|
@ -542,6 +561,9 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
|
|||
HighlightRange(R, LLoc.first, LLoc.second,
|
||||
"<span class='macro'>", Expansion.c_str());
|
||||
}
|
||||
|
||||
// Restore diagnostics object back to its own thing.
|
||||
PP.setDiagnostics(*OldDiags);
|
||||
}
|
||||
|
||||
void html::HighlightMacros(Rewriter &R, FileID FID,
|
||||
|
|
|
@ -9,3 +9,10 @@ int main(int argc, char **argv) {
|
|||
return F(argc, 1);
|
||||
}
|
||||
|
||||
// PR3798
|
||||
#define FOR_ALL_FILES(f,i) i
|
||||
|
||||
#if 0
|
||||
FOR_ALL_FILES(f) { }
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue