Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2249,7 +2249,14 @@ def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>; def std_default_EQ : Joined<["-"], "std-default=">; def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>, - Group, HelpText<"Language standard to compile for">; + Group, HelpText<"Language standard to compile for">, + ValuesCode<[{ + const char *Values = + #define LANGSTANDARD(id, name, lang, desc, features) name "," + #define LANGSTANDARD_ALIAS(id, alias) alias "," + #include "clang/Frontend/LangStandards.def" + ; + }]>; def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; Index: clang/test/Driver/autocomplete.c =================================================================== --- clang/test/Driver/autocomplete.c +++ clang/test/Driver/autocomplete.c @@ -95,3 +95,5 @@ // NOWARNING: -Wno-invalid-pp-token // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER // ANALYZER: unix.Malloc +// RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL +// STDVAL: c99 Index: llvm/utils/TableGen/OptParserEmitter.cpp =================================================================== --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -305,21 +305,22 @@ OS << "// Option Values\n\n"; for (unsigned I = 0, E = Opts.size(); I != E; ++I) { const Record &R = *Opts[I]; - if (!isa(R.getValueInit("ValuesCode"))) { - 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;\nassert(ValuesWereAdded &&"; - OS << " \"Couldn't add values to OptTable!\");\n"; + if (isa(R.getValueInit("ValuesCode"))) + continue; + OS << "{\n"; + OS << "bool ValuesWereAdded;\n"; + OS << R.getValueAsString("ValuesCode"); + OS << "\n"; + for (const std::string &Pref : R.getValueAsListOfStrings("Prefixes")) { + OS << "ValuesWereAdded = 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";