<div dir="ltr"><span style="font-size:13px">+    if (B->compare(".") == 0) {</span><br style="font-size:13px"><span style="font-size:13px">+    }</span><br><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">?</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Also, does this function implement the corresponding function of the filesystem TS correctly? If so, we should probably move it to sys::path.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">-- Sean Silva</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 11:31 AM, John Thompson <span dir="ltr"><<a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jtsoftware<br>
Date: Thu Feb 26 13:31:10 2015<br>
New Revision: 230665<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230665&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230665&view=rev</a><br>
Log:<br>
Fixed canonical path function.<br>
<br>
Modified:<br>
    clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp<br>
    clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp<br>
<br>
Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=230665&r1=230664&r2=230665&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=230665&r1=230664&r2=230665&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)<br>
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Thu Feb 26 13:31:10 2015<br>
@@ -341,13 +341,31 @@ bool ModularizeUtilities::collectUmbrell<br>
   }<br>
   return true;<br>
 }<br>
+<br>
+std::string normalize(StringRef Path) {<br>
+  SmallString<128> Buffer;<br>
+  llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),<br>
+    E = llvm::sys::path::end(Path);<br>
+  while (B != E) {<br>
+    if (B->compare(".") == 0) {<br>
+    }<br>
+    else if (B->compare("..") == 0)<br>
+      llvm::sys::path::remove_filename(Buffer);<br>
+    else<br>
+      llvm::sys::path::append(Buffer, *B);<br>
+    ++B;<br>
+  }<br>
+  if (Path.endswith("/") || Path.endswith("\\"))<br>
+    Buffer.append(1, Path.back());<br>
+  return Buffer.c_str();<br>
+}<br>
<br>
 // Convert header path to canonical form.<br>
 // The canonical form is basically just use forward slashes, and remove "./".<br>
 // \param FilePath The file path, relative to the module map directory.<br>
 // \returns The file path in canonical form.<br>
 std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) {<br>
-  std::string Tmp(FilePath);<br>
+  std::string Tmp(normalize(FilePath));<br>
   std::replace(Tmp.begin(), Tmp.end(), '\\', '/');<br>
   StringRef Tmp2(Tmp);<br>
   if (Tmp2.startswith("./"))<br>
<br>
Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=230665&r1=230664&r2=230665&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=230665&r1=230664&r2=230665&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)<br>
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Thu Feb 26 13:31:10 2015<br>
@@ -251,6 +251,7 @@<br>
 #include "llvm/ADT/SmallSet.h"<br>
 #include "llvm/Support/StringPool.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
+#include "ModularizeUtilities.h"<br>
<br>
 namespace Modularize {<br>
<br>
@@ -930,8 +931,8 @@ public:<br>
     // and block statement.<br>
     clang::FileID FileID = PP.getSourceManager().getFileID(BlockStartLoc);<br>
     std::string SourcePath = getSourceLocationFile(PP, BlockStartLoc);<br>
+    SourcePath = ModularizeUtilities::getCanonicalPath(SourcePath);<br>
     HeaderHandle SourceHandle = findHeaderHandle(SourcePath);<br>
-    // FIXME: Go back and fix getSourceLocation to use a canonical form.<br>
     if (SourceHandle == -1)<br>
       return true;<br>
     int BlockStartLine, BlockStartColumn, BlockEndLine, BlockEndColumn;<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>