diff options
author | David L. Jones <dlj@google.com> | 2017-11-15 01:40:05 +0000 |
---|---|---|
committer | David L. Jones <dlj@google.com> | 2017-11-15 01:40:05 +0000 |
commit | fdfce82b87b73e18577d493e84bdabe2585b95d0 (patch) | |
tree | e8d9290e273dba03920bf15a8c7742fcf5ed0b87 /unittests/Tooling | |
parent | 41af1698c520ea38edf83e7c91f1e519d34f20c1 (diff) | |
parent | a7540887e8b5cb34ee28c12bef863bad85c65b6f (diff) |
Creating branches/google/testing and tags/google/testing/2017-11-14 from r317716upstream/google/testing
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/testing@318248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Tooling')
-rw-r--r-- | unittests/Tooling/ASTSelectionTest.cpp | 32 | ||||
-rw-r--r-- | unittests/Tooling/ExecutionTest.cpp | 23 | ||||
-rw-r--r-- | unittests/Tooling/QualTypeNamesTest.cpp | 2 |
3 files changed, 41 insertions, 16 deletions
diff --git a/unittests/Tooling/ASTSelectionTest.cpp b/unittests/Tooling/ASTSelectionTest.cpp index 1435334d6c..f10d899a0a 100644 --- a/unittests/Tooling/ASTSelectionTest.cpp +++ b/unittests/Tooling/ASTSelectionTest.cpp @@ -972,4 +972,36 @@ TEST(ASTSelectionFinder, SimpleCodeRangeASTSelectionInObjCMethod) { SelectionFinderVisitor::Lang_OBJC); } +TEST(ASTSelectionFinder, CanonicalizeObjCStringLiteral) { + StringRef Source = R"( +void foo() { + (void)@"test"; +} + )"; + // Just '"test"': + findSelectedASTNodesWithRange( + Source, {3, 10}, FileRange{{3, 10}, {3, 16}}, + [](SourceRange SelectionRange, Optional<SelectedASTNode> Node) { + EXPECT_TRUE(Node); + Optional<CodeRangeASTSelection> SelectedCode = + CodeRangeASTSelection::create(SelectionRange, std::move(*Node)); + EXPECT_TRUE(SelectedCode); + EXPECT_EQ(SelectedCode->size(), 1u); + EXPECT_TRUE(isa<ObjCStringLiteral>((*SelectedCode)[0])); + }, + SelectionFinderVisitor::Lang_OBJC); + // Just 'test': + findSelectedASTNodesWithRange( + Source, {3, 11}, FileRange{{3, 11}, {3, 15}}, + [](SourceRange SelectionRange, Optional<SelectedASTNode> Node) { + EXPECT_TRUE(Node); + Optional<CodeRangeASTSelection> SelectedCode = + CodeRangeASTSelection::create(SelectionRange, std::move(*Node)); + EXPECT_TRUE(SelectedCode); + EXPECT_EQ(SelectedCode->size(), 1u); + EXPECT_TRUE(isa<ObjCStringLiteral>((*SelectedCode)[0])); + }, + SelectionFinderVisitor::Lang_OBJC); +} + } // end anonymous namespace diff --git a/unittests/Tooling/ExecutionTest.cpp b/unittests/Tooling/ExecutionTest.cpp index 44e37b4009..b0c16d6cc5 100644 --- a/unittests/Tooling/ExecutionTest.cpp +++ b/unittests/Tooling/ExecutionTest.cpp @@ -125,13 +125,6 @@ public: } }; -// This anchor is used to force the linker to link in the generated object file -// and thus register the plugin. -extern volatile int ToolExecutorPluginAnchorSource; - -static int LLVM_ATTRIBUTE_UNUSED TestToolExecutorPluginAnchorDest = - ToolExecutorPluginAnchorSource; - static ToolExecutorPluginRegistry::Add<TestToolExecutorPlugin> X("test-executor", "Plugin for TestToolExecutor."); @@ -140,8 +133,8 @@ llvm::cl::OptionCategory TestCategory("execution-test options"); TEST(CreateToolExecutorTest, FailedCreateExecutorUndefinedFlag) { std::vector<const char *> argv = {"prog", "--fake_flag_no_no_no", "f"}; int argc = argv.size(); - auto Executor = - createExecutorFromCommandLineArgs(argc, &argv[0], TestCategory); + auto Executor = internal::createExecutorFromCommandLineArgsImpl( + argc, &argv[0], TestCategory); ASSERT_FALSE((bool)Executor); llvm::consumeError(Executor.takeError()); } @@ -155,8 +148,8 @@ TEST(CreateToolExecutorTest, RegisterFlagsBeforeReset) { std::vector<const char *> argv = {"prog", "--before_reset=set", "f"}; int argc = argv.size(); - auto Executor = - createExecutorFromCommandLineArgs(argc, &argv[0], TestCategory); + auto Executor = internal::createExecutorFromCommandLineArgsImpl( + argc, &argv[0], TestCategory); ASSERT_TRUE((bool)Executor); EXPECT_EQ(BeforeReset, "set"); BeforeReset.removeArgument(); @@ -165,8 +158,8 @@ TEST(CreateToolExecutorTest, RegisterFlagsBeforeReset) { TEST(CreateToolExecutorTest, CreateStandaloneToolExecutor) { std::vector<const char *> argv = {"prog", "standalone.cpp"}; int argc = argv.size(); - auto Executor = - createExecutorFromCommandLineArgs(argc, &argv[0], TestCategory); + auto Executor = internal::createExecutorFromCommandLineArgsImpl( + argc, &argv[0], TestCategory); ASSERT_TRUE((bool)Executor); EXPECT_EQ(Executor->get()->getExecutorName(), StandaloneToolExecutor::ExecutorName); @@ -176,8 +169,8 @@ TEST(CreateToolExecutorTest, CreateTestToolExecutor) { std::vector<const char *> argv = {"prog", "test.cpp", "--executor=test-executor"}; int argc = argv.size(); - auto Executor = - createExecutorFromCommandLineArgs(argc, &argv[0], TestCategory); + auto Executor = internal::createExecutorFromCommandLineArgsImpl( + argc, &argv[0], TestCategory); ASSERT_TRUE((bool)Executor); EXPECT_EQ(Executor->get()->getExecutorName(), TestToolExecutor::ExecutorName); } diff --git a/unittests/Tooling/QualTypeNamesTest.cpp b/unittests/Tooling/QualTypeNamesTest.cpp index edd5060ba0..dd48f3bf45 100644 --- a/unittests/Tooling/QualTypeNamesTest.cpp +++ b/unittests/Tooling/QualTypeNamesTest.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Tooling/Core/QualTypeNames.h" +#include "clang/AST/QualTypeNames.h" #include "TestVisitor.h" using namespace clang; |