Skip to content

Commit 0e948bf

Browse files
authored
[NFC][clang][TableGen] Remove redundant llvm:: namespace qualifier (#108627)
Remove llvm:: from .cpp files, and add "using namespace llvm" if needed.
1 parent a06d84a commit 0e948bf

14 files changed

+186
-205
lines changed

clang/utils/TableGen/ASTTableGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace llvm;
2121
using namespace clang;
2222
using namespace clang::tblgen;
2323

24-
llvm::StringRef clang::tblgen::HasProperties::getName() const {
24+
StringRef clang::tblgen::HasProperties::getName() const {
2525
if (auto node = getAs<ASTNode>()) {
2626
return node.getName();
2727
} else if (auto typeCase = getAs<TypeCase>()) {

clang/utils/TableGen/ClangASTPropertiesEmitter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ class ASTPropsEmitter {
205205

206206
void visitAllNodesWithInfo(
207207
HasProperties derivedNode, const NodeInfo &derivedNodeInfo,
208-
llvm::function_ref<void(HasProperties node, const NodeInfo &info)>
209-
visit) {
208+
function_ref<void(HasProperties node, const NodeInfo &info)> visit) {
210209
visit(derivedNode, derivedNodeInfo);
211210

212211
// Also walk the bases if appropriate.

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 63 additions & 72 deletions
Large diffs are not rendered by default.

clang/utils/TableGen/ClangBuiltinsEmitter.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class PrototypeParser {
133133
if (!T.consume_front("<"))
134134
PrintFatalError(Loc, "Expected '<' after '_ExtVector'");
135135
unsigned long long Lanes;
136-
if (llvm::consumeUnsignedInteger(T, 10, Lanes))
136+
if (consumeUnsignedInteger(T, 10, Lanes))
137137
PrintFatalError(Loc, "Expected number of lanes after '_ExtVector<'");
138138
Type += "E" + std::to_string(Lanes);
139139
if (!T.consume_front(","))
@@ -187,7 +187,7 @@ class PrototypeParser {
187187
}
188188

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

192192
private:
193193
SMLoc Loc;
@@ -208,14 +208,13 @@ class HeaderNameParser {
208208
}
209209
}
210210

211-
void Print(llvm::raw_ostream &OS) const { OS << HeaderName; }
211+
void Print(raw_ostream &OS) const { OS << HeaderName; }
212212

213213
private:
214214
std::string HeaderName;
215215
};
216216

217-
void PrintAttributes(const Record *Builtin, BuiltinType BT,
218-
llvm::raw_ostream &OS) {
217+
void PrintAttributes(const Record *Builtin, BuiltinType BT, raw_ostream &OS) {
219218
OS << '\"';
220219
if (Builtin->isSubClassOf("LibBuiltin")) {
221220
if (BT == BuiltinType::LibBuiltin) {
@@ -241,7 +240,7 @@ void PrintAttributes(const Record *Builtin, BuiltinType BT,
241240
OS << '\"';
242241
}
243242

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

307-
for (auto [Affix, Substitution] : llvm::zip(Affixes, Substitutions)) {
306+
for (auto [Affix, Substitution] : zip(Affixes, Substitutions)) {
308307
temp.Substitution.emplace_back(Substitution);
309308
temp.Affix.emplace_back(Affix);
310309
}
311310
return temp;
312311
}
313312

314-
void EmitBuiltin(llvm::raw_ostream &OS, const Record *Builtin) {
313+
void EmitBuiltin(raw_ostream &OS, const Record *Builtin) {
315314
TemplateInsts Templates = {};
316315
if (Builtin->isSubClassOf("Template")) {
317316
Templates = getTemplateInsts(Builtin);
@@ -321,7 +320,7 @@ void EmitBuiltin(llvm::raw_ostream &OS, const Record *Builtin) {
321320
}
322321

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

348-
void clang::EmitClangBuiltins(const llvm::RecordKeeper &Records,
349-
llvm::raw_ostream &OS) {
347+
void clang::EmitClangBuiltins(const RecordKeeper &Records, raw_ostream &OS) {
350348
emitSourceFileHeader("List of builtins that Clang recognizes", OS);
351349

352350
OS << R"c++(

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ namespace {
131131
};
132132

133133
struct GroupInfo {
134-
llvm::StringRef GroupName;
134+
StringRef GroupName;
135135
std::vector<const Record*> DiagsInGroup;
136136
std::vector<std::string> SubGroups;
137137
unsigned IDNo = 0;
138138

139-
llvm::SmallVector<const Record *, 1> Defs;
139+
SmallVector<const Record *, 1> Defs;
140140

141141
GroupInfo() = default;
142142
};
@@ -213,7 +213,7 @@ static void groupDiagnostics(ArrayRef<const Record *> Diags,
213213
if (IsImplicit)
214214
continue;
215215

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

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

249249
typedef std::vector<const Record *> RecordVec;
250-
typedef llvm::DenseSet<const Record *> RecordSet;
251-
typedef llvm::PointerUnion<RecordVec*, RecordSet*> VecOrSet;
250+
typedef DenseSet<const Record *> RecordSet;
251+
typedef PointerUnion<RecordVec *, RecordSet *> VecOrSet;
252252

253253
namespace {
254254
class InferPedantic {
255-
typedef llvm::DenseMap<const Record *,
256-
std::pair<unsigned, std::optional<unsigned>>>
255+
typedef DenseMap<const Record *, std::pair<unsigned, std::optional<unsigned>>>
257256
GMap;
258257

259258
DiagGroupParentMap &DiagGroupParents;
260259
ArrayRef<const Record *> Diags;
261260
const std::vector<const Record *> DiagGroups;
262261
std::map<std::string, GroupInfo> &DiagsInGroup;
263-
llvm::DenseSet<const Record*> DiagsSet;
262+
DenseSet<const Record *> DiagsSet;
264263
GMap GroupCount;
265264
public:
266265
InferPedantic(DiagGroupParentMap &DiagGroupParents,
@@ -277,8 +276,7 @@ class InferPedantic {
277276

278277
private:
279278
/// Determine whether a group is a subgroup of another group.
280-
bool isSubGroupOfGroup(const Record *Group,
281-
llvm::StringRef RootGroupName);
279+
bool isSubGroupOfGroup(const Record *Group, StringRef RootGroupName);
282280

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

298-
bool InferPedantic::isSubGroupOfGroup(const Record *Group,
299-
llvm::StringRef GName) {
296+
bool InferPedantic::isSubGroupOfGroup(const Record *Group, StringRef GName) {
300297
const std::string &GroupName =
301298
std::string(Group->getValueAsString("GroupName"));
302299
if (GName == GroupName)
@@ -409,8 +406,8 @@ void InferPedantic::compute(VecOrSet DiagsInPedantic,
409406

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

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

1025-
constexpr llvm::StringLiteral StopSets[] = {"%", "%|}", "%|}$"};
1026-
llvm::StringRef StopSet = StopSets[static_cast<int>(Stop)];
1023+
constexpr StringLiteral StopSets[] = {"%", "%|}", "%|}$"};
1024+
StringRef StopSet = StopSets[static_cast<int>(Stop)];
10271025

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

1533-
static std::string getDiagCategoryEnum(llvm::StringRef name) {
1531+
static std::string getDiagCategoryEnum(StringRef name) {
15341532
if (name.empty())
15351533
return "DiagCat_None";
1536-
SmallString<256> enumName = llvm::StringRef("DiagCat_");
1537-
for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
1534+
SmallString<256> enumName = StringRef("DiagCat_");
1535+
for (StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
15381536
enumName += isalnum(*I) ? *I : '_';
15391537
return std::string(enumName);
15401538
}
@@ -1841,10 +1839,9 @@ void clang::EmitClangDiagsIndexName(const RecordKeeper &Records,
18411839
Index.push_back(RecordIndexElement(R));
18421840
}
18431841

1844-
llvm::sort(Index,
1845-
[](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) {
1846-
return Lhs.Name < Rhs.Name;
1847-
});
1842+
sort(Index, [](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) {
1843+
return Lhs.Name < Rhs.Name;
1844+
});
18481845

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

19421939
std::vector<const Record *> DiagGroups =
19431940
Records.getAllDerivedDefinitions("DiagGroup");
1944-
llvm::sort(DiagGroups, diagGroupBeforeByName);
1941+
sort(DiagGroups, diagGroupBeforeByName);
19451942

19461943
DiagGroupParentMap DGParentMap(Records);
19471944

@@ -1960,8 +1957,8 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {
19601957
DiagsInPedanticSet.end());
19611958
RecordVec GroupsInPedantic(GroupsInPedanticSet.begin(),
19621959
GroupsInPedanticSet.end());
1963-
llvm::sort(DiagsInPedantic, beforeThanCompare);
1964-
llvm::sort(GroupsInPedantic, beforeThanCompare);
1960+
sort(DiagsInPedantic, beforeThanCompare);
1961+
sort(GroupsInPedantic, beforeThanCompare);
19651962
PedDiags.DiagsInGroup.insert(PedDiags.DiagsInGroup.end(),
19661963
DiagsInPedantic.begin(),
19671964
DiagsInPedantic.end());
@@ -2012,7 +2009,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper &Records, raw_ostream &OS) {
20122009
OS << "Also controls ";
20132010

20142011
bool First = true;
2015-
llvm::sort(GroupInfo.SubGroups);
2012+
sort(GroupInfo.SubGroups);
20162013
for (const auto &Name : GroupInfo.SubGroups) {
20172014
if (!First) OS << ", ";
20182015
OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";

clang/utils/TableGen/ClangOpcodesEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ClangOpcodesEmitter {
5757

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

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

306306
std::function<void(size_t, const Twine &)> Rec;
307-
llvm::SmallVector<const Record *, 2> TS;
307+
SmallVector<const Record *, 2> TS;
308308
Rec = [this, &Rec, &OS, Types, &Args, R, &TS, N,
309309
EmitFuncName](size_t I, const Twine &ID) {
310310
if (I >= Types->size()) {

clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,7 @@ void BuiltinNameEmitter::GetOverloads() {
514514

515515
auto Signature = B->getValueAsListOfDefs("Signature");
516516
// Reuse signatures to avoid unnecessary duplicates.
517-
auto it =
518-
llvm::find_if(SignaturesList,
517+
auto it = find_if(SignaturesList,
519518
[&](const std::pair<std::vector<Record *>, unsigned> &a) {
520519
return a.first == Signature;
521520
});
@@ -687,7 +686,7 @@ void BuiltinNameEmitter::GroupBySignature() {
687686
CurSignatureList->push_back(Signature.second);
688687
}
689688
// Sort the list to facilitate future comparisons.
690-
llvm::sort(*CurSignatureList);
689+
sort(*CurSignatureList);
691690

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

12811280
for (const auto *B : Builtins) {
12821281
StringRef Name = B->getValueAsString("Name");

clang/utils/TableGen/ClangOptionDocEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Documentation extractDocumentation(const RecordKeeper &Records,
136136

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

@@ -145,7 +145,7 @@ Documentation extractDocumentation(const RecordKeeper &Records,
145145
Documentation D;
146146

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

158158
auto &Options = OptionsInGroup[R];
159-
llvm::sort(Options, CompareByName);
159+
sort(Options, CompareByName);
160160
for (const Record *O : Options)
161161
if (isOptionVisible(O, DocInfo))
162162
D.Options.push_back(DocumentationForOption(O));

clang/utils/TableGen/ClangSACheckersEmitter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static std::string getCheckerDocs(const Record &R) {
8585
return "";
8686

8787
std::string CheckerFullName = StringRef(getCheckerFullName(&R, "-")).lower();
88-
return (llvm::Twine("https://clang.llvm.org/docs/analyzer/checkers.html#") +
88+
return (Twine("https://clang.llvm.org/docs/analyzer/checkers.html#") +
8989
CheckerFullName)
9090
.str();
9191
}
@@ -137,7 +137,7 @@ static bool isHidden(const Record *R) {
137137
return false;
138138
}
139139

140-
static void printChecker(llvm::raw_ostream &OS, const Record &R) {
140+
static void printChecker(raw_ostream &OS, const Record &R) {
141141
OS << "CHECKER(" << "\"";
142142
OS.write_escaped(getCheckerFullName(&R)) << "\", ";
143143
OS << R.getName() << ", ";
@@ -155,8 +155,7 @@ static void printChecker(llvm::raw_ostream &OS, const Record &R) {
155155
OS << ")\n";
156156
}
157157

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

183-
using SortedRecords = llvm::StringMap<const Record *>;
182+
using SortedRecords = StringMap<const Record *>;
184183

185184
OS << "// This file is automatically generated. Do not edit this file by "
186185
"hand.\n";

0 commit comments

Comments
 (0)