diff options
-rw-r--r-- | clang/include/clang/Lex/PPCallbacks.h | 25 | ||||
-rw-r--r-- | clang/lib/Parse/ParsePragma.cpp | 9 |
2 files changed, 34 insertions, 0 deletions
diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h index dc585733526..f1ed897251b 100644 --- a/clang/include/clang/Lex/PPCallbacks.h +++ b/clang/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/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp index f5491fff9b5..6a1b5fff54a 100644 --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/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); } |