[clang-tools-extra] r184322 - cpp11-migrate: Fix parsing of '.' for header include/excludes

Edwin Vane edwin.vane at intel.com
Wed Jun 19 10:17:32 PDT 2013


Author: revane
Date: Wed Jun 19 12:17:31 2013
New Revision: 184322

URL: http://llvm.org/viewvc/llvm-project?rev=184322&view=rev
Log:
cpp11-migrate: Fix parsing of '.' for header include/excludes

sys::fs::make_absolute was turning '.' into '<path>/.' which broke prefix
comparison logic. Stripping these extra chars fixes the problem.


Modified:
    clang-tools-extra/trunk/cpp11-migrate/Core/IncludeExcludeInfo.cpp

Modified: clang-tools-extra/trunk/cpp11-migrate/Core/IncludeExcludeInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Core/IncludeExcludeInfo.cpp?rev=184322&r1=184321&r2=184322&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Core/IncludeExcludeInfo.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Core/IncludeExcludeInfo.cpp Wed Jun 19 12:17:31 2013
@@ -58,10 +58,18 @@ error_code parseCLInput(StringRef Line,
                                             E = Tokens.end();
        I != E; ++I) {
     // Convert each path to its absolute path.
-    SmallString<64> AbsolutePath = I->rtrim();
-    if (error_code Err = sys::fs::make_absolute(AbsolutePath))
+    SmallString<64> Path = I->rtrim();
+    if (error_code Err = sys::fs::make_absolute(Path))
       return Err;
-    List.push_back(std::string(AbsolutePath.str()));
+
+    // sys::fs::make_absolute will turn "." into "<pwd>/.". Need to strip "/."
+    // off or it interferes with prefix checking.
+    if (Path.endswith("/."))
+      List.push_back(Path.slice(0, Path.size() - 2).str());
+    else
+      List.push_back(Path.str());
+
+    llvm::errs() << "Parse: " <<List.back() << "\n";
   }
   return error_code::success();
 }





More information about the cfe-commits mailing list