From: Aaron Ballman Date: Mon, 24 Nov 2014 17:39:44 +0000 (+0000) Subject: Reverting r222646; the tests do not pass on Windows. Also reverts r222664, which... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14951ec70786dc6fd34db9da98fac8484bf55799;p=clang Reverting r222646; the tests do not pass on Windows. Also reverts r222664, which was required for r222646 to compile with Visual Studio 2012. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222667 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html index e70d1ec3fa..2eabff49cf 100644 --- a/docs/LibASTMatchersReference.html +++ b/docs/LibASTMatchersReference.html @@ -307,16 +307,6 @@ Example matches X, Z -Matcher<Decl>typedefDeclMatcher<TypedefDecl>... -
Matches typedef declarations.
-
-Given
-  typedef int X;
-typedefDecl()
-  matches "typedef int X"
-
- - Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.
 
@@ -349,15 +339,6 @@ usingDirectiveDecl()
   matches using namespace X 
-Matcher<Decl>valueDeclMatcher<ValueDecl>... -
Matches any value declaration.
-
-Example matches A, B, C and F
-  enum X { A, B, C };
-  void F();
-
- - Matcher<Decl>varDeclMatcher<VarDecl>...
Matches variable declarations.
 
@@ -1673,48 +1654,6 @@ f.
 
