Skip to content

Commit 1c58208

Browse files
committed
[clang-format][NFC] Remove redundnat llvm::, clang::, etc.
1 parent 560c2fd commit 1c58208

32 files changed

+199
-222
lines changed

clang/include/clang/Format/Format.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5239,7 +5239,7 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
52395239
/// Returns the replacements corresponding to applying and formatting
52405240
/// \p Replaces on success; otheriwse, return an llvm::Error carrying
52415241
/// llvm::StringError.
5242-
llvm::Expected<tooling::Replacements>
5242+
Expected<tooling::Replacements>
52435243
formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
52445244
const FormatStyle &Style);
52455245

@@ -5256,7 +5256,7 @@ formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
52565256
/// The include manipulation is done via ``tooling::HeaderInclude``, see its
52575257
/// documentation for more details on how include insertion points are found and
52585258
/// what edits are produced.
5259-
llvm::Expected<tooling::Replacements>
5259+
Expected<tooling::Replacements>
52605260
cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
52615261
const FormatStyle &Style);
52625262

@@ -5381,11 +5381,10 @@ extern const char *DefaultFallbackStyle;
53815381
/// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
53825382
/// "file" and no file is found, returns ``FallbackStyle``. If no style could be
53835383
/// determined, returns an Error.
5384-
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
5385-
StringRef FallbackStyle,
5386-
StringRef Code = "",
5387-
llvm::vfs::FileSystem *FS = nullptr,
5388-
bool AllowUnknownOptions = false);
5384+
Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
5385+
StringRef FallbackStyle, StringRef Code = "",
5386+
llvm::vfs::FileSystem *FS = nullptr,
5387+
bool AllowUnknownOptions = false);
53895388

53905389
// Guesses the language from the ``FileName`` and ``Code`` to be formatted.
53915390
// Defaults to FormatStyle::LK_Cpp.

clang/lib/Format/Format.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
using clang::format::FormatStyle;
3030

31-
LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::RawStringFormat)
31+
LLVM_YAML_IS_SEQUENCE_VECTOR(FormatStyle::RawStringFormat)
3232

