forked from OSchip/llvm-project
Revert r311552: [Bash-autocompletion] Add support for static analyzer flags
This reverts commit r311552 because it broke ubsan and asan bots. llvm-svn: 311557
This commit is contained in:
parent
2f55b958b1
commit
a93f087d3e
|
@ -99,19 +99,7 @@ def analyzer_stats : Flag<["-"], "analyzer-stats">,
|
|||
HelpText<"Print internal analyzer statistics.">;
|
||||
|
||||
def analyzer_checker : Separate<["-"], "analyzer-checker">,
|
||||
HelpText<"Choose analyzer checkers to enable">,
|
||||
ValuesCode<[{
|
||||
const char *Values =
|
||||
#define GET_CHECKERS
|
||||
#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME ","
|
||||
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
|
||||
#undef GET_CHECKERS
|
||||
#define GET_PACKAGES
|
||||
#define PACKAGE(FULLNAME, G, D) FULLNAME ","
|
||||
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
|
||||
#undef GET_PACKAGES
|
||||
;
|
||||
}]>;
|
||||
HelpText<"Choose analyzer checkers to enable">;
|
||||
def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">,
|
||||
Alias<analyzer_checker>;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Option/OptTable.h"
|
||||
#include "llvm/Option/Option.h"
|
||||
#include <cassert>
|
||||
|
||||
using namespace clang::driver;
|
||||
using namespace clang::driver::options;
|
||||
|
@ -41,13 +40,5 @@ public:
|
|||
}
|
||||
|
||||
std::unique_ptr<OptTable> clang::driver::createDriverOptTable() {
|
||||
auto Result = llvm::make_unique<DriverOptTable>();
|
||||
// Options.inc is included in DriverOptions.cpp, and calls OptTable's
|
||||
// addValues function.
|
||||
// Opt is a variable used in the code fragment in Options.inc.
|
||||
OptTable &Opt = *Result;
|
||||
#define OPTTABLE_ARG_INIT
|
||||
#include "clang/Driver/Options.inc"
|
||||
#undef OPTTABLE_ARG_INIT
|
||||
return std::move(Result);
|
||||
return llvm::make_unique<DriverOptTable>();
|
||||
}
|
||||
|
|
|
@ -93,5 +93,3 @@
|
|||
// WARNING-NEXT: -Wmax-unsigned-zero
|
||||
// RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING
|
||||
// NOWARNING: -Wno-invalid-pp-token
|
||||
// RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER
|
||||
// ANALYZER: unix.Malloc
|
||||
|
|
|
@ -93,7 +93,6 @@ class Option<list<string> prefixes, string name, OptionKind kind> {
|
|||
string HelpText = ?;
|
||||
string MetaVarName = ?;
|
||||
string Values = ?;
|
||||
code ValuesCode = ?;
|
||||
list<OptionFlag> Flags = [];
|
||||
OptionGroup Group = ?;
|
||||
Option Alias = ?;
|
||||
|
@ -129,7 +128,6 @@ class Group<OptionGroup group> { OptionGroup Group = group; }
|
|||
class HelpText<string text> { string HelpText = text; }
|
||||
class MetaVarName<string name> { string MetaVarName = name; }
|
||||
class Values<string value> { string Values = value; }
|
||||
class ValuesCode<code valuecode> { code ValuesCode = valuecode; }
|
||||
|
||||
// Predefined options.
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
/// \brief The option information table.
|
||||
std::vector<Info> OptionInfos;
|
||||
/// \brief The static option information table.
|
||||
ArrayRef<Info> OptionInfos;
|
||||
bool IgnoreCase;
|
||||
|
||||
unsigned TheInputOptionID = 0;
|
||||
|
@ -143,17 +143,6 @@ public:
|
|||
std::vector<std::string> findByPrefix(StringRef Cur,
|
||||
unsigned short DisableFlags) const;
|
||||
|
||||
/// Add Values to Option's Values class
|
||||
///
|
||||
/// \param [in] Option - Prefix + Name of the flag which Values will be
|
||||
/// changed. For example, "-analyzer-checker".
|
||||
/// \param [in] Values - String of Values seperated by ",", such as
|
||||
/// "foo, bar..", where foo and bar is the argument which the Option flag
|
||||
/// takes
|
||||
///
|
||||
/// \return true in success, and false in fail.
|
||||
bool addValues(const char *Option, const char *Values);
|
||||
|
||||
/// \brief Parse a single argument; returning the new argument and
|
||||
/// updating Index.
|
||||
///
|
||||
|
|
|
@ -196,7 +196,7 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str,
|
|||
|
||||
// Returns true if one of the Prefixes + In.Names matches Option
|
||||
static bool optionMatches(const OptTable::Info &In, StringRef Option) {
|
||||
if (In.Prefixes)
|
||||
if (In.Values && In.Prefixes)
|
||||
for (size_t I = 0; In.Prefixes[I]; I++)
|
||||
if (Option == std::string(In.Prefixes[I]) + In.Name)
|
||||
return true;
|
||||
|
@ -209,9 +209,8 @@ static bool optionMatches(const OptTable::Info &In, StringRef Option) {
|
|||
std::vector<std::string>
|
||||
OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
|
||||
// Search all options and return possible values.
|
||||
for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
|
||||
const Info &In = OptionInfos[I];
|
||||
if (!In.Values || !optionMatches(In, Option))
|
||||
for (const Info &In : OptionInfos.slice(FirstSearchableIndex)) {
|
||||
if (!optionMatches(In, Option))
|
||||
continue;
|
||||
|
||||
SmallVector<StringRef, 8> Candidates;
|
||||
|
@ -229,8 +228,7 @@ OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
|
|||
std::vector<std::string>
|
||||
OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
|
||||
std::vector<std::string> Ret;
|
||||
for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
|
||||
const Info &In = OptionInfos[I];
|
||||
for (const Info &In : OptionInfos.slice(FirstSearchableIndex)) {
|
||||
if (!In.Prefixes || (!In.HelpText && !In.GroupID))
|
||||
continue;
|
||||
if (In.Flags & DisableFlags)
|
||||
|
@ -247,17 +245,6 @@ OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
|
|||
return Ret;
|
||||
}
|
||||
|
||||
bool OptTable::addValues(const char *Option, const char *Values) {
|
||||
for (size_t I = FirstSearchableIndex, E = OptionInfos.size(); I < E; I++) {
|
||||
Info &In = OptionInfos[I];
|
||||
if (optionMatches(In, Option)) {
|
||||
In.Values = Values;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
|
||||
unsigned FlagsToInclude,
|
||||
unsigned FlagsToExclude) const {
|
||||
|
@ -269,8 +256,8 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
|
|||
if (isInput(PrefixesUnion, Str))
|
||||
return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
|
||||
|
||||
const Info *Start = OptionInfos.data() + FirstSearchableIndex;
|
||||
const Info *End = OptionInfos.data() + OptionInfos.size();
|
||||
const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
|
||||
const Info *End = OptionInfos.end();
|
||||
StringRef Name = StringRef(Str).ltrim(PrefixChars);
|
||||
|
||||
// Search for the first next option which could be a prefix.
|
||||
|
|
|
@ -298,31 +298,5 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) {
|
|||
OS << ")\n";
|
||||
}
|
||||
OS << "#endif // OPTION\n";
|
||||
|
||||
OS << "\n";
|
||||
OS << "#ifdef OPTTABLE_ARG_INIT\n";
|
||||
OS << "//////////\n";
|
||||
OS << "// Option Values\n\n";
|
||||
for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
|
||||
const Record &R = *Opts[I];
|
||||
if (isa<UnsetInit>(R.getValueInit("ValuesCode")))
|
||||
continue;
|
||||
OS << "{\n";
|
||||
OS << R.getValueAsString("ValuesCode");
|
||||
OS << "\n";
|
||||
for (const std::string &Pref : R.getValueAsListOfStrings("Prefixes")) {
|
||||
OS << "bool ValuesWereAdded = ";
|
||||
OS << "Opt.addValues(";
|
||||
std::string S = (Pref + R.getValueAsString("Name")).str();
|
||||
write_cstring(OS, S);
|
||||
OS << ", Values);\n";
|
||||
OS << "(void)ValuesWereAdded;\n";
|
||||
OS << "assert(ValuesWereAdded && \"Couldn't add values to "
|
||||
"OptTable!\");\n";
|
||||
}
|
||||
OS << "}\n";
|
||||
}
|
||||
OS << "\n";
|
||||
OS << "#endif // OPTTABLE_ARG_INIT\n";
|
||||
}
|
||||
} // end namespace llvm
|
||||
|
|
Loading…
Reference in New Issue