-Matcher<Decl>isExpansionInFileMatchingstd::string RegExp -
Matches AST nodes that were expanded within files whose name is
-partially matching a given regex.
-
-Example matches Y but not X
-    (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
-  #include "ASTMatcher.h"
-  class X {};
-ASTMatcher.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - -Matcher<Decl>isExpansionInMainFile -
Matches AST nodes that were expanded within the main-file.
-
-Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
-  #include <Y.h>
-  class X {};
-Y.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - -Matcher<Decl>isExpansionInSystemHeader -
Matches AST nodes that were expanded within system-header-files.
-
-Example matches Y but not X
-    (matcher = recordDecl(isExpansionInSystemHeader())
-  #include <SystemHeader.h>
-  class X {};
-SystemHeader.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - Matcher<Decl>isImplicit
Matches a declaration that has been implicitly added
 by the compiler (eg. implicit defaultcopy constructors).
@@ -1919,7 +1858,7 @@ memberExpr(isArrow())
 
-Matcher<NamedDecl>hasNamestd::string Name +Matcher<NamedDecl>hasNamestd::string Name
Matches NamedDecl nodes that have the specified name.
 
 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -2051,48 +1990,6 @@ and reference to that variable declaration within a compound statement.
 
-Matcher<Stmt>isExpansionInFileMatchingstd::string RegExp -
Matches AST nodes that were expanded within files whose name is
-partially matching a given regex.
-
-Example matches Y but not X
-    (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
-  #include "ASTMatcher.h"
-  class X {};
-ASTMatcher.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - -Matcher<Stmt>isExpansionInMainFile -
Matches AST nodes that were expanded within the main-file.
-
-Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
-  #include <Y.h>
-  class X {};
-Y.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - -Matcher<Stmt>isExpansionInSystemHeader -
Matches AST nodes that were expanded within system-header-files.
-
-Example matches Y but not X
-    (matcher = recordDecl(isExpansionInSystemHeader())
-  #include <SystemHeader.h>
-  class X {};
-SystemHeader.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - Matcher<Stmt>isInTemplateInstantiation
Matches statements inside of a template instantiation.
 
@@ -2164,48 +2061,6 @@ classTemplateSpecializationDecl(templateArgumentCountIs(1))
 
-Matcher<TypeLoc>isExpansionInFileMatchingstd::string RegExp -
Matches AST nodes that were expanded within files whose name is
-partially matching a given regex.
-
-Example matches Y but not X
-    (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
-  #include "ASTMatcher.h"
-  class X {};
-ASTMatcher.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - -Matcher<TypeLoc>isExpansionInMainFile -
Matches AST nodes that were expanded within the main-file.
-
-Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
-  #include <Y.h>
-  class X {};
-Y.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - -Matcher<TypeLoc>isExpansionInSystemHeader -
Matches AST nodes that were expanded within system-header-files.
-
-Example matches Y but not X
-    (matcher = recordDecl(isExpansionInSystemHeader())
-  #include <SystemHeader.h>
-  class X {};
-SystemHeader.h:
-  class Y {};
-
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
-
- - Matcher<Type>equalsBoundNodestd::string ID
Matches if a node equals a previously bound node.
 
diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h
index cbdca79fc4..37c7b16934 100644
--- a/include/clang/ASTMatchers/ASTMatchers.h
+++ b/include/clang/ASTMatchers/ASTMatchers.h
@@ -47,7 +47,6 @@
 
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclTemplate.h"
-#include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/ASTMatchers/ASTMatchersMacros.h"
 #include "llvm/ADT/Twine.h"
@@ -143,97 +142,6 @@ typedef internal::Matcher NestedNameSpecifierLocMatcher;
 /// Usable as: Any Matcher
 inline internal::TrueMatcher anything() { return internal::TrueMatcher(); }
 
-/// \brief Matches typedef declarations.
-///
-/// Given
-/// \code
-///   typedef int X;
-/// \endcode
-/// typedefDecl()
-///   matches "typedef int X"
-const internal::VariadicDynCastAllOfMatcher typedefDecl;
-
-/// \brief Matches AST nodes that were expanded within the main-file.
-///
-/// Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile())
-/// \code
-///   #include 
-///   class X {};
-/// \endcode
-/// Y.h:
-/// \code
-///   class Y {};
-/// \endcode
-///
-/// Usable as: Matcher, Matcher, Matcher
-AST_POLYMORPHIC_MATCHER(isExpansionInMainFile,
-                        AST_POLYMORPHIC_SUPPORTED_TYPES_3(Decl, Stmt,
-                                                          TypeLoc)) {
-  auto &SourceManager = Finder->getASTContext().getSourceManager();
-  return SourceManager.isInMainFile(
-      SourceManager.getExpansionLoc(Node.getLocStart()));
-}
-
-/// \brief Matches AST nodes that were expanded within system-header-files.
-///
-/// Example matches Y but not X
-///     (matcher = recordDecl(isExpansionInSystemHeader())
-/// \code
-///   #include 
-///   class X {};
-/// \endcode
-/// SystemHeader.h:
-/// \code
-///   class Y {};
-/// \endcode
-///
-/// Usable as: Matcher, Matcher, Matcher
-AST_POLYMORPHIC_MATCHER(isExpansionInSystemHeader,
-                        AST_POLYMORPHIC_SUPPORTED_TYPES_3(Decl, Stmt,
-                                                          TypeLoc)) {
-  auto &SourceManager = Finder->getASTContext().getSourceManager();
-  auto ExpansionLoc = SourceManager.getExpansionLoc(Node.getLocStart());
-  if (ExpansionLoc.isInvalid()) {
-    return false;
-  }
-  return SourceManager.isInSystemHeader(ExpansionLoc);
-}
-
-/// \brief Matches AST nodes that were expanded within files whose name is
-/// partially matching a given regex.
-///
-/// Example matches Y but not X
-///     (matcher = recordDecl(isExpansionInFileMatching("AST.*"))
-/// \code
-///   #include "ASTMatcher.h"
-///   class X {};
-/// \endcode
-/// ASTMatcher.h:
-/// \code
-///   class Y {};
-/// \endcode
-///
-/// Usable as: Matcher, Matcher, Matcher
-AST_POLYMORPHIC_MATCHER_P(isExpansionInFileMatching,
-                          AST_POLYMORPHIC_SUPPORTED_TYPES_3(Decl, Stmt,
-                                                            TypeLoc),
-                          std::string, RegExp) {
-  auto &SourceManager = Finder->getASTContext().getSourceManager();
-  auto ExpansionLoc = SourceManager.getExpansionLoc(Node.getLocStart());
-  if (ExpansionLoc.isInvalid()) {
-    return false;
-  }
-  auto FileEntry =
-      SourceManager.getFileEntryForID(SourceManager.getFileID(ExpansionLoc));
-  if (!FileEntry) {
-    return false;
-  }
-
-  auto Filename = FileEntry->getName();
-  llvm::Regex RE(RegExp);
-  return RE.match(Filename);
-}
-
 /// \brief Matches declarations.
 ///
 /// Examples matches \c X, \c C, and the friend declaration inside \c C;
diff --git a/include/clang/Tooling/Tooling.h b/include/clang/Tooling/Tooling.h
index 55152ffd29..89a4798b8c 100644
--- a/include/clang/Tooling/Tooling.h
+++ b/include/clang/Tooling/Tooling.h
@@ -143,10 +143,6 @@ inline std::unique_ptr newFrontendActionFactory(
 bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code,
                    const Twine &FileName = "input.cc");
 
-/// The first part of the pair is the filename, the second part the
-/// file-content.
-typedef std::vector> FileContentMappings;
-
 /// \brief Runs (and deletes) the tool on 'Code' with the -fsyntax-only flag and
 ///        with additional other flags.
 ///
@@ -156,10 +152,9 @@ typedef std::vector> FileContentMappings;
 /// \param FileName The file name which 'Code' will be mapped as.
 ///
 /// \return - True if 'ToolAction' was successfully executed.
-bool runToolOnCodeWithArgs(
-    clang::FrontendAction *ToolAction, const Twine &Code,
-    const std::vector &Args, const Twine &FileName = "input.cc",
-    const FileContentMappings &VirtualMappedFiles = FileContentMappings());
+bool runToolOnCodeWithArgs(clang::FrontendAction *ToolAction, const Twine &Code,
+                           const std::vector &Args,
+                           const Twine &FileName = "input.cc");
 
 /// \brief Builds an AST for 'Code'.
 ///
diff --git a/lib/ASTMatchers/Dynamic/Registry.cpp b/lib/ASTMatchers/Dynamic/Registry.cpp
index c0816ace44..dab4187171 100644
--- a/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -242,10 +242,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isExpr);
   REGISTER_MATCHER(isExternC);
   REGISTER_MATCHER(isImplicit);
-  REGISTER_MATCHER(isExpansionInFileMatching);
-  REGISTER_MATCHER(isExpansionInMainFile);
   REGISTER_MATCHER(isInstantiated);
-  REGISTER_MATCHER(isExpansionInSystemHeader);
   REGISTER_MATCHER(isInteger);
   REGISTER_MATCHER(isIntegral);
   REGISTER_MATCHER(isInTemplateInstantiation);
@@ -317,7 +314,6 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(to);
   REGISTER_MATCHER(tryStmt);
   REGISTER_MATCHER(type);
-  REGISTER_MATCHER(typedefDecl);
   REGISTER_MATCHER(typedefType);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp
index 95ef03eb56..64613ded3e 100644
--- a/lib/Tooling/Tooling.cpp
+++ b/lib/Tooling/Tooling.cpp
@@ -123,25 +123,17 @@ getSyntaxOnlyToolArgs(const std::vector &ExtraArgs,
 
 bool runToolOnCodeWithArgs(clang::FrontendAction *ToolAction, const Twine &Code,
                            const std::vector &Args,
-                           const Twine &FileName,
-                           const FileContentMappings &VirtualMappedFiles) {
-
+                           const Twine &FileName) {
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
   llvm::IntrusiveRefCntPtr Files(
       new FileManager(FileSystemOptions()));
-  ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef),
-                            ToolAction, Files.get());
+  ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef), ToolAction,
+                            Files.get());
 
   SmallString<1024> CodeStorage;
   Invocation.mapVirtualFile(FileNameRef,
                             Code.toNullTerminatedStringRef(CodeStorage));
-
-  for (auto &FilenameWithContent : VirtualMappedFiles) {
-    Invocation.mapVirtualFile(FilenameWithContent.first,
-                              FilenameWithContent.second);
-  }
-
   return Invocation.run();
 }
 
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index ba66a2da9e..c88a197643 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4625,53 +4625,5 @@ TEST(EqualsBoundNodeMatcher, UnlessDescendantsOfAncestorsMatch) {
           .bind("data")));
 }
 
