Revert the removal of PPCallbacks::PragmaComment() in r201821

The pp-trace clang tool was using it successfully.  We can still delete
the callbacks in Frontend/PrintPreprocessedOutput.cpp because they were
effectively dead.

llvm-svn: 201825
This commit is contained in:
Reid Kleckner 2014-02-20 23:37:45 +00:00
parent 2b0d66df24
commit 71966c99a5
2 changed files with 34 additions and 0 deletions

View File

@ -161,6 +161,18 @@ public:
PragmaIntroducerKind Introducer) {
}
/// \brief Callback invoked when a \#pragma comment directive is read.
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
const std::string &Str) {
}
/// \brief Callback invoked when a \#pragma detect_mismatch directive is
/// read.
virtual void PragmaDetectMismatch(SourceLocation Loc,
const std::string &Name,
const std::string &Value) {
}
/// \brief Callback invoked when a \#pragma clang __debug directive is read.
/// \param Loc The location of the debug directive.
/// \param DebugType The identifier following __debug.
@ -375,6 +387,19 @@ public:
Second->Ident(Loc, str);
}
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
const std::string &Str) {
First->PragmaComment(Loc, Kind, Str);
Second->PragmaComment(Loc, Kind, Str);
}
virtual void PragmaDetectMismatch(SourceLocation Loc,
const std::string &Name,
const std::string &Value) {
First->PragmaDetectMismatch(Loc, Name, Value);
Second->PragmaDetectMismatch(Loc, Name, Value);
}
virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace,
PragmaMessageKind Kind, StringRef Str) {
First->PragmaMessage(Loc, Namespace, Kind, Str);

View File

@ -1253,6 +1253,11 @@ void PragmaDetectMismatchHandler::HandlePragma(Preprocessor &PP,
return;
}
// If the pragma is lexically sound, notify any interested PPCallbacks.
if (PP.getPPCallbacks())
PP.getPPCallbacks()->PragmaDetectMismatch(CommentLoc, NameString,
ValueString);
Actions.ActOnPragmaDetectMismatch(NameString, ValueString);
}
@ -1323,5 +1328,9 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP,
return;
}
// If the pragma is lexically sound, notify any interested PPCallbacks.
if (PP.getPPCallbacks())
PP.getPPCallbacks()->PragmaComment(CommentLoc, II, ArgumentString);
Actions.ActOnPragmaMSComment(Kind, ArgumentString);
}