[PATCH] D38842: [CrossTU] Fix handling of Cross Translation Unit directory path
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 27 05:54:09 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316764: [CrossTU] Fix handling of Cross Translation Unit directory path (authored by xazax).
Changed prior to commit:
https://reviews.llvm.org/D38842?vs=118773&id=120576#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38842
Files:
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp
Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -93,10 +93,7 @@
index_error_code::multiple_definitions, IndexPath.str(), LineNo);
StringRef FileName = LineRef.substr(Pos + 1);
SmallString<256> FilePath = CrossTUDir;
- if (llvm::sys::path::is_absolute(FileName))
- FilePath = FileName;
- else
- llvm::sys::path::append(FilePath, FileName);
+ llvm::sys::path::append(FilePath, FileName);
Result[FunctionLookupName] = FilePath.str().str();
} else
return llvm::make_error<IndexError>(
Index: cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp
===================================================================
--- cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ cfe/trunk/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -109,9 +109,9 @@
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 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38842.120576.patch
Type: text/x-patch
Size: 2265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171027/379e699e/attachment.bin>
More information about the cfe-commits
mailing list