Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Validate -add-plugin arguments.
Browse files Browse the repository at this point in the history
-plugin already prints an error if the name of an unknown plugin is passed.
-add-plugin used to silently ignore that, now it errors too.

Differential Revision: https://reviews.llvm.org/D56273


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350340 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
nico committed Jan 3, 2019
1 parent a11ecd1 commit 5f2efcd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/Frontend/CompilerInvocation.cpp
Expand Up @@ -33,6 +33,7 @@
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Frontend/LangStandard.h"
#include "clang/Frontend/MigratorOptions.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
Expand Down Expand Up @@ -1663,7 +1664,20 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.ProgramAction = frontend::PluginAction;
Opts.ActionName = A->getValue();
}
Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
for (const std::string &Arg : Args.getAllArgValues(OPT_add_plugin)) {
bool Found = false;
for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
ie = FrontendPluginRegistry::end();
it != ie; ++it) {
if (it->getName() == Arg)
Found = true;
}
if (!Found) {
Diags.Report(diag::err_fe_invalid_plugin_name) << Arg;
continue;
}
Opts.AddPluginActions.push_back(Arg);
}
for (const auto *AA : Args.filtered(OPT_plugin_arg))
Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));

Expand Down
5 changes: 5 additions & 0 deletions test/Frontend/plugin-unknown.c
@@ -0,0 +1,5 @@
// RUN: not %clang_cc1 -plugin asdf %s 2>&1 | FileCheck %s
// RUN: not %clang_cc1 -add-plugin asdf %s 2>&1 | FileCheck --check-prefix=ADD %s

// CHECK: unable to find plugin 'asdf'
// ADD: unable to find plugin 'asdf'

0 comments on commit 5f2efcd

Please sign in to comment.