Re: [PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-10 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Nico!

On Tue, Apr 10, 2018 at 6:39 AM, Nico Weber via Phabricator
 wrote:
> thakis added a comment.
>
> r329698, thanks!
>
>
> https://reviews.llvm.org/D45165
>
>
>



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

r329698, thanks!


https://reviews.llvm.org/D45165



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D45165



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

bruno: ping


https://reviews.llvm.org/D45165



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-02 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: bruno.

No expected behavior change.


https://reviews.llvm.org/D45165

Files:
  lib/Basic/FileManager.cpp
  lib/Frontend/ModuleDependencyCollector.cpp


Index: lib/Frontend/ModuleDependencyCollector.cpp
===
--- lib/Frontend/ModuleDependencyCollector.cpp
+++ lib/Frontend/ModuleDependencyCollector.cpp
@@ -97,24 +97,6 @@
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl ) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader ) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -129,7 +111,7 @@
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -139,7 +121,7 @@
   // already expects when sensitivity isn't setup.
   for (auto  : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -189,7 +171,7 @@
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {
Index: lib/Basic/FileManager.cpp
===
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -534,23 +534,9 @@
 
   StringRef CanonicalName(Dir->getName());
 
-#ifdef LLVM_ON_UNIX
-  char CanonicalNameBuf[PATH_MAX];
-  if (realpath(Dir->getName().str().c_str(), CanonicalNameBuf))
+  SmallString CanonicalNameBuf;
+  if (!llvm::sys::fs::real_path(Dir->getName(), CanonicalNameBuf))
 CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#else
-  SmallString<256> CanonicalNameBuf(CanonicalName);
-  llvm::sys::fs::make_absolute(CanonicalNameBuf);
-  llvm::sys::path::native(CanonicalNameBuf);
-  // We've run into needing to remove '..' here in the wild though, so
-  // remove it.
-  // On Windows, symlinks are significantly less prevalent, so removing
-  // '..' is pretty safe.
-  // Ideally we'd have an equivalent of `realpath` and could implement
-  // sys::fs::canonical across all the platforms.
-  llvm::sys::path::remove_dots(CanonicalNameBuf, /* remove_dot_dot */ true);
-  CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
-#endif
 
   CanonicalDirNames.insert(std::make_pair(Dir, CanonicalName));
   return CanonicalName;


Index: lib/Frontend/ModuleDependencyCollector.cpp
===
--- lib/Frontend/ModuleDependencyCollector.cpp
+++ lib/Frontend/ModuleDependencyCollector.cpp
@@ -97,24 +97,6 @@
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl ) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader ) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -129,7 +111,7 @@
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -139,7 +121,7 @@
   // already expects when sensitivity isn't setup.
   for (auto  : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -189,7 +171,7 @@
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if