r200975 - ASTUnit: ArrayRef'ize RemappedFiles
Dmitri Gribenko
gribozavr at gmail.com
Fri Feb 7 07:00:22 PST 2014
Author: gribozavr
Date: Fri Feb 7 09:00:22 2014
New Revision: 200975
URL: http://llvm.org/viewvc/llvm-project?rev=200975&view=rev
Log:
ASTUnit: ArrayRef'ize RemappedFiles
Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=200975&r1=200974&r2=200975&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Fri Feb 7 09:00:22 2014
@@ -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,
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=200975&r1=200974&r2=200975&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Feb 7 09:00:22 2014
@@ -680,8 +680,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const
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
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(co
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(co
}
// 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(co
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 *Rema
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::Proc
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 Fil
// 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 *>()) {
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=200975&r1=200974&r2=200975&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Feb 7 09:00:22 2014
@@ -2603,11 +2603,10 @@ CXTranslationUnit clang_createTranslatio
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_I
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
Buffer));
}
- if (!CXXUnit->Reparse(RemappedFiles->size() ? &(*RemappedFiles)[0] : 0,
- RemappedFiles->size()))
+ if (!CXXUnit->Reparse(*RemappedFiles.get()))
RTUI->result = 0;
}
Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=200975&r1=200974&r2=200975&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Fri Feb 7 09:00:22 2014
@@ -718,7 +718,7 @@ void clang_codeCompleteAt_Impl(void *Use
// Perform completion.
AST->CodeComplete(complete_filename, complete_line, complete_column,
- RemappedFiles.data(), RemappedFiles.size(),
+ RemappedFiles,
(options & CXCodeComplete_IncludeMacros),
(options & CXCodeComplete_IncludeCodePatterns),
IncludeBriefComments,
More information about the cfe-commits
mailing list