summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2014-02-07 15:00:22 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2014-02-07 15:00:22 +0000
commit2febd212d3528b4bdebd545e7d5883bfaa1d8d89 (patch)
treeaa2cd6b81770d2d644f699551eeb325d2f207c66
parent649899685bfbfeea8c9ae10a3420eef016ea1ede (diff)
downloadbcm5719-llvm-2febd212d3528b4bdebd545e7d5883bfaa1d8d89.tar.gz
bcm5719-llvm-2febd212d3528b4bdebd545e7d5883bfaa1d8d89.zip
ASTUnit: ArrayRef'ize RemappedFiles
llvm-svn: 200975
-rw-r--r--clang/include/clang/Frontend/ASTUnit.h11
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp19
-rw-r--r--clang/tools/libclang/CIndex.cpp15
-rw-r--r--clang/tools/libclang/CIndexCodeCompletion.cpp2
4 files changed, 19 insertions, 28 deletions
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 3901e7d1479..b53d4f51e2e 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -695,8 +695,7 @@ public:
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
bool OnlyLocalDecls = false,
- RemappedFile *RemappedFiles = 0,
- unsigned NumRemappedFiles = 0,
+ ArrayRef<RemappedFile> RemappedFiles = None,
bool CaptureDiagnostics = false,
bool AllowPCHWithCompilerErrors = false,
bool UserFilesAreVolatile = false);
@@ -798,8 +797,7 @@ public:
StringRef ResourceFilesPath,
bool OnlyLocalDecls = false,
bool CaptureDiagnostics = false,
- RemappedFile *RemappedFiles = 0,
- unsigned NumRemappedFiles = 0,
+ ArrayRef<RemappedFile> RemappedFiles = None,
bool RemappedFilesKeepOriginalName = true,
bool PrecompilePreamble = false,
TranslationUnitKind TUKind = TU_Complete,
@@ -816,8 +814,7 @@ public:
///
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
- bool Reparse(RemappedFile *RemappedFiles = 0,
- unsigned NumRemappedFiles = 0);
+ bool Reparse(ArrayRef<RemappedFile> RemappedFiles = None);
/// \brief Perform code completion at the given file, line, and
/// column within this translation unit.
@@ -840,7 +837,7 @@ public:
/// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and
/// OwnedBuffers parameters are all disgusting hacks. They will go away.
void CodeComplete(StringRef File, unsigned Line, unsigned Column,
- RemappedFile *RemappedFiles, unsigned NumRemappedFiles,
+ ArrayRef<RemappedFile> RemappedFiles,
bool IncludeMacros, bool IncludeCodePatterns,
bool IncludeBriefComments,
CodeCompleteConsumer &Consumer,
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 1ee83835377..f57a4bc01a4 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -680,8 +680,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
bool OnlyLocalDecls,
- RemappedFile *RemappedFiles,
- unsigned NumRemappedFiles,
+ ArrayRef<RemappedFile> RemappedFiles,
bool CaptureDiagnostics,
bool AllowPCHWithCompilerErrors,
bool UserFilesAreVolatile) {
@@ -712,7 +711,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
AST->ASTFileLangOpts,
/*Target=*/0));
- for (unsigned I = 0; I != NumRemappedFiles; ++I) {
+ for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) {
FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
@@ -2021,8 +2020,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
StringRef ResourceFilesPath,
bool OnlyLocalDecls,
bool CaptureDiagnostics,
- RemappedFile *RemappedFiles,
- unsigned NumRemappedFiles,
+ ArrayRef<RemappedFile> RemappedFiles,
bool RemappedFilesKeepOriginalName,
bool PrecompilePreamble,
TranslationUnitKind TUKind,
@@ -2056,7 +2054,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
}
// Override any files that need remapping
- for (unsigned I = 0; I != NumRemappedFiles; ++I) {
+ for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) {
FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
@@ -2114,7 +2112,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
return AST.take();
}
-bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) {
+bool ASTUnit::Reparse(ArrayRef<RemappedFile> RemappedFiles) {
if (!Invocation)
return true;
@@ -2133,7 +2131,7 @@ bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) {
delete R->second;
}
Invocation->getPreprocessorOpts().clearRemappedFiles();
- for (unsigned I = 0; I != NumRemappedFiles; ++I) {
+ for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) {
FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
@@ -2415,8 +2413,7 @@ void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S,
void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
- RemappedFile *RemappedFiles,
- unsigned NumRemappedFiles,
+ ArrayRef<RemappedFile> RemappedFiles,
bool IncludeMacros,
bool IncludeCodePatterns,
bool IncludeBriefComments,
@@ -2499,7 +2496,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
// Remap files.
PreprocessorOpts.clearRemappedFiles();
PreprocessorOpts.RetainRemappedFileBuffers = true;
- for (unsigned I = 0; I != NumRemappedFiles; ++I) {
+ for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) {
FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index d1b02c4b654..1af4e55e093 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -2603,11 +2603,10 @@ CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
ASTUnit *TU = ASTUnit::LoadFromASTFile(ast_filename, Diags, FileSystemOpts,
- CXXIdx->getOnlyLocalDecls(),
- 0, 0,
- /*CaptureDiagnostics=*/true,
- /*AllowPCHWithCompilerErrors=*/true,
- /*UserFilesAreVolatile=*/true);
+ CXXIdx->getOnlyLocalDecls(), None,
+ /*CaptureDiagnostics=*/true,
+ /*AllowPCHWithCompilerErrors=*/true,
+ /*UserFilesAreVolatile=*/true);
return MakeCXTranslationUnit(CXXIdx, TU);
}
@@ -2745,8 +2744,7 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
CXXIdx->getClangResourcesPath(),
CXXIdx->getOnlyLocalDecls(),
/*CaptureDiagnostics=*/true,
- RemappedFiles->size() ? &(*RemappedFiles)[0]:0,
- RemappedFiles->size(),
+ *RemappedFiles.get(),
/*RemappedFilesKeepOriginalName=*/true,
PrecompilePreamble,
TUKind,
@@ -2953,8 +2951,7 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
Buffer));
}
- if (!CXXUnit->Reparse(RemappedFiles->size() ? &(*RemappedFiles)[0] : 0,
- RemappedFiles->size()))
+ if (!CXXUnit->Reparse(*RemappedFiles.get()))
RTUI->result = 0;
}
diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp
index 865bb585b54..04adb590498 100644
--- a/clang/tools/libclang/CIndexCodeCompletion.cpp
+++ b/clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -718,7 +718,7 @@ void clang_codeCompleteAt_Impl(void *UserData) {
// Perform completion.
AST->CodeComplete(complete_filename, complete_line, complete_column,
- RemappedFiles.data(), RemappedFiles.size(),
+ RemappedFiles,
(options & CXCodeComplete_IncludeMacros),
(options & CXCodeComplete_IncludeCodePatterns),
IncludeBriefComments,
OpenPOWER on IntegriCloud