summaryrefslogtreecommitdiff
path: root/unittests/Frontend
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-10-16 17:31:16 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-10-16 17:31:16 +0000
commit04999db339a83624f843fdc5d67d25b5f7170b49 (patch)
treed33b30eea2ea68843d28d7b07604607f446b7b19 /unittests/Frontend
parentf725de83140f86fe707bb45e0111d5582fb46696 (diff)
downloadclang-04999db339a83624f843fdc5d67d25b5f7170b49.tar.gz
Recommit r315738 "[clang-refactor] Apply source replacements"
The fixed commit ensures that ParsedSourceRange works correctly with Windows paths. Original message: This commit actually brings clang-refactor to a usable state as it can now apply the refactoring changes to source files. The -selection option is now also fully supported. Differential Revision: https://reviews.llvm.org/D38402 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Frontend')
-rw-r--r--unittests/Frontend/CMakeLists.txt1
-rw-r--r--unittests/Frontend/ParsedSourceLocationTest.cpp37
2 files changed, 38 insertions, 0 deletions
diff --git a/unittests/Frontend/CMakeLists.txt b/unittests/Frontend/CMakeLists.txt
index e3a21f57ba..c1f4f18635 100644
--- a/unittests/Frontend/CMakeLists.txt
+++ b/unittests/Frontend/CMakeLists.txt
@@ -7,6 +7,7 @@ add_clang_unittest(FrontendTests
CompilerInstanceTest.cpp
FrontendActionTest.cpp
CodeGenActionTest.cpp
+ ParsedSourceLocationTest.cpp
PCHPreambleTest.cpp
)
target_link_libraries(FrontendTests
diff --git a/unittests/Frontend/ParsedSourceLocationTest.cpp b/unittests/Frontend/ParsedSourceLocationTest.cpp
new file mode 100644
index 0000000000..0cbdc7e1d5
--- /dev/null
+++ b/unittests/Frontend/ParsedSourceLocationTest.cpp
@@ -0,0 +1,37 @@
+//===- unittests/Frontend/ParsedSourceLocationTest.cpp - ------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Frontend/CommandLineSourceLoc.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+TEST(ParsedSourceRange, ParseTest) {
+ auto Check = [](StringRef Value, StringRef Filename, unsigned BeginLine,
+ unsigned BeginColumn, unsigned EndLine, unsigned EndColumn) {
+ Optional<ParsedSourceRange> PSR = ParsedSourceRange::fromString(Value);
+ ASSERT_TRUE(PSR);
+ EXPECT_EQ(PSR->FileName, Filename);
+ EXPECT_EQ(PSR->Begin.first, BeginLine);
+ EXPECT_EQ(PSR->Begin.second, BeginColumn);
+ EXPECT_EQ(PSR->End.first, EndLine);
+ EXPECT_EQ(PSR->End.second, EndColumn);
+ };
+
+ Check("/Users/test/a-b.cpp:1:2", "/Users/test/a-b.cpp", 1, 2, 1, 2);
+ Check("/Users/test/a-b.cpp:1:2-3:4", "/Users/test/a-b.cpp", 1, 2, 3, 4);
+
+ Check("C:/Users/bob/a-b.cpp:1:2", "C:/Users/bob/a-b.cpp", 1, 2, 1, 2);
+ Check("C:/Users/bob/a-b.cpp:1:2-3:4", "C:/Users/bob/a-b.cpp", 1, 2, 3, 4);
+}
+
+} // anonymous namespace