ASTUnit: ArrayRef'ize RemappedFiles

llvm-svn: 200975
This commit is contained in:
Dmitri Gribenko 2014-02-07 15:00:22 +00:00
parent 649899685b
commit 2febd212d3
4 changed files with 19 additions and 28 deletions

View File

@ -695,8 +695,7 @@ public:
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, const FileSystemOptions &FileSystemOpts,
bool OnlyLocalDecls = false, bool OnlyLocalDecls = false,
RemappedFile *RemappedFiles = 0, ArrayRef<RemappedFile> RemappedFiles = None,
unsigned NumRemappedFiles = 0,
bool CaptureDiagnostics = false, bool CaptureDiagnostics = false,
bool AllowPCHWithCompilerErrors = false, bool AllowPCHWithCompilerErrors = false,
bool UserFilesAreVolatile = false); bool UserFilesAreVolatile = false);
@ -798,8 +797,7 @@ public:
StringRef ResourceFilesPath, StringRef ResourceFilesPath,
bool OnlyLocalDecls = false, bool OnlyLocalDecls = false,
bool CaptureDiagnostics = false, bool CaptureDiagnostics = false,
RemappedFile *RemappedFiles = 0, ArrayRef<RemappedFile> RemappedFiles = None,
unsigned NumRemappedFiles = 0,
bool RemappedFilesKeepOriginalName = true, bool RemappedFilesKeepOriginalName = true,
bool PrecompilePreamble = false, bool PrecompilePreamble = false,
TranslationUnitKind TUKind = TU_Complete, TranslationUnitKind TUKind = TU_Complete,
@ -816,8 +814,7 @@ public:
/// ///
/// \returns True if a failure occurred that causes the ASTUnit not to /// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise. /// contain any translation-unit information, false otherwise.
bool Reparse(RemappedFile *RemappedFiles = 0, bool Reparse(ArrayRef<RemappedFile> RemappedFiles = None);
unsigned NumRemappedFiles = 0);
/// \brief Perform code completion at the given file, line, and /// \brief Perform code completion at the given file, line, and
/// column within this translation unit. /// column within this translation unit.
@ -840,7 +837,7 @@ public:
/// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and
/// OwnedBuffers parameters are all disgusting hacks. They will go away. /// OwnedBuffers parameters are all disgusting hacks. They will go away.
void CodeComplete(StringRef File, unsigned Line, unsigned Column, void CodeComplete(StringRef File, unsigned Line, unsigned Column,
RemappedFile *RemappedFiles, unsigned NumRemappedFiles, ArrayRef<RemappedFile> RemappedFiles,
bool IncludeMacros, bool IncludeCodePatterns, bool IncludeMacros, bool IncludeCodePatterns,
bool IncludeBriefComments, bool IncludeBriefComments,
CodeCompleteConsumer &Consumer, CodeCompleteConsumer &Consumer,

View File

@ -680,8 +680,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, const FileSystemOptions &FileSystemOpts,
bool OnlyLocalDecls, bool OnlyLocalDecls,
RemappedFile *RemappedFiles, ArrayRef<RemappedFile> RemappedFiles,
unsigned NumRemappedFiles,
bool CaptureDiagnostics, bool CaptureDiagnostics,
bool AllowPCHWithCompilerErrors, bool AllowPCHWithCompilerErrors,
bool UserFilesAreVolatile) { bool UserFilesAreVolatile) {
@ -712,7 +711,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
AST->ASTFileLangOpts, AST->ASTFileLangOpts,
/*Target=*/0)); /*Target=*/0));
for (unsigned I = 0; I != NumRemappedFiles; ++I) { for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) {
FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second; FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer * if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) { memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
@ -2021,8 +2020,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
StringRef ResourceFilesPath, StringRef ResourceFilesPath,
bool OnlyLocalDecls, bool OnlyLocalDecls,
bool CaptureDiagnostics, bool CaptureDiagnostics,
RemappedFile *RemappedFiles, ArrayRef<RemappedFile> RemappedFiles,
unsigned NumRemappedFiles,
bool RemappedFilesKeepOriginalName, bool RemappedFilesKeepOriginalName,
bool PrecompilePreamble, bool PrecompilePreamble,
TranslationUnitKind TUKind, TranslationUnitKind TUKind,
@ -2056,7 +2054,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
} }
// Override any files that need remapping // 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; FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer * if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) { memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {
@ -2114,7 +2112,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
return AST.take(); return AST.take();
} }
bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) { bool ASTUnit::Reparse(ArrayRef<RemappedFile> RemappedFiles) {
if (!Invocation) if (!Invocation)
return true; return true;
@ -2133,7 +2131,7 @@ bool ASTUnit::Reparse(RemappedFile *RemappedFiles, unsigned NumRemappedFiles) {
delete R->second; delete R->second;
} }
Invocation->getPreprocessorOpts().clearRemappedFiles(); 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; FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer * if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<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, void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
RemappedFile *RemappedFiles, ArrayRef<RemappedFile> RemappedFiles,
unsigned NumRemappedFiles,
bool IncludeMacros, bool IncludeMacros,
bool IncludeCodePatterns, bool IncludeCodePatterns,
bool IncludeBriefComments, bool IncludeBriefComments,
@ -2499,7 +2496,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
// Remap files. // Remap files.
PreprocessorOpts.clearRemappedFiles(); PreprocessorOpts.clearRemappedFiles();
PreprocessorOpts.RetainRemappedFileBuffers = true; 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; FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second;
if (const llvm::MemoryBuffer * if (const llvm::MemoryBuffer *
memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) { memBuf = fileOrBuf.dyn_cast<const llvm::MemoryBuffer *>()) {

View File

@ -2603,11 +2603,10 @@ CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags; IntrusiveRefCntPtr<DiagnosticsEngine> Diags;
ASTUnit *TU = ASTUnit::LoadFromASTFile(ast_filename, Diags, FileSystemOpts, ASTUnit *TU = ASTUnit::LoadFromASTFile(ast_filename, Diags, FileSystemOpts,
CXXIdx->getOnlyLocalDecls(), CXXIdx->getOnlyLocalDecls(), None,
0, 0, /*CaptureDiagnostics=*/true,
/*CaptureDiagnostics=*/true, /*AllowPCHWithCompilerErrors=*/true,
/*AllowPCHWithCompilerErrors=*/true, /*UserFilesAreVolatile=*/true);
/*UserFilesAreVolatile=*/true);
return MakeCXTranslationUnit(CXXIdx, TU); return MakeCXTranslationUnit(CXXIdx, TU);
} }
@ -2745,8 +2744,7 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
CXXIdx->getClangResourcesPath(), CXXIdx->getClangResourcesPath(),
CXXIdx->getOnlyLocalDecls(), CXXIdx->getOnlyLocalDecls(),
/*CaptureDiagnostics=*/true, /*CaptureDiagnostics=*/true,
RemappedFiles->size() ? &(*RemappedFiles)[0]:0, *RemappedFiles.get(),
RemappedFiles->size(),
/*RemappedFilesKeepOriginalName=*/true, /*RemappedFilesKeepOriginalName=*/true,
PrecompilePreamble, PrecompilePreamble,
TUKind, TUKind,
@ -2953,8 +2951,7 @@ static void clang_reparseTranslationUnit_Impl(void *UserData) {
Buffer)); Buffer));
} }
if (!CXXUnit->Reparse(RemappedFiles->size() ? &(*RemappedFiles)[0] : 0, if (!CXXUnit->Reparse(*RemappedFiles.get()))
RemappedFiles->size()))
RTUI->result = 0; RTUI->result = 0;
} }

View File

@ -718,7 +718,7 @@ void clang_codeCompleteAt_Impl(void *UserData) {
// Perform completion. // Perform completion.
AST->CodeComplete(complete_filename, complete_line, complete_column, AST->CodeComplete(complete_filename, complete_line, complete_column,
RemappedFiles.data(), RemappedFiles.size(), RemappedFiles,
(options & CXCodeComplete_IncludeMacros), (options & CXCodeComplete_IncludeMacros),
(options & CXCodeComplete_IncludeCodePatterns), (options & CXCodeComplete_IncludeCodePatterns),
IncludeBriefComments, IncludeBriefComments,