[cfe-commits] r86337 - in /cfe/trunk: include/clang/Frontend/InitHeaderSearch.h lib/Frontend/InitHeaderSearch.cpp tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Fri Nov 6 20:20:39 PST 2009


Author: ddunbar
Date: Fri Nov  6 22:20:39 2009
New Revision: 86337

URL: http://llvm.org/viewvc/llvm-project?rev=86337&view=rev
Log:
Lift InitHeaderSearch::AddEnvVarPaths logic higher.

Modified:
    cfe/trunk/include/clang/Frontend/InitHeaderSearch.h
    cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/include/clang/Frontend/InitHeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/InitHeaderSearch.h?rev=86337&r1=86336&r2=86337&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/InitHeaderSearch.h (original)
+++ cfe/trunk/include/clang/Frontend/InitHeaderSearch.h Fri Nov  6 22:20:39 2009
@@ -53,10 +53,6 @@
                bool isCXXAware, bool isUserSupplied,
                bool isFramework, bool IgnoreSysRoot = false);
 
-  /// AddEnvVarPaths - Add a list of paths from an environment variable to a
-  ///  header search list.
-  void AddEnvVarPaths(const char *Name);
-
   /// AddGnuCPlusPlusIncludePaths - Add the necessary paths to suport a gnu
   ///  libstdc++.
   void AddGnuCPlusPlusIncludePaths(const std::string &Base, const char *Dir32,
@@ -69,9 +65,9 @@
                                      const char *Arch,
                                      const char *Version);
 
-  /// AddDefaultEnvVarPaths - Adds list of paths from default environment
-  ///  variables such as CPATH.
-  void AddDefaultEnvVarPaths(const LangOptions &Lang);
+  /// AddDelimitedPaths - Add a list of paths delimited by the system PATH
+  /// separator. The processing follows that of the CPATH variable for gcc.
+  void AddDelimitedPaths(const char *String);
 
   // AddDefaultCIncludePaths - Add paths that should always be searched.
   void AddDefaultCIncludePaths(const llvm::Triple &triple);
@@ -80,9 +76,6 @@
   //  compiling c++.
   void AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple);
 
-  // AddDefaultFrameworkIncludePaths - Add the framework paths. Used on darwin.
-  void AddDefaultFrameworkIncludePaths(const llvm::Triple &triple);
-
   /// AddDefaultSystemIncludePaths - Adds the default system include paths so
   ///  that e.g. stdio.h is found.
   void AddDefaultSystemIncludePaths(const LangOptions &Lang,

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=86337&r1=86336&r2=86337&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Nov  6 22:20:39 2009
@@ -82,9 +82,8 @@
 }
 
 
-void InitHeaderSearch::AddEnvVarPaths(const char *Name) {
-  const char* at = getenv(Name);
-  if (!at || *at == 0) // Empty string should not add '.' path.
+void InitHeaderSearch::AddDelimitedPaths(const char *at) {
+  if (*at == 0) // Empty string should not add '.' path.
     return;
 
   const char* delim = strchr(at, llvm::sys::PathSeparator);
@@ -443,35 +442,20 @@
   }
 }
 
-void InitHeaderSearch::AddDefaultFrameworkIncludePaths(const llvm::Triple &triple) {
-  llvm::Triple::OSType os = triple.getOS();
-  if (os != llvm::Triple::Darwin)
-    return;
-  AddPath("/System/Library/Frameworks", System, true, false, true);
-  AddPath("/Library/Frameworks", System, true, false, true);
-}
-
 void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
                                                     const llvm::Triple &triple) {
   AddDefaultCIncludePaths(triple);
-  AddDefaultFrameworkIncludePaths(triple);
+
+  // Add the default framework include paths on Darwin.
+  if (triple.getOS() == llvm::Triple::Darwin) {
+    AddPath("/System/Library/Frameworks", System, true, false, true);
+    AddPath("/Library/Frameworks", System, true, false, true);
+  }
+
   if (Lang.CPlusPlus)
     AddDefaultCPlusPlusIncludePaths(triple);
 }
 
-void InitHeaderSearch::AddDefaultEnvVarPaths(const LangOptions &Lang) {
-  AddEnvVarPaths("CPATH");
-  if (Lang.CPlusPlus && Lang.ObjC1)
-    AddEnvVarPaths("OBJCPLUS_INCLUDE_PATH");
-  else if (Lang.CPlusPlus)
-    AddEnvVarPaths("CPLUS_INCLUDE_PATH");
-  else if (Lang.ObjC1)
-    AddEnvVarPaths("OBJC_INCLUDE_PATH");
-  else
-    AddEnvVarPaths("C_INCLUDE_PATH");
-}
-
-
 /// RemoveDuplicates - If there are duplicate directory entries in the specified
 /// search list, remove the later (dead) ones.
 static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86337&r1=86336&r2=86337&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Fri Nov  6 22:20:39 2009
@@ -1149,7 +1149,24 @@
     }
   }
 
-  Init.AddDefaultEnvVarPaths(Lang);
+  // Add CPATH environment paths.
+  if (const char *Env = getenv("CPATH"))
+    Init.AddDelimitedPaths(Env);
+
+  // Add language specific environment paths.
+  if (Lang.CPlusPlus && Lang.ObjC1) {
+    if (const char *Env = getenv("OBJCPLUS_INCLUDE_PATH"))
+      Init.AddDelimitedPaths(Env);
+  } else if (Lang.CPlusPlus) {
+    if (const char *Env = getenv("CPLUS_INCLUDE_PATH"))
+      Init.AddDelimitedPaths(Env);
+  } else if (Lang.ObjC1) {
+    if (const char *Env = getenv("OBJC_INCLUDE_PATH"))
+      Init.AddDelimitedPaths(Env);
+  } else {
+    if (const char *Env = getenv("C_INCLUDE_PATH"))
+      Init.AddDelimitedPaths(Env);
+  }
 
   if (!nobuiltininc) {
     std::string P = GetBuiltinIncludePath(Argv0);





More information about the cfe-commits mailing list