diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-05-17 09:15:22 +0000 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-05-17 09:15:22 +0000 |
commit | f70d28b1f458c79aa70bcf85111c35442588d01e (patch) | |
tree | de438d94812f0d8644a9f32ffb0db46f7e5a78d2 /clang/lib/Frontend/ASTUnit.cpp | |
parent | 75cfa341567851509f916db580927a958487b4dc (diff) | |
download | bcm5719-llvm-f70d28b1f458c79aa70bcf85111c35442588d01e.tar.gz bcm5719-llvm-f70d28b1f458c79aa70bcf85111c35442588d01e.zip |
Revert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815
Windows line endings.
Requires proper resubmission.
llvm-svn: 332585
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 83 |
1 files changed, 36 insertions, 47 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 0ce7adb620e..9b672d97551 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1268,13 +1268,13 @@ makeStandaloneDiagnostic(const LangOptions &LangOpts, /// \returns If the precompiled preamble can be used, returns a newly-allocated /// buffer that should be used in place of the main file when doing so. /// Otherwise, returns a NULL pointer. -std::unique_ptr<llvm::MemoryBuffer>
-ASTUnit::getMainBufferWithPrecompiledPreamble(
- std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- CompilerInvocation &PreambleInvocationIn,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild,
- unsigned MaxLines) {
- auto MainFilePath =
+std::unique_ptr<llvm::MemoryBuffer> +ASTUnit::getMainBufferWithPrecompiledPreamble( + std::shared_ptr<PCHContainerOperations> PCHContainerOps, + const CompilerInvocation &PreambleInvocationIn, + IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild, + unsigned MaxLines) { + auto MainFilePath = PreambleInvocationIn.getFrontendOpts().Inputs[0].getFile(); std::unique_ptr<llvm::MemoryBuffer> MainFileBuffer = getBufferForFileHandlingRemapping(PreambleInvocationIn, VFS.get(), @@ -1335,24 +1335,15 @@ ASTUnit::getMainBufferWithPrecompiledPreamble( &NewPreambleDiagsStandalone); // We did not previously compute a preamble, or it can't be reused anyway. - SimpleTimer PreambleTimer(WantTiming);
- PreambleTimer.setOutput("Precompiling preamble");
-
- const bool PreviousSkipFunctionBodies =
- PreambleInvocationIn.getFrontendOpts().SkipFunctionBodies;
- if (SkipFunctionBodies == SkipFunctionBodiesScope::Preamble)
- PreambleInvocationIn.getFrontendOpts().SkipFunctionBodies = true;
-
- llvm::ErrorOr<PrecompiledPreamble> NewPreamble = PrecompiledPreamble::Build(
- PreambleInvocationIn, MainFileBuffer.get(), Bounds, *Diagnostics, VFS,
- PCHContainerOps, /*StoreInMemory=*/false, Callbacks);
-
- PreambleInvocationIn.getFrontendOpts().SkipFunctionBodies =
- PreviousSkipFunctionBodies;
-
- if (NewPreamble) {
- Preamble = std::move(*NewPreamble);
- PreambleRebuildCounter = 1;
+ SimpleTimer PreambleTimer(WantTiming); + PreambleTimer.setOutput("Precompiling preamble"); + + llvm::ErrorOr<PrecompiledPreamble> NewPreamble = PrecompiledPreamble::Build( + PreambleInvocationIn, MainFileBuffer.get(), Bounds, *Diagnostics, VFS, + PCHContainerOps, /*StoreInMemory=*/false, Callbacks); + if (NewPreamble) { + Preamble = std::move(*NewPreamble); + PreambleRebuildCounter = 1; } else { switch (static_cast<BuildPreambleError>(NewPreamble.getError().value())) { case BuildPreambleError::CouldntCreateTempFile: @@ -1697,13 +1688,13 @@ ASTUnit *ASTUnit::LoadFromCommandLine( std::shared_ptr<PCHContainerOperations> PCHContainerOps, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath, bool OnlyLocalDecls, bool CaptureDiagnostics, - ArrayRef<RemappedFile> RemappedFiles, bool RemappedFilesKeepOriginalName,
- unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
- bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
- bool AllowPCHWithCompilerErrors, SkipFunctionBodiesScope SkipFunctionBodies,
- bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization,
- llvm::Optional<StringRef> ModuleFormat, std::unique_ptr<ASTUnit> *ErrAST,
- IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
+ ArrayRef<RemappedFile> RemappedFiles, bool RemappedFilesKeepOriginalName, + unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind, + bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion, + bool AllowPCHWithCompilerErrors, bool SkipFunctionBodies, + bool SingleFileParse, bool UserFilesAreVolatile, bool ForSerialization, + llvm::Optional<StringRef> ModuleFormat, std::unique_ptr<ASTUnit> *ErrAST, + IntrusiveRefCntPtr<vfs::FileSystem> VFS) { assert(Diags.get() && "no DiagnosticsEngine was provided"); SmallVector<StoredDiagnostic, 4> StoredDiagnostics; @@ -1730,14 +1721,13 @@ ASTUnit *ASTUnit::LoadFromCommandLine( PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors; PPOpts.SingleFileParseMode = SingleFileParse; - // Override the resources path.
- CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
-
- CI->getFrontendOpts().SkipFunctionBodies =
- SkipFunctionBodies == SkipFunctionBodiesScope::PreambleAndMainFile;
-
- if (ModuleFormat)
- CI->getHeaderSearchOpts().ModuleFormat = ModuleFormat.getValue();
+ // Override the resources path. + CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath; + + CI->getFrontendOpts().SkipFunctionBodies = SkipFunctionBodies; + + if (ModuleFormat) + CI->getHeaderSearchOpts().ModuleFormat = ModuleFormat.getValue(); // Create the AST unit. std::unique_ptr<ASTUnit> AST; @@ -1757,13 +1747,12 @@ ASTUnit *ASTUnit::LoadFromCommandLine( AST->TUKind = TUKind; AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults; AST->IncludeBriefCommentsInCodeCompletion - = IncludeBriefCommentsInCodeCompletion;
- AST->UserFilesAreVolatile = UserFilesAreVolatile;
- AST->Invocation = CI;
- AST->SkipFunctionBodies = SkipFunctionBodies;
- if (ForSerialization)
- AST->WriterData.reset(new ASTWriterData(*AST->PCMCache));
- // Zero out now to ease cleanup during crash recovery.
+ = IncludeBriefCommentsInCodeCompletion; + AST->UserFilesAreVolatile = UserFilesAreVolatile; + AST->Invocation = CI; + if (ForSerialization) + AST->WriterData.reset(new ASTWriterData(*AST->PCMCache)); + // Zero out now to ease cleanup during crash recovery. CI = nullptr; Diags = nullptr; |