summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-06-20 18:53:08 +0000
committerAdrian Prantl <aprantl@apple.com>2015-06-20 18:53:08 +0000
commitbb165fb04db511d0f6927133662b74943f76cc39 (patch)
tree5c8150e9096c41f7a426c704aa4762e6420cd28e /clang/tools/libclang
parent6ed81cbcdb6e5f07f6ac71a446d970c2db8945a5 (diff)
downloadbcm5719-llvm-bb165fb04db511d0f6927133662b74943f76cc39.tar.gz
bcm5719-llvm-bb165fb04db511d0f6927133662b74943f76cc39.zip
Introduce a PCHContainerOperations interface (NFC).
A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
Diffstat (limited to 'clang/tools/libclang')
-rw-r--r--clang/tools/libclang/CIndex.cpp9
-rw-r--r--clang/tools/libclang/CIndexCodeCompletion.cpp12
-rw-r--r--clang/tools/libclang/CIndexer.h15
-rw-r--r--clang/tools/libclang/Indexing.cpp21
4 files changed, 31 insertions, 26 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index bdefa9b71b0..2216ec61afa 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2889,7 +2889,8 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(new DiagnosticOptions());
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
- ast_filename, Diags, FileSystemOpts, CXXIdx->getOnlyLocalDecls(), None,
+ ast_filename, CXXIdx->getPCHContainerOperations(), Diags, FileSystemOpts,
+ CXXIdx->getOnlyLocalDecls(), None,
/*CaptureDiagnostics=*/true,
/*AllowPCHWithCompilerErrors=*/true,
/*UserFilesAreVolatile=*/true);
@@ -3027,7 +3028,8 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
unsigned NumErrors = Diags->getClient()->getNumErrors();
std::unique_ptr<ASTUnit> ErrUnit;
std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCommandLine(
- Args->data(), Args->data() + Args->size(), Diags,
+ Args->data(), Args->data() + Args->size(),
+ CXXIdx->getPCHContainerOperations(), Diags,
CXXIdx->getClangResourcesPath(), CXXIdx->getOnlyLocalDecls(),
/*CaptureDiagnostics=*/true, *RemappedFiles.get(),
/*RemappedFilesKeepOriginalName=*/true, PrecompilePreamble, TUKind,
@@ -3268,7 +3270,8 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
}
- if (!CXXUnit->Reparse(*RemappedFiles.get()))
+ if (!CXXUnit->Reparse(CXXIdx->getPCHContainerOperations(),
+ *RemappedFiles.get()))
RTUI->result = CXError_Success;
else if (isASTReadError(CXXUnit))
RTUI->result = CXError_ASTReadError;
diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp
index ca167e8b2e7..a7b8e292047 100644
--- a/clang/tools/libclang/CIndexCodeCompletion.cpp
+++ b/clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -715,14 +715,12 @@ static void clang_codeCompleteAt_Impl(void *UserData) {
// Perform completion.
AST->CodeComplete(complete_filename, complete_line, complete_column,
- RemappedFiles,
- (options & CXCodeComplete_IncludeMacros),
+ RemappedFiles, (options & CXCodeComplete_IncludeMacros),
(options & CXCodeComplete_IncludeCodePatterns),
- IncludeBriefComments,
- Capture,
- *Results->Diag, Results->LangOpts, *Results->SourceMgr,
- *Results->FileMgr, Results->Diagnostics,
- Results->TemporaryBuffers);
+ IncludeBriefComments, Capture,
+ CXXIdx->getPCHContainerOperations(), *Results->Diag,
+ Results->LangOpts, *Results->SourceMgr, *Results->FileMgr,
+ Results->Diagnostics, Results->TemporaryBuffers);
Results->DiagnosticsWrappers.resize(Results->Diagnostics.size());
diff --git a/clang/tools/libclang/CIndexer.h b/clang/tools/libclang/CIndexer.h
index cb7c62e4b56..8a306cde67c 100644
--- a/clang/tools/libclang/CIndexer.h
+++ b/clang/tools/libclang/CIndexer.h
@@ -16,6 +16,8 @@
#define LLVM_CLANG_TOOLS_LIBCLANG_CINDEXER_H
#include "clang-c/Index.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Lex/ModuleLoader.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Path.h"
#include <vector>
@@ -38,11 +40,14 @@ class CIndexer {
unsigned Options; // CXGlobalOptFlags.
std::string ResourcesPath;
+ std::shared_ptr<PCHContainerOperations> PCHContainerOps;
public:
- CIndexer() : OnlyLocalDecls(false), DisplayDiagnostics(false),
- Options(CXGlobalOpt_None) { }
-
+ CIndexer(std::shared_ptr<PCHContainerOperations> PCHContainerOps =
+ std::make_shared<RawPCHContainerOperations>())
+ : OnlyLocalDecls(false), DisplayDiagnostics(false),
+ Options(CXGlobalOpt_None), PCHContainerOps(PCHContainerOps) {}
+
/// \brief Whether we only want to see "local" declarations (that did not
/// come from a previous precompiled header). If false, we want to see all
/// declarations.
@@ -54,6 +59,10 @@ public:
DisplayDiagnostics = Display;
}
+ std::shared_ptr<PCHContainerOperations> getPCHContainerOperations() const {
+ return PCHContainerOps;
+ }
+
unsigned getCXGlobalOptFlags() const { return Options; }
void setCXGlobalOptFlags(unsigned options) { Options = options; }
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index 0ede684a18e..e35640029e6 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -590,8 +590,7 @@ static void clang_indexSourceFile_Impl(void *UserData) {
if (index_options & CXIndexOpt_SuppressWarnings)
CInvok->getDiagnosticOpts().IgnoreWarnings = true;
- ASTUnit *Unit = ASTUnit::create(CInvok.get(), Diags,
- CaptureDiagnostics,
+ ASTUnit *Unit = ASTUnit::create(CInvok.get(), Diags, CaptureDiagnostics,
/*UserFilesAreVolatile=*/true);
if (!Unit) {
ITUI->result = CXError_InvalidArguments;
@@ -644,17 +643,13 @@ static void clang_indexSourceFile_Impl(void *UserData) {
PPOpts.DetailedRecord = false;
DiagnosticErrorTrap DiagTrap(*Diags);
- bool Success = ASTUnit::LoadFromCompilerInvocationAction(CInvok.get(), Diags,
- IndexAction.get(),
- Unit,
- Persistent,
- CXXIdx->getClangResourcesPath(),
- OnlyLocalDecls,
- CaptureDiagnostics,
- PrecompilePreamble,
- CacheCodeCompletionResults,
- /*IncludeBriefCommentsInCodeCompletion=*/false,
- /*UserFilesAreVolatile=*/true);
+ bool Success = ASTUnit::LoadFromCompilerInvocationAction(
+ CInvok.get(), CXXIdx->getPCHContainerOperations(), Diags,
+ IndexAction.get(), Unit, Persistent, CXXIdx->getClangResourcesPath(),
+ OnlyLocalDecls, CaptureDiagnostics, PrecompilePreamble,
+ CacheCodeCompletionResults,
+ /*IncludeBriefCommentsInCodeCompletion=*/false,
+ /*UserFilesAreVolatile=*/true);
if (DiagTrap.hasErrorOccurred() && CXXIdx->getDisplayDiagnostics())
printDiagsToStderr(Unit);
OpenPOWER on IntegriCloud