From: Reid Kleckner Date: Thu, 20 Feb 2014 23:37:45 +0000 (+0000) Subject: Revert the removal of PPCallbacks::PragmaComment() in r201821 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=484a61d841284596753ac84c71983aeb468cff2a;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201825 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index dc58573352..f1ed897251 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -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); diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp index f5491fff9b..6a1b5fff54 100644 --- a/lib/Parse/ParsePragma.cpp +++ b/lib/Parse/ParsePragma.cpp @@ -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); }