3333
namespace llvm {
3434
namespace yaml {
@@ -1235,7 +1235,7 @@ std::error_code make_error_code(ParseError e) {
12351235
return std::error_code(static_cast<int>(e), getParseCategory());
12361236
}
12371237

1238-
inline llvm::Error make_string_error(const llvm::Twine &Message) {
1238+
inline llvm::Error make_string_error(const Twine &Message) {
12391239
return llvm::make_error<llvm::StringError>(Message,
12401240
llvm::inconvertibleErrorCode());
12411241
}
@@ -2361,7 +2361,7 @@ class JavaScriptRequoter : public TokenAnalyzer {
23612361
// FIXME: handle error. For now, print error message and skip the
23622362
// replacement for release version.
23632363
if (Err) {
2364-
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
2364+
llvm::errs() << toString(std::move(Err)) << "\n";
23652365
assert(false);
23662366
}
23672367
};
@@ -2802,7 +2802,7 @@ class Cleaner : public TokenAnalyzer {
28022802
// FIXME: better error handling. for now just print error message and skip
28032803
// for the release version.
28042804
if (Err) {
2805-
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
2805+
llvm::errs() << toString(std::move(Err)) << "\n";
28062806
assert(false && "Fixes must not conflict!");
28072807
}
28082808
Idx = End + 1;
@@ -3074,7 +3074,7 @@ static void sortCppIncludes(const FormatStyle &Style,
30743074
llvm::to_vector<16>(llvm::seq<unsigned>(0, Includes.size()));
30753075

30763076
if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) {
3077-
llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
3077+
stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
30783078
const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
30793079
const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
30803080
return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
@@ -3083,7 +3083,7 @@ static void sortCppIncludes(const FormatStyle &Style,
30833083
Includes[RHSI].Filename);
30843084
});
30853085
} else {
3086-
llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
3086+
stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
30873087
return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
30883088
std::tie(Includes[RHSI].Priority, Includes[RHSI].Filename);
30893089
});
@@ -3115,7 +3115,7 @@ static void sortCppIncludes(const FormatStyle &Style,
31153115
// enough as additional newlines might be added or removed across #include
31163116
// blocks. This we handle below by generating the updated #include blocks and
31173117
// comparing it to the original.
3118-
if (Indices.size() == Includes.size() && llvm::is_sorted(Indices) &&
3118+
if (Indices.size() == Includes.size() && is_sorted(Indices) &&
31193119
Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve) {
31203120
return;
31213121
}
@@ -3154,7 +3154,7 @@ static void sortCppIncludes(const FormatStyle &Style,
31543154
// FIXME: better error handling. For now, just skip the replacement for the
31553155
// release version.
31563156
if (Err) {
3157-
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
3157+
llvm::errs() << toString(std::move(Err)) << "\n";
31583158
assert(false);
31593159
}
31603160
}
@@ -3307,7 +3307,7 @@ static void sortJavaImports(const FormatStyle &Style,
33073307

33083308
bool StaticImportAfterNormalImport =
33093309
Style.SortJavaStaticImport == FormatStyle::SJSIO_After;
3310-
llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
3310+
sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
33113311
// Negating IsStatic to push static imports above non-static imports.
33123312
return std::make_tuple(!Imports[LHSI].IsStatic ^
33133313
StaticImportAfterNormalImport,
@@ -3357,7 +3357,7 @@ static void sortJavaImports(const FormatStyle &Style,
33573357
// FIXME: better error handling. For now, just skip the replacement for the
33583358
// release version.
33593359
if (Err) {
3360-
llvm::errs() << llvm::toString(std::move(Err)) << "\n";
3360+
llvm::errs() << toString(std::move(Err)) << "\n";
33613361
assert(false);
33623362
}
33633363
}
@@ -3451,7 +3451,7 @@ tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
34513451
}
34523452

34533453
template <typename T>
3454-
static llvm::Expected<tooling::Replacements>
3454+
static Expected<tooling::Replacements>
34553455
processReplacements(T ProcessFunc, StringRef Code,
34563456
const tooling::Replacements &Replaces,
34573457
const FormatStyle &Style) {
@@ -3470,7 +3470,7 @@ processReplacements(T ProcessFunc, StringRef Code,
34703470
return Replaces.merge(FormatReplaces);
34713471
}
34723472

3473-
llvm::Expected<tooling::Replacements>
3473+
Expected<tooling::Replacements>
34743474
formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
34753475
const FormatStyle &Style) {
34763476
// We need to use lambda function here since there are two versions of
@@ -3515,21 +3515,21 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
35153515
return Replaces;
35163516

35173517
tooling::Replacements HeaderInsertions;
3518-
std::set<llvm::StringRef> HeadersToDelete;
3518+
std::set<StringRef> HeadersToDelete;
35193519
tooling::Replacements Result;
35203520
for (const auto &R : Replaces) {
35213521
if (isHeaderInsertion(R)) {
35223522
// Replacements from \p Replaces must be conflict-free already, so we can
35233523
// simply consume the error.
3524-
llvm::consumeError(HeaderInsertions.add(R));
3524+
consumeError(HeaderInsertions.add(R));
35253525
} else if (isHeaderDeletion(R)) {
35263526
HeadersToDelete.insert(R.getReplacementText());
35273527
} else if (R.getOffset() == UINT_MAX) {
35283528
llvm::errs() << "Insertions other than header #include insertion are "
35293529
"not supported! "
35303530
<< R.getReplacementText() << "\n";
35313531
} else {
3532-
llvm::consumeError(Result.add(R));
3532+
consumeError(Result.add(R));
35333533
}
35343534
}
35353535
if (HeaderInsertions.empty() && HeadersToDelete.empty())
@@ -3546,13 +3546,12 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
35463546
if (Err) {
35473547
// Ignore the deletion on conflict.
35483548
llvm::errs() << "Failed to add header deletion replacement for "
3549-
<< Header << ": " << llvm::toString(std::move(Err))
3550-
<< "\n";
3549+
<< Header << ": " << toString(std::move(Err)) << "\n";
35513550
}
35523551
}
35533552
}
35543553

3555-
llvm::SmallVector<StringRef, 4> Matches;
3554+
SmallVector<StringRef, 4> Matches;
35563555
for (const auto &R : HeaderInsertions) {
35573556
auto IncludeDirective = R.getReplacementText();
35583557
bool Matched =
@@ -3567,7 +3566,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
35673566
if (Replace) {
35683567
auto Err = Result.add(*Replace);
35693568
if (Err) {
3570-
llvm::consumeError(std::move(Err));
3569+
consumeError(std::move(Err));
35713570
unsigned NewOffset =
35723571
Result.getShiftedCodePosition(Replace->getOffset());
35733572
auto Shifted = tooling::Replacement(FileName, NewOffset, 0,
@@ -3581,7 +3580,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
35813580

35823581
} // anonymous namespace
35833582

3584-
llvm::Expected<tooling::Replacements>
3583+
Expected<tooling::Replacements>
35853584
cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
35863585
const FormatStyle &Style) {
35873586
// We need to use lambda function here since there are two versions of
@@ -3774,7 +3773,7 @@ reformat(const FormatStyle &Style, StringRef Code,
37743773
auto Err = NonNoOpFixes.add(Fix);
37753774
if (Err) {
37763775
llvm::errs() << "Error adding replacements : "
3777-
<< llvm::toString(std::move(Err)) << "\n";
3776+
<< toString(std::move(Err)) << "\n";
37783777
}
37793778
}
37803779
}
@@ -3956,17 +3955,16 @@ loadAndParseConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS,
39563955
return Text;
39573956
}
39583957

3959-
llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
3960-
StringRef FallbackStyleName,
3961-
StringRef Code, llvm::vfs::FileSystem *FS,
3962-
bool AllowUnknownOptions) {
3958+
Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
3959+
StringRef FallbackStyleName, StringRef Code,
3960+
llvm::vfs::FileSystem *FS,
3961+
bool AllowUnknownOptions) {
39633962
FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code));
39643963
FormatStyle FallbackStyle = getNoStyle();
39653964
if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle))
39663965
return make_string_error("Invalid fallback style: " + FallbackStyleName);
39673966

