]> granicus.if.org Git - clang/commitdiff
[Preprocessor] For the MacroExpands preprocessor callback, also pass the MacroArgs...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 3 May 2013 22:31:32 +0000 (22:31 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 3 May 2013 22:31:32 +0000 (22:31 +0000)
the argument tokens for a function macro.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181065 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/MacroArgs.h [moved from lib/Lex/MacroArgs.h with 100% similarity]
include/clang/Lex/PPCallbacks.h
include/clang/Lex/PreprocessingRecord.h
lib/ARCMigrate/ARCMT.cpp
lib/Lex/MacroArgs.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Lex/PreprocessingRecord.cpp
lib/Lex/Preprocessor.cpp
lib/Lex/TokenLexer.cpp
tools/libclang/Indexing.cpp
unittests/Basic/SourceManagerTest.cpp

index 45deb1756d65fd35ffd7938b225e40bcfdc65103..db2ecd247f40b650c2ac421e573bcada19bc36ec 100644 (file)
@@ -27,6 +27,7 @@ namespace clang {
   class Token;
   class IdentifierInfo;
   class MacroDirective;
+  class MacroArgs;
 
 /// \brief This interface provides a way to observe the actions of the
 /// preprocessor as it does its thing.
@@ -206,7 +207,7 @@ public:
   /// \brief Called by Preprocessor::HandleMacroExpandedIdentifier when a
   /// macro invocation is found.
   virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
-                            SourceRange Range) {
+                            SourceRange Range, const MacroArgs *Args) {
   }
 
   /// \brief Hook called whenever a macro definition is seen.
@@ -376,9 +377,9 @@ public:
   }
 
   virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
-                            SourceRange Range) {
-    First->MacroExpands(MacroNameTok, MD, Range);
-    Second->MacroExpands(MacroNameTok, MD, Range);
+                            SourceRange Range, const MacroArgs *Args) {
+    First->MacroExpands(MacroNameTok, MD, Range, Args);
+    Second->MacroExpands(MacroNameTok, MD, Range, Args);
   }
 
   virtual void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) {
index b13b2be7f3170984887f11941bf7695c320e7ba0..db74352aa81ece2d31b76062b2976295048aa671 100644 (file)
@@ -559,7 +559,7 @@ namespace clang {
         
   private:
     virtual void MacroExpands(const Token &Id, const MacroDirective *MD,
-                              SourceRange Range);
+                              SourceRange Range, const MacroArgs *Args);
     virtual void MacroDefined(const Token &Id, const MacroDirective *MD);
     virtual void MacroUndefined(const Token &Id, const MacroDirective *MD);
     virtual void InclusionDirective(SourceLocation HashLoc,
index 72f35205ca8e92d4fa70466d112f62a71b277e13..fb452cdc73f70204ee26b845f020eb490355b9d3 100644 (file)
@@ -482,7 +482,7 @@ public:
     : ARCMTMacroLocs(ARCMTMacroLocs) { }
 
   virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
-                            SourceRange Range) {
+                            SourceRange Range, const MacroArgs *Args) {
     if (MacroNameTok.getIdentifierInfo()->getName() == getARCMTMacroName())
       ARCMTMacroLocs.push_back(MacroNameTok.getLocation());
   }
index f6e781a936d47f7bd43c5142674a4aa55393556c..d2dc04b36cf7d4d8f37c0f316fa68109e86d485f 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "MacroArgs.h"
+#include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
index e5b00d6bb88e9799a7a0ae6c0be38c04e6a5d0aa..167823358afe0c47d8aad1330ff3eeef20497d79 100644 (file)
@@ -13,7 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Lex/Preprocessor.h"
-#include "MacroArgs.h"
+#include "clang/Lex/MacroArgs.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
@@ -223,7 +223,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
   // If this is a builtin macro, like __LINE__ or _Pragma, handle it specially.
   if (MI->isBuiltinMacro()) {
     if (Callbacks) Callbacks->MacroExpands(Identifier, MD,
-                                           Identifier.getLocation());
+                                           Identifier.getLocation(),/*Args=*/0);
     ExpandBuiltinMacro(Identifier);
     return false;
   }
@@ -277,11 +277,12 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
       DelayedMacroExpandsCallbacks.push_back(
                               MacroExpandsInfo(Identifier, MD, ExpansionRange));
     } else {
-      Callbacks->MacroExpands(Identifier, MD, ExpansionRange);
+      Callbacks->MacroExpands(Identifier, MD, ExpansionRange, Args);
       if (!DelayedMacroExpandsCallbacks.empty()) {
         for (unsigned i=0, e = DelayedMacroExpandsCallbacks.size(); i!=e; ++i) {
           MacroExpandsInfo &Info = DelayedMacroExpandsCallbacks[i];
-          Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range);
+          // FIXME: We lose macro args info with delayed callback.
+          Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range, /*Args=*/0);
         }
         DelayedMacroExpandsCallbacks.clear();
       }
index b10e7f7beeecb73130c5e7c198e9b14ccd255721..426b922562644b2685c91f7980c29e7361ad1b1c 100644 (file)
@@ -406,7 +406,8 @@ void PreprocessingRecord::Defined(const Token &MacroNameTok,
 }
 
 void PreprocessingRecord::MacroExpands(const Token &Id,const MacroDirective *MD,
-                                       SourceRange Range) {
+                                       SourceRange Range,
+                                       const MacroArgs *Args) {
   addMacroExpansion(Id, MD->getMacroInfo(), Range);
 }
 
index 09f827991dc3730e364885c70ca998aa6e6073a7..66f23f1018860749a56b979394a16f98f8bc8fa8 100644 (file)
@@ -26,7 +26,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Lex/Preprocessor.h"
-#include "MacroArgs.h"
+#include "clang/Lex/MacroArgs.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
index 5b41fe9b8d3f2a77def2edb5993cb0b4bef95dcd..07753c7d7c36cc946f673161550ffa9a0eebf671 100644 (file)
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Lex/TokenLexer.h"
-#include "MacroArgs.h"
+#include "clang/Lex/MacroArgs.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/MacroInfo.h"
index 2a504db2a49cefaa5ae817a0042ab8d37cd95f1e..27d8b8327f67c5074f54209580bd1a500a4e2264 100644 (file)
@@ -292,7 +292,7 @@ public:
 
   /// MacroExpands - This is called by when a macro invocation is found.
   virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
-                            SourceRange Range) {
+                            SourceRange Range, const MacroArgs *Args) {
   }
 
   /// SourceRangeSkipped - This hook is called when a source range is skipped.
index 3f09cbb0f9e82fbbfb5cbb20d09aa6d7ae07fe09..8e7f4a0371afd8806d64c9cc129bcd385764fb73 100644 (file)
@@ -257,7 +257,7 @@ public:
                                  true));
   }
   virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD,
-                            SourceRange Range) {
+                            SourceRange Range, const MacroArgs *Args) {
     Macros.push_back(MacroAction(MacroNameTok.getLocation(),
                                  MacroNameTok.getIdentifierInfo()->getName(),
                                  false));