diff options
| author | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2015-02-26 19:31:10 +0000 |
|---|---|---|
| committer | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2015-02-26 19:31:10 +0000 |
| commit | b70ecf6eefb7a85892c760f72d493e9717a5dedd (patch) | |
| tree | 560eaef2247b2ac66ad5f351566b83ff48c70e03 | |
| parent | f8ef71c17eae137d19fed3c147bb503fe4a5e5be (diff) | |
| download | bcm5719-llvm-b70ecf6eefb7a85892c760f72d493e9717a5dedd.tar.gz bcm5719-llvm-b70ecf6eefb7a85892c760f72d493e9717a5dedd.zip | |
Fixed canonical path function.
llvm-svn: 230665
| -rw-r--r-- | clang-tools-extra/modularize/ModularizeUtilities.cpp | 20 | ||||
| -rw-r--r-- | clang-tools-extra/modularize/PreprocessorTracker.cpp | 3 |
2 files changed, 21 insertions, 2 deletions
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 60388006187..50dd8b1f258 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -341,13 +341,31 @@ bool ModularizeUtilities::collectUmbrellaHeaders(StringRef UmbrellaDirName, } return true; } +
+std::string normalize(StringRef Path) {
+ SmallString<128> Buffer;
+ llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
+ E = llvm::sys::path::end(Path);
+ while (B != E) {
+ if (B->compare(".") == 0) {
+ }
+ else if (B->compare("..") == 0)
+ llvm::sys::path::remove_filename(Buffer);
+ else
+ llvm::sys::path::append(Buffer, *B);
+ ++B;
+ }
+ if (Path.endswith("/") || Path.endswith("\\"))
+ Buffer.append(1, Path.back());
+ return Buffer.c_str();
+}
// Convert header path to canonical form. // The canonical form is basically just use forward slashes, and remove "./". // \param FilePath The file path, relative to the module map directory. // \returns The file path in canonical form. std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) { - std::string Tmp(FilePath); + std::string Tmp(normalize(FilePath)); std::replace(Tmp.begin(), Tmp.end(), '\\', '/'); StringRef Tmp2(Tmp); if (Tmp2.startswith("./")) diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp index bda76699b85..0b761466b3f 100644 --- a/clang-tools-extra/modularize/PreprocessorTracker.cpp +++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp @@ -251,6 +251,7 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/Support/StringPool.h" #include "llvm/Support/raw_ostream.h" +#include "ModularizeUtilities.h" namespace Modularize { @@ -930,8 +931,8 @@ public: // and block statement. clang::FileID FileID = PP.getSourceManager().getFileID(BlockStartLoc); std::string SourcePath = getSourceLocationFile(PP, BlockStartLoc); + SourcePath = ModularizeUtilities::getCanonicalPath(SourcePath); HeaderHandle SourceHandle = findHeaderHandle(SourcePath); - // FIXME: Go back and fix getSourceLocation to use a canonical form. if (SourceHandle == -1) return true; int BlockStartLine, BlockStartColumn, BlockEndLine, BlockEndColumn; |

