<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 10:56 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span class=""><span style="font-size:13px">+    if (B->compare(".") == 0) {</span><br style="font-size:13px"><span style="font-size:13px">+    }</span><br style="font-size:12.8000001907349px"><div><span style="font-size:13px"><br></span></div></span><div><span style="font-size:13px">Hopefully this clause causes paths like ./node.h and node1/./node2.h to become node.h and node1/node2.h, respectively.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">I'm not sure what you mean by filesystem TS.</span></div></div></blockquote><div><br></div><div>That is the name of the ISO C++ document I pointed you to: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3803.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3803.pdf</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">One question is whether a "normalization" function should convert relative paths to absolute.  In this case I opted not to make it absolute.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">I decided to put it locally for now, due to time constraints.  Later I can move it when I can take more time to write a test and so forth.  Actually I think if might be an inefficient function, as I think it might do array resizing as it builds up the new path and allocates a new string for the return, but it's sufficient for my needs.</span></div></div></blockquote><div><br></div><div>Ok, if it is just a local modification, then I would avoid naming it the same thing as in the filesystem TS.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Comments about suitability for path.h/cpp would be appreciated.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">-John</span></div><div><span style="font-size:13px"><br></span></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 3:51 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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" target="_blank">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>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class=""><font color="#888888">-- <br><div>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a><br></div>
</font></span></div>
</blockquote></div><br></div></div>