summaryrefslogtreecommitdiffstats
path: root/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2017-10-27 12:53:37 +0000
committerGabor Horvath <xazax.hun@gmail.com>2017-10-27 12:53:37 +0000
commit724beacadcc97c70e214d6e822f106b43ac1235c (patch)
treecd0be03684e1bca33dd67c9fc8f9d6ee6aecc26b /clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
parentbe684eee8291a44fc4f65f53335e224a2feb7e71 (diff)
downloadbcm5719-llvm-724beacadcc97c70e214d6e822f106b43ac1235c.tar.gz
bcm5719-llvm-724beacadcc97c70e214d6e822f106b43ac1235c.zip
[CrossTU] Fix handling of Cross Translation Unit directory path
Differential Revision: https://reviews.llvm.org/D38842 llvm-svn: 316764
Diffstat (limited to 'clang/unittests/CrossTU/CrossTranslationUnitTest.cpp')
-rw-r--r--clang/unittests/CrossTU/CrossTranslationUnitTest.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
index 795a4351b50..5fbf56ed43b 100644
--- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -109,9 +109,9 @@ TEST(CrossTranslationUnit, CanLoadFunctionDefinition) {
TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
llvm::StringMap<std::string> Index;
- Index["a"] = "b";
- Index["c"] = "d";
- Index["e"] = "f";
+ Index["a"] = "/b/f1";
+ Index["c"] = "/d/f2";
+ Index["e"] = "/f/f3";
std::string IndexText = createCrossTUIndexString(Index);
int IndexFD;
@@ -134,5 +134,25 @@ TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
EXPECT_TRUE(Index.count(E.getKey()));
}
+TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
+ llvm::StringMap<std::string> Index;
+ Index["a"] = "/b/c/d";
+ std::string IndexText = createCrossTUIndexString(Index);
+
+ int IndexFD;
+ llvm::SmallString<256> IndexFileName;
+ ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
+ IndexFileName));
+ llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
+ IndexFile.os() << IndexText;
+ IndexFile.os().flush();
+ EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+ llvm::Expected<llvm::StringMap<std::string>> IndexOrErr =
+ parseCrossTUIndex(IndexFileName, "/ctudir");
+ EXPECT_TRUE((bool)IndexOrErr);
+ llvm::StringMap<std::string> ParsedIndex = IndexOrErr.get();
+ EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
+}
+
} // end namespace cross_tu
} // end namespace clang
OpenPOWER on IntegriCloud