[llvm-commits] CVS: llvm/lib/Linker/LinkModules.cpp Linker.cpp

Reid Spencer reid at x10sys.com
Thu Jul 7 16:22:01 PDT 2005



Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.106 -> 1.107
Linker.cpp updated: 1.6 -> 1.7
---
Log message:

For PR495: http://llvm.cs.uiuc.edu/PR495 :
Get rid of the difference between file paths and directory paths. The Path
class now simply stores a path that can refer to either a file or a 
directory. This required various changes in the implementation and interface
of the class with the corresponding impact to its users. Doxygen comments were
also updated to reflect these changes. Interface changes are:

appendDirectory -> appendComponent
appendFile -> appendComponent
elideDirectory -> eraseComponent
elideFile -> eraseComponent
elideSuffix -> eraseSuffix
renameFile -> rename
setDirectory -> set
setFile -> set

Changes pass Dejagnu and llvm-test/SingleSource tests.


---
Diffs of the changes:  (+28 -20)

 LinkModules.cpp |    2 +-
 Linker.cpp      |   46 +++++++++++++++++++++++++++-------------------
 2 files changed, 28 insertions(+), 20 deletions(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.106 llvm/lib/Linker/LinkModules.cpp:1.107
--- llvm/lib/Linker/LinkModules.cpp:1.106	Sun May  8 20:09:39 2005
+++ llvm/lib/Linker/LinkModules.cpp	Thu Jul  7 18:21:43 2005
@@ -899,7 +899,7 @@
   // If the source library's module id is in the dependent library list of the
   // destination library, remove it since that module is now linked in.
   sys::Path modId;
-  modId.setFile(Src->getModuleIdentifier());
+  modId.set(Src->getModuleIdentifier());
   if (!modId.isEmpty())
     Dest->removeLibrary(modId.getBasename());
 


Index: llvm/lib/Linker/Linker.cpp
diff -u llvm/lib/Linker/Linker.cpp:1.6 llvm/lib/Linker/Linker.cpp:1.7
--- llvm/lib/Linker/Linker.cpp:1.6	Thu Jul  7 13:21:42 2005
+++ llvm/lib/Linker/Linker.cpp	Thu Jul  7 18:21:43 2005
@@ -69,7 +69,6 @@
 
 void
 Linker::addPath(const sys::Path& path) {
-  assert(path.isDirectory() && "Can only insert directories into the path");
   LibPaths.push_back(path);
 }
 
@@ -77,7 +76,7 @@
 Linker::addPaths(const std::vector<std::string>& paths) {
   for (unsigned i = 0; i != paths.size(); ++i) {
     sys::Path aPath;
-    aPath.setDirectory(paths[i]);
+    aPath.set(paths[i]);
     LibPaths.push_back(aPath);
   }
 }
@@ -118,26 +117,35 @@
 static inline sys::Path IsLibrary(const std::string& Name,
                                   const sys::Path& Directory) {
 
-  assert(Directory.isDirectory() && "Need to specify a directory");
   sys::Path FullPath(Directory);
-  FullPath.appendFile("lib" + Name);
 
-  FullPath.appendSuffix("a");
-  if (FullPath.isArchive())
-    return FullPath;
-
-  FullPath.elideSuffix();
-  FullPath.appendSuffix("bca");
-  if (FullPath.isArchive())
-    return FullPath;
-
-  FullPath.elideSuffix();
-  FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
-  if (FullPath.isDynamicLibrary())  // Native shared library?
-    return FullPath;
-  if (FullPath.isBytecodeFile())    // .so file containing bytecode?
-    return FullPath;
+  // Make sure the directory actually is a directory in the file system.
+  if (FullPath.isDirectory())
+  {
+    // Try the libX.a form
+    FullPath.appendComponent("lib" + Name);
+    FullPath.appendSuffix("a");
+    if (FullPath.isArchive())
+      return FullPath;
+
+    // Try the libX.bca form
+    FullPath.eraseSuffix();
+    FullPath.appendSuffix("bca");
+    if (FullPath.isArchive())
+      return FullPath;
+
+    // Try the libX.so form
+    FullPath.eraseSuffix();
+    FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
+    if (FullPath.isDynamicLibrary())  // Native shared library?
+      return FullPath;
+    if (FullPath.isBytecodeFile())    // .so file containing bytecode?
+      return FullPath;
+
+    // Not found .. fall through
+  }
 
+  // Indicate that the library was not found in the directory.
   FullPath.clear();
   return FullPath;
 }






More information about the llvm-commits mailing list