[PATCH] D62137: [Frontend] Return an error on bad inputs to PrecompiledPreabmle
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 22 05:48:32 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361376: [Frontend] Return an error on bad inputs to PrecompiledPreabmle (authored by ibiryukov, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D62137?vs=200253&id=200713#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62137/new/
https://reviews.llvm.org/D62137
Files:
include/clang/Frontend/PrecompiledPreamble.h
lib/Frontend/ASTUnit.cpp
lib/Frontend/PrecompiledPreamble.cpp
Index: include/clang/Frontend/PrecompiledPreamble.h
===================================================================
--- include/clang/Frontend/PrecompiledPreamble.h
+++ include/clang/Frontend/PrecompiledPreamble.h
@@ -291,7 +291,8 @@
CouldntCreateTempFile = 1,
CouldntCreateTargetInfo,
BeginSourceFileFailed,
- CouldntEmitPCH
+ CouldntEmitPCH,
+ BadInputs
};
class BuildPreambleErrorCategory final : public std::error_category {
Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1368,6 +1368,7 @@
case BuildPreambleError::CouldntCreateTargetInfo:
case BuildPreambleError::BeginSourceFileFailed:
case BuildPreambleError::CouldntEmitPCH:
+ case BuildPreambleError::BadInputs:
// These erros are more likely to repeat, retry after some period.
PreambleRebuildCountdown = DefaultPreambleRebuildInterval;
return nullptr;
Index: lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -299,14 +299,13 @@
// created. This complexity should be lifted elsewhere.
Clang->getTarget().adjust(Clang->getLangOpts());
- assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
- "Invocation must have exactly one source file!");
- assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
- InputKind::Source &&
- "FIXME: AST inputs not yet supported here!");
- assert(Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() !=
- InputKind::LLVM_IR &&
- "IR inputs not support here!");
+ if (Clang->getFrontendOpts().Inputs.size() != 1 ||
+ Clang->getFrontendOpts().Inputs[0].getKind().getFormat() !=
+ InputKind::Source ||
+ Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() ==
+ InputKind::LLVM_IR) {
+ return BuildPreambleError::BadInputs;
+ }
// Clear out old caches and data.
Diagnostics.Reset();
@@ -784,6 +783,8 @@
return "BeginSourceFile() return an error";
case BuildPreambleError::CouldntEmitPCH:
return "Could not emit PCH";
+ case BuildPreambleError::BadInputs:
+ return "Command line arguments must contain exactly one source file";
}
llvm_unreachable("unexpected BuildPreambleError");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62137.200713.patch
Type: text/x-patch
Size: 2447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190522/f7602b30/attachment.bin>
More information about the cfe-commits
mailing list