3968-
llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 1>
3969-
ChildFormatTextToApply;
3967+
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 1> ChildFormatTextToApply;
39703968

39713969
if (StyleName.starts_with("{")) {
39723970
// Parse YAML/JSON style from the command line.
@@ -4041,7 +4039,7 @@ llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
40414039
};
40424040

40434041
// Look for .clang-format/_clang-format file in the file's parent directories.
4044-
llvm::SmallVector<std::string, 2> FilesToLookFor;
4042+
SmallVector<std::string, 2> FilesToLookFor;
40454043
FilesToLookFor.push_back(".clang-format");
40464044
FilesToLookFor.push_back("_clang-format");
40474045

clang/lib/Format/FormatTokenSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class IndexedTokenSource : public FormatTokenSource {
173173
return Next;
174174
}
175175

176-
void dbgToken(int Position, llvm::StringRef Indent = "") {
176+
void dbgToken(int Position, StringRef Indent = "") {
177177
FormatToken *Tok = Tokens[Position];
178178
llvm::dbgs() << Indent << "[" << Position
179179
<< "] Token: " << Tok->Tok.getName() << " / " << Tok->TokenText

clang/lib/Format/MacroExpander.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class MacroExpander::DefinitionParser {
119119
};
120120

121121
MacroExpander::MacroExpander(
122-
const std::vector<std::string> &Macros, clang::SourceManager &SourceMgr,
122+
const std::vector<std::string> &Macros, SourceManager &SourceMgr,
123123
const FormatStyle &Style,
124124
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
125125
IdentifierTable &IdentTable)
@@ -134,7 +134,7 @@ MacroExpander::~MacroExpander() = default;
134134
void MacroExpander::parseDefinition(const std::string &Macro) {
135135
Buffers.push_back(
136136
llvm::MemoryBuffer::getMemBufferCopy(Macro, "<scratch space>"));
137-
clang::FileID FID = SourceMgr.createFileID(Buffers.back()->getMemBufferRef());
137+
FileID FID = SourceMgr.createFileID(Buffers.back()->getMemBufferRef());
138138
FormatTokenLexer Lex(SourceMgr, FID, 0, Style, encoding::Encoding_UTF8,
139139
Allocator, IdentTable);
140140
const auto Tokens = Lex.lex();
@@ -150,20 +150,20 @@ void MacroExpander::parseDefinition(const std::string &Macro) {
150150
}
151151
}
152152

153-
bool MacroExpander::defined(llvm::StringRef Name) const {
153+
bool MacroExpander::defined(StringRef Name) const {
154154
return FunctionLike.contains(Name) || ObjectLike.contains(Name);
155155
}
156156

157-
bool MacroExpander::objectLike(llvm::StringRef Name) const {
157+
bool MacroExpander::objectLike(StringRef Name) const {
158158
return ObjectLike.contains(Name);
159159
}
160160

161-
bool MacroExpander::hasArity(llvm::StringRef Name, unsigned Arity) const {
161+
bool MacroExpander::hasArity(StringRef Name, unsigned Arity) const {
162162
auto it = FunctionLike.find(Name);
163163
return it != FunctionLike.end() && it->second.contains(Arity);
164164
}
165165

166-
llvm::SmallVector<FormatToken *, 8>
166+
SmallVector<FormatToken *, 8>
167167
MacroExpander::expand(FormatToken *ID,
168168
std::optional<ArgsList> OptionalArgs) const {
169169
if (OptionalArgs)

clang/lib/Format/Macros.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct UnwrappedLineNode;
7979
///
8080
class MacroExpander {
8181
public:
82-
using ArgsList = llvm::ArrayRef<llvm::SmallVector<FormatToken *, 8>>;
82+
using ArgsList = ArrayRef<SmallVector<FormatToken *, 8>>;
8383

8484
/// Construct a macro expander from a set of macro definitions.
8585
/// Macro definitions must be encoded as UTF-8.
@@ -95,27 +95,27 @@ class MacroExpander {
9595
/// Macros that cannot be parsed will be silently discarded.
9696
///
9797
MacroExpander(const std::vector<std::string> &Macros,
98-
clang::SourceManager &SourceMgr, const FormatStyle &Style,
98+
SourceManager &SourceMgr, const FormatStyle &Style,
9999
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator,
100100
IdentifierTable &IdentTable);
101101
~MacroExpander();
102102

103103
/// Returns whether any macro \p Name is defined, regardless of overloads.
104-
bool defined(llvm::StringRef Name) const;
104+
bool defined(StringRef Name) const;
105105

106106
/// Returns whetherh there is an object-like overload, i.e. where the macro
107107
/// has no arguments and should not consume subsequent parentheses.
108-
bool objectLike(llvm::StringRef Name) const;
108+
bool objectLike(StringRef Name) const;
109109

110110
/// Returns whether macro \p Name provides an overload with the given arity.
111-
bool hasArity(llvm::StringRef Name, unsigned Arity) const;
111+
bool hasArity(StringRef Name, unsigned Arity) const;
112112

113113
/// Returns the expanded stream of format tokens for \p ID, where
114114
/// each element in \p Args is a positional argument to the macro call.
115115
/// If \p Args is not set, the object-like overload is used.
116116
/// If \p Args is set, the overload with the arity equal to \c Args.size() is
117117
/// used.
118-
llvm::SmallVector<FormatToken *, 8>
118+
SmallVector<FormatToken *, 8>
119119
expand(FormatToken *ID, std::optional<ArgsList> OptionalArgs) const;
120120

121121
private:
@@ -124,7 +124,7 @@ class MacroExpander {
124124

125125
void parseDefinition(const std::string &Macro);
126126

127-
clang::SourceManager &SourceMgr;
127+
SourceManager &SourceMgr;
128128
const FormatStyle &Style;
129129
llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator;
130130
IdentifierTable &IdentTable;
@@ -260,7 +260,7 @@ class MacroCallReconstructor {
260260
LineNode() = default;
261261
LineNode(FormatToken *Tok) : Tok(Tok) {}
262262
FormatToken *Tok = nullptr;
263-
llvm::SmallVector<std::unique_ptr<ReconstructedLine>> Children;
263+
SmallVector<std::unique_ptr<ReconstructedLine>> Children;
264264
};
265265

266266
// Line in which we build up the resulting unwrapped line.
@@ -269,7 +269,7 @@ class MacroCallReconstructor {
269269
struct ReconstructedLine {
270270
explicit ReconstructedLine(unsigned Level) : Level(Level) {}
271271
unsigned Level;
272-
llvm::SmallVector<std::unique_ptr<LineNode>> Tokens;
272+
SmallVector<std::unique_ptr<LineNode>> Tokens;
273273
};
274274

275275
// The line in which we collect the resulting reconstructed output.
@@ -285,7 +285,7 @@ class MacroCallReconstructor {
285285

286286
// Stack of currently "open" lines, where each line's predecessor's last
287287
// token is the parent token for that line.
288-
llvm::SmallVector<ReconstructedLine *> ActiveReconstructedLines;
288+
SmallVector<ReconstructedLine *> ActiveReconstructedLines;
289289

290290
// Maps from the expanded token to the token that takes its place in the
291291
// reconstructed token stream in terms of parent-child relationships.
@@ -325,7 +325,7 @@ class MacroCallReconstructor {
325325
};
326326

327327
// Stack of macro calls for which we're in the middle of an expansion.
328-
llvm::SmallVector<Expansion> ActiveExpansions;
328+
SmallVector<Expansion> ActiveExpansions;
329329

330330
struct MacroCallState {
331331
MacroCallState(ReconstructedLine *Line, FormatToken *ParentLastToken,
@@ -368,7 +368,7 @@ class MacroCallReconstructor {
368368
// |- ,
369369
// | \- <argument>
370370
// \- )
371-
llvm::SmallVector<MacroCallState> MacroCallStructure;
371+
SmallVector<MacroCallState> MacroCallStructure;
372372

373373
// Maps from identifier of the macro call to an unwrapped line containing
374374
// all tokens of the macro call.

0 commit comments

Comments
 (0)