]> granicus.if.org Git - clang/commitdiff
Correctly store and keep track of the FileSystemOptions in ASTUnit and in clang_codeC...
authorAnders Carlsson <andersca@mac.com>
Fri, 18 Mar 2011 18:22:40 +0000 (18:22 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 18 Mar 2011 18:22:40 +0000 (18:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127890 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp
tools/libclang/CIndexCodeCompletion.cpp

index 3eb418c39b354d34b68d44fb80559f478ad7a3d0..32c805029cb3d3713e47bf0b2652ee800853000e 100644 (file)
@@ -881,7 +881,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
   // Configure the various subsystems.
   // FIXME: Should we retain the previous file manager?
   FileSystemOpts = Clang.getFileSystemOpts();
-  FileMgr.reset(new FileManager(Clang.getFileSystemOpts()));
+  FileMgr.reset(new FileManager(FileSystemOpts));
   SourceMgr.reset(new SourceManager(getDiagnostics(), *FileMgr));
   TheSema.reset();
   Ctx.reset();
@@ -1537,7 +1537,8 @@ ASTUnit *ASTUnit::create(CompilerInvocation *CI,
   ConfigureDiags(Diags, 0, 0, *AST, /*CaptureDiagnostics=*/false);
   AST->Diagnostics = Diags;
   AST->Invocation.reset(CI);
-  AST->FileMgr.reset(new FileManager(CI->getFileSystemOpts()));
+  AST->FileSystemOpts = CI->getFileSystemOpts();
+  AST->FileMgr.reset(new FileManager(AST->FileSystemOpts));
   AST->SourceMgr.reset(new SourceManager(*Diags, *AST->FileMgr));
 
   return AST.take();
@@ -1706,8 +1707,9 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
   AST.reset(new ASTUnit(false));
   ConfigureDiags(Diags, ArgBegin, ArgEnd, *AST, CaptureDiagnostics);
   AST->Diagnostics = Diags;
-  
-  AST->FileMgr.reset(new FileManager(FileSystemOptions()));
+
+  AST->FileSystemOpts = CI->getFileSystemOpts();
+  AST->FileMgr.reset(new FileManager(AST->FileSystemOpts));
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;
   AST->CompleteTranslationUnit = CompleteTranslationUnit;
index 292719bebdaeef5a7f08f13dbae24a174245e857..2b4a791b50ea02550edd433f8e412bcaf6c6e223 100644 (file)
@@ -201,7 +201,7 @@ clang_getCompletionAvailability(CXCompletionString completion_string) {
 /// \brief The CXCodeCompleteResults structure we allocate internally;
 /// the client only sees the initial CXCodeCompleteResults structure.
 struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
-  AllocatedCXCodeCompleteResults();
+  AllocatedCXCodeCompleteResults(const FileSystemOptions& FileSystemOpts);
   ~AllocatedCXCodeCompleteResults();
   
   /// \brief Diagnostics produced while performing code completion.
@@ -243,10 +243,12 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
 /// Used for debugging purposes only.
 static llvm::sys::cas_flag CodeCompletionResultObjects;
   
-AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults() 
+AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(
+                                      const FileSystemOptions& FileSystemOpts)
   : CXCodeCompleteResults(),
     Diag(new Diagnostic(
                    llvm::IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs))),
+    FileSystemOpts(FileSystemOpts),
     FileMgr(FileSystemOpts),
     SourceMgr(*Diag, FileMgr) { 
   if (getenv("LIBCLANG_OBJTRACKING")) {
@@ -380,7 +382,8 @@ void clang_codeCompleteAt_Impl(void *UserData) {
   }
 
   // Parse the resulting source file to find code-completion results.
-  AllocatedCXCodeCompleteResults *Results = new AllocatedCXCodeCompleteResults;
+  AllocatedCXCodeCompleteResults *Results = 
+        new AllocatedCXCodeCompleteResults(AST->getFileSystemOpts());
   Results->Results = 0;
   Results->NumResults = 0;