summaryrefslogtreecommitdiffstats
path: root/clang/tools/driver
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-09-04 14:26:28 +0000
committerIlya Biryukov <ibiryukov@google.com>2019-09-04 14:26:28 +0000
commit433927595dde3821c76b33725aab8ccd472a5137 (patch)
treec43b08da79c34b273d3ddc64a1e0d809c68d64c2 /clang/tools/driver
parentcbf1f3b771c8c0e0858deafe5f9457fb838ff2c2 (diff)
downloadbcm5719-llvm-433927595dde3821c76b33725aab8ccd472a5137.tar.gz
bcm5719-llvm-433927595dde3821c76b33725aab8ccd472a5137.zip
[Driver] Use shared singleton instance of DriverOptTable
Summary: This significantly reduces the time required to run clangd tests, by ~10%. Should also have an effect on other tests that run command-line parsing multiple times inside a single invocation. Reviewers: gribozavr, sammccall Reviewed By: sammccall Subscribers: kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67163 llvm-svn: 370908
Diffstat (limited to 'clang/tools/driver')
-rw-r--r--clang/tools/driver/cc1as_main.cpp18
-rw-r--r--clang/tools/driver/driver.cpp5
2 files changed, 11 insertions, 12 deletions
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 4a59b2056af..fbeea0dd3b0 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -176,12 +176,12 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
bool Success = true;
// Parse the arguments.
- std::unique_ptr<OptTable> OptTbl(createDriverOptTable());
+ const OptTable &OptTbl = getDriverOptTable();
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
unsigned MissingArgIndex, MissingArgCount;
- InputArgList Args = OptTbl->ParseArgs(Argv, MissingArgIndex, MissingArgCount,
- IncludedFlagsBitmask);
+ InputArgList Args = OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount,
+ IncludedFlagsBitmask);
// Check for missing argument error.
if (MissingArgCount) {
@@ -194,7 +194,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
for (const Arg *A : Args.filtered(OPT_UNKNOWN)) {
auto ArgString = A->getAsString(Args);
std::string Nearest;
- if (OptTbl->findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
+ if (OptTbl.findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
Diags.Report(diag::err_drv_unknown_argument) << ArgString;
else
Diags.Report(diag::err_drv_unknown_argument_with_suggestion)
@@ -574,11 +574,11 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
return 1;
if (Asm.ShowHelp) {
- std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
- Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
- "Clang Integrated Assembler",
- /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
- /*ShowAllAliases=*/false);
+ getDriverOptTable().PrintHelp(
+ llvm::outs(), "clang -cc1as [options] file...",
+ "Clang Integrated Assembler",
+ /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
+ /*ShowAllAliases=*/false);
return 0;
}
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 01338d01c30..eebc8920fe0 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -271,10 +271,9 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
static DiagnosticOptions *
CreateAndPopulateDiagOpts(ArrayRef<const char *> argv) {
auto *DiagOpts = new DiagnosticOptions;
- std::unique_ptr<OptTable> Opts(createDriverOptTable());
unsigned MissingArgIndex, MissingArgCount;
- InputArgList Args =
- Opts->ParseArgs(argv.slice(1), MissingArgIndex, MissingArgCount);
+ InputArgList Args = getDriverOptTable().ParseArgs(
+ argv.slice(1), MissingArgIndex, MissingArgCount);
// We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
// Any errors that would be diagnosed here will also be diagnosed later,
// when the DiagnosticsEngine actually exists.
OpenPOWER on IntegriCloud