Skip to content

[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

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/utils/TableGen/ASTTableGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>()) {
Expand Down
3 changes: 1 addition & 2 deletions clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
135 changes: 63 additions & 72 deletions clang/utils/TableGen/ClangAttrEmitter.cpp

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions clang/utils/TableGen/ClangBuiltinsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class PrototypeParser {
if (!T.consume_front("<"))
PrintFatalError(Loc, "Expected '<' after '_ExtVector'");
unsigned long long Lanes;
if (llvm::consumeUnsignedInteger(T, 10, Lanes))
if (consumeUnsignedInteger(T, 10, Lanes))
PrintFatalError(Loc, "Expected number of lanes after '_ExtVector<'");
Type += "E" + std::to_string(Lanes);
if (!T.consume_front(","))
Expand Down Expand Up @@ -187,7 +187,7 @@ class PrototypeParser {
}

public:
void Print(llvm::raw_ostream &OS) const { OS << ", \"" << Type << '\"'; }
void Print(raw_ostream &OS) const { OS << ", \"" << Type << '\"'; }

private:
SMLoc Loc;
Expand All @@ -208,14 +208,13 @@ class HeaderNameParser {
}
}

void Print(llvm::raw_ostream &OS) const { OS << HeaderName; }
void Print(raw_ostream &OS) const { OS << HeaderName; }

private:
std::string HeaderName;
};

