Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/Option/ArgList.h b/linux-x64/clang/include/llvm/Option/ArgList.h
index 74bfadc..9ce7839 100644
--- a/linux-x64/clang/include/llvm/Option/ArgList.h
+++ b/linux-x64/clang/include/llvm/Option/ArgList.h
@@ -412,6 +412,10 @@
return ArgStrings[Index];
}
+ void replaceArgString(unsigned Index, const Twine &S) {
+ ArgStrings[Index] = MakeArgString(S);
+ }
+
unsigned getNumInputArgStrings() const override {
return NumInputArgStrings;
}
diff --git a/linux-x64/clang/include/llvm/Option/OptParser.td b/linux-x64/clang/include/llvm/Option/OptParser.td
index a68f17a..94437ef 100644
--- a/linux-x64/clang/include/llvm/Option/OptParser.td
+++ b/linux-x64/clang/include/llvm/Option/OptParser.td
@@ -13,7 +13,7 @@
// Define the kinds of options.
-class OptionKind<string name, int precedence = 0, bit sentinel = 0> {
+class OptionKind<string name, int precedence = 0, bit sentinel = false> {
string Name = name;
// The kind precedence, kinds with lower precedence are matched first.
int Precedence = precedence;
@@ -24,9 +24,9 @@
// An option group.
def KIND_GROUP : OptionKind<"Group">;
// The input option kind.
-def KIND_INPUT : OptionKind<"Input", 1, 1>;
+def KIND_INPUT : OptionKind<"Input", 1, true>;
// The unknown option kind.
-def KIND_UNKNOWN : OptionKind<"Unknown", 2, 1>;
+def KIND_UNKNOWN : OptionKind<"Unknown", 2, true>;
// A flag with no values.
def KIND_FLAG : OptionKind<"Flag">;
// An option which prefixes its (single) value.
@@ -97,6 +97,20 @@
OptionGroup Group = ?;
Option Alias = ?;
list<string> AliasArgs = [];
+ code MacroPrefix = "";
+ code KeyPath = ?;
+ code DefaultValue = ?;
+ code ImpliedValue = ?;
+ code ImpliedCheck = "false";
+ code ShouldParse = "true";
+ bit ShouldAlwaysEmit = false;
+ code NormalizerRetTy = ?;
+ code NormalizedValuesScope = "";
+ code Normalizer = "";
+ code Denormalizer = "";
+ code ValueMerger = "mergeForwardValue";
+ code ValueExtractor = "extractForwardValue";
+ list<code> NormalizedValues = ?;
}
// Helpers for defining options.
@@ -130,6 +144,88 @@
class Values<string value> { string Values = value; }
class ValuesCode<code valuecode> { code ValuesCode = valuecode; }
+// Helpers for defining marshalling information.
+
+class KeyPathAndMacro<string key_path_prefix, string key_path_base,
+ string macro_prefix = ""> {
+ code KeyPath = !strconcat(key_path_prefix, key_path_base);
+ code MacroPrefix = macro_prefix;
+}
+
+def EmptyKPM : KeyPathAndMacro<"", "">;
+
+class ImpliedByAnyOf<list<Option> options, code value = "true"> {
+ code ImpliedCheck = !foldl("false", options, accumulator, option,
+ !strconcat(accumulator, " || ", option.KeyPath));
+ code ImpliedValue = value;
+}
+
+class MarshallingInfo<KeyPathAndMacro kpm, code defaultvalue> {
+ code KeyPath = kpm.KeyPath;
+ code MacroPrefix = kpm.MacroPrefix;
+ code DefaultValue = defaultvalue;
+}
+
+class MarshallingInfoString<KeyPathAndMacro kpm, code defaultvalue="std::string()">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeString";
+ code Denormalizer = "denormalizeString";
+}
+
+class MarshallingInfoStringInt<KeyPathAndMacro kpm, code defaultvalue="0", code type="unsigned">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeStringIntegral<"#type#">";
+ code Denormalizer = "denormalizeString";
+}
+
+class MarshallingInfoStringVector<KeyPathAndMacro kpm>
+ : MarshallingInfo<kpm, "std::vector<std::string>({})"> {
+ code Normalizer = "normalizeStringVector";
+ code Denormalizer = "denormalizeStringVector";
+}
+
+class MarshallingInfoFlag<KeyPathAndMacro kpm, code defaultvalue = "false">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeSimpleFlag";
+ code Denormalizer = "denormalizeSimpleFlag";
+}
+
+class MarshallingInfoNegativeFlag<KeyPathAndMacro kpm, code defaultvalue = "true">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeSimpleNegativeFlag";
+ code Denormalizer = "denormalizeSimpleFlag";
+}
+
+class MarshallingInfoBitfieldFlag<KeyPathAndMacro kpm, code value>
+ : MarshallingInfoFlag<kpm, "0u"> {
+ code Normalizer = "makeFlagToValueNormalizer("#value#")";
+ code ValueMerger = "mergeMaskValue";
+ code ValueExtractor = "(extractMaskValue<unsigned, decltype("#value#"), "#value#">)";
+}
+
+// Marshalling info for booleans. Applied to the flag setting keypath to false.
+class MarshallingInfoBooleanFlag<KeyPathAndMacro kpm, code defaultvalue, code value, code name,
+ code other_value, code other_name>
+ : MarshallingInfoFlag<kpm, defaultvalue> {
+ code Normalizer = "makeBooleanOptionNormalizer("#value#", "#other_value#", OPT_"#other_name#")";
+ code Denormalizer = "makeBooleanOptionDenormalizer("#value#")";
+}
+
+// Mixins for additional marshalling attributes.
+
+class ShouldParseIf<code condition> { code ShouldParse = condition; }
+class AlwaysEmit { bit ShouldAlwaysEmit = true; }
+class Normalizer<code normalizer> { code Normalizer = normalizer; }
+class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }
+class NormalizedValuesScope<code scope> { code NormalizedValuesScope = scope; }
+class NormalizedValues<list<code> definitions> { list<code> NormalizedValues = definitions; }
+class AutoNormalizeEnum {
+ code Normalizer = "normalizeSimpleEnum";
+ code Denormalizer = "denormalizeSimpleEnum";
+}
+class ValueMerger<code merger> { code ValueMerger = merger; }
+class ValueExtractor<code extractor> { code ValueExtractor = extractor; }
+
// Predefined options.
// FIXME: Have generator validate that these appear in correct position (and
diff --git a/linux-x64/clang/include/llvm/Option/OptTable.h b/linux-x64/clang/include/llvm/Option/OptTable.h
index 5db3043..58c09b2 100644
--- a/linux-x64/clang/include/llvm/Option/OptTable.h
+++ b/linux-x64/clang/include/llvm/Option/OptTable.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Option/OptSpecifier.h"
+#include "llvm/Support/StringSaver.h"
#include <cassert>
#include <string>
#include <vector>
@@ -20,6 +21,7 @@
namespace llvm {
class raw_ostream;
+template <typename Fn> class function_ref;
namespace opt {
@@ -48,7 +50,7 @@
unsigned ID;
unsigned char Kind;
unsigned char Param;
- unsigned short Flags;
+ unsigned int Flags;
unsigned short GroupID;
unsigned short AliasID;
const char *AliasArgs;
@@ -59,6 +61,8 @@
/// The option information table.
std::vector<Info> OptionInfos;
bool IgnoreCase;
+ bool GroupedShortOptions = false;
+ const char *EnvVar = nullptr;
unsigned TheInputOptionID = 0;
unsigned TheUnknownOptionID = 0;
@@ -79,6 +83,8 @@
return OptionInfos[id - 1];
}
+ Arg *parseOneArgGrouped(InputArgList &Args, unsigned &Index) const;
+
protected:
OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
@@ -120,6 +126,12 @@
return getInfo(id).MetaVar;
}
+ /// Specify the environment variable where initial options should be read.
+ void setInitialOptionsFromEnvironment(const char *E) { EnvVar = E; }
+
+ /// Support grouped short options. e.g. -ab represents -a -b.
+ void setGroupedShortOptions(bool Value) { GroupedShortOptions = Value; }
+
/// Find possible value for given flags. This is used for shell
/// autocompletion.
///
@@ -140,7 +152,7 @@
///
/// \return The vector of flags which start with Cur.
std::vector<std::string> findByPrefix(StringRef Cur,
- unsigned short DisableFlags) const;
+ unsigned int DisableFlags) const;
/// Find the OptTable option that most closely matches the given string.
///
@@ -213,6 +225,18 @@
unsigned &MissingArgCount, unsigned FlagsToInclude = 0,
unsigned FlagsToExclude = 0) const;
+ /// A convenience helper which handles optional initial options populated from
+ /// an environment variable, expands response files recursively and parses
+ /// options.
+ ///
+ /// \param ErrorFn - Called on a formatted error message for missing arguments
+ /// or unknown options.
+ /// \return An InputArgList; on error this will contain all the options which
+ /// could be parsed.
+ InputArgList parseArgs(int Argc, char *const *Argv, OptSpecifier Unknown,
+ StringSaver &Saver,
+ function_ref<void(StringRef)> ErrorFn) const;
+
/// Render the help text for an option table.
///
/// \param OS - The stream to write the help text to.
diff --git a/linux-x64/clang/include/llvm/Option/Option.h b/linux-x64/clang/include/llvm/Option/Option.h
index 33813d2..196cf65 100644
--- a/linux-x64/clang/include/llvm/Option/Option.h
+++ b/linux-x64/clang/include/llvm/Option/Option.h
@@ -130,11 +130,23 @@
/// Get the name of this option with the default prefix.
std::string getPrefixedName() const {
- std::string Ret = getPrefix();
+ std::string Ret(getPrefix());
Ret += getName();
return Ret;
}
+ /// Get the help text for this option.
+ StringRef getHelpText() const {
+ assert(Info && "Must have a valid info!");
+ return Info->HelpText;
+ }
+
+ /// Get the meta-variable list for this option.
+ StringRef getMetaVar() const {
+ assert(Info && "Must have a valid info!");
+ return Info->MetaVar;
+ }
+
unsigned getNumArgs() const { return Info->Param; }
bool hasNoOptAsInput() const { return Info->Flags & RenderAsInput;}
@@ -201,14 +213,16 @@
/// Index to the position where argument parsing should resume
/// (even if the argument is missing values).
///
- /// \param ArgSize The number of bytes taken up by the matched Option prefix
- /// and name. This is used to determine where joined values
- /// start.
- Arg *accept(const ArgList &Args, unsigned &Index, unsigned ArgSize) const;
+ /// \p CurArg The argument to be matched. It may be shorter than the
+ /// underlying storage to represent a Joined argument.
+ /// \p GroupedShortOption If true, we are handling the fallback case of
+ /// parsing a prefix of the current argument as a short option.
+ Arg *accept(const ArgList &Args, StringRef CurArg, bool GroupedShortOption,
+ unsigned &Index) const;
private:
- Arg *acceptInternal(const ArgList &Args, unsigned &Index,
- unsigned ArgSize) const;
+ Arg *acceptInternal(const ArgList &Args, StringRef CurArg,
+ unsigned &Index) const;
public:
void print(raw_ostream &O) const;