]> granicus.if.org Git - clang/commitdiff
Teach the driver to always pass down a module cache path. If none is
authorDouglas Gregor <dgregor@apple.com>
Wed, 14 Sep 2011 20:28:46 +0000 (20:28 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 14 Sep 2011 20:28:46 +0000 (20:28 +0000)
supplied, use something derived from the system's temporary
directory. Depends on LLVM r139725.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139726 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
include/clang/Driver/Options.td
lib/Driver/Tools.cpp

index 9969abb6009497ba81a8d5921e44e8a94bf0e7b3..acc53a038a3b191c7c0594cec75979305caf6a04 100644 (file)
@@ -605,7 +605,7 @@ def nostdincxx : Flag<"-nostdinc++">,
   HelpText<"Disable standard #include directories for the C++ standard library">;
 def nobuiltininc : Flag<"-nobuiltininc">,
   HelpText<"Disable builtin #include directories">;
-def fmodule_cache_path : JoinedOrSeparate<"-fmodule-cache-path">, 
+def fmodule_cache_path : Separate<"-fmodule-cache-path">, 
   MetaVarName<"<directory>">,
   HelpText<"Specify the module cache path">;           
 def fdisable_module_hash : Flag<"-fdisable-module-hash">,
index d1040adfc9b1723573b6ee20c613592b080fbf27..55bf2e9db3872384abca8c0e8b84c8b6122179b8 100644 (file)
@@ -342,6 +342,8 @@ def fmessage_length_EQ : Joined<"-fmessage-length=">, Group<f_Group>;
 def fms_extensions : Flag<"-fms-extensions">, Group<f_Group>;
 def fmsc_version : Joined<"-fmsc-version=">, Group<f_Group>;
 def fdelayed_template_parsing : Flag<"-fdelayed-template-parsing">, Group<f_Group>;
+def fmodule_cache_path : Separate<"-fmodule-cache-path">, Group<i_Group>, 
+  Flags<[NoForward]>;
 def fmudflapth : Flag<"-fmudflapth">, Group<f_Group>;
 def fmudflap : Flag<"-fmudflap">, Group<f_Group>;
 def fnested_functions : Flag<"-fnested-functions">, Group<f_Group>;
index 691e96cb115ea42cc8061b0aecf7d7c45f7e49da..28a14a29703072040ca03a629f45a07f0664f446 100644 (file)
@@ -375,6 +375,21 @@ void Clang::AddPreprocessingOptions(const Driver &D,
       CmdArgs.push_back(A->getValue(Args));
     }
   }
+  
+  // If a module path was provided, pass it along. Otherwise, use a temporary
+  // directory.
+  if (Arg *A = Args.getLastArg(options::OPT_fmodule_cache_path)) {
+    CmdArgs.push_back(A->getValue(Args));
+    A->claim();
+    A->render(Args, CmdArgs);
+  } else {
+    llvm::SmallString<128> DefaultModuleCache;
+    llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, 
+                                           DefaultModuleCache);
+    llvm::sys::path::append(DefaultModuleCache, "clang-module-cache");
+    CmdArgs.push_back("-fmodule-cache-path");
+    CmdArgs.push_back(Args.MakeArgString(DefaultModuleCache));
+  }
 }
 
 /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.