]> granicus.if.org Git - clang/commitdiff
Revert the removal of PPCallbacks::PragmaComment() in r201821
authorReid Kleckner <reid@kleckner.net>
Thu, 20 Feb 2014 23:37:45 +0000 (23:37 +0000)
committerReid Kleckner <reid@kleckner.net>
Thu, 20 Feb 2014 23:37:45 +0000 (23:37 +0000)
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

include/clang/Lex/PPCallbacks.h
lib/Parse/ParsePragma.cpp

index dc58573352619490f6ed3d0ffe80e213f5a0be77..f1ed897251bb83e80cfc99abbbd4ab91603e6d10 100644 (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);
index f5491fff9b5efb5a480e3b6d80672c96aa0dcdcc..6a1b5fff54a79bdefd58ab1a8353843d3c014107 100644 (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);
 }