[PATCH] D96149: [clang][cli] Store InputKind in FrontendOptions
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 8 08:00:12 PST 2021
jansvoboda11 updated this revision to Diff 322113.
jansvoboda11 added a comment.
Fix typo in comment
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96149/new/
https://reviews.llvm.org/D96149
Files:
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2151,9 +2151,10 @@
return false;
}
-static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
- DiagnosticsEngine &Diags,
- bool &IsHeaderFile) {
+static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
+ DiagnosticsEngine &Diags, bool &IsHeaderFile) {
+ unsigned NumErrorsBefore = Diags.getNumErrors();
+
Opts.ProgramAction = frontend::ParseSyntaxOnly;
if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
switch (A->getOption().getID()) {
@@ -2422,7 +2423,9 @@
Opts.Inputs.emplace_back(std::move(Inputs[i]), IK, IsSystem);
}
- return DashX;
+ Opts.DashX = DashX;
+
+ return Diags.getNumErrors() == NumErrorsBefore;
}
std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
@@ -3956,9 +3959,10 @@
}
Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
/*DefaultDiagColor=*/false);
+ Success &= ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
+ LangOpts.IsHeaderFile);
// FIXME: We shouldn't have to pass the DashX option around here
- InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
- LangOpts.IsHeaderFile);
+ InputKind DashX = Res.getFrontendOpts().DashX;
ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
llvm::Triple T(Res.getTargetOpts().Triple);
ParseHeaderSearchArgs(Res, Res.getHeaderSearchOpts(), Args, Diags,
Index: clang/include/clang/Frontend/FrontendOptions.h
===================================================================
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -374,6 +374,10 @@
std::string MTMigrateDir;
std::string ARCMTMigrateReportOut;
+ /// The input kind, either specified via -x argument or deduced from the input
+ /// file name.
+ InputKind DashX;
+
/// The input files and their types.
SmallVector<FrontendInputFile, 0> Inputs;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96149.322113.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210208/925ed1ca/attachment-0001.bin>
More information about the cfe-commits
mailing list