diff options
| author | Haojian Wu <hokein@google.com> | 2018-08-17 14:25:10 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2018-08-17 14:25:10 +0000 |
| commit | 70560ba8db05609565051b7c4fb178806117218a (patch) | |
| tree | aff8a2929aa468bcd2b5604344728b7418704a2a /clang/lib/Frontend | |
| parent | 39a979c838114383ca5dc6bc99ae22c315a4636a (diff) | |
| download | bcm5719-llvm-70560ba8db05609565051b7c4fb178806117218a.tar.gz bcm5719-llvm-70560ba8db05609565051b7c4fb178806117218a.zip | |
[Preamble] Empty preamble is not an error.
Summary:
Empty preamble is valid for source file which doesn't have any
preprocessor and #includes.
This patch makes clang treat an empty preamble as a normal preamble.
Check: ninja check-clang
A testcase is added in https://reviews.llvm.org/D50627.
Reviewers: ilya-biryukov
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D50628
llvm-svn: 340029
Diffstat (limited to 'clang/lib/Frontend')
| -rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Frontend/PrecompiledPreamble.cpp | 8 |
2 files changed, 0 insertions, 9 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index e4c313fed30..701f07f22e3 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1363,7 +1363,6 @@ ASTUnit::getMainBufferWithPrecompiledPreamble( } else { switch (static_cast<BuildPreambleError>(NewPreamble.getError().value())) { case BuildPreambleError::CouldntCreateTempFile: - case BuildPreambleError::PreambleIsEmpty: // Try again next time. PreambleRebuildCounter = 1; return nullptr; diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp index 30ae2db26d8..4bff339711d 100644 --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -237,9 +237,6 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build( PreambleCallbacks &Callbacks) { assert(VFS && "VFS is null"); - if (!Bounds.Size) - return BuildPreambleError::PreambleIsEmpty; - auto PreambleInvocation = std::make_shared<CompilerInvocation>(Invocation); FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts(); PreprocessorOptions &PreprocessorOpts = @@ -423,9 +420,6 @@ bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation, PreprocessorOptions &PreprocessorOpts = PreambleInvocation->getPreprocessorOpts(); - if (!Bounds.Size) - return false; - // We've previously computed a preamble. Check whether we have the same // preamble now that we did before, and that there's enough space in // the main-file buffer within the precompiled preamble to fit the @@ -758,8 +752,6 @@ const char *BuildPreambleErrorCategory::name() const noexcept { std::string BuildPreambleErrorCategory::message(int condition) const { switch (static_cast<BuildPreambleError>(condition)) { - case BuildPreambleError::PreambleIsEmpty: - return "Preamble is empty"; case BuildPreambleError::CouldntCreateTempFile: return "Could not create temporary file for PCH"; case BuildPreambleError::CouldntCreateTargetInfo: |

