[cfe-commits] r94395 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp lib/Frontend/ASTUnit.cpp

Daniel Dunbar daniel at zuster.org
Sun Jan 24 16:44:02 PST 2010


Author: ddunbar
Date: Sun Jan 24 18:44:02 2010
New Revision: 94395

URL: http://llvm.org/viewvc/llvm-project?rev=94395&view=rev
Log:
ASTUnit: Don't check that input files exist when parsing ASTs from the command
line -- they may be remapped (fake) files. This is useful for testing parsing
entirely from memory.

Modified:
    cfe/trunk/include/clang/Driver/Driver.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=94395&r1=94394&r2=94395&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Sun Jan 24 18:44:02 2010
@@ -77,32 +77,36 @@
   /// Information about the host which can be overriden by the user.
   std::string HostBits, HostMachine, HostSystem, HostRelease;
 
+  /// Name to use when calling the generic gcc.
+  std::string CCCGenericGCCName;
+
   /// Whether the driver should follow g++ like behavior.
-  bool CCCIsCXX : 1;
+  unsigned CCCIsCXX : 1;
 
   /// Echo commands while executing (in -v style).
-  bool CCCEcho : 1;
+  unsigned CCCEcho : 1;
 
   /// Only print tool bindings, don't build any jobs.
-  bool CCCPrintBindings : 1;
-
-  /// Name to use when calling the generic gcc.
-  std::string CCCGenericGCCName;
+  unsigned CCCPrintBindings : 1;
 
 private:
+  /// Whether to check that input files exist when constructing compilation
+  /// jobs.
+  unsigned CheckInputsExist : 1;
+
   /// Use the clang compiler where possible.
-  bool CCCUseClang : 1;
+  unsigned CCCUseClang : 1;
 
   /// Use clang for handling C++ and Objective-C++ inputs.
-  bool CCCUseClangCXX : 1;
+  unsigned CCCUseClangCXX : 1;
 
   /// Use clang as a preprocessor (clang's preprocessor will still be
   /// used where an integrated CPP would).
-  bool CCCUseClangCPP : 1;
+  unsigned CCCUseClangCPP : 1;
 
 public:
   /// Use lazy precompiled headers for PCH support.
-  bool CCCUsePCH;
+  unsigned CCCUsePCH : 1;
 
 private:
   /// Only use clang for the given architectures (only used when
@@ -129,6 +133,10 @@
 
   const Diagnostic &getDiags() const { return Diags; }
 
+  bool getCheckInputsExist() const { return CheckInputsExist; }
+
+  void setCheckInputsExist(bool Value) { CheckInputsExist = Value; }
+
   /// @}
   /// @name Primary Functionality
   /// @{

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=94395&r1=94394&r2=94395&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sun Jan 24 18:44:02 2010
@@ -50,8 +50,8 @@
     Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
     DefaultImageName(_DefaultImageName),
     Host(0),
-    CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
-    CCCGenericGCCName("gcc"), CCCUseClang(true),
+    CCCGenericGCCName("gcc"), CCCIsCXX(false), CCCEcho(false),
+    CCCPrintBindings(false), CheckInputsExist(true), CCCUseClang(true),
     CCCUseClangCXX(true), CCCUseClangCPP(true), CCCUsePCH(true),
     SuppressMissingInputWarning(false) {
   if (IsProduction) {
@@ -579,10 +579,9 @@
         Ty = InputType;
       }
 
-      // Check that the file exists. It isn't clear this is worth doing, since
-      // the tool presumably does this anyway, and this just adds an extra stat
-      // to the equation, but this is gcc compatible.
-      if (memcmp(Value, "-", 2) != 0 && !llvm::sys::Path(Value).exists())
+      // Check that the file exists, if enabled.
+      if (CheckInputsExist && memcmp(Value, "-", 2) != 0 &&
+          !llvm::sys::Path(Value).exists())
         Diag(clang::diag::err_drv_no_such_file) << A->getValue(Args);
       else
         Inputs.push_back(std::make_pair(Ty, A));

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

==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Sun Jan 24 18:44:02 2010
@@ -324,6 +324,10 @@
   // FIXME: We shouldn't have to pass in the path info.
   driver::Driver TheDriver("clang", "/", llvm::sys::getHostTriple(),
                            "a.out", false, Diags);
+
+  // Don't check that inputs exist, they have been remapped.
+  TheDriver.setCheckInputsExist(false);
+
   llvm::OwningPtr<driver::Compilation> C(
     TheDriver.BuildCompilation(Args.size(), Args.data()));
 





More information about the cfe-commits mailing list