-TEST(TypeDefDeclMatcher, Match) {
-  EXPECT_TRUE(matches("typedef int typedefDeclTest;",
-                      typedefDecl(hasName("typedefDeclTest"))));
-}
-
-TEST(Matcher, IsExpansionInMainFileMatcher) {
-  EXPECT_TRUE(matches("class X {};",
-                      recordDecl(hasName("X"), isExpansionInMainFile())));
-  EXPECT_TRUE(notMatches("", recordDecl(isExpansionInMainFile())));
-  FileContentMappings M;
-  M.push_back(std::make_pair("/other", "class X {};"));
-  EXPECT_TRUE(matchesConditionally("#include \n",
-                                   recordDecl(isExpansionInMainFile()), false,
-                                   "-isystem/", M));
-}
-
-TEST(Matcher, IsExpansionInSystemHeader) {
-  FileContentMappings M;
-  M.push_back(std::make_pair("/other", "class X {};"));
-  EXPECT_TRUE(matchesConditionally(
-      "#include \"other\"\n", recordDecl(isExpansionInSystemHeader()), true,
-      "-isystem/", M));
-  EXPECT_TRUE(matchesConditionally("#include \"other\"\n",
-                                   recordDecl(isExpansionInSystemHeader()),
-                                   false, "-I/", M));
-  EXPECT_TRUE(notMatches("class X {};",
-                         recordDecl(isExpansionInSystemHeader())));
-  EXPECT_TRUE(notMatches("", recordDecl(isExpansionInSystemHeader())));
-}
-
-TEST(Matcher, IsExpansionInFileMatching) {
-  FileContentMappings M;
-  M.push_back(std::make_pair("/foo", "class A {};"));
-  M.push_back(std::make_pair("/bar", "class B {};"));
-  EXPECT_TRUE(matchesConditionally(
-      "#include \n"
-      "#include \n"
-      "class X {};",
-      recordDecl(isExpansionInFileMatching("b.*"), hasName("B")), true,
-      "-isystem/", M));
-  EXPECT_TRUE(matchesConditionally(
-      "#include \n"
-      "#include \n"
-      "class X {};",
-      recordDecl(isExpansionInFileMatching("f.*"), hasName("X")), false,
-      "-isystem/", M));
-}
-
 } // end namespace ast_matchers
 } // end namespace clang
diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h
index a2ab9feee2..2e5b3da5a5 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/unittests/ASTMatchers/ASTMatchersTest.h
@@ -22,7 +22,6 @@ using clang::tooling::buildASTFromCodeWithArgs;
 using clang::tooling::newFrontendActionFactory;
 using clang::tooling::runToolOnCodeWithArgs;
 using clang::tooling::FrontendActionFactory;
-using clang::tooling::FileContentMappings;
 
 class BoundNodesCallback {
 public:
@@ -59,10 +58,10 @@ private:
 };
 
 template 
-testing::AssertionResult matchesConditionally(
-    const std::string &Code, const T &AMatcher, bool ExpectMatch,
-    llvm::StringRef CompileArg,
-    const FileContentMappings &VirtualMappedFiles = FileContentMappings()) {
+testing::AssertionResult matchesConditionally(const std::string &Code,
+                                              const T &AMatcher,
+                                              bool ExpectMatch,
+                                              llvm::StringRef CompileArg) {
   bool Found = false, DynamicFound = false;
   MatchFinder Finder;
   VerifyMatch VerifyFound(nullptr, &Found);
@@ -74,8 +73,7 @@ testing::AssertionResult matchesConditionally(
       newFrontendActionFactory(&Finder));
   // Some tests use typeof, which is a gnu extension.
   std::vector Args(1, CompileArg);
-  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, "input.cc",
-                             VirtualMappedFiles)) {
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) {
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (Found != DynamicFound) {