[llvm-branch-commits] [cfe-branch] r159669 - in /cfe/branches/tooling: include/clang/ASTMatchers/ASTMatchFinder.h lib/ASTMatchers/ASTMatchFinder.cpp

Manuel Klimek klimek at google.com
Tue Jul 3 10:45:33 PDT 2012


Author: klimek
Date: Tue Jul  3 12:45:33 2012
New Revision: 159669

URL: http://llvm.org/viewvc/llvm-project?rev=159669&view=rev
Log:
Prepares decoupling of the ASTMatchers from the Frontend by
cleaning up tunneling of the source manager now that I understand
that we don't need that...


Modified:
    cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchFinder.h
    cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp

Modified: cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchFinder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchFinder.h?rev=159669&r1=159668&r2=159669&view=diff
==============================================================================
--- cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchFinder.h (original)
+++ cfe/branches/tooling/include/clang/ASTMatchers/ASTMatchFinder.h Tue Jul  3 12:45:33 2012
@@ -68,8 +68,7 @@
   /// Every time a match is found, the MatchFinder will invoke the registered
   /// MatchCallback with a MatchResult containing information about the match.
   struct MatchResult {
-    MatchResult(const BoundNodes &Nodes, clang::ASTContext *Context,
-                clang::SourceManager *SourceManager);
+    MatchResult(const BoundNodes &Nodes, clang::ASTContext *Context);
 
     /// \brief Contains the nodes bound on the current match.
     ///

Modified: cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp?rev=159669&r1=159668&r2=159669&view=diff
==============================================================================
--- cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/branches/tooling/lib/ASTMatchers/ASTMatchFinder.cpp Tue Jul  3 12:45:33 2012
@@ -202,15 +202,9 @@
                         public ASTMatchFinder {
 public:
   MatchASTVisitor(std::vector< std::pair<const UntypedBaseMatcher*,
-                               MatchFinder::MatchCallback*> > *Triggers,
-                  clang::SourceManager *VisitorSourceManager,
-                  clang::LangOptions *LanguageOptions)
+                               MatchFinder::MatchCallback*> > *Triggers)
      : Triggers(Triggers),
-       VisitorSourceManager(VisitorSourceManager),
        ActiveASTContext(NULL) {
-    assert(VisitorSourceManager != NULL);
-    assert(LanguageOptions != NULL);
-    // FIXME: add rewriter_(*source_manager, *language_options)
   }
 
   void set_active_ast_context(clang::ASTContext *NewActiveASTContext) {
@@ -341,18 +335,16 @@
   class MatchVisitor : public BoundNodesTree::Visitor {
   public:
     MatchVisitor(clang::ASTContext* Context,
-                 clang::SourceManager* Sources,
                  MatchFinder::MatchCallback* Callback)
-      : Context(Context), Sources(Sources),
+      : Context(Context),
         Callback(Callback) {}
 
     virtual void visitMatch(const BoundNodes& BoundNodesView) {
-      Callback->run(MatchFinder::MatchResult(BoundNodesView, Context, Sources));
+      Callback->run(MatchFinder::MatchResult(BoundNodesView, Context));
     }
 
   private:
     clang::ASTContext* Context;
-    clang::SourceManager* Sources;
     MatchFinder::MatchCallback* Callback;
   };
 
@@ -379,8 +371,7 @@
       BoundNodesTreeBuilder Builder;
       if (It->first->matches(node, this, &Builder)) {
         BoundNodesTree BoundNodes = Builder.build();
-        MatchVisitor Visitor(ActiveASTContext, VisitorSourceManager,
-                             It->second);
+        MatchVisitor Visitor(ActiveASTContext, It->second);
         BoundNodes.visitMatches(&Visitor);
       }
     }
@@ -388,7 +379,6 @@
 
   std::vector< std::pair<const UntypedBaseMatcher*,
                MatchFinder::MatchCallback*> > *const Triggers;
-  clang::SourceManager *const VisitorSourceManager;
   clang::ASTContext *ActiveASTContext;
 
   // Maps a canonical type to the names of its typedefs.
@@ -496,10 +486,8 @@
 public:
   MatchASTConsumer(std::vector< std::pair<const UntypedBaseMatcher*,
                                 MatchFinder::MatchCallback*> > *Triggers,
-                   MatchFinder::ParsingDoneTestCallback *ParsingDone,
-                   clang::SourceManager *ConsumerSourceManager,
-                   clang::LangOptions *LanaguageOptions)
-      : Visitor(Triggers, ConsumerSourceManager, LanaguageOptions),
+                   MatchFinder::ParsingDoneTestCallback *ParsingDone)
+      : Visitor(Triggers),
         ParsingDone(ParsingDone) {}
 
 private:
@@ -529,10 +517,7 @@
   clang::ASTConsumer *CreateASTConsumer(
       clang::CompilerInstance &Compiler,
       llvm::StringRef) {
-    return new MatchASTConsumer(Triggers,
-                                ParsingDone,
-                                &Compiler.getSourceManager(),
-                                &Compiler.getLangOpts());
+    return new MatchASTConsumer(Triggers, ParsingDone);
   }
 
   std::vector< std::pair<const UntypedBaseMatcher*,
@@ -544,9 +529,9 @@
 } // end namespace internal
 
 MatchFinder::MatchResult::MatchResult(const BoundNodes &Nodes,
-                                      clang::ASTContext *Context,
-                                      clang::SourceManager *SourceManager)
-  : Nodes(Nodes), Context(Context), SourceManager(SourceManager) {}
+                                      clang::ASTContext *Context)
+  : Nodes(Nodes), Context(Context),
+    SourceManager(&Context->getSourceManager()) {}
 
 MatchFinder::MatchCallback::~MatchCallback() {}
 MatchFinder::ParsingDoneTestCallback::~ParsingDoneTestCallback() {}





More information about the llvm-branch-commits mailing list