-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC][clang][TableGen] Remove redundant llvm:: namespace qualifier #108627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Remove llvm:: from .cpp files, and add "using namespace llvm" if needed.
73a8e42
to
18064b1
Compare
@llvm/pr-subscribers-clang Author: Rahul Joshi (jurahul) ChangesRemove llvm:: from .cpp files, and add "using namespace llvm" if needed. Patch is 55.70 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/108627.diff 14 Files Affected:
diff --git a/clang/utils/TableGen/ASTTableGen.cpp b/clang/utils/TableGen/ASTTableGen.cpp
index 47344777e9311a..46bb6c21997f09 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
using namespace clang;
using namespace clang::tblgen;
-llvm::StringRef clang::tblgen::HasProperties::getName() const {
+StringRef clang::tblgen::HasProperties::getName() const {
if (auto node = getAs<ASTNode>()) {
return node.getName();
} else if (auto typeCase = getAs<TypeCase>()) {
diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index 2d67b6b643637c..3151ff199f5762 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -205,8 +205,7 @@ class ASTPropsEmitter {
void visitAllNodesWithInfo(
HasProperties derivedNode, const NodeInfo &derivedNodeInfo,
- llvm::function_ref<void(HasProperties node, const NodeInfo &info)>
- visit) {
+ function_ref<void(HasProperties node, const NodeInfo &info)> visit) {
visit(derivedNode, derivedNodeInfo);
// Also walk the bases if appropriate.
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 9b2249ac90bc5c..f593f6428fe4cc 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1475,7 +1475,7 @@ createArgument(const Record &Arg, StringRef Attr,
Search = &Arg;
std::unique_ptr<Argument> Ptr;
- llvm::StringRef ArgName = Search->getName();
+ StringRef ArgName = Search->getName();
if (ArgName == "AlignedArgument")
Ptr = std::make_unique<AlignedArgument>(Arg, Attr);
@@ -1532,7 +1532,7 @@ createArgument(const Record &Arg, StringRef Attr,
if (!Ptr) {
// Search in reverse order so that the most-derived type is handled first.
ArrayRef<std::pair<Record*, SMRange>> Bases = Search->getSuperClasses();
- for (const auto &Base : llvm::reverse(Bases)) {
+ for (const auto &Base : reverse(Bases)) {
if ((Ptr = createArgument(Arg, Attr, Base.first)))
break;
}
@@ -1611,11 +1611,11 @@ writePrettyPrintFunction(const Record &R,
<< " break;\n";
for (unsigned I = 0; I < Spellings.size(); ++ I) {
- llvm::SmallString<16> Prefix;
- llvm::SmallString<8> Suffix;
+ SmallString<16> Prefix;
+ SmallString<8> Suffix;
// The actual spelling of the name and namespace (if applicable)
// of an attribute without considering prefix and suffix.
- llvm::SmallString<64> Spelling;
+ SmallString<64> Spelling;
std::string Name = Spellings[I].name();
std::string Variety = Spellings[I].variety();
@@ -1680,7 +1680,7 @@ writePrettyPrintFunction(const Record &R,
// printing spurious commas at the end of an argument list, we need to
// determine where the last provided non-fake argument is.
bool FoundNonOptArg = false;
- for (const auto &arg : llvm::reverse(Args)) {
+ for (const auto &arg : reverse(Args)) {
if (arg->isFake())
continue;
if (FoundNonOptArg)
@@ -1776,7 +1776,7 @@ SpellingNamesAreCommon(const std::vector<FlattenedSpelling>& Spellings) {
assert(!Spellings.empty() && "An empty list of spellings was provided");
std::string FirstName =
std::string(NormalizeNameForSpellingComparison(Spellings.front().name()));
- for (const auto &Spelling : llvm::drop_begin(Spellings)) {
+ for (const auto &Spelling : drop_begin(Spellings)) {
std::string Name =
std::string(NormalizeNameForSpellingComparison(Spelling.name()));
if (Name != FirstName)
@@ -1834,7 +1834,7 @@ CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
// enumeration, but the spelling index and semantic spelling values are
// meant to be equivalent, so we must specify a concrete value for each
// enumerator.
- Ret += " " + EnumName + " = " + llvm::utostr(Idx);
+ Ret += " " + EnumName + " = " + utostr(Idx);
}
Ret += ",\n SpellingNotCalculated = 15\n";
Ret += "\n };\n\n";
@@ -1871,15 +1871,14 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
SmallVector<Record *, 1> SuperClasses;
LAPK->getDirectSuperClasses(SuperClasses);
if (SuperClasses.size() != 1)
- PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
+ PrintFatalError(Attr, "Field `" + Twine(LateParsedStr) +
"`should only have one super class");
if (SuperClasses[0]->getName() != LateAttrParseKindStr)
- PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
- "`should only have type `" +
- llvm::Twine(LateAttrParseKindStr) +
- "` but found type `" +
- SuperClasses[0]->getName() + "`");
+ PrintFatalError(
+ Attr, "Field `" + Twine(LateParsedStr) + "`should only have type `" +
+ Twine(LateAttrParseKindStr) + "` but found type `" +
+ SuperClasses[0]->getName() + "`");
// Get Kind and verify the enum name matches the name in `Attr.td`.
unsigned Kind = LAPK->getValueAsInt(KindFieldStr);
@@ -1887,11 +1886,11 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
#define CASE(X) \
case LateAttrParseKind::X: \
if (LAPK->getName().compare("LateAttrParse" #X) != 0) { \
- PrintFatalError(Attr, \
- "Field `" + llvm::Twine(LateParsedStr) + "` set to `" + \
- LAPK->getName() + \
- "` but this converts to `LateAttrParseKind::" + \
- llvm::Twine(#X) + "`"); \
+ PrintFatalError( \
+ Attr, \
+ "Field `" + Twine(LateParsedStr) + "` set to `" + LAPK->getName() + \
+ "` but this converts to `LateAttrParseKind::" + Twine(#X) + \
+ "`"); \
} \
return LateAttrParseKind::X;
@@ -1902,11 +1901,10 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
}
// The Kind value is completely invalid
- auto KindValueStr = llvm::utostr(Kind);
- PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "` set to `" +
+ auto KindValueStr = utostr(Kind);
+ PrintFatalError(Attr, "Field `" + Twine(LateParsedStr) + "` set to `" +
LAPK->getName() + "` has unexpected `" +
- llvm::Twine(KindFieldStr) + "` value of " +
- KindValueStr);
+ Twine(KindFieldStr) + "` value of " + KindValueStr);
}
// Emits the LateParsed property for attributes.
@@ -2061,7 +2059,7 @@ struct PragmaClangAttributeSupport {
return RuleOrAggregateRuleSet(Rules, /*IsRule=*/false);
}
};
- llvm::DenseMap<const Record *, RuleOrAggregateRuleSet> SubjectsToRules;
+ DenseMap<const Record *, RuleOrAggregateRuleSet> SubjectsToRules;
PragmaClangAttributeSupport(const RecordKeeper &Records);
@@ -2301,7 +2299,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " return std::nullopt;\n";
OS << "}\n\n";
- llvm::MapVector<const Record *, std::vector<AttributeSubjectMatchRule>>
+ MapVector<const Record *, std::vector<AttributeSubjectMatchRule>>
SubMatchRules;
for (const auto &Rule : Rules) {
if (!Rule.isSubRule())
@@ -2404,7 +2402,7 @@ void generateNameToAttrsMap(const RecordKeeper &Records) {
for (const auto &S : Spellings) {
auto It = NameToAttrsMap.find(S.name());
if (It != NameToAttrsMap.end()) {
- if (llvm::none_of(It->second, [&](const Record *R) { return R == A; }))
+ if (none_of(It->second, [&](const Record *R) { return R == A; }))
It->second.emplace_back(A);
} else {
std::vector<const Record *> V;
@@ -2542,17 +2540,16 @@ static void emitClangAttrArgContextList(const RecordKeeper &Records,
static bool isIdentifierArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
- .Case("IdentifierArgument", true)
- .Case("EnumArgument", true)
- .Case("VariadicEnumArgument", true)
- .Default(false);
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
+ .Case("IdentifierArgument", true)
+ .Case("EnumArgument", true)
+ .Case("VariadicEnumArgument", true)
+ .Default(false);
}
static bool isVariadicIdentifierArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("VariadicIdentifierArgument", true)
.Case("VariadicParamOrParamIdxArgument", true)
.Default(false);
@@ -2560,8 +2557,7 @@ static bool isVariadicIdentifierArgument(const Record *Arg) {
static bool isVariadicExprArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("VariadicExprArgument", true)
.Default(false);
}
@@ -2658,7 +2654,7 @@ static void emitClangAttrStrictIdentifierArgList(const RecordKeeper &Records,
continue;
// Check that there is really an identifier argument.
std::vector<Record *> Args = Attr->getValueAsListOfDefs("Args");
- if (llvm::none_of(Args, [&](Record *R) { return isIdentifierArgument(R); }))
+ if (none_of(Args, [&](Record *R) { return isIdentifierArgument(R); }))
continue;
generateFlattenedSpellingInfo(*Attr, FSIMap);
}
@@ -2668,8 +2664,7 @@ static void emitClangAttrStrictIdentifierArgList(const RecordKeeper &Records,
static bool keywordThisIsaIdentifierInArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("VariadicParamOrParamIdxArgument", true)
.Default(false);
}
@@ -2759,7 +2754,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
assert(!Supers.empty() && "Forgot to specify a superclass for the attr");
std::string SuperName;
bool Inheritable = false;
- for (const auto &Super : llvm::reverse(Supers)) {
+ for (const auto &Super : reverse(Supers)) {
const Record *R = Super.first;
if (R->getName() != "TargetSpecificAttr" &&
R->getName() != "DeclOrTypeAttr" && SuperName.empty())
@@ -2843,8 +2838,8 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
if (Header)
OS << SpellingEnum;
- const auto &ParsedAttrSpellingItr = llvm::find_if(
- AttrMap, [R](const std::pair<std::string, const Record *> &P) {
+ const auto &ParsedAttrSpellingItr =
+ find_if(AttrMap, [R](const std::pair<std::string, const Record *> &P) {
return &R == P.second;
});
@@ -3133,7 +3128,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
// Emit constructors that takes no arguments if none already exists.
// This is used for delaying arguments.
bool HasRequiredArgs =
- llvm::count_if(Args, [=](const std::unique_ptr<Argument> &arg) {
+ count_if(Args, [=](const std::unique_ptr<Argument> &arg) {
return !arg->isFake() && !arg->isOptional();
});
if (DelayedArgs && HasRequiredArgs)
@@ -3280,7 +3275,7 @@ static void emitAttrList(raw_ostream &OS, StringRef Class,
// Determines if an attribute has a Pragma spelling.
static bool AttrHasPragmaSpelling(const Record *R) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
- return llvm::any_of(Spellings, [](const FlattenedSpelling &S) {
+ return any_of(Spellings, [](const FlattenedSpelling &S) {
return S.variety() == "Pragma";
});
}
@@ -3646,7 +3641,7 @@ static bool GenerateTargetSpecificAttrChecks(const Record *R,
std::string *FnName) {
bool AnyTargetChecks = false;
- // It is assumed that there will be an llvm::Triple object
+ // It is assumed that there will be an Triple object
// named "T" and a TargetInfo object named "Target" within
// scope that can be used to determine whether the attribute exists in
// a given target.
@@ -3756,8 +3751,8 @@ static void GenerateHasAttrSpellingStringSwitch(
}
std::string TestStr = !Test.empty()
- ? Test + " ? " + llvm::itostr(Version) + " : 0"
- : llvm::itostr(Version);
+ ? Test + " ? " + itostr(Version) + " : 0"
+ : itostr(Version);
if (Scope.empty() || Scope == Spelling.nameSpace())
OS << " .Case(\"" << Spelling.name() << "\", " << TestStr << ")\n";
}
@@ -3780,7 +3775,7 @@ void EmitClangRegularKeywordAttributeInfo(const RecordKeeper &Records,
if (!isRegularKeywordAttribute(S))
continue;
std::vector<Record *> Args = R->getValueAsListOfDefs("Args");
- bool HasArgs = llvm::any_of(
+ bool HasArgs = any_of(
Args, [](const Record *Arg) { return !Arg->getValueAsBit("Fake"); });
OS << "KEYWORD_ATTRIBUTE("
@@ -4136,7 +4131,7 @@ static std::string CalculateDiagnostic(const Record &S) {
// The node may contain a list of elements itself, so split the elements
// by a comma, and trim any whitespace.
SmallVector<StringRef, 2> Frags;
- llvm::SplitString(V, Frags, ",");
+ SplitString(V, Frags, ",");
for (auto Str : Frags) {
DiagList.push_back(std::string(Str.trim()));
}
@@ -4164,7 +4159,7 @@ static std::string CalculateDiagnostic(const Record &S) {
// elements with a comma. This leaves the string in the state: foo, bar,
// baz (but misses quux). We can then add ", and " for the last element
// manually.
- std::string Diag = llvm::join(DiagList.begin(), DiagList.end() - 1, ", ");
+ std::string Diag = join(DiagList.begin(), DiagList.end() - 1, ", ");
return '"' + Diag + ", and " + *(DiagList.end() - 1) + '"';
}
@@ -4230,12 +4225,11 @@ static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
// enough statement attributes with custom subject needs to warrant
// the implementation effort.
std::vector<Record *> DeclSubjects, StmtSubjects;
- llvm::copy_if(
- Subjects, std::back_inserter(DeclSubjects), [](const Record *R) {
- return R->isSubClassOf("SubsetSubject") || !R->isSubClassOf("StmtNode");
- });
- llvm::copy_if(Subjects, std::back_inserter(StmtSubjects),
- [](const Record *R) { return R->isSubClassOf("StmtNode"); });
+ copy_if(Subjects, std::back_inserter(DeclSubjects), [](const Record *R) {
+ return R->isSubClassOf("SubsetSubject") || !R->isSubClassOf("StmtNode");
+ });
+ copy_if(Subjects, std::back_inserter(StmtSubjects),
+ [](const Record *R) { return R->isSubClassOf("StmtNode"); });
// We should have sorted all of the subjects into two lists.
// FIXME: this assertion will be wrong if we ever add type attribute subjects.
@@ -4353,7 +4347,7 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
auto IsCurAttr = [Attr](const Record *R) {
return R->getName() == Attr.getName();
};
- if (llvm::any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
+ if (any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
// This list of exclusions includes the attribute we're looking for, so
// add the exclusive attributes to the proper list for checking.
for (const Record *AttrToExclude : MutuallyExclusiveAttrs) {
@@ -4565,8 +4559,7 @@ GenerateSpellingTargetRequirements(const Record &Attr,
Test += "((SpellingListIndex == ";
for (unsigned Index = 0; Index < Spellings.size(); ++Index) {
- Test +=
- llvm::itostr(getSpellingListIndex(SpellingList, Spellings[Index]));
+ Test += itostr(getSpellingListIndex(SpellingList, Spellings[Index]));
if (Index != Spellings.size() - 1)
Test += " ||\n SpellingListIndex == ";
else
@@ -4632,8 +4625,7 @@ static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) {
static bool isParamExpr(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("ExprArgument", true)
.Case("VariadicExprArgument", true)
.Default(false);
@@ -4683,9 +4675,8 @@ void GenerateHandleAttrWithDelayedArgs(const RecordKeeper &Records,
static bool IsKnownToGCC(const Record &Attr) {
// Look at the spellings for this subject; if there are any spellings which
// claim to be known to GCC, the attribute is known to GCC.
- return llvm::any_of(
- GetFlattenedSpellings(Attr),
- [](const FlattenedSpelling &S) { return S.knownToGCC(); });
+ return any_of(GetFlattenedSpellings(Attr),
+ [](const FlattenedSpelling &S) { return S.knownToGCC(); });
}
/// Emits the parsed attribute helpers
@@ -4967,7 +4958,7 @@ void EmitClangAttrTextNodeDump(const RecordKeeper &Records, raw_ostream &OS) {
// spelling used for the attribute.
std::string FunctionContent;
- llvm::raw_string_ostream SS(FunctionContent);
+ raw_string_ostream SS(FunctionContent);
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(R);
if (Spellings.size() > 1 && !SpellingNamesAreCommon(Spellings))
@@ -5001,7 +4992,7 @@ void EmitClangAttrNodeTraverse(const RecordKeeper &Records, raw_ostream &OS) {
continue;
std::string FunctionContent;
- llvm::raw_string_ostream SS(FunctionContent);
+ raw_string_ostream SS(FunctionContent);
std::vector<Record *> Args = R.getValueAsListOfDefs("Args");
for (const auto *Arg : Args)
@@ -5173,7 +5164,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
// concatenating all the spellings. Might not be great, but better than
// nothing.
else if (Cat == "Undocumented")
- Heading = llvm::join(Uniques.begin(), Uniques.end(), ", ");
+ Heading = join(Uniques.begin(), Uniques.end(), ", ");
}
}
@@ -5291,10 +5282,10 @@ void EmitClangAttrDocs(const RecordKeeper &Records, raw_ostream &OS) {
for (auto &I : SplitDocs) {
WriteCategoryHeader(I.first, OS);
- llvm::sort(I.second,
- [](const DocumentationData &D1, const DocumentationData &D2) {
- return D1.Heading < D2.Heading;
- });
+ sort(I.second,
+ [](const DocumentationData &D1, const DocumentationData &D2) {
+ return D1.Heading < D2.Heading;
+ });
// Walk over each of the attributes in the category and write out their
// documentation.
@@ -5321,7 +5312,7 @@ void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
SubjectObj->getValueAsListOfDefs("Subjects");
OS << " (";
bool PrintComma = false;
- for (const auto &Subject : llvm::enumerate(Subjects)) {
+ for (const auto &Subject : enumerate(Subjects)) {
if (!isSupportedPragmaClangAttributeSubject(*Subject.value()))
continue;
if (PrintComma)
@@ -5334,7 +5325,7 @@ void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
continu...
[truncated]
|
@llvm/pr-subscribers-backend-risc-v Author: Rahul Joshi (jurahul) ChangesRemove llvm:: from .cpp files, and add "using namespace llvm" if needed. Patch is 55.70 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/108627.diff 14 Files Affected:
diff --git a/clang/utils/TableGen/ASTTableGen.cpp b/clang/utils/TableGen/ASTTableGen.cpp
index 47344777e9311a..46bb6c21997f09 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
using namespace clang;
using namespace clang::tblgen;
-llvm::StringRef clang::tblgen::HasProperties::getName() const {
+StringRef clang::tblgen::HasProperties::getName() const {
if (auto node = getAs<ASTNode>()) {
return node.getName();
} else if (auto typeCase = getAs<TypeCase>()) {
diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index 2d67b6b643637c..3151ff199f5762 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -205,8 +205,7 @@ class ASTPropsEmitter {
void visitAllNodesWithInfo(
HasProperties derivedNode, const NodeInfo &derivedNodeInfo,
- llvm::function_ref<void(HasProperties node, const NodeInfo &info)>
- visit) {
+ function_ref<void(HasProperties node, const NodeInfo &info)> visit) {
visit(derivedNode, derivedNodeInfo);
// Also walk the bases if appropriate.
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 9b2249ac90bc5c..f593f6428fe4cc 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1475,7 +1475,7 @@ createArgument(const Record &Arg, StringRef Attr,
Search = &Arg;
std::unique_ptr<Argument> Ptr;
- llvm::StringRef ArgName = Search->getName();
+ StringRef ArgName = Search->getName();
if (ArgName == "AlignedArgument")
Ptr = std::make_unique<AlignedArgument>(Arg, Attr);
@@ -1532,7 +1532,7 @@ createArgument(const Record &Arg, StringRef Attr,
if (!Ptr) {
// Search in reverse order so that the most-derived type is handled first.
ArrayRef<std::pair<Record*, SMRange>> Bases = Search->getSuperClasses();
- for (const auto &Base : llvm::reverse(Bases)) {
+ for (const auto &Base : reverse(Bases)) {
if ((Ptr = createArgument(Arg, Attr, Base.first)))
break;
}
@@ -1611,11 +1611,11 @@ writePrettyPrintFunction(const Record &R,
<< " break;\n";
for (unsigned I = 0; I < Spellings.size(); ++ I) {
- llvm::SmallString<16> Prefix;
- llvm::SmallString<8> Suffix;
+ SmallString<16> Prefix;
+ SmallString<8> Suffix;
// The actual spelling of the name and namespace (if applicable)
// of an attribute without considering prefix and suffix.
- llvm::SmallString<64> Spelling;
+ SmallString<64> Spelling;
std::string Name = Spellings[I].name();
std::string Variety = Spellings[I].variety();
@@ -1680,7 +1680,7 @@ writePrettyPrintFunction(const Record &R,
// printing spurious commas at the end of an argument list, we need to
// determine where the last provided non-fake argument is.
bool FoundNonOptArg = false;
- for (const auto &arg : llvm::reverse(Args)) {
+ for (const auto &arg : reverse(Args)) {
if (arg->isFake())
continue;
if (FoundNonOptArg)
@@ -1776,7 +1776,7 @@ SpellingNamesAreCommon(const std::vector<FlattenedSpelling>& Spellings) {
assert(!Spellings.empty() && "An empty list of spellings was provided");
std::string FirstName =
std::string(NormalizeNameForSpellingComparison(Spellings.front().name()));
- for (const auto &Spelling : llvm::drop_begin(Spellings)) {
+ for (const auto &Spelling : drop_begin(Spellings)) {
std::string Name =
std::string(NormalizeNameForSpellingComparison(Spelling.name()));
if (Name != FirstName)
@@ -1834,7 +1834,7 @@ CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
// enumeration, but the spelling index and semantic spelling values are
// meant to be equivalent, so we must specify a concrete value for each
// enumerator.
- Ret += " " + EnumName + " = " + llvm::utostr(Idx);
+ Ret += " " + EnumName + " = " + utostr(Idx);
}
Ret += ",\n SpellingNotCalculated = 15\n";
Ret += "\n };\n\n";
@@ -1871,15 +1871,14 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
SmallVector<Record *, 1> SuperClasses;
LAPK->getDirectSuperClasses(SuperClasses);
if (SuperClasses.size() != 1)
- PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
+ PrintFatalError(Attr, "Field `" + Twine(LateParsedStr) +
"`should only have one super class");
if (SuperClasses[0]->getName() != LateAttrParseKindStr)
- PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) +
- "`should only have type `" +
- llvm::Twine(LateAttrParseKindStr) +
- "` but found type `" +
- SuperClasses[0]->getName() + "`");
+ PrintFatalError(
+ Attr, "Field `" + Twine(LateParsedStr) + "`should only have type `" +
+ Twine(LateAttrParseKindStr) + "` but found type `" +
+ SuperClasses[0]->getName() + "`");
// Get Kind and verify the enum name matches the name in `Attr.td`.
unsigned Kind = LAPK->getValueAsInt(KindFieldStr);
@@ -1887,11 +1886,11 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
#define CASE(X) \
case LateAttrParseKind::X: \
if (LAPK->getName().compare("LateAttrParse" #X) != 0) { \
- PrintFatalError(Attr, \
- "Field `" + llvm::Twine(LateParsedStr) + "` set to `" + \
- LAPK->getName() + \
- "` but this converts to `LateAttrParseKind::" + \
- llvm::Twine(#X) + "`"); \
+ PrintFatalError( \
+ Attr, \
+ "Field `" + Twine(LateParsedStr) + "` set to `" + LAPK->getName() + \
+ "` but this converts to `LateAttrParseKind::" + Twine(#X) + \
+ "`"); \
} \
return LateAttrParseKind::X;
@@ -1902,11 +1901,10 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) {
}
// The Kind value is completely invalid
- auto KindValueStr = llvm::utostr(Kind);
- PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "` set to `" +
+ auto KindValueStr = utostr(Kind);
+ PrintFatalError(Attr, "Field `" + Twine(LateParsedStr) + "` set to `" +
LAPK->getName() + "` has unexpected `" +
- llvm::Twine(KindFieldStr) + "` value of " +
- KindValueStr);
+ Twine(KindFieldStr) + "` value of " + KindValueStr);
}
// Emits the LateParsed property for attributes.
@@ -2061,7 +2059,7 @@ struct PragmaClangAttributeSupport {
return RuleOrAggregateRuleSet(Rules, /*IsRule=*/false);
}
};
- llvm::DenseMap<const Record *, RuleOrAggregateRuleSet> SubjectsToRules;
+ DenseMap<const Record *, RuleOrAggregateRuleSet> SubjectsToRules;
PragmaClangAttributeSupport(const RecordKeeper &Records);
@@ -2301,7 +2299,7 @@ void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
OS << " return std::nullopt;\n";
OS << "}\n\n";
- llvm::MapVector<const Record *, std::vector<AttributeSubjectMatchRule>>
+ MapVector<const Record *, std::vector<AttributeSubjectMatchRule>>
SubMatchRules;
for (const auto &Rule : Rules) {
if (!Rule.isSubRule())
@@ -2404,7 +2402,7 @@ void generateNameToAttrsMap(const RecordKeeper &Records) {
for (const auto &S : Spellings) {
auto It = NameToAttrsMap.find(S.name());
if (It != NameToAttrsMap.end()) {
- if (llvm::none_of(It->second, [&](const Record *R) { return R == A; }))
+ if (none_of(It->second, [&](const Record *R) { return R == A; }))
It->second.emplace_back(A);
} else {
std::vector<const Record *> V;
@@ -2542,17 +2540,16 @@ static void emitClangAttrArgContextList(const RecordKeeper &Records,
static bool isIdentifierArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
- .Case("IdentifierArgument", true)
- .Case("EnumArgument", true)
- .Case("VariadicEnumArgument", true)
- .Default(false);
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
+ .Case("IdentifierArgument", true)
+ .Case("EnumArgument", true)
+ .Case("VariadicEnumArgument", true)
+ .Default(false);
}
static bool isVariadicIdentifierArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("VariadicIdentifierArgument", true)
.Case("VariadicParamOrParamIdxArgument", true)
.Default(false);
@@ -2560,8 +2557,7 @@ static bool isVariadicIdentifierArgument(const Record *Arg) {
static bool isVariadicExprArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("VariadicExprArgument", true)
.Default(false);
}
@@ -2658,7 +2654,7 @@ static void emitClangAttrStrictIdentifierArgList(const RecordKeeper &Records,
continue;
// Check that there is really an identifier argument.
std::vector<Record *> Args = Attr->getValueAsListOfDefs("Args");
- if (llvm::none_of(Args, [&](Record *R) { return isIdentifierArgument(R); }))
+ if (none_of(Args, [&](Record *R) { return isIdentifierArgument(R); }))
continue;
generateFlattenedSpellingInfo(*Attr, FSIMap);
}
@@ -2668,8 +2664,7 @@ static void emitClangAttrStrictIdentifierArgList(const RecordKeeper &Records,
static bool keywordThisIsaIdentifierInArgument(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("VariadicParamOrParamIdxArgument", true)
.Default(false);
}
@@ -2759,7 +2754,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
assert(!Supers.empty() && "Forgot to specify a superclass for the attr");
std::string SuperName;
bool Inheritable = false;
- for (const auto &Super : llvm::reverse(Supers)) {
+ for (const auto &Super : reverse(Supers)) {
const Record *R = Super.first;
if (R->getName() != "TargetSpecificAttr" &&
R->getName() != "DeclOrTypeAttr" && SuperName.empty())
@@ -2843,8 +2838,8 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
if (Header)
OS << SpellingEnum;
- const auto &ParsedAttrSpellingItr = llvm::find_if(
- AttrMap, [R](const std::pair<std::string, const Record *> &P) {
+ const auto &ParsedAttrSpellingItr =
+ find_if(AttrMap, [R](const std::pair<std::string, const Record *> &P) {
return &R == P.second;
});
@@ -3133,7 +3128,7 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
// Emit constructors that takes no arguments if none already exists.
// This is used for delaying arguments.
bool HasRequiredArgs =
- llvm::count_if(Args, [=](const std::unique_ptr<Argument> &arg) {
+ count_if(Args, [=](const std::unique_ptr<Argument> &arg) {
return !arg->isFake() && !arg->isOptional();
});
if (DelayedArgs && HasRequiredArgs)
@@ -3280,7 +3275,7 @@ static void emitAttrList(raw_ostream &OS, StringRef Class,
// Determines if an attribute has a Pragma spelling.
static bool AttrHasPragmaSpelling(const Record *R) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
- return llvm::any_of(Spellings, [](const FlattenedSpelling &S) {
+ return any_of(Spellings, [](const FlattenedSpelling &S) {
return S.variety() == "Pragma";
});
}
@@ -3646,7 +3641,7 @@ static bool GenerateTargetSpecificAttrChecks(const Record *R,
std::string *FnName) {
bool AnyTargetChecks = false;
- // It is assumed that there will be an llvm::Triple object
+ // It is assumed that there will be an Triple object
// named "T" and a TargetInfo object named "Target" within
// scope that can be used to determine whether the attribute exists in
// a given target.
@@ -3756,8 +3751,8 @@ static void GenerateHasAttrSpellingStringSwitch(
}
std::string TestStr = !Test.empty()
- ? Test + " ? " + llvm::itostr(Version) + " : 0"
- : llvm::itostr(Version);
+ ? Test + " ? " + itostr(Version) + " : 0"
+ : itostr(Version);
if (Scope.empty() || Scope == Spelling.nameSpace())
OS << " .Case(\"" << Spelling.name() << "\", " << TestStr << ")\n";
}
@@ -3780,7 +3775,7 @@ void EmitClangRegularKeywordAttributeInfo(const RecordKeeper &Records,
if (!isRegularKeywordAttribute(S))
continue;
std::vector<Record *> Args = R->getValueAsListOfDefs("Args");
- bool HasArgs = llvm::any_of(
+ bool HasArgs = any_of(
Args, [](const Record *Arg) { return !Arg->getValueAsBit("Fake"); });
OS << "KEYWORD_ATTRIBUTE("
@@ -4136,7 +4131,7 @@ static std::string CalculateDiagnostic(const Record &S) {
// The node may contain a list of elements itself, so split the elements
// by a comma, and trim any whitespace.
SmallVector<StringRef, 2> Frags;
- llvm::SplitString(V, Frags, ",");
+ SplitString(V, Frags, ",");
for (auto Str : Frags) {
DiagList.push_back(std::string(Str.trim()));
}
@@ -4164,7 +4159,7 @@ static std::string CalculateDiagnostic(const Record &S) {
// elements with a comma. This leaves the string in the state: foo, bar,
// baz (but misses quux). We can then add ", and " for the last element
// manually.
- std::string Diag = llvm::join(DiagList.begin(), DiagList.end() - 1, ", ");
+ std::string Diag = join(DiagList.begin(), DiagList.end() - 1, ", ");
return '"' + Diag + ", and " + *(DiagList.end() - 1) + '"';
}
@@ -4230,12 +4225,11 @@ static void GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
// enough statement attributes with custom subject needs to warrant
// the implementation effort.
std::vector<Record *> DeclSubjects, StmtSubjects;
- llvm::copy_if(
- Subjects, std::back_inserter(DeclSubjects), [](const Record *R) {
- return R->isSubClassOf("SubsetSubject") || !R->isSubClassOf("StmtNode");
- });
- llvm::copy_if(Subjects, std::back_inserter(StmtSubjects),
- [](const Record *R) { return R->isSubClassOf("StmtNode"); });
+ copy_if(Subjects, std::back_inserter(DeclSubjects), [](const Record *R) {
+ return R->isSubClassOf("SubsetSubject") || !R->isSubClassOf("StmtNode");
+ });
+ copy_if(Subjects, std::back_inserter(StmtSubjects),
+ [](const Record *R) { return R->isSubClassOf("StmtNode"); });
// We should have sorted all of the subjects into two lists.
// FIXME: this assertion will be wrong if we ever add type attribute subjects.
@@ -4353,7 +4347,7 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
auto IsCurAttr = [Attr](const Record *R) {
return R->getName() == Attr.getName();
};
- if (llvm::any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
+ if (any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
// This list of exclusions includes the attribute we're looking for, so
// add the exclusive attributes to the proper list for checking.
for (const Record *AttrToExclude : MutuallyExclusiveAttrs) {
@@ -4565,8 +4559,7 @@ GenerateSpellingTargetRequirements(const Record &Attr,
Test += "((SpellingListIndex == ";
for (unsigned Index = 0; Index < Spellings.size(); ++Index) {
- Test +=
- llvm::itostr(getSpellingListIndex(SpellingList, Spellings[Index]));
+ Test += itostr(getSpellingListIndex(SpellingList, Spellings[Index]));
if (Index != Spellings.size() - 1)
Test += " ||\n SpellingListIndex == ";
else
@@ -4632,8 +4625,7 @@ static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) {
static bool isParamExpr(const Record *Arg) {
return !Arg->getSuperClasses().empty() &&
- llvm::StringSwitch<bool>(
- Arg->getSuperClasses().back().first->getName())
+ StringSwitch<bool>(Arg->getSuperClasses().back().first->getName())
.Case("ExprArgument", true)
.Case("VariadicExprArgument", true)
.Default(false);
@@ -4683,9 +4675,8 @@ void GenerateHandleAttrWithDelayedArgs(const RecordKeeper &Records,
static bool IsKnownToGCC(const Record &Attr) {
// Look at the spellings for this subject; if there are any spellings which
// claim to be known to GCC, the attribute is known to GCC.
- return llvm::any_of(
- GetFlattenedSpellings(Attr),
- [](const FlattenedSpelling &S) { return S.knownToGCC(); });
+ return any_of(GetFlattenedSpellings(Attr),
+ [](const FlattenedSpelling &S) { return S.knownToGCC(); });
}
/// Emits the parsed attribute helpers
@@ -4967,7 +4958,7 @@ void EmitClangAttrTextNodeDump(const RecordKeeper &Records, raw_ostream &OS) {
// spelling used for the attribute.
std::string FunctionContent;
- llvm::raw_string_ostream SS(FunctionContent);
+ raw_string_ostream SS(FunctionContent);
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(R);
if (Spellings.size() > 1 && !SpellingNamesAreCommon(Spellings))
@@ -5001,7 +4992,7 @@ void EmitClangAttrNodeTraverse(const RecordKeeper &Records, raw_ostream &OS) {
continue;
std::string FunctionContent;
- llvm::raw_string_ostream SS(FunctionContent);
+ raw_string_ostream SS(FunctionContent);
std::vector<Record *> Args = R.getValueAsListOfDefs("Args");
for (const auto *Arg : Args)
@@ -5173,7 +5164,7 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
// concatenating all the spellings. Might not be great, but better than
// nothing.
else if (Cat == "Undocumented")
- Heading = llvm::join(Uniques.begin(), Uniques.end(), ", ");
+ Heading = join(Uniques.begin(), Uniques.end(), ", ");
}
}
@@ -5291,10 +5282,10 @@ void EmitClangAttrDocs(const RecordKeeper &Records, raw_ostream &OS) {
for (auto &I : SplitDocs) {
WriteCategoryHeader(I.first, OS);
- llvm::sort(I.second,
- [](const DocumentationData &D1, const DocumentationData &D2) {
- return D1.Heading < D2.Heading;
- });
+ sort(I.second,
+ [](const DocumentationData &D1, const DocumentationData &D2) {
+ return D1.Heading < D2.Heading;
+ });
// Walk over each of the attributes in the category and write out their
// documentation.
@@ -5321,7 +5312,7 @@ void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
SubjectObj->getValueAsListOfDefs("Subjects");
OS << " (";
bool PrintComma = false;
- for (const auto &Subject : llvm::enumerate(Subjects)) {
+ for (const auto &Subject : enumerate(Subjects)) {
if (!isSupportedPragmaClangAttributeSubject(*Subject.value()))
continue;
if (PrintComma)
@@ -5334,7 +5325,7 @@ void EmitTestPragmaAttributeSupportedAttributes(const RecordKeeper &Records,
continu...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/7115 Here is the relevant piece of the build log for the reference
|
Hi, we see the same errors on our buildbots, two as examples: https://lab.llvm.org/buildbot/#/builders/30/builds/6250 |
I have a proposed fix here: #108826 |
Fix has been merged: #108826 |
This was not flagged by pre-commit CI. I am wondering if the CI can be tweaked to flag this pre commit. |
I see that the warning is not yet implemented in clang, but its in GCC, so only GCC based builds flagged it as an error. So what we really need it a GCC based build, which is not a tweak. |
Remove llvm:: from .cpp files, and add "using namespace llvm" if needed.