void PrintAttributes(const Record *Builtin, BuiltinType BT,
llvm::raw_ostream &OS) {
void PrintAttributes(const Record *Builtin, BuiltinType BT, raw_ostream &OS) {
OS << '\"';
if (Builtin->isSubClassOf("LibBuiltin")) {
if (BT == BuiltinType::LibBuiltin) {
Expand All @@ -241,7 +240,7 @@ void PrintAttributes(const Record *Builtin, BuiltinType BT,
OS << '\"';
}

void EmitBuiltinDef(llvm::raw_ostream &OS, StringRef Substitution,
void EmitBuiltinDef(raw_ostream &OS, StringRef Substitution,
const Record *Builtin, Twine Spelling, BuiltinType BT) {
if (Builtin->getValueAsBit("RequiresUndef"))
OS << "#undef " << Spelling << '\n';
Expand Down Expand Up @@ -304,14 +303,14 @@ TemplateInsts getTemplateInsts(const Record *R) {
PrintFatalError(R->getLoc(), "Substitutions and affixes "
"don't have the same lengths");

for (auto [Affix, Substitution] : llvm::zip(Affixes, Substitutions)) {
for (auto [Affix, Substitution] : zip(Affixes, Substitutions)) {
temp.Substitution.emplace_back(Substitution);
temp.Affix.emplace_back(Affix);
}
return temp;
}

void EmitBuiltin(llvm::raw_ostream &OS, const Record *Builtin) {
void EmitBuiltin(raw_ostream &OS, const Record *Builtin) {
TemplateInsts Templates = {};
if (Builtin->isSubClassOf("Template")) {
Templates = getTemplateInsts(Builtin);
Expand All @@ -321,7 +320,7 @@ void EmitBuiltin(llvm::raw_ostream &OS, const Record *Builtin) {
}

for (auto [Substitution, Affix] :
llvm::zip(Templates.Substitution, Templates.Affix)) {
zip(Templates.Substitution, Templates.Affix)) {
for (StringRef Spelling : Builtin->getValueAsListOfStrings("Spellings")) {
auto FullSpelling =
(Templates.IsPrefix ? Affix + Spelling : Spelling + Affix).str();
Expand All @@ -345,8 +344,7 @@ void EmitBuiltin(llvm::raw_ostream &OS, const Record *Builtin) {
}
} // namespace

void clang::EmitClangBuiltins(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
void clang::EmitClangBuiltins(const RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("List of builtins that Clang recognizes", OS);

OS << R"c++(
Expand Down
61 changes: 29 additions & 32 deletions clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ namespace {
};

struct GroupInfo {
llvm::StringRef GroupName;
StringRef GroupName;
std::vector<const Record*> DiagsInGroup;
std::vector<std::string> SubGroups;
unsigned IDNo = 0;

llvm::SmallVector<const Record *, 1> Defs;
SmallVector<const Record *, 1> Defs;

GroupInfo() = default;
};
Expand Down Expand Up @@ -213,7 +213,7 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
if (IsImplicit)
continue;

llvm::SMLoc Loc = Def->getLoc().front();
SMLoc Loc = Def->getLoc().front();
if (First) {
SrcMgr.PrintMessage(Loc, SourceMgr::DK_Error,
Twine("group '") + Group.first +
Expand All @@ -228,7 +228,7 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
if (!cast<DefInit>(Diag->getValueInit("Group"))->getDef()->isAnonymous())
continue;

llvm::SMLoc Loc = Diag->getLoc().front();
SMLoc Loc = Diag->getLoc().front();
if (First) {
SrcMgr.PrintMessage(Loc, SourceMgr::DK_Error,
Twine("group '") + Group.first +
Expand All @@ -247,20 +247,19 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
//===----------------------------------------------------------------------===//

typedef std::vector<const Record *> RecordVec;
typedef llvm::DenseSet<const Record *> RecordSet;
typedef llvm::PointerUnion<RecordVec*, RecordSet*> VecOrSet;
typedef DenseSet<const Record *> RecordSet;
typedef PointerUnion<RecordVec *, RecordSet *> VecOrSet;

namespace {
class InferPedantic {
typedef llvm::DenseMap<const Record *,
std::pair<unsigned, std::optional<unsigned>>>
typedef DenseMap<const Record *, std::pair<unsigned, std::optional<unsigned>>>
GMap;

DiagGroupParentMap &DiagGroupParents;
ArrayRef<const Record *> Diags;
const std::vector<const Record *> DiagGroups;
std::map<std::string, GroupInfo> &DiagsInGroup;
llvm::DenseSet<const Record*> DiagsSet;
DenseSet<const Record *> DiagsSet;
GMap GroupCount;
public:
InferPedantic(DiagGroupParentMap &DiagGroupParents,
Expand All @@ -277,8 +276,7 @@ class InferPedantic {

private:
/// Determine whether a group is a subgroup of another group.
bool isSubGroupOfGroup(const Record *Group,
llvm::StringRef RootGroupName);
bool isSubGroupOfGroup(const Record *Group, StringRef RootGroupName);

/// Determine if the diagnostic is an extension.
bool isExtension(const Record *Diag);
Expand All @@ -295,8 +293,7 @@ class InferPedantic {
};
} // end anonymous namespace

bool InferPedantic::isSubGroupOfGroup(const Record *Group,
llvm::StringRef GName) {
bool InferPedantic::isSubGroupOfGroup(const Record *Group, StringRef GName) {
const std::string &GroupName =
std::string(Group->getValueAsString("GroupName"));
if (GName == GroupName)
Expand Down Expand Up @@ -409,8 +406,8 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,

const std::vector<const Record *> &Parents =
DiagGroupParents.getParents(Group);
bool AllParentsInPedantic = llvm::all_of(
Parents, [&](const Record *R) { return groupInPedantic(R); });
bool AllParentsInPedantic =
all_of(Parents, [&](const Record *R) { return groupInPedantic(R); });
// If all the parents are in -Wpedantic, this means that this diagnostic
// group will be indirectly included by -Wpedantic already. In that
// case, do not add it directly to -Wpedantic. If the group has no
Expand Down Expand Up @@ -613,11 +610,12 @@ struct DiagnosticTextBuilder {
Piece *getSubstitution(SubstitutionPiece *S) const {
auto It = Substitutions.find(S->Name);
if (It == Substitutions.end())
PrintFatalError("Failed to find substitution with name: " + S->Name);
llvm::PrintFatalError("Failed to find substitution with name: " +
S->Name);
return It->second.Root;
}

[[noreturn]] void PrintFatalError(llvm::Twine const &Msg) const {
[[noreturn]] void PrintFatalError(Twine const &Msg) const {
assert(EvaluatingRecord && "not evaluating a record?");
llvm::PrintFatalError(EvaluatingRecord->getLoc(), Msg);
}
Expand Down Expand Up @@ -1022,8 +1020,8 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
StopAt Stop) {
std::vector<Piece *> Parsed;

constexpr llvm::StringLiteral StopSets[] = {"%", "%|}", "%|}$"};
llvm::StringRef StopSet = StopSets[static_cast<int>(Stop)];
constexpr StringLiteral StopSets[] = {"%", "%|}", "%|}$"};
StringRef StopSet = StopSets[static_cast<int>(Stop)];

while (!Text.empty()) {
size_t End = (size_t)-2;
Expand All @@ -1050,7 +1048,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
size_t ModLength = Text.find_first_of("0123456789{");
StringRef Modifier = Text.slice(0, ModLength);
Text = Text.slice(ModLength, StringRef::npos);
ModifierType ModType = llvm::StringSwitch<ModifierType>{Modifier}
ModifierType ModType = StringSwitch<ModifierType>{Modifier}
.Case("select", MT_Select)
.Case("sub", MT_Sub)
.Case("diff", MT_Diff)
Expand Down Expand Up @@ -1227,7 +1225,7 @@ static bool isExemptAtStart(StringRef Text) {
// OBJECT_MODE. However, if there's only a single letter other than "C", we
// do not exempt it so that we catch a case like "A really bad idea" while
// still allowing a case like "C does not allow...".
if (llvm::all_of(Text, [](char C) {
if (all_of(Text, [](char C) {
return isUpper(C) || isDigit(C) || C == '+' || C == '_';
}))
return Text.size() > 1 || Text[0] == 'C';
Expand Down Expand Up @@ -1530,11 +1528,11 @@ void clang::EmitClangDiagsDefs(const RecordKeeper &Records, raw_ostream &OS,
// Warning Group Tables generation
//===----------------------------------------------------------------------===//

static std::string getDiagCategoryEnum(llvm::StringRef name) {
static std::string getDiagCategoryEnum(StringRef name) {
if (name.empty())
return "DiagCat_None";
SmallString<256> enumName = llvm::StringRef("DiagCat_");
for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
SmallString<256> enumName = StringRef("DiagCat_");
for (StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
enumName += isalnum(*I) ? *I : '_';
return std::string(enumName);
}
Expand Down Expand Up @@ -1841,10 +1839,9 @@ void clang::EmitClangDiagsIndexName(const RecordKeeper &Records,
Index.push_back(RecordIndexElement(R));
}

llvm::sort(Index,
[](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) {
return Lhs.Name < Rhs.Name;
});
sort(Index, [](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) {
return Lhs.Name < Rhs.Name;
});

for (unsigned i = 0, e = Index.size(); i != e; ++i) {
const RecordIndexElement &R = Index[i];
Expand Down Expand Up @@ -1941,7 +1938,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {

std::vector<const Record *> DiagGroups =
Records.getAllDerivedDefinitions("DiagGroup");
llvm::sort(DiagGroups, diagGroupBeforeByName);
sort(DiagGroups, diagGroupBeforeByName);

DiagGroupParentMap DGParentMap(Records);

Expand All @@ -1960,8 +1957,8 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {
DiagsInPedanticSet.end());
RecordVec GroupsInPedantic(GroupsInPedanticSet.begin(),
GroupsInPedanticSet.end());
llvm::sort(DiagsInPedantic, beforeThanCompare);
llvm::sort(GroupsInPedantic, beforeThanCompare);
sort(DiagsInPedantic, beforeThanCompare);
sort(GroupsInPedantic, beforeThanCompare);
PedDiags.DiagsInGroup.insert(PedDiags.DiagsInGroup.end(),
DiagsInPedantic.begin(),
DiagsInPedantic.end());
Expand Down Expand Up @@ -2012,7 +2009,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {
OS << "Also controls ";

bool First = true;
llvm::sort(GroupInfo.SubGroups);
sort(GroupInfo.SubGroups);
for (const auto &Name : GroupInfo.SubGroups) {
if (!First) OS << ", ";
OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
Expand Down
4 changes: 2 additions & 2 deletions clang/utils/TableGen/ClangOpcodesEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ClangOpcodesEmitter {

void Enumerate(const Record *R, StringRef N,
std::function<void(ArrayRef<const Record *>, Twine)> &&F) {
llvm::SmallVector<const Record *, 2> TypePath;
SmallVector<const Record *, 2> TypePath;
const auto *Types = R->getValueAsListInit("Types");

std::function<void(size_t, const Twine &)> Rec;
Expand Down Expand Up @@ -304,7 +304,7 @@ void ClangOpcodesEmitter::EmitGroup(raw_ostream &OS, StringRef N,
OS << "const SourceInfo &I) {\n";

std::function<void(size_t, const Twine &)> Rec;
llvm::SmallVector<const Record *, 2> TS;
SmallVector<const Record *, 2> TS;
Rec = [this, &Rec, &OS, Types, &Args, R, &TS, N,
EmitFuncName](size_t I, const Twine &ID) {
if (I >= Types->size()) {
Expand Down
7 changes: 3 additions & 4 deletions clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ void BuiltinNameEmitter::GetOverloads() {

auto Signature = B->getValueAsListOfDefs("Signature");
// Reuse signatures to avoid unnecessary duplicates.
auto it =
llvm::find_if(SignaturesList,
auto it = find_if(SignaturesList,
[&](const std::pair<std::vector<Record *>, unsigned> &a) {
return a.first == Signature;
});
Expand Down Expand Up @@ -688,7 +687,7 @@ void BuiltinNameEmitter::GroupBySignature() {
CurSignatureList->push_back(Signature.second);
}
// Sort the list to facilitate future comparisons.
llvm::sort(*CurSignatureList);
sort(*CurSignatureList);

// Check if we have already seen another function with the same list of
// signatures. If so, just add the name of the function.
Expand Down Expand Up @@ -1278,7 +1277,7 @@ void OpenCLBuiltinHeaderEmitter::emit() {
// Iterate over all builtins; sort to follow order of definition in .td file.
std::vector<const Record *> Builtins =
Records.getAllDerivedDefinitions("Builtin");
llvm::sort(Builtins, LessRecord());
sort(Builtins, LessRecord());

for (const auto *B : Builtins) {
StringRef Name = B->getValueAsString("Name");
Expand Down
6 changes: 3 additions & 3 deletions clang/utils/TableGen/ClangOptionDocEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Documentation extractDocumentation(const RecordKeeper &Records,

auto DocumentationForOption = [&](const Record *R) -> DocumentedOption {
auto &A = Aliases[R];
llvm::sort(A, CompareByName);
sort(A, CompareByName);
return {R, std::move(A)};
};

Expand All @@ -145,7 +145,7 @@ Documentation extractDocumentation(const RecordKeeper &Records,
Documentation D;

auto &Groups = GroupsInGroup[R];
llvm::sort(Groups, CompareByLocation);
sort(Groups, CompareByLocation);
for (const Record *G : Groups) {
D.Groups.emplace_back();
D.Groups.back().Group = G;
Expand All @@ -156,7 +156,7 @@ Documentation extractDocumentation(const RecordKeeper &Records,
}

auto &Options = OptionsInGroup[R];
llvm::sort(Options, CompareByName);
sort(Options, CompareByName);
for (const Record *O : Options)
if (isOptionVisible(O, DocInfo))
D.Options.push_back(DocumentationForOption(O));
Expand Down
9 changes: 4 additions & 5 deletions clang/utils/TableGen/ClangSACheckersEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static std::string getCheckerDocs(const Record &R) {
return "";

std::string CheckerFullName = StringRef(getCheckerFullName(&R, "-")).lower();
return (llvm::Twine("https://clang.llvm.org/docs/analyzer/checkers.html#") +
return (Twine("https://clang.llvm.org/docs/analyzer/checkers.html#") +
CheckerFullName)
.str();
}
Expand Down Expand Up @@ -137,7 +137,7 @@ static bool isHidden(const Record *R) {
return false;
}

static void printChecker(llvm::raw_ostream &OS, const Record &R) {
static void printChecker(raw_ostream &OS, const Record &R) {
OS << "CHECKER(" << "\"";
OS.write_escaped(getCheckerFullName(&R)) << "\", ";
OS << R.getName() << ", ";
Expand All @@ -155,8 +155,7 @@ static void printChecker(llvm::raw_ostream &OS, const Record &R) {
OS << ")\n";
}

static void printOption(llvm::raw_ostream &OS, StringRef FullName,
const Record &R) {
static void printOption(raw_ostream &OS, StringRef FullName, const Record &R) {
OS << "\"";
OS.write_escaped(getCheckerOptionType(R)) << "\", \"";
OS.write_escaped(FullName) << "\", ";
Expand All @@ -180,7 +179,7 @@ void clang::EmitClangSACheckers(const RecordKeeper &Records, raw_ostream &OS) {
ArrayRef<const Record *> packages =
Records.getAllDerivedDefinitions("Package");

using SortedRecords = llvm::StringMap<const Record *>;
using SortedRecords = StringMap<const Record *>;

OS << "// This file is automatically generated. Do not edit this file by "
"hand.\n";
Expand Down
Loading
Loading