[clang-tools-extra] 6f23ba2 - [clang-tidy][NFC] Don't qualify names unless strictly necessary (#185169)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 11 06:40:31 PDT 2026
Author: Victor Chernyakin
Date: 2026-03-11T06:40:25-07:00
New Revision: 6f23ba2555f6d9ab271fc6fc67a7bc9c946cb7ec
URL: https://github.com/llvm/llvm-project/commit/6f23ba2555f6d9ab271fc6fc67a7bc9c946cb7ec
DIFF: https://github.com/llvm/llvm-project/commit/6f23ba2555f6d9ab271fc6fc67a7bc9c946cb7ec.diff
LOG: [clang-tidy][NFC] Don't qualify names unless strictly necessary (#185169)
We have a de-facto policy in clang-tidy to not qualify names unless
absolutely necessary. We're *mostly* consistent about that (especially
in new code), but a number of deviations have accumulated over the
years. We even have cases where the same name is sometimes qualified and
sometimes not *in the same file*. This makes it jarring to read the
code, and, I imagine, more confusing for newcomers to contribute to the
project (do I qualify X or not?). This PR tries to improve the situation
and regularize the codebase.
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidy.h
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyModule.h
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
clang-tools-extra/clang-tidy/GlobList.cpp
clang-tools-extra/clang-tidy/GlobList.h
clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h
clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.h
clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.h
clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnsafeToAllowExceptionsCheck.h
clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
clang-tools-extra/clang-tidy/custom/QueryCheck.h
clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h
clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.h
clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h
clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.h
clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
clang-tools-extra/clang-tidy/misc/OverrideWithDifferentVisibilityCheck.h
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h
clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStringViewCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp
clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.h
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h
clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.h
clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp
clang-tools-extra/clang-tidy/utils/DesignatedInitializers.h
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
clang-tools-extra/clang-tidy/utils/IncludeInserter.h
clang-tools-extra/clang-tidy/utils/Matchers.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h
clang-tools-extra/clang-tidy/utils/NamespaceAliaser.h
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
clang-tools-extra/clang-tidy/utils/UsingInserter.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 1a4fe62cb20af..60f4823d930c1 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -363,9 +363,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
}
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
-static void
-setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
- clang::AnalyzerOptions &AnalyzerOptions) {
+static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
+ AnalyzerOptions &AnalyzerOptions) {
for (const auto &Opt : Opts.CheckOptions) {
StringRef OptName(Opt.getKey());
if (!OptName.consume_front(AnalyzerCheckNamePrefix))
@@ -410,9 +409,9 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
}
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
-std::unique_ptr<clang::ASTConsumer>
-ClangTidyASTConsumerFactory::createASTConsumer(
- clang::CompilerInstance &Compiler, StringRef File) {
+std::unique_ptr<ASTConsumer>
+ClangTidyASTConsumerFactory::createASTConsumer(CompilerInstance &Compiler,
+ StringRef File) {
// FIXME: Move this to a separate method, so that CreateASTConsumer doesn't
// modify Compiler.
SourceManager *SM = &Compiler.getSourceManager();
@@ -517,10 +516,10 @@ ClangTidyOptions::OptionMap ClangTidyASTConsumerFactory::getCheckOptions() {
std::vector<std::string> getCheckNames(const ClangTidyOptions &Options,
bool AllowEnablingAnalyzerAlphaCheckers,
bool ExperimentalCustomChecks) {
- clang::tidy::ClangTidyContext Context(
- std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
- Options),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ ClangTidyContext Context(std::make_unique<DefaultOptionsProvider>(
+ ClangTidyGlobalOptions(), Options),
+ AllowEnablingAnalyzerAlphaCheckers, false,
+ ExperimentalCustomChecks);
ClangTidyASTConsumerFactory Factory(Context);
return Factory.getCheckNames();
}
@@ -543,10 +542,10 @@ ClangTidyOptions::OptionMap
getCheckOptions(const ClangTidyOptions &Options,
bool AllowEnablingAnalyzerAlphaCheckers,
bool ExperimentalCustomChecks) {
- clang::tidy::ClangTidyContext Context(
- std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
- Options),
- AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
+ ClangTidyContext Context(std::make_unique<DefaultOptionsProvider>(
+ ClangTidyGlobalOptions(), Options),
+ AllowEnablingAnalyzerAlphaCheckers, false,
+ ExperimentalCustomChecks);
ClangTidyDiagnosticConsumer DiagConsumer(Context);
auto DiagOpts = std::make_unique<DiagnosticOptions>();
DiagnosticsEngine DE(llvm::makeIntrusiveRefCnt<DiagnosticIDs>(), *DiagOpts,
@@ -557,12 +556,11 @@ getCheckOptions(const ClangTidyOptions &Options,
}
std::vector<ClangTidyError>
-runClangTidy(clang::tidy::ClangTidyContext &Context,
- const CompilationDatabase &Compilations,
+runClangTidy(ClangTidyContext &Context, const CompilationDatabase &Compilations,
ArrayRef<std::string> InputFiles,
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
bool ApplyAnyFix, bool EnableCheckProfile,
- llvm::StringRef StoreCheckProfile, bool Quiet) {
+ StringRef StoreCheckProfile, bool Quiet) {
ClangTool Tool(Compilations, InputFiles,
std::make_shared<PCHContainerOperations>(), BaseFS);
@@ -686,7 +684,7 @@ void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
}
-void exportReplacements(const llvm::StringRef MainFilePath,
+void exportReplacements(const StringRef MainFilePath,
const std::vector<ClangTidyError> &Errors,
raw_ostream &OS) {
TranslationUnitDiagnostics TUD;
@@ -707,7 +705,7 @@ ChecksAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers,
ChecksAndOptions Result;
ClangTidyOptions Opts;
Opts.Checks = "*";
- clang::tidy::ClangTidyContext Context(
+ ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(), Opts),
AllowEnablingAnalyzerAlphaCheckers, false, ExperimentalCustomChecks);
ClangTidyCheckFactories Factories;
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.h b/clang-tools-extra/clang-tidy/ClangTidy.h
index e238f2357caeb..5fac25bd3bbca 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.h
+++ b/clang-tools-extra/clang-tidy/ClangTidy.h
@@ -38,8 +38,8 @@ class ClangTidyASTConsumerFactory {
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS = nullptr);
/// Returns an ASTConsumer that runs the specified clang-tidy checks.
- std::unique_ptr<clang::ASTConsumer>
- createASTConsumer(clang::CompilerInstance &Compiler, StringRef File);
+ std::unique_ptr<ASTConsumer> createASTConsumer(CompilerInstance &Compiler,
+ StringRef File);
/// Get the list of enabled checks.
std::vector<std::string> getCheckNames();
@@ -91,13 +91,12 @@ void filterCheckOptions(ClangTidyOptions &Options,
/// the profile will not be output to stderr, but will instead be stored
/// as a JSON file in the specified directory.
std::vector<ClangTidyError>
-runClangTidy(clang::tidy::ClangTidyContext &Context,
+runClangTidy(ClangTidyContext &Context,
const tooling::CompilationDatabase &Compilations,
ArrayRef<std::string> InputFiles,
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
bool ApplyAnyFix, bool EnableCheckProfile = false,
- llvm::StringRef StoreCheckProfile = StringRef(),
- bool Quiet = false);
+ StringRef StoreCheckProfile = {}, bool Quiet = false);
/// Controls what kind of fixes clang-tidy is allowed to apply.
enum FixBehaviour {
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 337d660b1f93b..f7232645a329c 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -510,57 +510,57 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
for (unsigned Index = 0; Index < Info.getNumArgs(); ++Index) {
const DiagnosticsEngine::ArgumentKind Kind = Info.getArgKind(Index);
switch (Kind) {
- case clang::DiagnosticsEngine::ak_std_string:
+ case DiagnosticsEngine::ak_std_string:
Builder << Info.getArgStdStr(Index);
break;
- case clang::DiagnosticsEngine::ak_c_string:
+ case DiagnosticsEngine::ak_c_string:
Builder << Info.getArgCStr(Index);
break;
- case clang::DiagnosticsEngine::ak_sint:
+ case DiagnosticsEngine::ak_sint:
Builder << Info.getArgSInt(Index);
break;
- case clang::DiagnosticsEngine::ak_uint:
+ case DiagnosticsEngine::ak_uint:
Builder << Info.getArgUInt(Index);
break;
- case clang::DiagnosticsEngine::ak_tokenkind:
+ case DiagnosticsEngine::ak_tokenkind:
Builder << static_cast<tok::TokenKind>(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_identifierinfo:
+ case DiagnosticsEngine::ak_identifierinfo:
Builder << Info.getArgIdentifier(Index);
break;
- case clang::DiagnosticsEngine::ak_qual:
+ case DiagnosticsEngine::ak_qual:
Builder << Qualifiers::fromOpaqueValue(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_qualtype:
+ case DiagnosticsEngine::ak_qualtype:
Builder << QualType::getFromOpaquePtr(
reinterpret_cast<void *>(Info.getRawArg(Index)));
break;
- case clang::DiagnosticsEngine::ak_declarationname:
+ case DiagnosticsEngine::ak_declarationname:
Builder << DeclarationName::getFromOpaqueInteger(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_nameddecl:
+ case DiagnosticsEngine::ak_nameddecl:
Builder << reinterpret_cast<const NamedDecl *>(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_nestednamespec:
+ case DiagnosticsEngine::ak_nestednamespec:
Builder << NestedNameSpecifier::getFromVoidPointer(
reinterpret_cast<void *>(Info.getRawArg(Index)));
break;
- case clang::DiagnosticsEngine::ak_declcontext:
+ case DiagnosticsEngine::ak_declcontext:
Builder << reinterpret_cast<DeclContext *>(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_qualtype_pair:
+ case DiagnosticsEngine::ak_qualtype_pair:
assert(false); // This one is not passed around.
break;
- case clang::DiagnosticsEngine::ak_attr:
+ case DiagnosticsEngine::ak_attr:
Builder << reinterpret_cast<Attr *>(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_attr_info:
+ case DiagnosticsEngine::ak_attr_info:
Builder << reinterpret_cast<AttributeCommonInfo *>(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_addrspace:
+ case DiagnosticsEngine::ak_addrspace:
Builder << static_cast<LangAS>(Info.getRawArg(Index));
break;
- case clang::DiagnosticsEngine::ak_expr:
+ case DiagnosticsEngine::ak_expr:
Builder << reinterpret_cast<const Expr *>(Info.getRawArg(Index));
}
}
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h b/clang-tools-extra/clang-tidy/ClangTidyModule.h
index c2d623540999b..3db92c2dab981 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -28,12 +28,12 @@ class ClangTidyContext;
class ClangTidyCheckFactories {
public:
using CheckFactory = std::function<std::unique_ptr<ClangTidyCheck>(
- llvm::StringRef Name, ClangTidyContext *Context)>;
+ StringRef Name, ClangTidyContext *Context)>;
/// Registers check \p Factory with name \p Name.
///
/// For all checks that have default constructors, use \c registerCheck.
- void registerCheckFactory(llvm::StringRef Name, CheckFactory Factory);
+ void registerCheckFactory(StringRef Name, CheckFactory Factory);
/// Registers the \c CheckType with the name \p Name.
///
@@ -56,14 +56,14 @@ class ClangTidyCheckFactories {
/// }
/// };
/// \endcode
- template <typename CheckType> void registerCheck(llvm::StringRef CheckName) {
+ template <typename CheckType> void registerCheck(StringRef CheckName) {
registerCheckFactory(CheckName,
- [](llvm::StringRef Name, ClangTidyContext *Context) {
+ [](StringRef Name, ClangTidyContext *Context) {
return std::make_unique<CheckType>(Name, Context);
});
}
- void eraseCheck(llvm::StringRef CheckName) { Factories.erase(CheckName); }
+ void eraseCheck(StringRef CheckName) { Factories.erase(CheckName); }
/// Create instances of checks that are enabled.
std::vector<std::unique_ptr<ClangTidyCheck>>
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 317fbd9173af7..0a0f392346f6d 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -324,8 +324,7 @@ ClangTidyOptions ClangTidyOptions::merge(const ClangTidyOptions &Other,
return Result;
}
-ClangTidyOptions
-ClangTidyOptionsProvider::getOptions(llvm::StringRef FileName) {
+ClangTidyOptions ClangTidyOptionsProvider::getOptions(StringRef FileName) {
ClangTidyOptions Result;
unsigned Priority = 0;
for (auto &Source : getRawOptions(FileName))
@@ -334,7 +333,7 @@ ClangTidyOptionsProvider::getOptions(llvm::StringRef FileName) {
}
std::vector<OptionsSource>
-DefaultOptionsProvider::getRawOptions(llvm::StringRef FileName) {
+DefaultOptionsProvider::getRawOptions(StringRef FileName) {
std::vector<OptionsSource> Result;
Result.emplace_back(DefaultOptions, OptionsSourceTypeDefaultBinary);
return Result;
@@ -350,14 +349,14 @@ ConfigOptionsProvider::ConfigOptionsProvider(
ConfigOptions(std::move(ConfigOptions)) {}
std::vector<OptionsSource>
-ConfigOptionsProvider::getRawOptions(llvm::StringRef FileName) {
+ConfigOptionsProvider::getRawOptions(StringRef FileName) {
std::vector<OptionsSource> RawOptions =
DefaultOptionsProvider::getRawOptions(FileName);
if (ConfigOptions.InheritParentConfig.value_or(false)) {
LLVM_DEBUG(llvm::dbgs()
<< "Getting options for file " << FileName << "...\n");
- llvm::ErrorOr<llvm::SmallString<128>> AbsoluteFilePath =
+ llvm::ErrorOr<SmallString<128>> AbsoluteFilePath =
getNormalizedAbsolutePath(FileName);
if (AbsoluteFilePath)
addRawFileOptions(AbsoluteFilePath->str(), RawOptions);
@@ -390,10 +389,10 @@ FileOptionsBaseProvider::FileOptionsBaseProvider(
OverrideOptions(std::move(OverrideOptions)),
ConfigHandlers(std::move(ConfigHandlers)) {}
-llvm::ErrorOr<llvm::SmallString<128>>
-FileOptionsBaseProvider::getNormalizedAbsolutePath(llvm::StringRef Path) {
+llvm::ErrorOr<SmallString<128>>
+FileOptionsBaseProvider::getNormalizedAbsolutePath(StringRef Path) {
assert(FS && "FS must be set.");
- llvm::SmallString<128> NormalizedAbsolutePath = {Path};
+ SmallString<128> NormalizedAbsolutePath = {Path};
const std::error_code Err = FS->makeAbsolute(NormalizedAbsolutePath);
if (Err)
return Err;
@@ -402,7 +401,7 @@ FileOptionsBaseProvider::getNormalizedAbsolutePath(llvm::StringRef Path) {
}
void FileOptionsBaseProvider::addRawFileOptions(
- llvm::StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions) {
+ StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions) {
auto CurSize = CurOptions.size();
// Look for a suitable configuration file in all parent directories of the
// file. Start with the immediate parent directory and move up.
@@ -465,7 +464,7 @@ FileOptionsProvider::getRawOptions(StringRef FileName) {
LLVM_DEBUG(llvm::dbgs() << "Getting options for file " << FileName
<< "...\n");
- const llvm::ErrorOr<llvm::SmallString<128>> AbsoluteFilePath =
+ const llvm::ErrorOr<SmallString<128>> AbsoluteFilePath =
getNormalizedAbsolutePath(FileName);
if (!AbsoluteFilePath)
return {};
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index 23bbfb01c2ecd..73fdbabd5bdba 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -116,7 +116,7 @@ struct ClangTidyOptions {
struct ClangTidyValue {
ClangTidyValue() = default;
ClangTidyValue(const char *Value) : Value(Value) {}
- ClangTidyValue(llvm::StringRef Value, unsigned Priority = 0)
+ ClangTidyValue(StringRef Value, unsigned Priority = 0)
: Value(Value), Priority(Priority) {}
std::string Value;
@@ -138,9 +138,9 @@ struct ClangTidyOptions {
struct CustomCheckValue {
std::string Name;
std::string Query;
- llvm::SmallVector<CustomCheckDiag> Diags;
+ SmallVector<CustomCheckDiag> Diags;
};
- using CustomCheckValueList = llvm::SmallVector<CustomCheckValue>;
+ using CustomCheckValueList = SmallVector<CustomCheckValue>;
std::optional<CustomCheckValueList> CustomChecks;
using ArgList = std::vector<std::string>;
@@ -193,12 +193,11 @@ class ClangTidyOptionsProvider {
/// Returns an ordered vector of OptionsSources, in order of increasing
/// priority.
- virtual std::vector<OptionsSource>
- getRawOptions(llvm::StringRef FileName) = 0;
+ virtual std::vector<OptionsSource> getRawOptions(StringRef FileName) = 0;
/// Returns options applying to a specific translation unit with the
/// specified \p FileName.
- ClangTidyOptions getOptions(llvm::StringRef FileName);
+ ClangTidyOptions getOptions(StringRef FileName);
};
/// Implementation of the \c ClangTidyOptionsProvider interface, which
@@ -212,7 +211,7 @@ class DefaultOptionsProvider : public ClangTidyOptionsProvider {
const ClangTidyGlobalOptions &getGlobalOptions() override {
return GlobalOptions;
}
- std::vector<OptionsSource> getRawOptions(llvm::StringRef FileName) override;
+ std::vector<OptionsSource> getRawOptions(StringRef FileName) override;
private:
ClangTidyGlobalOptions GlobalOptions;
@@ -256,19 +255,19 @@ class FileOptionsBaseProvider : public DefaultOptionsProvider {
ClangTidyOptions OverrideOptions,
ConfigFileHandlers ConfigHandlers);
- void addRawFileOptions(llvm::StringRef AbsolutePath,
+ void addRawFileOptions(StringRef AbsolutePath,
std::vector<OptionsSource> &CurOptions);
- llvm::ErrorOr<llvm::SmallString<128>>
- getNormalizedAbsolutePath(llvm::StringRef AbsolutePath);
+ llvm::ErrorOr<SmallString<128>>
+ getNormalizedAbsolutePath(StringRef AbsolutePath);
/// Try to read configuration files from \p Directory using registered
/// \c ConfigHandlers.
- std::optional<OptionsSource> tryReadConfigFile(llvm::StringRef Directory);
+ std::optional<OptionsSource> tryReadConfigFile(StringRef Directory);
struct OptionsCache {
llvm::StringMap<size_t> Memorized;
- llvm::SmallVector<OptionsSource, 4U> Storage;
+ SmallVector<OptionsSource, 4U> Storage;
} CachedOptions;
ClangTidyOptions OverrideOptions;
ConfigFileHandlers ConfigHandlers;
@@ -283,7 +282,7 @@ class ConfigOptionsProvider : public FileOptionsBaseProvider {
ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
ClangTidyOptions ConfigOptions, ClangTidyOptions OverrideOptions,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = nullptr);
- std::vector<OptionsSource> getRawOptions(llvm::StringRef FileName) override;
+ std::vector<OptionsSource> getRawOptions(StringRef FileName) override;
private:
ClangTidyOptions ConfigOptions;
@@ -336,11 +335,11 @@ class FileOptionsProvider : public FileOptionsBaseProvider {
ClangTidyOptions OverrideOptions,
ConfigFileHandlers ConfigHandlers);
- std::vector<OptionsSource> getRawOptions(llvm::StringRef FileName) override;
+ std::vector<OptionsSource> getRawOptions(StringRef FileName) override;
};
/// Parses LineFilter from JSON and stores it to the \p Options.
-std::error_code parseLineFilter(llvm::StringRef LineFilter,
+std::error_code parseLineFilter(StringRef LineFilter,
ClangTidyGlobalOptions &Options);
/// Parses configuration from JSON and returns \c ClangTidyOptions or an
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 8a865f1352599..cb6de9962956d 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -88,11 +88,11 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
HeaderInfo = std::make_unique<HeaderSearch>(HSOpts, Sources, Diags, LangOpts,
&Compiler.getTarget());
- PP = std::make_unique<clang::Preprocessor>(Compiler.getPreprocessorOpts(),
- Diags, LangOpts, Sources,
- *HeaderInfo, ModuleLoader,
- /*IILookup=*/nullptr,
- /*OwnsHeaderSearch=*/false);
+ PP = std::make_unique<Preprocessor>(Compiler.getPreprocessorOpts(), Diags,
+ LangOpts, Sources, *HeaderInfo,
+ ModuleLoader,
+ /*IILookup=*/nullptr,
+ /*OwnsHeaderSearch=*/false);
PP->Initialize(Compiler.getTarget(), Compiler.getAuxTarget());
InitializePreprocessor(*PP, Compiler.getPreprocessorOpts(),
Compiler.getPCHContainerReader(),
diff --git a/clang-tools-extra/clang-tidy/GlobList.cpp b/clang-tools-extra/clang-tidy/GlobList.cpp
index 7c72af9d06b12..442322f68fdb3 100644
--- a/clang-tools-extra/clang-tidy/GlobList.cpp
+++ b/clang-tools-extra/clang-tidy/GlobList.cpp
@@ -22,7 +22,7 @@ static bool consumeNegativeIndicator(StringRef &GlobList) {
// Extracts the first glob from the comma-separated list of globs,
// removes it and the trailing comma from the GlobList and
// returns the extracted glob.
-static llvm::StringRef extractNextGlob(StringRef &GlobList) {
+static StringRef extractNextGlob(StringRef &GlobList) {
const StringRef UntrimmedGlob =
GlobList.substr(0, GlobList.find_first_of(",\n"));
const StringRef Glob = UntrimmedGlob.trim();
@@ -31,7 +31,7 @@ static llvm::StringRef extractNextGlob(StringRef &GlobList) {
}
static llvm::Regex createRegexFromGlob(StringRef &Glob) {
- llvm::SmallString<128> RegexText("^");
+ SmallString<128> RegexText("^");
const StringRef MetaChars("()^$|*+?.[]\\{}");
for (const char C : Glob) {
if (C == '*')
diff --git a/clang-tools-extra/clang-tidy/GlobList.h b/clang-tools-extra/clang-tidy/GlobList.h
index 9567abf6b1d10..a48ef0132fc6c 100644
--- a/clang-tools-extra/clang-tidy/GlobList.h
+++ b/clang-tools-extra/clang-tidy/GlobList.h
@@ -44,7 +44,7 @@ class GlobList {
struct GlobListItem {
bool IsPositive;
llvm::Regex Regex;
- llvm::StringRef Text;
+ StringRef Text;
};
SmallVector<GlobListItem, 0> Items;
diff --git a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h
index e33d0f2781886..4aafd34b33956 100644
--- a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h
+++ b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h
@@ -33,8 +33,8 @@ class NoLintDirectiveHandler {
~NoLintDirectiveHandler();
bool shouldSuppress(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Diag, llvm::StringRef DiagName,
- llvm::SmallVectorImpl<tooling::Diagnostic> &NoLintErrors,
+ const Diagnostic &Diag, StringRef DiagName,
+ SmallVectorImpl<tooling::Diagnostic> &NoLintErrors,
bool AllowIO, bool EnableNoLintBlocks);
private:
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
index 421e5973d4fe0..60d0ac0b0fb66 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
@@ -29,19 +29,19 @@ void DurationAdditionCheck::registerMatchers(MatchFinder *Finder) {
}
void DurationAdditionCheck::check(const MatchFinder::MatchResult &Result) {
- const auto *Binop = Result.Nodes.getNodeAs<clang::BinaryOperator>("binop");
- const auto *Call = Result.Nodes.getNodeAs<clang::CallExpr>("call");
+ const auto *Binop = Result.Nodes.getNodeAs<BinaryOperator>("binop");
+ const auto *Call = Result.Nodes.getNodeAs<CallExpr>("call");
// Don't try to replace things inside of macro definitions.
if (Binop->getExprLoc().isMacroID() || Binop->getExprLoc().isInvalid())
return;
std::optional<DurationScale> Scale = getScaleForTimeInverse(
- Result.Nodes.getNodeAs<clang::FunctionDecl>("function_decl")->getName());
+ Result.Nodes.getNodeAs<FunctionDecl>("function_decl")->getName());
if (!Scale)
return;
- const llvm::StringRef TimeFactory = getTimeInverseForScale(*Scale);
+ const StringRef TimeFactory = getTimeInverseForScale(*Scale);
FixItHint Hint;
if (Call == Binop->getLHS()->IgnoreParenImpCasts()) {
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
index ef06a9e2ba572..ae2cf5b4cb642 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
@@ -51,8 +51,7 @@ void DurationConversionCastCheck::check(
// Casting a double to an integer.
if (MatchedCast->getTypeAsWritten()->isIntegerType() &&
ConversionFuncName.contains("Double")) {
- const llvm::StringRef NewFuncName =
- getDurationInverseForScale(*Scale).second;
+ const StringRef NewFuncName = getDurationInverseForScale(*Scale).second;
diag(MatchedCast->getBeginLoc(),
"duration should be converted directly to an integer rather than "
@@ -67,8 +66,7 @@ void DurationConversionCastCheck::check(
// Casting an integer to a double.
if (MatchedCast->getTypeAsWritten()->isRealFloatingType() &&
ConversionFuncName.contains("Int64")) {
- const llvm::StringRef NewFuncName =
- getDurationInverseForScale(*Scale).first;
+ const StringRef NewFuncName = getDurationInverseForScale(*Scale).first;
diag(MatchedCast->getBeginLoc(), "duration should be converted directly to "
"a floating-point number rather than "
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
index 83906fe05054f..6528d4ed306b3 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp
@@ -20,9 +20,9 @@ namespace clang::tidy::abseil {
// Returns `true` if `Range` is inside a macro definition.
static bool insideMacroDefinition(const MatchFinder::MatchResult &Result,
SourceRange Range) {
- return !clang::Lexer::makeFileCharRange(
- clang::CharSourceRange::getCharRange(Range),
- *Result.SourceManager, Result.Context->getLangOpts())
+ return !Lexer::makeFileCharRange(CharSourceRange::getCharRange(Range),
+ *Result.SourceManager,
+ Result.Context->getLangOpts())
.isValid();
}
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
index b29fd3a0b94ee..4f1a288d219ec 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -20,8 +20,7 @@ namespace clang::tidy::abseil {
// Given the name of a duration factory function, return the appropriate
// `DurationScale` for that factory. If no factory can be found for
// `FactoryName`, return `std::nullopt`.
-static std::optional<DurationScale>
-getScaleForFactory(llvm::StringRef FactoryName) {
+static std::optional<DurationScale> getScaleForFactory(StringRef FactoryName) {
return llvm::StringSwitch<std::optional<DurationScale>>(FactoryName)
.Case("Nanoseconds", DurationScale::Nanoseconds)
.Case("Microseconds", DurationScale::Microseconds)
@@ -169,8 +168,8 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
// cases where a user is multiplying by something such as 1e-3.
// First check the LHS
- const auto *IntLit = llvm::dyn_cast<IntegerLiteral>(MultBinOp->getLHS());
- const auto *FloatLit = llvm::dyn_cast<FloatingLiteral>(MultBinOp->getLHS());
+ const auto *IntLit = dyn_cast<IntegerLiteral>(MultBinOp->getLHS());
+ const auto *FloatLit = dyn_cast<FloatingLiteral>(MultBinOp->getLHS());
if (IntLit || FloatLit) {
NewScale = getNewScale(Scale, getValue(IntLit, FloatLit));
if (NewScale)
@@ -179,8 +178,8 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
// If we weren't able to scale based on the LHS, check the RHS
if (!NewScale) {
- IntLit = llvm::dyn_cast<IntegerLiteral>(MultBinOp->getRHS());
- FloatLit = llvm::dyn_cast<FloatingLiteral>(MultBinOp->getRHS());
+ IntLit = dyn_cast<IntegerLiteral>(MultBinOp->getRHS());
+ FloatLit = dyn_cast<FloatingLiteral>(MultBinOp->getRHS());
if (IntLit || FloatLit) {
NewScale = getNewScale(Scale, getValue(IntLit, FloatLit));
if (NewScale)
@@ -191,7 +190,7 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
Result.Nodes.getNodeAs<BinaryOperator>("div_binop")) {
// We next handle division.
// For division, we only check the RHS.
- const auto *FloatLit = llvm::cast<FloatingLiteral>(DivBinOp->getRHS());
+ const auto *FloatLit = cast<FloatingLiteral>(DivBinOp->getRHS());
std::optional<DurationScale> NewScale =
getNewScale(Scale, 1.0 / FloatLit->getValueAsApproximateDouble());
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index a78d07d2e5861..035e7d642c8b7 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -30,10 +30,10 @@ truncateIfIntegral(const FloatingLiteral &FloatLiteral) {
return std::nullopt;
}
-const std::pair<llvm::StringRef, llvm::StringRef> &
+const std::pair<StringRef, StringRef> &
getDurationInverseForScale(DurationScale Scale) {
- static constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 6>
- InverseMap = {{
+ static constexpr std::array<std::pair<StringRef, StringRef>, 6> InverseMap = {
+ {
{"::absl::ToDoubleHours", "::absl::ToInt64Hours"},
{"::absl::ToDoubleMinutes", "::absl::ToInt64Minutes"},
{"::absl::ToDoubleSeconds", "::absl::ToInt64Seconds"},
@@ -50,7 +50,7 @@ getDurationInverseForScale(DurationScale Scale) {
static std::optional<std::string>
rewriteInverseDurationCall(const MatchFinder::MatchResult &Result,
DurationScale Scale, const Expr &Node) {
- const std::pair<llvm::StringRef, llvm::StringRef> &InverseFunctions =
+ const std::pair<StringRef, StringRef> &InverseFunctions =
getDurationInverseForScale(Scale);
if (const auto *MaybeCallArg = selectFirst<const Expr>(
"e",
@@ -69,7 +69,7 @@ rewriteInverseDurationCall(const MatchFinder::MatchResult &Result,
static std::optional<std::string>
rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
DurationScale Scale, const Expr &Node) {
- const llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
+ const StringRef InverseFunction = getTimeInverseForScale(Scale);
if (const auto *MaybeCallArg = selectFirst<const Expr>(
"e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
hasArgument(0, expr().bind("e"))),
@@ -81,8 +81,8 @@ rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
}
/// Returns the factory function name for a given `Scale`.
-llvm::StringRef getDurationFactoryForScale(DurationScale Scale) {
- static constexpr std::array<llvm::StringRef, 6> FactoryMap = {
+StringRef getDurationFactoryForScale(DurationScale Scale) {
+ static constexpr std::array<StringRef, 6> FactoryMap = {
"absl::Hours", "absl::Minutes", "absl::Seconds",
"absl::Milliseconds", "absl::Microseconds", "absl::Nanoseconds",
};
@@ -90,8 +90,8 @@ llvm::StringRef getDurationFactoryForScale(DurationScale Scale) {
return FactoryMap[llvm::to_underlying(Scale)];
}
-llvm::StringRef getTimeFactoryForScale(DurationScale Scale) {
- static constexpr std::array<llvm::StringRef, 6> FactoryMap = {
+StringRef getTimeFactoryForScale(DurationScale Scale) {
+ static constexpr std::array<StringRef, 6> FactoryMap = {
"absl::FromUnixHours", "absl::FromUnixMinutes", "absl::FromUnixSeconds",
"absl::FromUnixMillis", "absl::FromUnixMicros", "absl::FromUnixNanos",
};
@@ -100,8 +100,8 @@ llvm::StringRef getTimeFactoryForScale(DurationScale Scale) {
}
/// Returns the Time factory function name for a given `Scale`.
-llvm::StringRef getTimeInverseForScale(DurationScale Scale) {
- static constexpr std::array<llvm::StringRef, 6> InverseMap = {
+StringRef getTimeInverseForScale(DurationScale Scale) {
+ static constexpr std::array<StringRef, 6> InverseMap = {
"absl::ToUnixHours", "absl::ToUnixMinutes", "absl::ToUnixSeconds",
"absl::ToUnixMillis", "absl::ToUnixMicros", "absl::ToUnixNanos",
};
@@ -115,14 +115,14 @@ bool isLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) {
anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
// Check to see if we're using a zero directly.
- if (selectFirst<const clang::Expr>(
+ if (selectFirst<const Expr>(
"val", match(expr(ignoringImpCasts(ZeroMatcher)).bind("val"), Node,
*Result.Context)) != nullptr)
return true;
// Now check to see if we're using a functional cast with a scalar
// initializer expression, e.g. `int{0}`.
- if (selectFirst<const clang::Expr>(
+ if (selectFirst<const Expr>(
"val", match(cxxFunctionalCastExpr(
hasDestinationType(
anyOf(isInteger(), realFloatingPointType())),
@@ -158,7 +158,7 @@ stripFloatCast(const ast_matchers::MatchFinder::MatchResult &Result,
std::optional<std::string>
stripFloatLiteralFraction(const MatchFinder::MatchResult &Result,
const Expr &Node) {
- if (const auto *LitFloat = llvm::dyn_cast<FloatingLiteral>(&Node))
+ if (const auto *LitFloat = dyn_cast<FloatingLiteral>(&Node))
// Attempt to simplify a `Duration` factory call with a literal argument.
if (std::optional<llvm::APSInt> IntValue = truncateIfIntegral(*LitFloat))
return toString(*IntValue, /*radix=*/10);
@@ -181,7 +181,7 @@ std::string simplifyDurationFactoryArg(const MatchFinder::MatchResult &Result,
return tooling::fixit::getText(Node, *Result.Context).str();
}
-std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
+std::optional<DurationScale> getScaleForDurationInverse(StringRef Name) {
static const llvm::StringMap<DurationScale> ScaleMap(
{{"ToDoubleHours", DurationScale::Hours},
{"ToInt64Hours", DurationScale::Hours},
@@ -203,7 +203,7 @@ std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
return ScaleIter->second;
}
-std::optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
+std::optional<DurationScale> getScaleForTimeInverse(StringRef Name) {
static const llvm::StringMap<DurationScale> ScaleMap(
{{"ToUnixHours", DurationScale::Hours},
{"ToUnixMinutes", DurationScale::Minutes},
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
index e3b1753e95a16..f9e42a752c185 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.h
@@ -11,7 +11,7 @@
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
-#include <cinttypes>
+#include <cstdint>
#include <optional>
namespace clang::tidy::abseil {
@@ -28,11 +28,11 @@ enum class DurationScale : std::uint8_t {
/// Given a `Scale`, return the appropriate factory function call for
/// constructing a `Duration` for that scale.
-llvm::StringRef getDurationFactoryForScale(DurationScale Scale);
+StringRef getDurationFactoryForScale(DurationScale Scale);
/// Given a 'Scale', return the appropriate factory function call for
/// constructing a `Time` for that scale.
-llvm::StringRef getTimeFactoryForScale(DurationScale Scale);
+StringRef getTimeFactoryForScale(DurationScale Scale);
// Determine if `Node` represents a literal floating point or integral zero.
bool isLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result,
@@ -63,20 +63,20 @@ simplifyDurationFactoryArg(const ast_matchers::MatchFinder::MatchResult &Result,
/// Given the name of an inverse Duration function (e.g., `ToDoubleSeconds`),
/// return its `DurationScale`, or `std::nullopt` if a match is not found.
-std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name);
+std::optional<DurationScale> getScaleForDurationInverse(StringRef Name);
/// Given the name of an inverse Time function (e.g., `ToUnixSeconds`),
/// return its `DurationScale`, or `std::nullopt` if a match is not found.
-std::optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name);
+std::optional<DurationScale> getScaleForTimeInverse(StringRef Name);
/// Given a `Scale` return the fully qualified inverse functions for it.
/// The first returned value is the inverse for `double`, and the second
/// returned value is the inverse for `int64`.
-const std::pair<llvm::StringRef, llvm::StringRef> &
+const std::pair<StringRef, StringRef> &
getDurationInverseForScale(DurationScale Scale);
/// Returns the Time inverse function name for a given `Scale`.
-llvm::StringRef getTimeInverseForScale(DurationScale Scale);
+StringRef getTimeInverseForScale(DurationScale Scale);
/// Assuming `Node` has type `double` or `int` representing a time interval of
/// `Scale`, return the expression to make it a suitable `Duration`.
diff --git a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
index 0827526ba3b5d..391777225f739 100644
--- a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -28,7 +28,7 @@ makeCharacterLiteral(const StringLiteral *Literal, const ASTContext &Context) {
"Only single character string should be matched");
assert(Literal->getCharByteWidth() == 1 &&
"StrSplit doesn't support wide char");
- std::string Result = clang::tooling::fixit::getText(*Literal, Context).str();
+ std::string Result = tooling::fixit::getText(*Literal, Context).str();
const bool IsRawStringLiteral = StringRef(Result).starts_with(R"(R")");
// Since raw string literal might contain unescaped non-printable characters,
// we normalize them using `StringLiteral::outputString`.
diff --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
index a58c0410c4e35..79d16c7034cef 100644
--- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -61,9 +61,9 @@ static void removeCallLeaveArgs(const CallExpr *Call,
Call->getRParenLoc(), Call->getEndLoc().getLocWithOffset(1))));
}
-static const clang::CallExpr *
-processArgument(const Expr *Arg, const MatchFinder::MatchResult &Result,
- StrCatCheckResult *CheckResult) {
+static const CallExpr *processArgument(const Expr *Arg,
+ const MatchFinder::MatchResult &Result,
+ StrCatCheckResult *CheckResult) {
const auto IsAlphanum = hasDeclaration(cxxMethodDecl(hasName("AlphaNum")));
static const auto *const Strcat = new auto(hasName("::absl::StrCat"));
const auto IsStrcat = cxxBindTemporaryExpr(
@@ -89,17 +89,15 @@ static StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
while (!CallsToProcess.empty()) {
++CheckResult.NumCalls;
- const CallExpr *CallExpr = CallsToProcess.front();
+ const CallExpr *Call = CallsToProcess.front();
CallsToProcess.pop_front();
- int StartArg = CallExpr == RootCall && IsAppend;
- for (const auto *Arg : CallExpr->arguments()) {
+ int StartArg = Call == RootCall && IsAppend;
+ for (const auto *Arg : Call->arguments()) {
if (StartArg-- > 0)
continue;
- if (const clang::CallExpr *Sub =
- processArgument(Arg, Result, &CheckResult)) {
+ if (const CallExpr *Sub = processArgument(Arg, Result, &CheckResult))
CallsToProcess.push_back(Sub);
- }
}
}
return CheckResult;
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
index 4ae49d285930d..b7d5cf69fdf68 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
@@ -20,9 +20,9 @@ namespace clang::tidy::abseil {
// Returns `true` if `Range` is inside a macro definition.
static bool insideMacroDefinition(const MatchFinder::MatchResult &Result,
SourceRange Range) {
- return !clang::Lexer::makeFileCharRange(
- clang::CharSourceRange::getCharRange(Range),
- *Result.SourceManager, Result.Context->getLangOpts())
+ return !Lexer::makeFileCharRange(CharSourceRange::getCharRange(Range),
+ *Result.SourceManager,
+ Result.Context->getLangOpts())
.isValid();
}
@@ -85,7 +85,7 @@ static bool parensRequired(const MatchFinder::MatchResult &Result,
}
void TimeSubtractionCheck::emitDiagnostic(const Expr *Node,
- llvm::StringRef Replacement) {
+ StringRef Replacement) {
diag(Node->getBeginLoc(), "perform subtraction in the time domain")
<< FixItHint::CreateReplacement(Node->getSourceRange(), Replacement);
}
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
index 3f44a3ded91e4..10850e7edde90 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
@@ -29,7 +29,7 @@ class TimeSubtractionCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- void emitDiagnostic(const Expr *Node, llvm::StringRef Replacement);
+ void emitDiagnostic(const Expr *Node, StringRef Replacement);
};
} // namespace clang::tidy::abseil
diff --git a/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp b/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
index 698c3965366ce..3dcdbd37e7795 100644
--- a/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
@@ -48,7 +48,7 @@ void UncheckedStatusOrAccessCheck::check(
return;
UncheckedStatusOrAccessDiagnoser Diagnoser;
- if (llvm::Expected<llvm::SmallVector<SourceLocation>> Locs =
+ if (llvm::Expected<SmallVector<SourceLocation>> Locs =
dataflow::diagnoseFunction<UncheckedStatusOrAccessModel,
SourceLocation>(*FuncDecl, *Result.Context,
Diagnoser))
diff --git a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
index 1a6ff30fc8d96..be09ad9782399 100644
--- a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
@@ -113,7 +113,7 @@ void UpgradeDurationConversionsCheck::registerMatchers(MatchFinder *Finder) {
void UpgradeDurationConversionsCheck::check(
const MatchFinder::MatchResult &Result) {
- const llvm::StringRef Message =
+ static constexpr StringRef Message =
"implicit conversion to 'int64_t' is deprecated in this context; use an "
"explicit cast instead";
diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index 22e8c03805e3f..4a12a44bbbf79 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -52,7 +52,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
return;
// Get sizing info for the struct.
- llvm::SmallVector<std::pair<unsigned int, unsigned int>, 10> FieldSizes;
+ SmallVector<std::pair<unsigned int, unsigned int>, 10> FieldSizes;
unsigned int TotalBitSize = 0;
for (const FieldDecl *StructField : Struct->fields()) {
// For each StructField, record how big it is (in bits).
@@ -73,7 +73,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
const CharUnits CurrSize =
Result.Context->getASTRecordLayout(Struct).getSize();
const CharUnits MinByteSize =
- CharUnits::fromQuantity(std::max<clang::CharUnits::QuantityType>(
+ CharUnits::fromQuantity(std::max<CharUnits::QuantityType>(
std::ceil(static_cast<float>(TotalBitSize) / CharSize), 1));
const CharUnits MaxAlign = CharUnits::fromQuantity(
std::ceil(static_cast<float>(Struct->getMaxAlignment()) / CharSize));
diff --git a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
index a72d8a3d4f390..e976a7eecbfcb 100644
--- a/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/boost/UseRangesCheck.cpp
@@ -207,7 +207,7 @@ utils::UseRangesCheck::ReplacerMap UseRangesCheck::getReplacerMap() const {
const auto AddFrom =
[&Results](llvm::IntrusiveRefCntPtr<UseRangesCheck::Replacer> Replacer,
std::initializer_list<StringRef> Names, StringRef Prefix) {
- llvm::SmallString<64> Buffer;
+ SmallString<64> Buffer;
for (const auto &Name : Names) {
Buffer.assign({"::", Prefix, (Prefix.empty() ? "" : "::"), Name});
Results.try_emplace(Buffer, Replacer);
diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index eb9b710b28549..e3139f96cfb09 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -273,7 +273,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
}
for (const auto &Comment : Comments) {
- llvm::SmallVector<StringRef, 2> Matches;
+ SmallVector<StringRef, 2> Matches;
if (IdentRE.match(Comment.Text, &Matches) &&
!sameName(Matches[2], II->getName(), StrictMode)) {
{
@@ -297,7 +297,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
// If the argument comments are missing for literals add them.
if (Comments.empty() && shouldAddComment(Args[I])) {
- llvm::SmallString<32> ArgComment;
+ SmallString<32> ArgComment;
(llvm::Twine("/*") + II->getName() + "=*/").toStringRef(ArgComment);
const DiagnosticBuilder Diag =
diag(Args[I]->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
index 6eadae21fae2f..574ccfc255a53 100644
--- a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
@@ -24,7 +24,7 @@ namespace clang::tidy::bugprone {
namespace {
AST_MATCHER_P2(Expr, hasSideEffect, bool, CheckFunctionCalls,
- clang::ast_matchers::internal::Matcher<NamedDecl>,
+ ast_matchers::internal::Matcher<NamedDecl>,
IgnoredFunctionsMatcher) {
const Expr *E = &Node;
diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index e1bca0e459c71..588f9bfe076df 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -20,7 +20,7 @@ using namespace clang::ast_matchers;
namespace {
/// A branch in a switch may consist of several statements; while a branch in
/// an if/else if/else chain is one statement (which may be a CompoundStmt).
-using SwitchBranch = llvm::SmallVector<const Stmt *, 2>;
+using SwitchBranch = SmallVector<const Stmt *, 2>;
} // anonymous namespace
/// Determines if the bodies of two branches in a switch statements are Type I
@@ -305,7 +305,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
// This is the complicated case when we start an if/else if/else chain.
// To find all the duplicates, we collect all the branches into a vector.
- llvm::SmallVector<const Stmt *, 4> Branches;
+ SmallVector<const Stmt *, 4> Branches;
const IfStmt *Cur = IS;
while (true) {
// Store the `then` branch.
@@ -388,7 +388,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
// (`case:` or `default:`) children of Body; that is, we ignore `case:` or
// `default:` labels embedded inside other statements and we do not follow
// the effects of `break` and other manipulation of the control-flow.
- llvm::SmallVector<SwitchBranch, 4> Branches;
+ SmallVector<SwitchBranch, 4> Branches;
for (const Stmt *S : Body->body()) {
// If this is a `case` or `default`, we start a new, empty branch.
if (isa<SwitchCase>(S))
diff --git a/clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp
index 8b1c8aaa48e3e..1c70fb482aa2d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp
@@ -37,14 +37,14 @@ AST_MATCHER(CXXOperatorCallExpr,
}
struct ChainedComparisonData {
- llvm::SmallString<256U> Name;
- llvm::SmallVector<const Expr *, 32U> Operands;
+ SmallString<256U> Name;
+ SmallVector<const Expr *, 32U> Operands;
explicit ChainedComparisonData(const Expr *Op) { extract(Op); }
private:
void add(const Expr *Operand);
- void add(llvm::StringRef Opcode);
+ void add(StringRef Opcode);
void extract(const Expr *Op);
void extract(const BinaryOperator *Op);
void extract(const CXXOperatorCallExpr *Op);
@@ -60,7 +60,7 @@ void ChainedComparisonData::add(const Expr *Operand) {
Operands.push_back(Operand);
}
-void ChainedComparisonData::add(llvm::StringRef Opcode) {
+void ChainedComparisonData::add(StringRef Opcode) {
Name += ' ';
Name += Opcode;
}
@@ -148,7 +148,7 @@ void ChainedComparisonCheck::check(const MatchFinder::MatchResult &Result) {
"chained comparison '%0' may generate unintended results, use "
"parentheses to specify order of evaluation or a logical operator to "
"separate comparison expressions")
- << llvm::StringRef(Data.Name).trim() << MatchedOperator->getSourceRange();
+ << StringRef(Data.Name).trim() << MatchedOperator->getSourceRange();
for (std::size_t Index = 0U; Index < Data.Operands.size(); ++Index) {
diag(Data.Operands[Index]->getBeginLoc(), "operand 'v%0' is here",
diff --git a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
index 5e6eda674d35b..91290c2850c57 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
@@ -65,7 +65,7 @@ void ComparePointerToMemberVirtualFunctionCheck::check(
return;
}
// compare with variable which type is pointer to member function.
- llvm::SmallVector<SourceLocation, 12U> SameSignatureVirtualMethods{};
+ SmallVector<SourceLocation, 12U> SameSignatureVirtualMethods{};
const auto *MPT = cast<MemberPointerType>(DRE->getType().getCanonicalType());
const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
if (RD == nullptr)
diff --git a/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp
index 7c5867619cf4e..d50569fa70851 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/DerivedMethodShadowingBaseMethodCheck.cpp
@@ -43,14 +43,13 @@ namespace {
AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) {
const CXXRecordDecl *DerivedClass = Node.getParent();
for (const auto &Base : DerivedClass->bases()) {
- llvm::SmallVector<const CXXBaseSpecifier *, 8> Stack;
+ SmallVector<const CXXBaseSpecifier *, 8> Stack;
Stack.push_back(&Base);
while (!Stack.empty()) {
const CXXBaseSpecifier *CurrentBaseSpec = Stack.back();
Stack.pop_back();
- if (CurrentBaseSpec->getAccessSpecifier() ==
- clang::AccessSpecifier::AS_private)
+ if (CurrentBaseSpec->getAccessSpecifier() == AccessSpecifier::AS_private)
continue;
const CXXRecordDecl *CurrentRecord =
@@ -66,8 +65,7 @@ AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) {
for (const auto &BaseMethod : CurrentRecord->methods()) {
if (namesCollide(*BaseMethod, Node)) {
const ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
- Builder->setBinding("base_method",
- clang::DynTypedNode::create(*BaseMethod));
+ Builder->setBinding("base_method", DynTypedNode::create(*BaseMethod));
return true;
}
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
index d40662ab0e7ad..ebbc197e0189a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
@@ -17,7 +17,7 @@ namespace clang::tidy::bugprone {
namespace {
-AST_MATCHER(clang::VarDecl, hasConstantDeclaration) {
+AST_MATCHER(VarDecl, hasConstantDeclaration) {
if (Node.isConstexpr() || Node.hasAttr<ConstInitAttr>())
return true;
if (const VarDecl *Def = Node.getDefinition();
diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 7774c34927ce1..e95af89375dc8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -1198,7 +1198,7 @@ class UserDefinedConversionSelector {
}
private:
- llvm::SmallVector<PreparedConversion, 2> FlaggedConversions;
+ SmallVector<PreparedConversion, 2> FlaggedConversions;
const TheCheck &Check;
};
@@ -1740,7 +1740,7 @@ class AccessedSameMemberOf {
/// Implements the heuristic that marks two parameters related if
diff erent
/// ReturnStmts return them from the function.
class Returned {
- llvm::SmallVector<const ParmVarDecl *, SmallDataStructureSize> ReturnedParams;
+ SmallVector<const ParmVarDecl *, SmallDataStructureSize> ReturnedParams;
public:
void setup(const FunctionDecl *FD) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
index 5cf7cfeb3cd39..9e5e1219b6387 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
@@ -35,8 +35,7 @@ AST_MATCHER_P(CXXCatchStmt, hasCaughtType, Matcher<QualType>, InnerMatcher) {
return InnerMatcher.matches(Node.getCaughtType(), Finder, Builder);
}
-AST_MATCHER_P(CompoundStmt, hasAnyTextFromList, std::vector<llvm::StringRef>,
- List) {
+AST_MATCHER_P(CompoundStmt, hasAnyTextFromList, std::vector<StringRef>, List) {
if (List.empty())
return false;
diff --git a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.h b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.h
index db8ee02dfd404..293bc5675a2a6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.h
@@ -28,8 +28,8 @@ class EmptyCatchCheck : public ClangTidyCheck {
std::optional<TraversalKind> getCheckTraversalKind() const override;
private:
- std::vector<llvm::StringRef> IgnoreCatchWithKeywords;
- std::vector<llvm::StringRef> AllowEmptyCatchForExceptions;
+ std::vector<StringRef> IgnoreCatchWithKeywords;
+ std::vector<StringRef> AllowEmptyCatchForExceptions;
};
} // namespace clang::tidy::bugprone
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
index 41e0cdaf6ee61..e4facdad2c7aa 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -68,7 +68,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
TreatFunctionsWithoutSpecificationAsThrowing(
Options.get("TreatFunctionsWithoutSpecificationAsThrowing",
TreatFunctionsWithoutSpecification::None)) {
- llvm::SmallVector<StringRef, 8> FunctionsThatShouldNotThrowVec,
+ SmallVector<StringRef, 8> FunctionsThatShouldNotThrowVec,
IgnoredExceptionsVec, CheckedSwapFunctionsVec;
RawFunctionsThatShouldNotThrow.split(FunctionsThatShouldNotThrowVec, ",", -1,
false);
diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
index 263ab635d9458..8d4d9d67f17f4 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
@@ -46,7 +46,7 @@ AST_MATCHER(QualType, isEnableIf) {
return false;
}
AST_MATCHER_P(TemplateTypeParmDecl, hasDefaultArgument,
- clang::ast_matchers::internal::Matcher<QualType>, TypeMatcher) {
+ ast_matchers::internal::Matcher<QualType>, TypeMatcher) {
return Node.hasDefaultArgument() &&
TypeMatcher.matches(
Node.getDefaultArgument().getArgument().getAsType(), Finder,
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
index 5ded16a019618..57961724bf1be 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
@@ -44,7 +44,7 @@ void IncorrectEnableSharedFromThisCheck::check(
BaseSpec->getAccessSpecifierAsWritten() != AS_none;
const auto ReplacementRange = CharSourceRange(
SourceRange(BaseSpec->getBeginLoc()), HasWrittenAccessSpecifier);
- const llvm::StringRef Replacement =
+ const StringRef Replacement =
HasWrittenAccessSpecifier ? "public" : "public ";
const FixItHint Hint =
IsEnableSharedFromThisDirectBase
diff --git a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
index 2bc4545f439f0..f0a0f6c9b3106 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp
@@ -299,13 +299,13 @@ static bool isFloatExactlyRepresentable(const ASTContext &Context,
return !Overflows && IsExact;
}
-static llvm::SmallString<64> getValueAsString(const llvm::APSInt &Value,
- uint64_t HexBits) {
- llvm::SmallString<64> Str;
+static SmallString<64> getValueAsString(const llvm::APSInt &Value,
+ uint64_t HexBits) {
+ SmallString<64> Str;
Value.toString(Str, 10);
if (HexBits > 0) {
Str.append(" (0x");
- llvm::SmallString<32> HexValue;
+ SmallString<32> HexValue;
Value.toStringUnsigned(HexValue, 16);
for (size_t I = HexValue.size(); I < (HexBits / 4); ++I)
Str.append("0");
@@ -550,7 +550,7 @@ void NarrowingConversionsCheck::handleBinaryOperator(const ASTContext &Context,
bool NarrowingConversionsCheck::handleConditionalOperator(
const ASTContext &Context, const Expr &Lhs, const Expr &Rhs) {
- if (const auto *CO = llvm::dyn_cast<ConditionalOperator>(&Rhs)) {
+ if (const auto *CO = dyn_cast<ConditionalOperator>(&Rhs)) {
// We have an expression like so: `output = cond ? lhs : rhs`
// From the point of view of narrowing conversion we treat it as two
// expressions `output = lhs` and `output = rhs`.
@@ -563,7 +563,7 @@ bool NarrowingConversionsCheck::handleConditionalOperator(
void NarrowingConversionsCheck::handleConditionalOperatorArgument(
const ASTContext &Context, const Expr &Lhs, const Expr *Arg) {
- if (const auto *ICE = llvm::dyn_cast<ImplicitCastExpr>(Arg))
+ if (const auto *ICE = dyn_cast<ImplicitCastExpr>(Arg))
if (!Arg->getIntegerConstantExpr(Context))
Arg = ICE->getSubExpr();
diff --git a/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
index 9cd8930394a2f..446e62e41d16c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
@@ -153,7 +153,7 @@ void OptionalValueConversionCheck::check(
<< FixItHint::CreateRemoval(
CharSourceRange::getTokenRange(Begin, CallExpr->getEndLoc()));
if (const auto *Member =
- llvm::dyn_cast<MemberExpr>(CallExpr->getCallee()->IgnoreImplicit());
+ dyn_cast<MemberExpr>(CallExpr->getCallee()->IgnoreImplicit());
Member && Member->isArrow())
Diag << FixItHint::CreateInsertion(CallExpr->getBeginLoc(), "*");
return;
diff --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
index 4a57cf1ebfe12..6c7e237331571 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
@@ -17,7 +17,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {
-using BasesVector = llvm::SmallVector<const CXXRecordDecl *, 5>;
+using BasesVector = SmallVector<const CXXRecordDecl *, 5>;
static bool isParentOf(const CXXRecordDecl &Parent,
const CXXRecordDecl &ThisClass) {
@@ -65,8 +65,7 @@ static std::string getNameAsString(const NamedDecl *Decl) {
// Returns E as written in the source code. Used to handle 'using' and
// 'typedef'ed names of grand-parent classes.
-static std::string getExprAsString(const clang::Expr &E,
- clang::ASTContext &AC) {
+static std::string getExprAsString(const Expr &E, ASTContext &AC) {
std::string Text = tooling::fixit::getText(E, AC).str();
llvm::erase_if(Text, [](char C) {
return llvm::isSpace(static_cast<unsigned char>(C));
diff --git a/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
index e212301047ce2..59942a9fb12e6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
@@ -44,7 +44,7 @@ static const char BuiltinMemCmp[] = "::std::memcmp;"
"::std::strcmp;"
"::strcmp;"
"::strncmp;";
-static constexpr llvm::StringRef ComparisonOperators[] = {
+static constexpr StringRef ComparisonOperators[] = {
"operator==", "operator!=", "operator<",
"operator>", "operator<=", "operator>="};
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index 62e22450800ea..f8db3602f0ec7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -37,9 +37,9 @@ static int getMessageSelectIndex(StringRef Tag) {
return 0;
}
-llvm::SmallVector<llvm::Regex>
+SmallVector<llvm::Regex>
ReservedIdentifierCheck::parseAllowedIdentifiers() const {
- llvm::SmallVector<llvm::Regex> AllowedIdentifiers;
+ SmallVector<llvm::Regex> AllowedIdentifiers;
AllowedIdentifiers.reserve(AllowedIdentifiersRaw.size());
for (const auto &Identifier : AllowedIdentifiersRaw) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
index 89e2c86f99a8f..49de2442d530e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
@@ -31,7 +31,7 @@ namespace clang::tidy::bugprone {
class ReservedIdentifierCheck final : public RenamerClangTidyCheck {
const bool Invert;
const std::vector<StringRef> AllowedIdentifiersRaw;
- const llvm::SmallVector<llvm::Regex> AllowedIdentifiers;
+ const SmallVector<llvm::Regex> AllowedIdentifiers;
public:
ReservedIdentifierCheck(StringRef Name, ClangTidyContext *Context);
@@ -47,7 +47,7 @@ class ReservedIdentifierCheck final : public RenamerClangTidyCheck {
const SourceManager &SM) const override;
DiagInfo getDiagInfo(const NamingCheckId &ID,
const NamingCheckFailure &Failure) const override;
- llvm::SmallVector<llvm::Regex> parseAllowedIdentifiers() const;
+ SmallVector<llvm::Regex> parseAllowedIdentifiers() const;
};
} // namespace clang::tidy::bugprone
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
index 2b9a8d36c2835..dda687ff7ade5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
@@ -65,7 +65,7 @@ static bool hasSameParameterTypes(const FunctionDecl &FD, const FunctionDecl &O,
const ParmVarDecl *DPD = FD.getParamDecl(I);
const QualType OPT = O.getParamDecl(I)->getType();
if (DPD == &PD) {
- if (!llvm::isa<RValueReferenceType>(OPT) ||
+ if (!isa<RValueReferenceType>(OPT) ||
!isSameTypeIgnoringConstRef(DPD->getType(), OPT))
return false;
} else {
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
index 6479ede6bf606..0f9a5f967c153 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
@@ -532,7 +532,7 @@ bool SignalHandlerCheck::isStandardFunctionAsyncSafe(
}
void SignalHandlerCheck::reportHandlerChain(
- const llvm::df_iterator<const clang::CallGraphNode *> &Itr,
+ const llvm::df_iterator<const CallGraphNode *> &Itr,
const DeclRefExpr *HandlerRef, bool SkipPathEnd) {
int CallLevel = Itr.getPathLength() - 2;
assert(CallLevel >= -1 && "Empty iterator?");
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
index 324b2c88207fd..6833cae6879d4 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
@@ -65,11 +65,10 @@ class SignalHandlerCheck : public ClangTidyCheck {
/// registered as signal handler.
/// @param SkipPathEnd If true the last item of the call chain (farthest away
/// from the \c signal call) is omitted from note generation.
- void
- reportHandlerChain(const llvm::df_iterator<const clang::CallGraphNode *> &Itr,
- const DeclRefExpr *HandlerRef, bool SkipPathEnd);
+ void reportHandlerChain(const llvm::df_iterator<const CallGraphNode *> &Itr,
+ const DeclRefExpr *HandlerRef, bool SkipPathEnd);
- clang::CallGraph CG;
+ CallGraph CG;
AsyncSafeFunctionSetKind AsyncSafeFunctionSet;
llvm::StringSet<> ConformingFunctions;
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
index 31c5413b8aa4c..88a2614b266b9 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -32,8 +32,8 @@ void SignedCharMisuseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
}
// Create a matcher for char -> integer cast.
-BindableMatcher<clang::Stmt> SignedCharMisuseCheck::charCastExpression(
- bool IsSigned, const Matcher<clang::QualType> &IntegerType,
+BindableMatcher<Stmt> SignedCharMisuseCheck::charCastExpression(
+ bool IsSigned, const Matcher<QualType> &IntegerType,
const std::string &CastBindName) const {
// We can ignore typedefs which are some kind of integer types
// (e.g. typedef char sal_Int8). In this case, we don't need to
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
index c6d9f29523c5e..970c2aa5f8e0b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h
@@ -30,9 +30,9 @@ class SignedCharMisuseCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- ast_matchers::internal::BindableMatcher<clang::Stmt> charCastExpression(
+ ast_matchers::internal::BindableMatcher<Stmt> charCastExpression(
bool IsSigned,
- const ast_matchers::internal::Matcher<clang::QualType> &IntegerType,
+ const ast_matchers::internal::Matcher<QualType> &IntegerType,
const std::string &CastBindName) const;
const StringRef CharTypedefsToIgnoreList;
diff --git a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
index af478b105fdd1..a0db39ab6f90d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
@@ -89,7 +89,7 @@ void SmartPtrArrayMismatchCheck::check(const MatchFinder::MatchResult &Result) {
if (VarOrField) {
auto TSTypeLoc = VarOrField->getTypeSourceInfo()
->getTypeLoc()
- .getAsAdjusted<clang::TemplateSpecializationTypeLoc>();
+ .getAsAdjusted<TemplateSpecializationTypeLoc>();
assert(TSTypeLoc.getNumArgs() >= 1 &&
"Matched type should have at least 1 template argument.");
diff --git a/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
index 056ae4b80f109..1d72f3e9f387b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
@@ -129,14 +129,13 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
auto Candidates = HeuristicResolver(Context).lookupDependentName(
MemberCall->getRecordDecl(), Name, [](const NamedDecl *ND) {
return isa<CXXMethodDecl>(ND) &&
- llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
- 0 &&
- !llvm::cast<CXXMethodDecl>(ND)->isConst();
+ cast<CXXMethodDecl>(ND)->getMinRequiredArguments() == 0 &&
+ !cast<CXXMethodDecl>(ND)->isConst();
});
const bool HasClear = !Candidates.empty();
if (HasClear) {
- const auto *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0));
+ const auto *Clear = cast<CXXMethodDecl>(Candidates.at(0));
const QualType RangeType =
MemberCall->getImplicitObjectArgument()->getType();
const bool QualifierIncompatible =
@@ -179,15 +178,14 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
auto Candidates = HeuristicResolver(Context).lookupDependentName(
ArgRecordDecl, Name, [](const NamedDecl *ND) {
return isa<CXXMethodDecl>(ND) &&
- llvm::cast<CXXMethodDecl>(ND)->getMinRequiredArguments() ==
- 0 &&
- !llvm::cast<CXXMethodDecl>(ND)->isConst();
+ cast<CXXMethodDecl>(ND)->getMinRequiredArguments() == 0 &&
+ !cast<CXXMethodDecl>(ND)->isConst();
});
const bool HasClear = !Candidates.empty();
if (HasClear) {
- const auto *Clear = llvm::cast<CXXMethodDecl>(Candidates.at(0));
+ const auto *Clear = cast<CXXMethodDecl>(Candidates.at(0));
const bool QualifierIncompatible =
(!Clear->isVolatile() && Arg->getType().isVolatileQualified()) ||
Arg->getType().isConstQualified();
@@ -201,7 +199,7 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
SourceRange(NonMemberLoc, NonMemberEndLoc);
diag(NonMemberLoc,
"ignoring the result of '%0'; did you mean 'clear()'?")
- << llvm::dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
+ << dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
->getQualifiedNameAsString()
<< FixItHint::CreateReplacement(ReplacementRange, ReplacementText);
return;
@@ -209,7 +207,7 @@ void StandaloneEmptyCheck::check(const MatchFinder::MatchResult &Result) {
}
diag(NonMemberLoc, "ignoring the result of '%0'")
- << llvm::dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
+ << dyn_cast<NamedDecl>(NonMemberCall->getCalleeDecl())
->getQualifiedNameAsString();
}
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
index 8a79db184e87a..4c167eb4892c5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
@@ -19,9 +19,9 @@ AST_POLYMORPHIC_MATCHER_P(
hasAnyTemplateArgumentIncludingPack,
AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,
TemplateSpecializationType, FunctionDecl),
- clang::ast_matchers::internal::Matcher<TemplateArgument>, InnerMatcher) {
+ ast_matchers::internal::Matcher<TemplateArgument>, InnerMatcher) {
const ArrayRef<TemplateArgument> Args =
- clang::ast_matchers::internal::getTemplateSpecializationArgs(Node);
+ ast_matchers::internal::getTemplateSpecializationArgs(Node);
for (const auto &Arg : Args) {
if (Arg.getKind() != TemplateArgument::Pack)
continue;
diff --git a/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
index faa07fff5a369..6da20d3f6fecb 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
@@ -27,8 +27,8 @@ AST_MATCHER_P(InitListExpr, initCountIs, unsigned, N) {
return Node.getNumInits() == N;
}
-AST_MATCHER(clang::VarDecl, isDirectInitialization) {
- return Node.getInitStyle() != clang::VarDecl::InitializationStyle::CInit;
+AST_MATCHER(VarDecl, isDirectInitialization) {
+ return Node.getInitStyle() != VarDecl::InitializationStyle::CInit;
}
} // namespace
@@ -59,7 +59,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
// Matches `nullptr` and `(nullptr)` binding to a pointer
auto NullLiteral = implicitCastExpr(
- hasCastKind(clang::CK_NullToPointer),
+ hasCastKind(CK_NullToPointer),
hasSourceExpression(ignoringParens(cxxNullPtrLiteralExpr())));
// Matches `{nullptr}` and `{(nullptr)}` binding to a pointer
@@ -233,7 +233,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
cxxOperatorCallExpr(
hasOverloadedOperatorName("=="),
hasOperands(ignoringImpCasts(BasicStringViewConstructingFromNullExpr),
- traverse(clang::TK_IgnoreUnlessSpelledInSource,
+ traverse(TK_IgnoreUnlessSpelledInSource,
expr().bind("instance"))))
.bind("root"),
changeTo(node("root"), cat(access("instance", cat("empty")), "()")),
@@ -244,7 +244,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
cxxOperatorCallExpr(
hasOverloadedOperatorName("!="),
hasOperands(ignoringImpCasts(BasicStringViewConstructingFromNullExpr),
- traverse(clang::TK_IgnoreUnlessSpelledInSource,
+ traverse(TK_IgnoreUnlessSpelledInSource,
expr().bind("instance"))))
.bind("root"),
changeTo(node("root"), cat("!", access("instance", cat("empty")), "()")),
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.h b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.h
index eae8aad5b7d3e..ee7301f77611b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.h
@@ -29,8 +29,8 @@ class SuspiciousStringviewDataUsageCheck : public ClangTidyCheck {
std::optional<TraversalKind> getCheckTraversalKind() const override;
private:
- std::vector<llvm::StringRef> StringViewTypes;
- std::vector<llvm::StringRef> AllowedCallees;
+ std::vector<StringRef> StringViewTypes;
+ std::vector<StringRef> AllowedCallees;
};
} // namespace clang::tidy::bugprone
diff --git a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
index 3e43a1802c43f..0c64b68fba591 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
@@ -43,7 +43,7 @@ AST_MATCHER_P2(RecordDecl, fieldCountOfKindIsOne,
// is used for matching.
//
// For precedence, see commit: 5b07de1a5faf4a22ae6fd982b877c5e7e3a76559
- clang::ast_matchers::internal::BoundNodesTreeBuilder TempBuilder;
+ ast_matchers::internal::BoundNodesTreeBuilder TempBuilder;
const FieldDecl *FirstMatch = nullptr;
for (const FieldDecl *Field : Node.fields()) {
@@ -55,7 +55,7 @@ AST_MATCHER_P2(RecordDecl, fieldCountOfKindIsOne,
}
if (FirstMatch) {
- Builder->setBinding(BindName, clang::DynTypedNode::create(*FirstMatch));
+ Builder->setBinding(BindName, DynTypedNode::create(*FirstMatch));
return true;
}
return false;
diff --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
index 6521a95d2b80f..79d6e4974c316 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
@@ -53,9 +53,9 @@ void UncheckedOptionalAccessCheck::check(
UncheckedOptionalAccessDiagnoser Diagnoser(ModelOptions);
// FIXME: Allow user to set the (defaulted) SAT iterations max for
// `diagnoseFunction` with config options.
- if (llvm::Expected<llvm::SmallVector<UncheckedOptionalAccessDiagnostic>>
- Diags = dataflow::diagnoseFunction<UncheckedOptionalAccessModel,
- UncheckedOptionalAccessDiagnostic>(
+ if (llvm::Expected<SmallVector<UncheckedOptionalAccessDiagnostic>> Diags =
+ dataflow::diagnoseFunction<UncheckedOptionalAccessModel,
+ UncheckedOptionalAccessDiagnostic>(
*FuncDecl, *Result.Context, Diagnoser))
for (const UncheckedOptionalAccessDiagnostic &Diag : *Diags) {
diag(Diag.Range.getBegin(), "unchecked access to optional value")
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
index e10b17ca20753..5056172cd38a6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
@@ -90,7 +90,7 @@ void UnintendedCharOstreamOutputCheck::check(
const QualType T = Value->getType();
const Type *UnqualifiedDesugaredType = T->getUnqualifiedDesugaredType();
- const llvm::StringRef CastType = CastTypeName.value_or(
+ const StringRef CastType = CastTypeName.value_or(
UnqualifiedDesugaredType->isSpecificBuiltinType(BuiltinType::SChar)
? "int"
: "unsigned int");
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 793645dafda6d..d87511b6bdd73 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -227,7 +227,7 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
}
if (!CustomFunctions.empty()) {
- std::vector<llvm::StringRef> FunctionNames;
+ std::vector<StringRef> FunctionNames;
FunctionNames.reserve(CustomFunctions.size());
for (const auto &Entry : CustomFunctions)
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeToAllowExceptionsCheck.h b/clang-tools-extra/clang-tidy/bugprone/UnsafeToAllowExceptionsCheck.h
index d91d48427ce4a..5d113b2f6ce65 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeToAllowExceptionsCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeToAllowExceptionsCheck.h
@@ -29,7 +29,7 @@ class UnsafeToAllowExceptionsCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- std::vector<llvm::StringRef> CheckedSwapFunctions;
+ std::vector<StringRef> CheckedSwapFunctions;
};
} // namespace clang::tidy::bugprone
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
index 7aee725cae434..c5792cd17b9b2 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -44,7 +44,7 @@ AST_MATCHER(FunctionDecl, isAssignmentOverloadedOperator) {
}
} // namespace
-UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
+UnusedReturnValueCheck::UnusedReturnValueCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
CheckedFunctions(utils::options::parseStringList(
@@ -148,13 +148,13 @@ UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
AllowCastToVoid(Options.get("AllowCastToVoid", false)) {}
UnusedReturnValueCheck::UnusedReturnValueCheck(
- llvm::StringRef Name, ClangTidyContext *Context,
+ StringRef Name, ClangTidyContext *Context,
std::vector<StringRef> CheckedFunctions)
: UnusedReturnValueCheck(Name, Context, std::move(CheckedFunctions), {},
false) {}
UnusedReturnValueCheck::UnusedReturnValueCheck(
- llvm::StringRef Name, ClangTidyContext *Context,
+ StringRef Name, ClangTidyContext *Context,
std::vector<StringRef> CheckedFunctions,
std::vector<StringRef> CheckedReturnTypes, bool AllowCastToVoid)
: ClangTidyCheck(Name, Context),
diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index 7dc648f8ed405..8e9f48ee0cd21 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -65,7 +65,7 @@ class UseAfterMoveFinder {
const Expr *MovingCall,
const ValueDecl *MovedVariable);
void getUsesAndReinits(const CFGBlock *Block, const ValueDecl *MovedVariable,
- llvm::SmallVectorImpl<const DeclRefExpr *> *Uses,
+ SmallVectorImpl<const DeclRefExpr *> *Uses,
llvm::SmallPtrSetImpl<const Stmt *> *Reinits);
void getDeclRefs(const CFGBlock *Block, const Decl *MovedVariable,
llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs);
@@ -133,9 +133,9 @@ makeReinitMatcher(const ValueDecl *MovedVariable,
StandardResettableOwnerTypeMatcher)),
callee(cxxMethodDecl(hasName("reset")))),
// Methods that have the [[clang::reinitializes]] attribute.
- cxxMemberCallExpr(on(DeclRefMatcher),
- callee(cxxMethodDecl(
- hasAttr(clang::attr::Reinitializes)))),
+ cxxMemberCallExpr(
+ on(DeclRefMatcher),
+ callee(cxxMethodDecl(hasAttr(attr::Reinitializes)))),
// Functions that are specified in ReinitializationFunctions
// option.
callExpr(
@@ -243,7 +243,7 @@ UseAfterMoveFinder::findInternal(const CFGBlock *Block, const Expr *MovingCall,
Visited.insert(Block);
// Get all uses and reinits in the block.
- llvm::SmallVector<const DeclRefExpr *, 1> Uses;
+ SmallVector<const DeclRefExpr *, 1> Uses;
llvm::SmallPtrSet<const Stmt *, 1> Reinits;
getUsesAndReinits(Block, MovedVariable, &Uses, &Reinits);
@@ -251,7 +251,7 @@ UseAfterMoveFinder::findInternal(const CFGBlock *Block, const Expr *MovingCall,
// reinit.
// If `Reinit` is identical to `MovingCall`, we're looking at a move-to-self
// (e.g. `a = std::move(a)`). Count these as reinitializations.
- llvm::SmallVector<const Stmt *, 1> ReinitsToDelete;
+ SmallVector<const Stmt *, 1> ReinitsToDelete;
for (const Stmt *Reinit : Reinits)
if (MovingCall && Reinit != MovingCall &&
Sequence->potentiallyAfter(MovingCall, Reinit))
@@ -303,7 +303,7 @@ UseAfterMoveFinder::findInternal(const CFGBlock *Block, const Expr *MovingCall,
void UseAfterMoveFinder::getUsesAndReinits(
const CFGBlock *Block, const ValueDecl *MovedVariable,
- llvm::SmallVectorImpl<const DeclRefExpr *> *Uses,
+ SmallVectorImpl<const DeclRefExpr *> *Uses,
llvm::SmallPtrSetImpl<const Stmt *> *Reinits) {
llvm::SmallPtrSet<const DeclRefExpr *, 1> DeclRefs;
llvm::SmallPtrSet<const DeclRefExpr *, 1> ReinitDeclRefs;
@@ -550,7 +550,7 @@ void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
return;
// Collect all code blocks that could use the arg after move.
- llvm::SmallVector<Stmt *> CodeBlocks{};
+ SmallVector<Stmt *> CodeBlocks{};
if (ContainingCtor) {
CodeBlocks.push_back(ContainingCtor->getBody());
if (ContainingCtorInit) {
diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index f64cb47d18b4e..8b62ef69e1290 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -42,194 +42,191 @@
#include "../readability/EnumInitialValueCheck.h"
#include "../readability/UppercaseLiteralSuffixCheck.h"
-namespace {
+namespace clang::tidy {
// Checked functions for cert-err33-c.
// The following functions are deliberately excluded because they can be
// called with NULL argument and in this case the check is not applicable:
// `mblen, mbrlen, mbrtowc, mbtowc, wctomb, wctomb_s`.
// FIXME: The check can be improved to handle such cases.
-const llvm::StringRef CertErr33CCheckedFunctions = "^::aligned_alloc$;"
- "^::asctime_s$;"
- "^::at_quick_exit$;"
- "^::atexit$;"
- "^::bsearch$;"
- "^::bsearch_s$;"
- "^::btowc$;"
- "^::c16rtomb$;"
- "^::c32rtomb$;"
- "^::calloc$;"
- "^::clock$;"
- "^::cnd_broadcast$;"
- "^::cnd_init$;"
- "^::cnd_signal$;"
- "^::cnd_timedwait$;"
- "^::cnd_wait$;"
- "^::ctime_s$;"
- "^::fclose$;"
- "^::fflush$;"
- "^::fgetc$;"
- "^::fgetpos$;"
- "^::fgets$;"
- "^::fgetwc$;"
- "^::fopen$;"
- "^::fopen_s$;"
- "^::fprintf$;"
- "^::fprintf_s$;"
- "^::fputc$;"
- "^::fputs$;"
- "^::fputwc$;"
- "^::fputws$;"
- "^::fread$;"
- "^::freopen$;"
- "^::freopen_s$;"
- "^::fscanf$;"
- "^::fscanf_s$;"
- "^::fseek$;"
- "^::fsetpos$;"
- "^::ftell$;"
- "^::fwprintf$;"
- "^::fwprintf_s$;"
- "^::fwrite$;"
- "^::fwscanf$;"
- "^::fwscanf_s$;"
- "^::getc$;"
- "^::getchar$;"
- "^::getenv$;"
- "^::getenv_s$;"
- "^::gets_s$;"
- "^::getwc$;"
- "^::getwchar$;"
- "^::gmtime$;"
- "^::gmtime_s$;"
- "^::localtime$;"
- "^::localtime_s$;"
- "^::malloc$;"
- "^::mbrtoc16$;"
- "^::mbrtoc32$;"
- "^::mbsrtowcs$;"
- "^::mbsrtowcs_s$;"
- "^::mbstowcs$;"
- "^::mbstowcs_s$;"
- "^::memchr$;"
- "^::mktime$;"
- "^::mtx_init$;"
- "^::mtx_lock$;"
- "^::mtx_timedlock$;"
- "^::mtx_trylock$;"
- "^::mtx_unlock$;"
- "^::printf_s$;"
- "^::putc$;"
- "^::putwc$;"
- "^::raise$;"
- "^::realloc$;"
- "^::remove$;"
- "^::rename$;"
- "^::scanf$;"
- "^::scanf_s$;"
- "^::setlocale$;"
- "^::setvbuf$;"
- "^::signal$;"
- "^::snprintf$;"
- "^::snprintf_s$;"
- "^::sprintf$;"
- "^::sprintf_s$;"
- "^::sscanf$;"
- "^::sscanf_s$;"
- "^::strchr$;"
- "^::strerror_s$;"
- "^::strftime$;"
- "^::strpbrk$;"
- "^::strrchr$;"
- "^::strstr$;"
- "^::strtod$;"
- "^::strtof$;"
- "^::strtoimax$;"
- "^::strtok$;"
- "^::strtok_s$;"
- "^::strtol$;"
- "^::strtold$;"
- "^::strtoll$;"
- "^::strtoul$;"
- "^::strtoull$;"
- "^::strtoumax$;"
- "^::strxfrm$;"
- "^::swprintf$;"
- "^::swprintf_s$;"
- "^::swscanf$;"
- "^::swscanf_s$;"
- "^::thrd_create$;"
- "^::thrd_detach$;"
- "^::thrd_join$;"
- "^::thrd_sleep$;"
- "^::time$;"
- "^::timespec_get$;"
- "^::tmpfile$;"
- "^::tmpfile_s$;"
- "^::tmpnam$;"
- "^::tmpnam_s$;"
- "^::tss_create$;"
- "^::tss_get$;"
- "^::tss_set$;"
- "^::ungetc$;"
- "^::ungetwc$;"
- "^::vfprintf$;"
- "^::vfprintf_s$;"
- "^::vfscanf$;"
- "^::vfscanf_s$;"
- "^::vfwprintf$;"
- "^::vfwprintf_s$;"
- "^::vfwscanf$;"
- "^::vfwscanf_s$;"
- "^::vprintf_s$;"
- "^::vscanf$;"
- "^::vscanf_s$;"
- "^::vsnprintf$;"
- "^::vsnprintf_s$;"
- "^::vsprintf$;"
- "^::vsprintf_s$;"
- "^::vsscanf$;"
- "^::vsscanf_s$;"
- "^::vswprintf$;"
- "^::vswprintf_s$;"
- "^::vswscanf$;"
- "^::vswscanf_s$;"
- "^::vwprintf_s$;"
- "^::vwscanf$;"
- "^::vwscanf_s$;"
- "^::wcrtomb$;"
- "^::wcschr$;"
- "^::wcsftime$;"
- "^::wcspbrk$;"
- "^::wcsrchr$;"
- "^::wcsrtombs$;"
- "^::wcsrtombs_s$;"
- "^::wcsstr$;"
- "^::wcstod$;"
- "^::wcstof$;"
- "^::wcstoimax$;"
- "^::wcstok$;"
- "^::wcstok_s$;"
- "^::wcstol$;"
- "^::wcstold$;"
- "^::wcstoll$;"
- "^::wcstombs$;"
- "^::wcstombs_s$;"
- "^::wcstoul$;"
- "^::wcstoull$;"
- "^::wcstoumax$;"
- "^::wcsxfrm$;"
- "^::wctob$;"
- "^::wctrans$;"
- "^::wctype$;"
- "^::wmemchr$;"
- "^::wprintf_s$;"
- "^::wscanf$;"
- "^::wscanf_s$;";
+static constexpr StringRef CertErr33CCheckedFunctions = "^::aligned_alloc$;"
+ "^::asctime_s$;"
+ "^::at_quick_exit$;"
+ "^::atexit$;"
+ "^::bsearch$;"
+ "^::bsearch_s$;"
+ "^::btowc$;"
+ "^::c16rtomb$;"
+ "^::c32rtomb$;"
+ "^::calloc$;"
+ "^::clock$;"
+ "^::cnd_broadcast$;"
+ "^::cnd_init$;"
+ "^::cnd_signal$;"
+ "^::cnd_timedwait$;"
+ "^::cnd_wait$;"
+ "^::ctime_s$;"
+ "^::fclose$;"
+ "^::fflush$;"
+ "^::fgetc$;"
+ "^::fgetpos$;"
+ "^::fgets$;"
+ "^::fgetwc$;"
+ "^::fopen$;"
+ "^::fopen_s$;"
+ "^::fprintf$;"
+ "^::fprintf_s$;"
+ "^::fputc$;"
+ "^::fputs$;"
+ "^::fputwc$;"
+ "^::fputws$;"
+ "^::fread$;"
+ "^::freopen$;"
+ "^::freopen_s$;"
+ "^::fscanf$;"
+ "^::fscanf_s$;"
+ "^::fseek$;"
+ "^::fsetpos$;"
+ "^::ftell$;"
+ "^::fwprintf$;"
+ "^::fwprintf_s$;"
+ "^::fwrite$;"
+ "^::fwscanf$;"
+ "^::fwscanf_s$;"
+ "^::getc$;"
+ "^::getchar$;"
+ "^::getenv$;"
+ "^::getenv_s$;"
+ "^::gets_s$;"
+ "^::getwc$;"
+ "^::getwchar$;"
+ "^::gmtime$;"
+ "^::gmtime_s$;"
+ "^::localtime$;"
+ "^::localtime_s$;"
+ "^::malloc$;"
+ "^::mbrtoc16$;"
+ "^::mbrtoc32$;"
+ "^::mbsrtowcs$;"
+ "^::mbsrtowcs_s$;"
+ "^::mbstowcs$;"
+ "^::mbstowcs_s$;"
+ "^::memchr$;"
+ "^::mktime$;"
+ "^::mtx_init$;"
+ "^::mtx_lock$;"
+ "^::mtx_timedlock$;"
+ "^::mtx_trylock$;"
+ "^::mtx_unlock$;"
+ "^::printf_s$;"
+ "^::putc$;"
+ "^::putwc$;"
+ "^::raise$;"
+ "^::realloc$;"
+ "^::remove$;"
+ "^::rename$;"
+ "^::scanf$;"
+ "^::scanf_s$;"
+ "^::setlocale$;"
+ "^::setvbuf$;"
+ "^::signal$;"
+ "^::snprintf$;"
+ "^::snprintf_s$;"
+ "^::sprintf$;"
+ "^::sprintf_s$;"
+ "^::sscanf$;"
+ "^::sscanf_s$;"
+ "^::strchr$;"
+ "^::strerror_s$;"
+ "^::strftime$;"
+ "^::strpbrk$;"
+ "^::strrchr$;"
+ "^::strstr$;"
+ "^::strtod$;"
+ "^::strtof$;"
+ "^::strtoimax$;"
+ "^::strtok$;"
+ "^::strtok_s$;"
+ "^::strtol$;"
+ "^::strtold$;"
+ "^::strtoll$;"
+ "^::strtoul$;"
+ "^::strtoull$;"
+ "^::strtoumax$;"
+ "^::strxfrm$;"
+ "^::swprintf$;"
+ "^::swprintf_s$;"
+ "^::swscanf$;"
+ "^::swscanf_s$;"
+ "^::thrd_create$;"
+ "^::thrd_detach$;"
+ "^::thrd_join$;"
+ "^::thrd_sleep$;"
+ "^::time$;"
+ "^::timespec_get$;"
+ "^::tmpfile$;"
+ "^::tmpfile_s$;"
+ "^::tmpnam$;"
+ "^::tmpnam_s$;"
+ "^::tss_create$;"
+ "^::tss_get$;"
+ "^::tss_set$;"
+ "^::ungetc$;"
+ "^::ungetwc$;"
+ "^::vfprintf$;"
+ "^::vfprintf_s$;"
+ "^::vfscanf$;"
+ "^::vfscanf_s$;"
+ "^::vfwprintf$;"
+ "^::vfwprintf_s$;"
+ "^::vfwscanf$;"
+ "^::vfwscanf_s$;"
+ "^::vprintf_s$;"
+ "^::vscanf$;"
+ "^::vscanf_s$;"
+ "^::vsnprintf$;"
+ "^::vsnprintf_s$;"
+ "^::vsprintf$;"
+ "^::vsprintf_s$;"
+ "^::vsscanf$;"
+ "^::vsscanf_s$;"
+ "^::vswprintf$;"
+ "^::vswprintf_s$;"
+ "^::vswscanf$;"
+ "^::vswscanf_s$;"
+ "^::vwprintf_s$;"
+ "^::vwscanf$;"
+ "^::vwscanf_s$;"
+ "^::wcrtomb$;"
+ "^::wcschr$;"
+ "^::wcsftime$;"
+ "^::wcspbrk$;"
+ "^::wcsrchr$;"
+ "^::wcsrtombs$;"
+ "^::wcsrtombs_s$;"
+ "^::wcsstr$;"
+ "^::wcstod$;"
+ "^::wcstof$;"
+ "^::wcstoimax$;"
+ "^::wcstok$;"
+ "^::wcstok_s$;"
+ "^::wcstol$;"
+ "^::wcstold$;"
+ "^::wcstoll$;"
+ "^::wcstombs$;"
+ "^::wcstombs_s$;"
+ "^::wcstoul$;"
+ "^::wcstoull$;"
+ "^::wcstoumax$;"
+ "^::wcsxfrm$;"
+ "^::wctob$;"
+ "^::wctrans$;"
+ "^::wctype$;"
+ "^::wmemchr$;"
+ "^::wprintf_s$;"
+ "^::wscanf$;"
+ "^::wscanf_s$;";
-} // namespace
-
-namespace clang::tidy {
namespace cert {
namespace {
diff --git a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
index f8050bcfe3263..1a14f7219d324 100644
--- a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
@@ -11,8 +11,10 @@
using namespace clang::ast_matchers;
+namespace clang::tidy {
+
// Initial list was extracted from gcc documentation
-static const clang::StringRef GlibcFunctions[] = {
+static constexpr StringRef GlibcFunctions[] = {
"::argp_error",
"::argp_help",
"::argp_parse",
@@ -171,7 +173,7 @@ static const clang::StringRef GlibcFunctions[] = {
"::wordexp",
};
-static const clang::StringRef PosixFunctions[] = {
+static constexpr StringRef PosixFunctions[] = {
"::asctime",
"::basename",
"::catgets",
@@ -256,8 +258,6 @@ static const clang::StringRef PosixFunctions[] = {
"::wctomb",
};
-namespace clang::tidy {
-
template <> struct OptionEnumMapping<concurrency::MtUnsafeCheck::FunctionSet> {
static llvm::ArrayRef<
std::pair<concurrency::MtUnsafeCheck::FunctionSet, StringRef>>
@@ -273,7 +273,7 @@ template <> struct OptionEnumMapping<concurrency::MtUnsafeCheck::FunctionSet> {
namespace concurrency {
-static ast_matchers::internal::Matcher<clang::NamedDecl>
+static ast_matchers::internal::Matcher<NamedDecl>
hasAnyMtUnsafeNames(MtUnsafeCheck::FunctionSet Libc) {
switch (Libc) {
case MtUnsafeCheck::FunctionSet::Posix:
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
index e1636e40507ea..a8f2dcc8f5e1b 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
@@ -48,7 +48,7 @@ static std::string createReplacementText(const LambdaExpr *Lambda) {
std::string Replacement;
llvm::raw_string_ostream Stream(Replacement);
- auto AppendName = [&](llvm::StringRef Name) {
+ auto AppendName = [&](StringRef Name) {
if (!Replacement.empty())
Stream << ", ";
if (Lambda->getCaptureDefault() == LCD_ByRef && Name != "this")
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
index ee3a45c171e32..f2460aec3b2fd 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
@@ -56,7 +56,7 @@ void NoSuspendWithLockCheck::check(const MatchFinder::MatchResult &Result) {
Options.AddTemporaryDtors = true;
const std::unique_ptr<CFG> TheCFG = CFG::buildCFG(
- nullptr, const_cast<clang::CompoundStmt *>(Block), &Context, Options);
+ nullptr, const_cast<CompoundStmt *>(Block), &Context, Options);
if (!TheCFG)
return;
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
index 164943293c8d2..f04b5e87a084c 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -251,12 +251,12 @@ void PreferMemberInitializerCheck::check(
// comma.
InsertPrefix = ", ";
} else {
- InsertPos = Lexer::getLocForEndOfToken(
- Ctor->getTypeSourceInfo()
- ->getTypeLoc()
- .getAs<clang::FunctionTypeLoc>()
- .getLocalRangeEnd(),
- 0, *Result.SourceManager, getLangOpts());
+ InsertPos = Lexer::getLocForEndOfToken(Ctor->getTypeSourceInfo()
+ ->getTypeLoc()
+ .getAs<FunctionTypeLoc>()
+ .getLocalRangeEnd(),
+ 0, *Result.SourceManager,
+ getLangOpts());
// If this is first time in the loop, there are no initializers so
// `:` declares member initialization list. If this is a
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
index 73f43d3cd3b1a..a98dabbb14f5f 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
@@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::cppcoreguidelines {
-static constexpr llvm::StringRef DefaultExclusionStr =
+static constexpr StringRef DefaultExclusionStr =
"::std::map;::std::unordered_map;::std::flat_map";
ProBoundsAvoidUncheckedContainerAccessCheck::
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h
index 85b5a93940562..68d4c83ef6191 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h
@@ -35,11 +35,11 @@ class ProBoundsAvoidUncheckedContainerAccessCheck : public ClangTidyCheck {
private:
// A list of class names that are excluded from the warning
- std::vector<llvm::StringRef> ExcludedClasses;
+ std::vector<StringRef> ExcludedClasses;
// Setting which fix to suggest
FixModes FixMode;
- llvm::StringRef FixFunction;
- llvm::StringRef FixFunctionEmptyArgs;
+ StringRef FixFunction;
+ StringRef FixFunctionEmptyArgs;
};
} // namespace clang::tidy::cppcoreguidelines
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
index a8ef59157958f..1ef64b702cd66 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -76,7 +76,7 @@ void SpecialMemberFunctionsCheck::registerMatchers(MatchFinder *Finder) {
this);
}
-static llvm::StringRef
+static StringRef
toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
switch (K) {
case SpecialMemberFunctionsCheck::SpecialMemberFunctionKind::Destructor:
@@ -101,7 +101,7 @@ toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K) {
static std::string
join(ArrayRef<SpecialMemberFunctionsCheck::SpecialMemberFunctionKind> SMFS,
- llvm::StringRef AndOr) {
+ StringRef AndOr) {
assert(!SMFS.empty() &&
"List of defined or undefined members should never be empty.");
std::string Buffer;
@@ -126,7 +126,7 @@ void SpecialMemberFunctionsCheck::check(
std::string(MatchedDecl->getName()));
auto StoreMember = [this, &ID](SpecialMemberFunctionData Data) {
- llvm::SmallVectorImpl<SpecialMemberFunctionData> &Members =
+ SmallVectorImpl<SpecialMemberFunctionData> &Members =
ClassWithSpecialMembers[ID];
if (!llvm::is_contained(Members, Data))
Members.push_back(std::move(Data));
@@ -165,7 +165,7 @@ void SpecialMemberFunctionsCheck::onEndOfTranslationUnit() {
void SpecialMemberFunctionsCheck::checkForMissingMembers(
const ClassDefId &ID,
llvm::ArrayRef<SpecialMemberFunctionData> DefinedMembers) {
- llvm::SmallVector<SpecialMemberFunctionKind, 5> MissingMembers;
+ SmallVector<SpecialMemberFunctionKind, 5> MissingMembers;
auto HasMember = [&](SpecialMemberFunctionKind Kind) {
return llvm::any_of(DefinedMembers, [Kind](const auto &Data) {
@@ -234,7 +234,7 @@ void SpecialMemberFunctionsCheck::checkForMissingMembers(
}
if (!MissingMembers.empty()) {
- llvm::SmallVector<SpecialMemberFunctionKind, 5> DefinedMemberKinds;
+ SmallVector<SpecialMemberFunctionKind, 5> DefinedMemberKinds;
for (const auto &Data : DefinedMembers)
if (!Data.IsImplicit)
DefinedMemberKinds.push_back(Data.FunctionKind);
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
index 6d76e07078f3b..ecf43468eea20 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -56,8 +56,7 @@ class SpecialMemberFunctionsCheck : public ClangTidyCheck {
using ClassDefId = std::pair<SourceLocation, std::string>;
using ClassDefiningSpecialMembersMap =
- llvm::DenseMap<ClassDefId,
- llvm::SmallVector<SpecialMemberFunctionData, 5>>;
+ llvm::DenseMap<ClassDefId, SmallVector<SpecialMemberFunctionData, 5>>;
private:
void checkForMissingMembers(
diff --git a/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp b/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
index f2267c2549eac..c68d186eefd7d 100644
--- a/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/custom/CustomTidyModule.cpp
@@ -15,17 +15,17 @@ namespace custom {
// will changed dynamically when switching to
diff erent source file.
static void registerCustomChecks(const ClangTidyOptions &Options,
ClangTidyCheckFactories &Factories) {
- static llvm::SmallSet<llvm::SmallString<32>, 8> CustomCheckNames{};
+ static llvm::SmallSet<SmallString<32>, 8> CustomCheckNames{};
if (!Options.CustomChecks.has_value() || Options.CustomChecks->empty())
return;
- for (const llvm::SmallString<32> &Name : CustomCheckNames)
+ for (const SmallString<32> &Name : CustomCheckNames)
Factories.eraseCheck(Name);
for (const ClangTidyOptions::CustomCheckValue &V :
Options.CustomChecks.value()) {
- llvm::SmallString<32> Name = llvm::StringRef{"custom-" + V.Name};
+ SmallString<32> Name = StringRef{"custom-" + V.Name};
Factories.registerCheckFactory(
// add custom- prefix to avoid conflicts with builtin checks
- Name, [&V](llvm::StringRef Name, ClangTidyContext *Context) {
+ Name, [&V](StringRef Name, ClangTidyContext *Context) {
return std::make_unique<custom::QueryCheck>(Name, V, Context);
});
CustomCheckNames.insert(std::move(Name));
diff --git a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp b/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
index 315ce5840e5d4..60f2f91708c7b 100644
--- a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
@@ -31,27 +31,27 @@ parseQuery(const ClangTidyOptions::CustomCheckValue &V,
ClangTidyContext *Context) {
SmallVector<ast_matchers::dynamic::DynTypedMatcher> Matchers{};
clang::query::QuerySession QS({});
- llvm::StringRef QueryStringRef{V.Query};
+ StringRef QueryStringRef{V.Query};
while (!QueryStringRef.empty()) {
const query::QueryRef Q = query::QueryParser::parse(QueryStringRef, QS);
switch (Q->Kind) {
case query::QK_Match: {
- const auto &MatchQuery = llvm::cast<query::MatchQuery>(*Q);
+ const auto &MatchQuery = cast<query::MatchQuery>(*Q);
Matchers.push_back(MatchQuery.Matcher);
break;
}
case query::QK_Let: {
- const auto &LetQuery = llvm::cast<query::LetQuery>(*Q);
+ const auto &LetQuery = cast<query::LetQuery>(*Q);
LetQuery.run(llvm::errs(), QS);
break;
}
case query::QK_NoOp: {
- const auto &NoOpQuery = llvm::cast<query::NoOpQuery>(*Q);
+ const auto &NoOpQuery = cast<query::NoOpQuery>(*Q);
NoOpQuery.run(llvm::errs(), QS);
break;
}
case query::QK_Invalid: {
- const auto &InvalidQuery = llvm::cast<query::InvalidQuery>(*Q);
+ const auto &InvalidQuery = cast<query::InvalidQuery>(*Q);
emitConfigurationDiag(Context, InvalidQuery.ErrStr, V.Name);
return {};
}
@@ -99,7 +99,7 @@ parseQuery(const ClangTidyOptions::CustomCheckValue &V,
return Matchers;
}
-QueryCheck::QueryCheck(llvm::StringRef Name,
+QueryCheck::QueryCheck(StringRef Name,
const ClangTidyOptions::CustomCheckValue &V,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {
@@ -107,11 +107,11 @@ QueryCheck::QueryCheck(llvm::StringRef Name,
auto DiagnosticIdIt =
Diags
.try_emplace(D.Level.value_or(DiagnosticIDs::Warning),
- llvm::StringMap<llvm::SmallVector<std::string>>{})
+ llvm::StringMap<SmallVector<std::string>>{})
.first;
auto DiagMessageIt =
DiagnosticIdIt->getSecond()
- .try_emplace(D.BindName, llvm::SmallVector<std::string>{})
+ .try_emplace(D.BindName, SmallVector<std::string>{})
.first;
DiagMessageIt->second.emplace_back(D.Message);
}
diff --git a/clang-tools-extra/clang-tidy/custom/QueryCheck.h b/clang-tools-extra/clang-tidy/custom/QueryCheck.h
index 3dcdc518736c2..15ca8e0884f7d 100644
--- a/clang-tools-extra/clang-tidy/custom/QueryCheck.h
+++ b/clang-tools-extra/clang-tidy/custom/QueryCheck.h
@@ -22,15 +22,14 @@ namespace clang::tidy::custom {
/// Not directly visible to users.
class QueryCheck : public ClangTidyCheck {
public:
- QueryCheck(llvm::StringRef Name, const ClangTidyOptions::CustomCheckValue &V,
+ QueryCheck(StringRef Name, const ClangTidyOptions::CustomCheckValue &V,
ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- llvm::SmallVector<ast_matchers::dynamic::DynTypedMatcher> Matchers;
- using BindNameMapToDiagMessage =
- llvm::StringMap<llvm::SmallVector<std::string>>;
+ SmallVector<ast_matchers::dynamic::DynTypedMatcher> Matchers;
+ using BindNameMapToDiagMessage = llvm::StringMap<SmallVector<std::string>>;
using DiagMaps =
llvm::DenseMap<DiagnosticIDs::Level, BindNameMapToDiagMessage>;
DiagMaps Diags;
diff --git a/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp b/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
index 459cc1bbe9b48..e0b4ba5351b02 100644
--- a/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
@@ -75,7 +75,7 @@ static FixItHint generateFixItHint(const FunctionDecl *Decl) {
if (NewName != Name)
return FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
- llvm::StringRef(NewName));
+ StringRef(NewName));
return {};
}
diff --git a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
index 7470b1eb206bb..ec4fe724fcf58 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -46,13 +46,12 @@ static FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
return {};
}
- auto NewName = (IsConst ? "k" : "g") +
- llvm::StringRef(std::string(1, FC)).upper() +
+ auto NewName = (IsConst ? "k" : "g") + StringRef(std::string(1, FC)).upper() +
Decl->getName().substr(1).str();
return FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
- llvm::StringRef(NewName));
+ StringRef(NewName));
}
void GlobalVariableDeclarationCheck::registerMatchers(MatchFinder *Finder) {
diff --git a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
index f6a6811af006f..006430cbc7522 100644
--- a/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
@@ -41,8 +41,7 @@ class TodoCommentCheck::TodoCommentHandler : public CommentHandler {
TodoCommentHandler(TodoCommentCheck &Check, std::optional<std::string> User)
: Check(Check), User(User ? *User : "unknown"),
TodoMatch(R"(^// *TODO *((\((.*)\))?:?( )?|: *(.*) *- *)?(.*)$)") {
- const llvm::StringRef TodoStyleString =
- Check.Options.get("Style", "Hyphen");
+ const StringRef TodoStyleString = Check.Options.get("Style", "Hyphen");
for (const auto &[Value, Name] :
OptionEnumMapping<StyleKind>::getEnumMapping()) {
if (Name == TodoStyleString) {
diff --git a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
index 9ca23aaeb6211..a5124ad784a2f 100644
--- a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -17,13 +17,12 @@ using namespace clang::ast_matchers;
namespace clang::tidy::google {
-static const llvm::StringRef RenameCaseToSuiteMessage =
+static constexpr StringRef RenameCaseToSuiteMessage =
"Google Test APIs named with 'case' are deprecated; use equivalent APIs "
"named with 'suite'";
-static std::optional<llvm::StringRef>
-getNewMacroName(llvm::StringRef MacroName) {
- static const llvm::StringMap<llvm::StringRef> ReplacementMap = {
+static std::optional<StringRef> getNewMacroName(StringRef MacroName) {
+ static const llvm::StringMap<StringRef> ReplacementMap = {
{"TYPED_TEST_CASE", "TYPED_TEST_SUITE"},
{"TYPED_TEST_CASE_P", "TYPED_TEST_SUITE_P"},
{"REGISTER_TYPED_TEST_CASE_P", "REGISTER_TYPED_TEST_SUITE_P"},
@@ -62,7 +61,7 @@ class UpgradeGoogletestCasePPCallback : public PPCallbacks {
// We check if the newly defined macro is one of the target replacements.
// This ensures that the check creates warnings only if it is including a
// recent enough version of Google Test.
- const llvm::StringRef FileName = PP->getSourceManager().getFilename(
+ const StringRef FileName = PP->getSourceManager().getFilename(
MD->getMacroInfo()->getDefinitionLoc());
ReplacementFound = FileName.ends_with("gtest/gtest-typed-test.h") &&
PP->getSpelling(MacroNameTok) == "TYPED_TEST_SUITE";
@@ -87,18 +86,18 @@ class UpgradeGoogletestCasePPCallback : public PPCallbacks {
private:
enum class CheckAction { Warn, Rename };
- void macroUsed(const clang::Token &MacroNameTok, const MacroDefinition &MD,
+ void macroUsed(const Token &MacroNameTok, const MacroDefinition &MD,
SourceLocation Loc, CheckAction Action) {
if (!ReplacementFound)
return;
const std::string Name = PP->getSpelling(MacroNameTok);
- std::optional<llvm::StringRef> Replacement = getNewMacroName(Name);
+ std::optional<StringRef> Replacement = getNewMacroName(Name);
if (!Replacement)
return;
- const llvm::StringRef FileName = PP->getSourceManager().getFilename(
+ const StringRef FileName = PP->getSourceManager().getFilename(
MD.getMacroInfo()->getDefinitionLoc());
if (!FileName.ends_with("gtest/gtest-typed-test.h"))
return;
@@ -201,8 +200,8 @@ void UpgradeGoogletestCaseCheck::registerMatchers(MatchFinder *Finder) {
this);
}
-static llvm::StringRef getNewMethodName(llvm::StringRef CurrentName) {
- static const llvm::StringMap<llvm::StringRef> ReplacementMap = {
+static StringRef getNewMethodName(StringRef CurrentName) {
+ static const llvm::StringMap<StringRef> ReplacementMap = {
{"SetUpTestCase", "SetUpTestSuite"},
{"TearDownTestCase", "TearDownTestSuite"},
{"test_case_name", "test_suite_name"},
@@ -238,7 +237,7 @@ static bool isInTemplate(const NodeType &Node,
static bool
derivedTypeHasReplacementMethod(const MatchFinder::MatchResult &Result,
- llvm::StringRef ReplacementMethod) {
+ StringRef ReplacementMethod) {
const auto *Class = Result.Nodes.getNodeAs<CXXRecordDecl>("class");
return !match(cxxRecordDecl(
unless(isExpansionInFileMatching(
@@ -264,7 +263,7 @@ getAliasNameRange(const MatchFinder::MatchResult &Result) {
}
void UpgradeGoogletestCaseCheck::check(const MatchFinder::MatchResult &Result) {
- llvm::StringRef ReplacementText;
+ StringRef ReplacementText;
CharSourceRange ReplacementRange;
if (const auto *Method = Result.Nodes.getNodeAs<CXXMethodDecl>("method")) {
ReplacementText = getNewMethodName(Method->getName());
@@ -273,7 +272,7 @@ void UpgradeGoogletestCaseCheck::check(const MatchFinder::MatchResult &Result) {
bool IsInTemplate = false;
bool AddFix = true;
if (const auto *Call = Result.Nodes.getNodeAs<CXXMemberCallExpr>("call")) {
- const auto *Callee = llvm::cast<MemberExpr>(Call->getCallee());
+ const auto *Callee = cast<MemberExpr>(Call->getCallee());
ReplacementRange = CharSourceRange::getTokenRange(Callee->getMemberLoc(),
Callee->getMemberLoc());
IsInInstantiation = isInInstantiation(*Call, Result);
diff --git a/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
index e4564149066bd..ca3e778e573c1 100644
--- a/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
@@ -50,14 +50,14 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
auto NextToken = [&](std::optional<Token> CurrentToken) {
if (!CurrentToken)
return CurrentToken;
- if (CurrentToken->is(clang::tok::eof))
+ if (CurrentToken->is(tok::eof))
return std::optional<Token>();
return utils::lexer::findNextTokenSkippingComments(
CurrentToken->getLocation(), SM, LangOpts);
};
std::optional<Token> LessToken =
utils::lexer::findNextTokenSkippingComments(Begin, SM, LangOpts);
- while (LessToken && LessToken->getKind() != clang::tok::less)
+ while (LessToken && LessToken->getKind() != tok::less)
LessToken = NextToken(LessToken);
if (!LessToken) {
return llvm::make_error<llvm::StringError>(llvm::errc::invalid_argument,
@@ -66,7 +66,7 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
std::optional<Token> EndToken = NextToken(LessToken);
std::optional<Token> GreaterToken = NextToken(EndToken);
- for (; GreaterToken && GreaterToken->getKind() != clang::tok::greater;
+ for (; GreaterToken && GreaterToken->getKind() != tok::greater;
GreaterToken = NextToken(GreaterToken)) {
EndToken = GreaterToken;
}
@@ -76,7 +76,7 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
}
std::optional<Token> ArgStart = NextToken(GreaterToken);
- if (!ArgStart || ArgStart->getKind() != clang::tok::l_paren) {
+ if (!ArgStart || ArgStart->getKind() != tok::l_paren) {
return llvm::make_error<llvm::StringError>(llvm::errc::invalid_argument,
"missing '(' token");
}
@@ -85,7 +85,7 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
return llvm::make_error<llvm::StringError>(llvm::errc::invalid_argument,
"unexpected end of file");
}
- const bool HasArgs = Arg->getKind() != clang::tok::r_paren;
+ const bool HasArgs = Arg->getKind() != tok::r_paren;
Expected<CharSourceRange> BuilderRange = Builder(Result);
if (!BuilderRange)
@@ -93,7 +93,7 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
// Helper for concatting below.
auto GetText = [&](const CharSourceRange &Range) {
- return clang::Lexer::getSourceText(Range, SM, LangOpts);
+ return Lexer::getSourceText(Range, SM, LangOpts);
};
Edit Replace;
diff --git a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
index dd1ef076c65e1..8f3d150ce0117 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
@@ -64,7 +64,7 @@ void CalleeNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
<< FuncDecl << RequiredNamespaceRefMacroName;
diag(FuncDecl->getLocation(), "resolves to this declaration",
- clang::DiagnosticIDs::Note);
+ DiagnosticIDs::Note);
}
} // namespace clang::tidy::llvm_libc
diff --git a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
index 9f09947c4da29..9eb749dede6d2 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
@@ -78,8 +78,7 @@ void InlineFunctionDeclCheck::check(const MatchFinder::MatchResult &Result) {
// Check if decl starts with LIBC_INLINE
auto Loc = FullSourceLoc(Result.SourceManager->getFileLoc(SrcBegin),
*Result.SourceManager);
- const llvm::StringRef SrcText =
- Loc.getBufferData().drop_front(Loc.getFileOffset());
+ const StringRef SrcText = Loc.getBufferData().drop_front(Loc.getFileOffset());
if (SrcText.starts_with("LIBC_INLINE"))
return;
diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
index cef2c0ebb94f0..f386bd613dfc6 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
@@ -45,7 +45,7 @@ ConfusableIdentifierCheck::~ConfusableIdentifierCheck() = default;
// We're skipping 1. and 3. for the sake of simplicity, but this can lead to
// false positive.
-static llvm::SmallString<64U> skeleton(StringRef Name) {
+static SmallString<64U> skeleton(StringRef Name) {
using namespace llvm;
SmallString<64U> Skeleton;
Skeleton.reserve(1U + Name.size());
@@ -102,7 +102,7 @@ struct Entry {
// that has no corresponding context, such as an alias template or variable
// template.
using DeclsWithinContextMap =
- llvm::DenseMap<const Decl *, llvm::SmallVector<Entry, 1>>;
+ llvm::DenseMap<const Decl *, SmallVector<Entry, 1>>;
static bool addToContext(DeclsWithinContextMap &DeclsWithinContext,
const Decl *Context, Entry E) {
@@ -189,7 +189,7 @@ void ConfusableIdentifierCheck::addDeclToCheck(const NamedDecl *ND,
}
void ConfusableIdentifierCheck::onEndOfTranslationUnit() {
- llvm::StringMap<llvm::SmallVector<const IdentifierInfo *, 1>> SkeletonToNames;
+ llvm::StringMap<SmallVector<const IdentifierInfo *, 1>> SkeletonToNames;
// Compute the skeleton for each identifier.
for (auto &[Ident, Decls] : NameToDecls)
SkeletonToNames[skeleton(Ident->getName())].push_back(Ident);
diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h
index 5b98d48780eb5..e88bfc9025536 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h
@@ -33,9 +33,8 @@ class ConfusableIdentifierCheck : public ClangTidyCheck {
private:
void addDeclToCheck(const NamedDecl *ND, const Decl *Parent);
- llvm::DenseMap<
- const IdentifierInfo *,
- llvm::SmallVector<std::pair<const NamedDecl *, const Decl *>, 1>>
+ llvm::DenseMap<const IdentifierInfo *,
+ SmallVector<std::pair<const NamedDecl *, const Decl *>, 1>>
NameToDecls;
};
diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp b/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
index f5dcc7f4edcb6..e041e83ccb2fd 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
return 2;
}
- const llvm::StringRef From = Values[0].trim();
+ const StringRef From = Values[0].trim();
llvm::UTF32 CodePoint = 0;
From.getAsInteger(16, CodePoint);
diff --git a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.h b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.h
index 12ad1b1e0e220..16760f439d014 100644
--- a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.h
+++ b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.h
@@ -25,7 +25,7 @@ namespace clang::tidy::misc {
/// https://clang.llvm.org/extra/clang-tidy/checks/misc/coroutine-hostile-raii.html
class CoroutineHostileRAIICheck : public ClangTidyCheck {
public:
- CoroutineHostileRAIICheck(llvm::StringRef Name, ClangTidyContext *Context);
+ CoroutineHostileRAIICheck(StringRef Name, ClangTidyContext *Context);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus20;
diff --git a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
index d69f3bbd168cc..be554c0c7365f 100644
--- a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
@@ -43,7 +43,7 @@ class CyclicDependencyCallbacks : public PPCallbacks {
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override {
- if (FileType != clang::SrcMgr::C_User)
+ if (FileType != SrcMgr::C_User)
return;
if (Reason != EnterFile && Reason != ExitFile)
@@ -77,7 +77,7 @@ class CyclicDependencyCallbacks : public PPCallbacks {
OptionalFileEntryRef File, StringRef, StringRef,
const Module *, bool,
SrcMgr::CharacteristicKind FileType) override {
- if (FileType != clang::SrcMgr::C_User)
+ if (FileType != SrcMgr::C_User)
return;
NextToEnter = Range.getBegin();
diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 558c368901f1c..94232fa2ff626 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -123,7 +123,7 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
const FileEntry *MainFile = SM->getFileEntryForID(SM->getMainFileID());
llvm::DenseSet<const include_cleaner::Include *> Used;
std::vector<MissingIncludeInfo> Missing;
- llvm::SmallVector<Decl *> MainFileDecls;
+ SmallVector<Decl *> MainFileDecls;
for (Decl *D : Result.Nodes.getNodeAs<TranslationUnitDecl>("top")->decls()) {
if (!SM->isWrittenInMainFile(SM->getExpansionLoc(D->getLocation())))
continue;
@@ -200,7 +200,7 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
Unused.push_back(&I);
}
- const llvm::StringRef Code = SM->getBufferData(SM->getMainFileID());
+ const StringRef Code = SM->getBufferData(SM->getMainFileID());
auto FileStyle =
format::getStyle(format::DefaultFormatStyle, getCurrentMainFile(),
format::DefaultFallbackStyle, Code,
@@ -227,14 +227,14 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
for (const auto &Inc : Missing) {
const std::string Spelling = include_cleaner::spellHeader(
{Inc.Missing, PP->getHeaderSearchInfo(), MainFile});
- const bool Angled = llvm::StringRef{Spelling}.starts_with("<");
+ const bool Angled = StringRef{Spelling}.starts_with("<");
// We might suggest insertion of an existing include in edge cases, e.g.,
// include is present in a PP-disabled region, or spelling of the header
// turns out to be the same as one of the unresolved includes in the
// main file.
- if (auto Replacement = HeaderIncludes.insert(
- llvm::StringRef{Spelling}.trim("\"<>"), Angled,
- tooling::IncludeDirective::Include)) {
+ if (auto Replacement =
+ HeaderIncludes.insert(StringRef{Spelling}.trim("\"<>"), Angled,
+ tooling::IncludeDirective::Include)) {
const DiagnosticBuilder DB =
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
"no header providing \"%0\" is directly included")
diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h
index 619d8191ab41f..ab97565775e46 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h
@@ -51,7 +51,7 @@ class IncludeCleanerCheck : public ClangTidyCheck {
const bool UnusedIncludes;
// Whether to report missing includes.
const bool MissingIncludes;
- llvm::SmallVector<llvm::Regex> IgnoreHeadersRegex;
+ SmallVector<llvm::Regex> IgnoreHeadersRegex;
bool shouldIgnore(const include_cleaner::Header &H);
};
diff --git a/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.h b/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.h
index 36af07c9fbd17..7053e5d9fc1bc 100644
--- a/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.h
@@ -14,8 +14,7 @@
namespace clang::tidy::misc {
class NewDeleteOverloadsCheck : public ClangTidyCheck {
- llvm::DenseMap<const CXXRecordDecl *,
- llvm::SmallVector<const FunctionDecl *, 4>>
+ llvm::DenseMap<const CXXRecordDecl *, SmallVector<const FunctionDecl *, 4>>
Overloads;
public:
diff --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index 8bcbb61961fa6..e1c0612336df5 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -148,8 +148,7 @@ template <typename T, unsigned SmallSize> class SmartSmallSetVector {
constexpr unsigned SmallCallStackSize = 16;
constexpr unsigned SmallSCCSize = 32;
-using CallStackTy =
- llvm::SmallVector<CallGraphNode::CallRecord, SmallCallStackSize>;
+using CallStackTy = SmallVector<CallGraphNode::CallRecord, SmallCallStackSize>;
} // namespace
diff --git a/clang-tools-extra/clang-tidy/misc/OverrideWithDifferentVisibilityCheck.h b/clang-tools-extra/clang-tidy/misc/OverrideWithDifferentVisibilityCheck.h
index d8da30bd738d6..7300be0002c55 100644
--- a/clang-tools-extra/clang-tidy/misc/OverrideWithDifferentVisibilityCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/OverrideWithDifferentVisibilityCheck.h
@@ -35,7 +35,7 @@ class OverrideWithDifferentVisibilityCheck : public ClangTidyCheck {
ChangeKind DetectVisibilityChange;
bool CheckDestructors;
bool CheckOperators;
- std::vector<llvm::StringRef> IgnoredFunctions;
+ std::vector<StringRef> IgnoredFunctions;
};
} // namespace clang::tidy::misc
diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index 945da332130a3..9db297990b274 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -868,14 +868,14 @@ static bool areExprsMacroAndNonMacro(const Expr *&LhsExpr,
return LhsLoc.isMacroID() != RhsLoc.isMacroID();
}
-static bool areStringsSameIgnoreSpaces(const llvm::StringRef Left,
- const llvm::StringRef Right) {
+static bool areStringsSameIgnoreSpaces(const StringRef Left,
+ const StringRef Right) {
if (Left == Right)
return true;
// Do running comparison ignoring spaces
- llvm::StringRef L = Left.trim();
- llvm::StringRef R = Right.trim();
+ StringRef L = Left.trim();
+ StringRef R = Right.trim();
while (!L.empty() && !R.empty()) {
L = L.ltrim();
R = R.ltrim();
@@ -905,9 +905,9 @@ static bool areExprsSameMacroOrLiteral(const BinaryOperator *BinOp,
// Left is macro so right macro too
if (Rsr.getBegin().isMacroID()) {
// Both sides are macros so they are same macro or literal
- const llvm::StringRef L = Lexer::getSourceText(
+ const StringRef L = Lexer::getSourceText(
CharSourceRange::getTokenRange(Lsr), SM, Context->getLangOpts());
- const llvm::StringRef R = Lexer::getSourceText(
+ const StringRef R = Lexer::getSourceText(
CharSourceRange::getTokenRange(Rsr), SM, Context->getLangOpts());
return areStringsSameIgnoreSpaces(L, R);
}
diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
index 51ceceec6b65e..b331426d09c7b 100644
--- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -51,8 +51,8 @@ bool ThrowByValueCatchByReferenceCheck::isFunctionParameter(
bool ThrowByValueCatchByReferenceCheck::isCatchVariable(
const DeclRefExpr *DeclRefExpr) {
auto *ValueDecl = DeclRefExpr->getDecl();
- if (auto *VarDecl = dyn_cast<clang::VarDecl>(ValueDecl))
- return VarDecl->isExceptionVariable();
+ if (auto *Var = dyn_cast<VarDecl>(ValueDecl))
+ return Var->isExceptionVariable();
return false;
}
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index cb5eee4d0dd9c..b5011d982bf76 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -20,13 +20,13 @@ namespace clang::tidy::misc {
namespace {
AST_MATCHER_P(DeducedTemplateSpecializationType, refsToTemplatedDecl,
- clang::ast_matchers::internal::Matcher<NamedDecl>, DeclMatcher) {
+ ast_matchers::internal::Matcher<NamedDecl>, DeclMatcher) {
if (const auto *TD = Node.getTemplateName().getAsTemplateDecl())
return DeclMatcher.matches(*TD, Finder, Builder);
return false;
}
-AST_MATCHER_P(Type, asTagDecl, clang::ast_matchers::internal::Matcher<TagDecl>,
+AST_MATCHER_P(Type, asTagDecl, ast_matchers::internal::Matcher<TagDecl>,
DeclMatcher) {
if (const TagDecl *ND = Node.getAsTagDecl())
return DeclMatcher.matches(*ND, Finder, Builder);
diff --git a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
index ed36d486a1734..90643264a7d29 100644
--- a/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
@@ -24,7 +24,7 @@ AST_POLYMORPHIC_MATCHER_P(isInHeaderFile,
}
AST_MATCHER(FunctionDecl, isMemberFunction) {
- return llvm::isa<CXXMethodDecl>(&Node);
+ return isa<CXXMethodDecl>(&Node);
}
AST_MATCHER(VarDecl, isStaticDataMember) { return Node.isStaticDataMember(); }
} // namespace
@@ -52,8 +52,7 @@ void UseAnonymousNamespaceCheck::registerMatchers(MatchFinder *Finder) {
void UseAnonymousNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *MatchedDecl = Result.Nodes.getNodeAs<NamedDecl>("x")) {
- const StringRef Type =
- llvm::isa<VarDecl>(MatchedDecl) ? "variable" : "function";
+ const StringRef Type = isa<VarDecl>(MatchedDecl) ? "variable" : "function";
diag(MatchedDecl->getLocation(),
"%0 %1 declared 'static', move to anonymous namespace instead")
<< Type << MatchedDecl;
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index 3f522041b863d..dd8fb6889e14d 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -391,7 +391,7 @@ static std::vector<const FunctionDecl *>
findCandidateCallOperators(const CXXRecordDecl *RecordDecl, size_t NumArgs) {
std::vector<const FunctionDecl *> Candidates;
- for (const clang::CXXMethodDecl *Method : RecordDecl->methods()) {
+ for (const CXXMethodDecl *Method : RecordDecl->methods()) {
const OverloadedOperatorKind OOK = Method->getOverloadedOperator();
if (OOK != OverloadedOperatorKind::OO_Call)
@@ -404,7 +404,7 @@ findCandidateCallOperators(const CXXRecordDecl *RecordDecl, size_t NumArgs) {
}
// Find templated operator(), if any.
- for (const clang::Decl *D : RecordDecl->decls()) {
+ for (const Decl *D : RecordDecl->decls()) {
const auto *FTD = dyn_cast<FunctionTemplateDecl>(D);
if (!FTD)
continue;
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
index b153e3fb0b824..b056255b8e23b 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
@@ -17,49 +17,44 @@ namespace clang::tidy::modernize {
template <typename TargetType, typename NodeType>
static const TargetType *getAs(const NodeType *Node) {
- if constexpr (std::is_same_v<NodeType, clang::DynTypedNode>)
+ if constexpr (std::is_same_v<NodeType, DynTypedNode>)
return Node->template get<TargetType>();
else
- return llvm::dyn_cast<TargetType>(Node);
+ return dyn_cast<TargetType>(Node);
}
namespace {
-AST_MATCHER(clang::TypeLoc, hasValidBeginLoc) {
- return Node.getBeginLoc().isValid();
-}
+AST_MATCHER(TypeLoc, hasValidBeginLoc) { return Node.getBeginLoc().isValid(); }
-AST_MATCHER_P(clang::TypeLoc, hasType,
- clang::ast_matchers::internal::Matcher<clang::Type>,
+AST_MATCHER_P(TypeLoc, hasType, ast_matchers::internal::Matcher<Type>,
InnerMatcher) {
- const clang::Type *TypeNode = Node.getTypePtr();
+ const Type *TypeNode = Node.getTypePtr();
return TypeNode != nullptr &&
InnerMatcher.matches(*TypeNode, Finder, Builder);
}
-AST_MATCHER(clang::RecordDecl, isExternCContext) {
- return Node.isExternCContext();
-}
+AST_MATCHER(RecordDecl, isExternCContext) { return Node.isExternCContext(); }
-AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) {
- const clang::DeclContext *DC = Node.getDeclContext();
- const auto *FD = llvm::dyn_cast<clang::FunctionDecl>(DC);
+AST_MATCHER(ParmVarDecl, isArgvOfMain) {
+ const DeclContext *DC = Node.getDeclContext();
+ const auto *FD = dyn_cast<FunctionDecl>(DC);
return FD ? FD->isMain() : false;
}
-AST_MATCHER(clang::TypeLoc, isWithinImplicitTemplateInstantiation) {
+AST_MATCHER(TypeLoc, isWithinImplicitTemplateInstantiation) {
const auto IsImplicitTemplateInstantiation = [](const auto *Node) {
const auto IsImplicitInstantiation = [](const auto *Node) {
return (Node != nullptr) && (Node->getTemplateSpecializationKind() ==
TSK_ImplicitInstantiation);
};
- return (IsImplicitInstantiation(getAs<clang::CXXRecordDecl>(Node)) ||
- IsImplicitInstantiation(getAs<clang::FunctionDecl>(Node)) ||
- IsImplicitInstantiation(getAs<clang::VarDecl>(Node)));
+ return (IsImplicitInstantiation(getAs<CXXRecordDecl>(Node)) ||
+ IsImplicitInstantiation(getAs<FunctionDecl>(Node)) ||
+ IsImplicitInstantiation(getAs<VarDecl>(Node)));
};
DynTypedNodeList ParentNodes = Finder->getASTContext().getParents(Node);
- const clang::NamedDecl *ParentDecl = nullptr;
+ const NamedDecl *ParentDecl = nullptr;
while (!ParentNodes.empty()) {
const DynTypedNode &ParentNode = ParentNodes[0];
if (IsImplicitTemplateInstantiation(&ParentNode))
@@ -68,14 +63,14 @@ AST_MATCHER(clang::TypeLoc, isWithinImplicitTemplateInstantiation) {
// in case of a `NamedDecl` as parent node, it is more efficient to proceed
// with the upward traversal via DeclContexts (see below) instead of via
// parent nodes
- if ((ParentDecl = ParentNode.template get<clang::NamedDecl>()))
+ if ((ParentDecl = ParentNode.get<NamedDecl>()))
break;
ParentNodes = Finder->getASTContext().getParents(ParentNode);
}
if (ParentDecl != nullptr) {
- const clang::DeclContext *DeclContext = ParentDecl->getDeclContext();
+ const DeclContext *DeclContext = ParentDecl->getDeclContext();
while (DeclContext != nullptr) {
if (IsImplicitTemplateInstantiation(DeclContext))
return true;
@@ -141,7 +136,7 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
Result.Nodes.getNodeAs<ParmVarDecl>("param_decl") != nullptr;
const bool IsVLA = ArrayTypeLoc.getTypePtr()->isVariableArrayType();
enum class RecommendType { Array, Vector, Span };
- llvm::SmallVector<const char *> RecommendTypes{};
+ SmallVector<const char *> RecommendTypes{};
if (IsVLA) {
RecommendTypes.push_back("'std::vector'");
} else if (ArrayTypeLoc.getTypePtr()->isIncompleteArrayType() && IsInParam) {
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
index 94eb0a59c6fbd..7010b8774deca 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
@@ -58,7 +58,7 @@ static bool pointedUnqualifiedTypesAreEqual(QualType T1, QualType T2) {
return T1.getUnqualifiedType() == T2.getUnqualifiedType();
}
-static clang::CharSourceRange getReplaceRange(const ExplicitCastExpr *Expr) {
+static CharSourceRange getReplaceRange(const ExplicitCastExpr *Expr) {
if (const auto *CastExpr = dyn_cast<CStyleCastExpr>(Expr))
return CharSourceRange::getCharRange(
CastExpr->getLParenLoc(),
@@ -254,7 +254,7 @@ void AvoidCStyleCastCheck::check(const MatchFinder::MatchResult &Result) {
}
[[fallthrough]];
- case clang::CK_IntegralCast:
+ case CK_IntegralCast:
// Convert integral and no-op casts between builtin types and enums to
// static_cast. A cast from enum to integer may be unnecessary, but it's
// still retained.
diff --git a/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h b/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
index 9886cb5a2d7d9..74585e39105ad 100644
--- a/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
@@ -15,9 +15,9 @@
namespace clang::tidy::modernize {
-using NamespaceName = llvm::SmallString<40>;
+using NamespaceName = SmallString<40>;
-class NS : public llvm::SmallVector<const NamespaceDecl *, 6> {
+class NS : public SmallVector<const NamespaceDecl *, 6> {
public:
std::optional<SourceRange>
getCleanedNamespaceFrontRange(const SourceManager &SM,
@@ -43,7 +43,7 @@ class ConcatNestedNamespacesCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- using NamespaceContextVec = llvm::SmallVector<NS, 6>;
+ using NamespaceContextVec = SmallVector<NS, 6>;
void reportDiagnostic(const SourceManager &SM, const LangOptions &LangOpts);
NamespaceContextVec Namespaces;
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index 2d63da2fef974..0179f649a0e9f 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -1074,7 +1074,7 @@ void LoopConvertCheck::check(const MatchFinder::MatchResult &Result) {
Finder.aliasFromForInit(), Loop, Descriptor);
}
-llvm::StringRef LoopConvertCheck::getReverseFunction() const {
+StringRef LoopConvertCheck::getReverseFunction() const {
if (!ReverseFunction.empty())
return ReverseFunction;
if (UseReverseRanges)
@@ -1082,7 +1082,7 @@ llvm::StringRef LoopConvertCheck::getReverseFunction() const {
return "";
}
-llvm::StringRef LoopConvertCheck::getReverseHeader() const {
+StringRef LoopConvertCheck::getReverseHeader() const {
if (!ReverseHeader.empty())
return ReverseHeader;
if (UseReverseRanges && ReverseFunction.empty())
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
index 5d0800d8e7880..0c295fd5d0820 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
@@ -15,8 +15,6 @@
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
#include <algorithm>
#include <memory>
#include <string>
@@ -32,29 +30,26 @@ enum LoopFixerKind {
};
/// A map used to walk the AST in reverse: maps child Stmt to parent Stmt.
-using StmtParentMap = llvm::DenseMap<const clang::Stmt *, const clang::Stmt *>;
+using StmtParentMap = llvm::DenseMap<const Stmt *, const Stmt *>;
/// A map used to walk the AST in reverse:
/// maps VarDecl to the to parent DeclStmt.
-using DeclParentMap =
- llvm::DenseMap<const clang::VarDecl *, const clang::DeclStmt *>;
+using DeclParentMap = llvm::DenseMap<const VarDecl *, const DeclStmt *>;
/// A map used to track which variables have been removed by a refactoring pass.
/// It maps the parent ForStmt to the removed index variable's VarDecl.
-using ReplacedVarsMap =
- llvm::DenseMap<const clang::ForStmt *, const clang::VarDecl *>;
+using ReplacedVarsMap = llvm::DenseMap<const ForStmt *, const VarDecl *>;
/// A map used to remember the variable names generated in a Stmt
-using StmtGeneratedVarNameMap =
- llvm::DenseMap<const clang::Stmt *, std::string>;
+using StmtGeneratedVarNameMap = llvm::DenseMap<const Stmt *, std::string>;
/// A vector used to store the AST subtrees of an Expr.
-using ComponentVector = llvm::SmallVector<const clang::Expr *, 16>;
+using ComponentVector = SmallVector<const Expr *, 16>;
/// Class used build the reverse AST properties needed to detect
/// name conflicts and free variables.
class StmtAncestorASTVisitor
- : public clang::RecursiveASTVisitor<StmtAncestorASTVisitor> {
+ : public RecursiveASTVisitor<StmtAncestorASTVisitor> {
public:
StmtAncestorASTVisitor() { StmtStack.push_back(nullptr); }
@@ -72,50 +67,50 @@ class StmtAncestorASTVisitor
/// Accessor for DeclParents.
const DeclParentMap &getDeclToParentStmtMap() { return DeclParents; }
- friend class clang::RecursiveASTVisitor<StmtAncestorASTVisitor>;
+ friend class RecursiveASTVisitor<StmtAncestorASTVisitor>;
private:
StmtParentMap StmtAncestors;
DeclParentMap DeclParents;
- llvm::SmallVector<const clang::Stmt *, 16> StmtStack;
+ SmallVector<const Stmt *, 16> StmtStack;
- bool TraverseStmt(clang::Stmt *Statement);
- bool VisitDeclStmt(clang::DeclStmt *Statement);
+ bool TraverseStmt(Stmt *Statement);
+ bool VisitDeclStmt(DeclStmt *Statement);
};
/// Class used to find the variables and member expressions on which an
/// arbitrary expression depends.
class ComponentFinderASTVisitor
- : public clang::RecursiveASTVisitor<ComponentFinderASTVisitor> {
+ : public RecursiveASTVisitor<ComponentFinderASTVisitor> {
public:
ComponentFinderASTVisitor() = default;
/// Find the components of an expression and place them in a ComponentVector.
- void findExprComponents(const clang::Expr *SourceExpr) {
- TraverseStmt(const_cast<clang::Expr *>(SourceExpr));
+ void findExprComponents(const Expr *SourceExpr) {
+ TraverseStmt(const_cast<Expr *>(SourceExpr));
}
/// Accessor for Components.
const ComponentVector &getComponents() { return Components; }
- friend class clang::RecursiveASTVisitor<ComponentFinderASTVisitor>;
+ friend class RecursiveASTVisitor<ComponentFinderASTVisitor>;
private:
ComponentVector Components;
- bool VisitDeclRefExpr(clang::DeclRefExpr *E);
- bool VisitMemberExpr(clang::MemberExpr *Member);
+ bool VisitDeclRefExpr(DeclRefExpr *E);
+ bool VisitMemberExpr(MemberExpr *Member);
};
/// Class used to determine if an expression is dependent on a variable declared
/// inside of the loop where it would be used.
class DependencyFinderASTVisitor
- : public clang::RecursiveASTVisitor<DependencyFinderASTVisitor> {
+ : public RecursiveASTVisitor<DependencyFinderASTVisitor> {
public:
DependencyFinderASTVisitor(const StmtParentMap *StmtParents,
const DeclParentMap *DeclParents,
const ReplacedVarsMap *ReplacedVars,
- const clang::Stmt *ContainingStmt)
+ const Stmt *ContainingStmt)
: StmtParents(StmtParents), DeclParents(DeclParents),
ContainingStmt(ContainingStmt), ReplacedVars(ReplacedVars) {}
@@ -149,31 +144,30 @@ class DependencyFinderASTVisitor
/// In order to avoid this, this class looks at the container expression
/// `arr[k]` and decides whether or not it contains a sub-expression declared
/// within the loop body.
- bool dependsOnInsideVariable(const clang::Stmt *Body) {
+ bool dependsOnInsideVariable(const Stmt *Body) {
DependsOnInsideVariable = false;
- TraverseStmt(const_cast<clang::Stmt *>(Body));
+ TraverseStmt(const_cast<Stmt *>(Body));
return DependsOnInsideVariable;
}
- friend class clang::RecursiveASTVisitor<DependencyFinderASTVisitor>;
+ friend class RecursiveASTVisitor<DependencyFinderASTVisitor>;
private:
const StmtParentMap *StmtParents;
const DeclParentMap *DeclParents;
- const clang::Stmt *ContainingStmt;
+ const Stmt *ContainingStmt;
const ReplacedVarsMap *ReplacedVars;
bool DependsOnInsideVariable;
- bool VisitVarDecl(clang::VarDecl *V);
- bool VisitDeclRefExpr(clang::DeclRefExpr *D);
+ bool VisitVarDecl(VarDecl *V);
+ bool VisitDeclRefExpr(DeclRefExpr *D);
};
/// Class used to determine if any declarations used in a Stmt would conflict
/// with a particular identifier. This search includes the names that don't
/// actually appear in the AST (i.e. created by a refactoring tool) by including
/// a map from Stmts to generated names associated with those stmts.
-class DeclFinderASTVisitor
- : public clang::RecursiveASTVisitor<DeclFinderASTVisitor> {
+class DeclFinderASTVisitor : public RecursiveASTVisitor<DeclFinderASTVisitor> {
public:
DeclFinderASTVisitor(const StringRef &Name,
const StmtGeneratedVarNameMap *GeneratedDecls)
@@ -182,13 +176,13 @@ class DeclFinderASTVisitor
/// Attempts to find any usages of variables name Name in Body, returning
/// true when it is used in Body. This includes the generated loop variables
/// of ForStmts which have already been transformed.
- bool findUsages(const clang::Stmt *Body) {
+ bool findUsages(const Stmt *Body) {
Found = false;
- TraverseStmt(const_cast<clang::Stmt *>(Body));
+ TraverseStmt(const_cast<Stmt *>(Body));
return Found;
}
- friend class clang::RecursiveASTVisitor<DeclFinderASTVisitor>;
+ friend class RecursiveASTVisitor<DeclFinderASTVisitor>;
private:
std::string Name;
@@ -197,10 +191,10 @@ class DeclFinderASTVisitor
const StmtGeneratedVarNameMap *GeneratedDecls;
bool Found = false;
- bool VisitForStmt(clang::ForStmt *);
- bool VisitNamedDecl(clang::NamedDecl *);
- bool VisitDeclRefExpr(clang::DeclRefExpr *);
- bool VisitTypeLoc(clang::TypeLoc);
+ bool VisitForStmt(ForStmt *);
+ bool VisitNamedDecl(NamedDecl *);
+ bool VisitDeclRefExpr(DeclRefExpr *);
+ bool VisitTypeLoc(TypeLoc);
};
/// The information needed to describe a valid convertible usage
@@ -270,7 +264,7 @@ class Confidence {
};
// The main computational result of ForLoopIndexVisitor.
-using UsageResult = llvm::SmallVector<Usage, 8>;
+using UsageResult = SmallVector<Usage, 8>;
// General functions used by ForLoopIndexUseVisitor and LoopConvertCheck.
const Expr *digThroughConstructorsConversions(const Expr *E);
@@ -385,7 +379,7 @@ class ForLoopIndexUseVisitor
///
/// If any of these expressions are encountered outside of an acceptable usage
/// of the loop element, lower our confidence level.
- llvm::SmallVector<std::pair<const Expr *, llvm::FoldingSetNodeID>, 16>
+ SmallVector<std::pair<const Expr *, llvm::FoldingSetNodeID>, 16>
DependentExprs;
/// The parent-in-waiting. Will become the real parent once we traverse down
@@ -435,10 +429,9 @@ class VariableNamer {
};
VariableNamer(StmtGeneratedVarNameMap *GeneratedDecls,
- const StmtParentMap *ReverseAST, const clang::Stmt *SourceStmt,
- const clang::VarDecl *OldIndex,
- const clang::ValueDecl *TheContainer,
- const clang::ASTContext *Context, NamingStyle Style)
+ const StmtParentMap *ReverseAST, const Stmt *SourceStmt,
+ const VarDecl *OldIndex, const ValueDecl *TheContainer,
+ const ASTContext *Context, NamingStyle Style)
: GeneratedDecls(GeneratedDecls), ReverseAST(ReverseAST),
SourceStmt(SourceStmt), OldIndex(OldIndex), TheContainer(TheContainer),
Context(Context), Style(Style) {}
@@ -453,15 +446,15 @@ class VariableNamer {
private:
StmtGeneratedVarNameMap *GeneratedDecls;
const StmtParentMap *ReverseAST;
- const clang::Stmt *SourceStmt;
- const clang::VarDecl *OldIndex;
- const clang::ValueDecl *TheContainer;
- const clang::ASTContext *Context;
+ const Stmt *SourceStmt;
+ const VarDecl *OldIndex;
+ const ValueDecl *TheContainer;
+ const ASTContext *Context;
const NamingStyle Style;
// Determine whether or not a declaration that would conflict with Symbol
// exists in an outer context or in any statement contained in SourceStmt.
- bool declarationExists(llvm::StringRef Symbol);
+ bool declarationExists(StringRef Symbol);
};
} // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
index b13d95633c12e..91a1f22c0033d 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -12,8 +12,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::modernize {
-MakeUniqueCheck::MakeUniqueCheck(StringRef Name,
- clang::tidy::ClangTidyContext *Context)
+MakeUniqueCheck::MakeUniqueCheck(StringRef Name, ClangTidyContext *Context)
: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
RequireCPlusPlus14(Options.get("MakeSmartPtrFunction", "").empty()) {}
diff --git a/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
index f4592950fc05e..3f61a2d5d8bba 100644
--- a/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
@@ -13,7 +13,9 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Lexer.h"
-using namespace clang;
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
namespace {
@@ -21,15 +23,11 @@ struct FindArgsResult {
const Expr *First;
const Expr *Last;
const Expr *Compare;
- SmallVector<const clang::Expr *, 2> Args;
+ SmallVector<const Expr *, 2> Args;
};
} // anonymous namespace
-using namespace clang::ast_matchers;
-
-namespace clang::tidy::modernize {
-
static FindArgsResult findArgs(const CallExpr *Call) {
FindArgsResult Result;
Result.First = nullptr;
diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
index 2619331cba0b0..77add86cb85c1 100644
--- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
@@ -173,9 +173,9 @@ static bool hasRValueOverload(const CXXConstructorDecl *Ctor,
C->getNumParams() != Ctor->getNumParams())
return false;
for (int I = 0, E = C->getNumParams(); I < E; ++I) {
- const clang::QualType CandidateParamType =
+ const QualType CandidateParamType =
C->parameters()[I]->getType().getCanonicalType();
- const clang::QualType CtorParamType =
+ const QualType CtorParamType =
Ctor->parameters()[I]->getType().getCanonicalType();
const bool IsLValueRValuePair =
CtorParamType->isLValueReferenceType() &&
diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
index b10e2cc1c2e2e..8d09b9a88f0ad 100644
--- a/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
@@ -39,7 +39,7 @@ class ReplaceDisallowCopyAndAssignMacroCallbacks : public PPCallbacks {
// For now we only support simple argument that don't need to be
// pre-expanded.
return;
- const clang::IdentifierInfo *ClassIdent = ClassNameTok->getIdentifierInfo();
+ const IdentifierInfo *ClassIdent = ClassNameTok->getIdentifierInfo();
if (!ClassIdent)
return;
diff --git a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
index e32ddbf87efe9..a13e270bf85e1 100644
--- a/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ShrinkToFitCheck.cpp
@@ -50,7 +50,7 @@ void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) {
if (!MemberCall->getBeginLoc().isMacroID()) {
const LangOptions &Opts = getLangOpts();
std::string ReplacementText;
- if (const auto *UnaryOp = llvm::dyn_cast<UnaryOperator>(Container)) {
+ if (const auto *UnaryOp = dyn_cast<UnaryOperator>(Container)) {
ReplacementText = std::string(
Lexer::getSourceText(CharSourceRange::getTokenRange(
UnaryOp->getSubExpr()->getSourceRange()),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
index 1666987411790..cebab03e2ab03 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
@@ -428,13 +428,13 @@ void UseAutoCheck::replaceExpr(
// Space after 'auto' to handle cases where the '*' in the pointer type is
// next to the identifier. This avoids changing 'int *p' into 'autop'.
- const llvm::StringRef Auto = ShouldReplenishVariableName
- ? (RemoveStars ? "auto " : "auto *")
- : (RemoveStars ? "auto " : "auto");
+ const StringRef Auto = ShouldReplenishVariableName
+ ? (RemoveStars ? "auto " : "auto *")
+ : (RemoveStars ? "auto " : "auto");
const std::string ReplenishedVariableName =
ShouldReplenishVariableName ? FirstDecl->getQualifiedNameAsString() : "";
const std::string Replacement =
- (Auto + llvm::StringRef{ReplenishedVariableName}).str();
+ (Auto + StringRef{ReplenishedVariableName}).str();
Diag << FixItHint::CreateReplacement(Range, Replacement) << StarRemovals;
}
diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 9521bfcd6ba58..025290df43719 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
@@ -326,12 +326,12 @@ static std::optional<std::string> getConditionText(const Expr *ConditionExpr,
SM, LangOpts) == "//";
bool Invalid = false;
- const llvm::StringRef ConditionText = Lexer::getSourceText(
+ const StringRef ConditionText = Lexer::getSourceText(
CharSourceRange::getCharRange(ConditionRange), SM, LangOpts, &Invalid);
if (Invalid)
return std::nullopt;
- auto AddParens = [&](llvm::StringRef Text) -> std::string {
+ auto AddParens = [&](StringRef Text) -> std::string {
if (isPrimaryExpression(ConditionExpr))
return Text.str();
return "(" + Text.str() + ")";
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
index 5a8f3e3c9e922..5874c061d299f 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
@@ -55,19 +55,19 @@ struct Designators {
unsigned size() { return getCached().size(); }
- std::optional<llvm::StringRef> operator[](const SourceLocation &Location) {
+ std::optional<StringRef> operator[](const SourceLocation &Location) {
const auto &Designators = getCached();
const auto Result = Designators.find(Location);
if (Result == Designators.end())
return {};
- const llvm::StringRef Designator = Result->getSecond();
+ const StringRef Designator = Result->getSecond();
return (Designator.front() == '.' ? Designator.substr(1) : Designator)
.trim("\0"); // Trim NULL characters appearing on Windows in the
// name.
}
private:
- using LocationToNameMap = llvm::DenseMap<clang::SourceLocation, std::string>;
+ using LocationToNameMap = llvm::DenseMap<SourceLocation, std::string>;
std::optional<LocationToNameMap> CachedDesignators;
const InitListExpr *InitList;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
index c37f23665b68a..5fcc03dea6b42 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -51,8 +51,8 @@ AST_MATCHER_P(NamedDecl, hasAnyNameIgnoringTemplates, std::vector<StringRef>,
}
// Checks if the given matcher is the last argument of the given CallExpr.
-AST_MATCHER_P(CallExpr, hasLastArgument,
- clang::ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
+AST_MATCHER_P(CallExpr, hasLastArgument, ast_matchers::internal::Matcher<Expr>,
+ InnerMatcher) {
if (Node.getNumArgs() == 0)
return false;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index 574cbea46124b..8128acb055c84 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -18,23 +18,21 @@ namespace clang::tidy::modernize {
/// Find if the passed type is the actual "char" type,
/// not applicable to explicit "signed char" or "unsigned char" types.
-static bool isActualCharType(const clang::QualType &Ty) {
+static bool isActualCharType(const QualType &Ty) {
using namespace clang;
const Type *DesugaredType = Ty->getUnqualifiedDesugaredType();
- if (const auto *BT = llvm::dyn_cast<BuiltinType>(DesugaredType))
+ if (const auto *BT = dyn_cast<BuiltinType>(DesugaredType))
return (BT->getKind() == BuiltinType::Char_U ||
BT->getKind() == BuiltinType::Char_S);
return false;
}
namespace {
-AST_MATCHER(clang::QualType, isActualChar) {
- return clang::tidy::modernize::isActualCharType(Node);
-}
+AST_MATCHER(QualType, isActualChar) { return isActualCharType(Node); }
} // namespace
-static BindableMatcher<clang::Stmt>
-intCastExpression(bool IsSigned, StringRef CastBindName = {}) {
+static BindableMatcher<Stmt> intCastExpression(bool IsSigned,
+ StringRef CastBindName = {}) {
// std::cmp_{} functions trigger a compile-time error if either LHS or RHS
// is a non-integer type, char, enum or bool
// (unsigned char/ signed char are Ok and can be used).
@@ -134,13 +132,13 @@ void UseIntegerSignComparisonCheck::check(
SourceRange R2(BinaryOp->getOperatorLoc());
SourceRange R3(Lexer::getLocForEndOfToken(
RHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
- if (const auto *LHSCast = llvm::dyn_cast<ExplicitCastExpr>(LHS)) {
+ if (const auto *LHSCast = dyn_cast<ExplicitCastExpr>(LHS)) {
SubExprLHS = LHSCast->getSubExpr();
R1.setEnd(SubExprLHS->getBeginLoc().getLocWithOffset(-1));
R2.setBegin(Lexer::getLocForEndOfToken(
SubExprLHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
}
- if (const auto *RHSCast = llvm::dyn_cast<ExplicitCastExpr>(RHS)) {
+ if (const auto *RHSCast = dyn_cast<ExplicitCastExpr>(RHS)) {
SubExprRHS = RHSCast->getSubExpr();
R2.setEnd(SubExprRHS->getBeginLoc().getLocWithOffset(-1));
R3.setBegin(Lexer::getLocForEndOfToken(
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
index 7e8d98241118a..4940b5590f803 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
@@ -17,7 +17,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::modernize {
static bool doesNoDiscardMacroExist(ASTContext &Context,
- const llvm::StringRef &MacroId) {
+ const StringRef &MacroId) {
// Don't check for the Macro existence if we are using an attribute
// either a C++17 standard attribute or pre C++17 syntax
if (MacroId.starts_with("[[") || MacroId.starts_with("__attribute__"))
@@ -92,11 +92,10 @@ void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) {
isConst(), isDefinitionOrInline(),
unless(anyOf(
returns(voidType()),
- returns(
- hasDeclaration(decl(hasAttr(clang::attr::WarnUnusedResult)))),
+ returns(hasDeclaration(decl(hasAttr(attr::WarnUnusedResult)))),
isNoReturn(), isOverloadedOperator(), isVariadic(),
hasTemplateReturnType(), hasClassMutableFields(),
- isConversionOperator(), hasAttr(clang::attr::WarnUnusedResult),
+ isConversionOperator(), hasAttr(attr::WarnUnusedResult),
hasType(isInstantiationDependentType()),
hasAnyParameter(
anyOf(parmVarDecl(anyOf(hasType(FunctionObj),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
index a170b7e6b7b91..74f15a68d6326 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
@@ -40,9 +40,8 @@ static bool isLockGuard(const QualType &Type) {
return false;
}
-static llvm::SmallVector<const VarDecl *>
-getLockGuardsFromDecl(const DeclStmt *DS) {
- llvm::SmallVector<const VarDecl *> LockGuards;
+static SmallVector<const VarDecl *> getLockGuardsFromDecl(const DeclStmt *DS) {
+ SmallVector<const VarDecl *> LockGuards;
for (const Decl *Decl : DS->decls()) {
if (const auto *VD = dyn_cast<VarDecl>(Decl)) {
@@ -58,12 +57,12 @@ getLockGuardsFromDecl(const DeclStmt *DS) {
// Scans through the statements in a block and groups consecutive
// 'std::lock_guard' variable declarations together.
-static llvm::SmallVector<llvm::SmallVector<const VarDecl *>>
+static SmallVector<SmallVector<const VarDecl *>>
findLocksInCompoundStmt(const CompoundStmt *Block,
const ast_matchers::MatchFinder::MatchResult &Result) {
// store groups of consecutive 'std::lock_guard' declarations
- llvm::SmallVector<llvm::SmallVector<const VarDecl *>> LockGuardGroups;
- llvm::SmallVector<const VarDecl *> CurrentLockGuardGroup;
+ SmallVector<SmallVector<const VarDecl *>> LockGuardGroups;
+ SmallVector<const VarDecl *> CurrentLockGuardGroup;
auto AddAndClearCurrentGroup = [&]() {
if (!CurrentLockGuardGroup.empty()) {
@@ -74,8 +73,7 @@ findLocksInCompoundStmt(const CompoundStmt *Block,
for (const Stmt *Stmt : Block->body()) {
if (const auto *DS = dyn_cast<DeclStmt>(Stmt)) {
- const llvm::SmallVector<const VarDecl *> LockGuards =
- getLockGuardsFromDecl(DS);
+ const SmallVector<const VarDecl *> LockGuards = getLockGuardsFromDecl(DS);
if (!LockGuards.empty()) {
CurrentLockGuardGroup.append(LockGuards);
@@ -172,7 +170,7 @@ void UseScopedLockCheck::registerMatchers(MatchFinder *Finder) {
void UseScopedLockCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *DS = Result.Nodes.getNodeAs<DeclStmt>("lock-decl-single")) {
- const llvm::SmallVector<const VarDecl *> Decls = getLockGuardsFromDecl(DS);
+ const SmallVector<const VarDecl *> Decls = getLockGuardsFromDecl(DS);
diagOnMultipleLocks({Decls}, Result);
return;
}
@@ -249,9 +247,9 @@ void UseScopedLockCheck::diagOnSingleLock(
}
void UseScopedLockCheck::diagOnMultipleLocks(
- const llvm::SmallVector<llvm::SmallVector<const VarDecl *>> &LockGroups,
+ const SmallVector<SmallVector<const VarDecl *>> &LockGroups,
const ast_matchers::MatchFinder::MatchResult &Result) {
- for (const llvm::SmallVector<const VarDecl *> &Group : LockGroups) {
+ for (const SmallVector<const VarDecl *> &Group : LockGroups) {
if (Group.size() == 1) {
if (WarnOnSingleLocks)
diagOnSingleLock(Group[0], Result);
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h
index 8f6b5a4b2aaff..7bf4c773984b5 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h
@@ -38,7 +38,7 @@ class UseScopedLockCheck : public ClangTidyCheck {
void diagOnSingleLock(const VarDecl *LockGuard,
const ast_matchers::MatchFinder::MatchResult &Result);
void diagOnMultipleLocks(
- const llvm::SmallVector<llvm::SmallVector<const VarDecl *>> &LockGroups,
+ const SmallVector<SmallVector<const VarDecl *>> &LockGroups,
const ast_matchers::MatchFinder::MatchResult &Result);
void diagOnSourceInfo(const TypeSourceInfo *LockGuardSourceInfo,
const ast_matchers::MatchFinder::MatchResult &Result);
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index eebd609cc84a8..97d71ef774924 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -20,14 +20,13 @@ using namespace clang::ast_matchers;
namespace clang::tidy::modernize {
static bool isNegativeComparison(const Expr *ComparisonExpr) {
- if (const auto *Op = llvm::dyn_cast<BinaryOperator>(ComparisonExpr))
+ if (const auto *Op = dyn_cast<BinaryOperator>(ComparisonExpr))
return Op->getOpcode() == BO_NE;
- if (const auto *Op = llvm::dyn_cast<CXXOperatorCallExpr>(ComparisonExpr))
+ if (const auto *Op = dyn_cast<CXXOperatorCallExpr>(ComparisonExpr))
return Op->getOperator() == OO_ExclaimEqual;
- if (const auto *Op =
- llvm::dyn_cast<CXXRewrittenBinaryOperator>(ComparisonExpr))
+ if (const auto *Op = dyn_cast<CXXRewrittenBinaryOperator>(ComparisonExpr))
return Op->getOperator() == BO_NE;
return false;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
index 2b84dcbe4eab8..912c2927d1aee 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
@@ -36,35 +36,35 @@
#include <tuple>
#include <utility>
-namespace {
using namespace clang::ast_matchers;
using clang::ast_matchers::internal::Matcher;
-using llvm::StringRef;
-AST_MATCHER_P2(clang::FloatingLiteral, near, double, Value, double,
- DiffThreshold) {
+namespace clang::tidy::modernize {
+
+namespace {
+
+AST_MATCHER_P2(FloatingLiteral, near, double, Value, double, DiffThreshold) {
return std::abs(Node.getValueAsApproximateDouble() - Value) < DiffThreshold;
}
-AST_MATCHER_P(clang::QualType, hasCanonicalTypeUnqualified,
- Matcher<clang::QualType>, InnerMatcher) {
+AST_MATCHER_P(QualType, hasCanonicalTypeUnqualified, Matcher<QualType>,
+ InnerMatcher) {
return !Node.isNull() &&
InnerMatcher.matches(Node->getCanonicalTypeUnqualified(), Finder,
Builder);
}
-AST_MATCHER(clang::QualType, isArithmetic) {
+AST_MATCHER(QualType, isArithmetic) {
return !Node.isNull() && Node->isArithmeticType();
}
-AST_MATCHER(clang::QualType, isFloating) {
+AST_MATCHER(QualType, isFloating) {
return !Node.isNull() && Node->isFloatingType();
}
-AST_MATCHER_P(clang::Expr, anyOfExhaustive, std::vector<Matcher<clang::Stmt>>,
- Exprs) {
+AST_MATCHER_P(Expr, anyOfExhaustive, std::vector<Matcher<Stmt>>, Exprs) {
bool FoundMatch = false;
for (const auto &InnerMatcher : Exprs) {
- clang::ast_matchers::internal::BoundNodesTreeBuilder Result = *Builder;
+ ast_matchers::internal::BoundNodesTreeBuilder Result = *Builder;
if (InnerMatcher.matches(Node, Finder, &Result)) {
*Builder = std::move(Result);
FoundMatch = true;
@@ -79,18 +79,16 @@ AST_MATCHER_P(clang::Expr, anyOfExhaustive, std::vector<Matcher<clang::Stmt>>,
// the literal of every constant and for formulas' subexpressions that look at
// literals.
struct MatchBuilder {
- auto
- ignoreParenAndArithmeticCasting(const Matcher<clang::Expr> &Matcher) const {
+ auto ignoreParenAndArithmeticCasting(const Matcher<Expr> &Matcher) const {
return expr(hasType(qualType(isArithmetic())), ignoringParenCasts(Matcher));
}
- auto
- ignoreParenAndFloatingCasting(const Matcher<clang::Expr> &Matcher) const {
+ auto ignoreParenAndFloatingCasting(const Matcher<Expr> &Matcher) const {
return expr(hasType(qualType(isFloating())), ignoringParenCasts(Matcher));
}
auto matchMathCall(const StringRef FunctionName,
- const Matcher<clang::Expr> &ArgumentMatcher) const {
+ const Matcher<Expr> &ArgumentMatcher) const {
auto HasAnyPrecisionName = hasAnyName(
FunctionName, (FunctionName + "l").str(),
(FunctionName + "f").str()); // Support long double(l) and float(f).
@@ -100,7 +98,7 @@ struct MatchBuilder {
hasArgument(0, ArgumentMatcher))));
}
- auto matchSqrt(const Matcher<clang::Expr> &ArgumentMatcher) const {
+ auto matchSqrt(const Matcher<Expr> &ArgumentMatcher) const {
return matchMathCall("sqrt", ArgumentMatcher);
}
@@ -148,7 +146,7 @@ struct MatchBuilder {
return expr(anyOf(Int, Float, Dref));
}
- auto match1Div(const Matcher<clang::Expr> &Match) const {
+ auto match1Div(const Matcher<Expr> &Match) const {
return binaryOperator(hasOperatorName("/"), hasLHS(matchValue(1)),
hasRHS(Match));
}
@@ -266,24 +264,23 @@ static std::string getCode(const StringRef Constant, const bool IsFloat,
return ("std::numbers::" + Constant).str();
}
-static bool isRangeOfCompleteMacro(const clang::SourceRange &Range,
- const clang::SourceManager &SM,
- const clang::LangOptions &LO) {
+static bool isRangeOfCompleteMacro(const SourceRange &Range,
+ const SourceManager &SM,
+ const LangOptions &LO) {
if (!Range.getBegin().isMacroID())
return false;
- if (!clang::Lexer::isAtStartOfMacroExpansion(Range.getBegin(), SM, LO))
+ if (!Lexer::isAtStartOfMacroExpansion(Range.getBegin(), SM, LO))
return false;
if (!Range.getEnd().isMacroID())
return false;
- if (!clang::Lexer::isAtEndOfMacroExpansion(Range.getEnd(), SM, LO))
+ if (!Lexer::isAtEndOfMacroExpansion(Range.getEnd(), SM, LO))
return false;
return true;
}
-namespace clang::tidy::modernize {
UseStdNumbersCheck::UseStdNumbersCheck(const StringRef Name,
ClangTidyContext *const Context)
: ClangTidyCheck(Name, Context),
@@ -301,7 +298,7 @@ UseStdNumbersCheck::UseStdNumbersCheck(const StringRef Name,
void UseStdNumbersCheck::registerMatchers(MatchFinder *const Finder) {
const auto Matches = MatchBuilder{DiffThreshold};
- const std::vector<Matcher<clang::Stmt>> ConstantMatchers = {
+ const std::vector<Matcher<Stmt>> ConstantMatchers = {
Matches.matchLog2Euler(), Matches.matchLog10Euler(),
Matches.matchEulerTopLevel(), Matches.matchEgamma(),
Matches.matchInvSqrtPi(), Matches.matchInvPi(),
@@ -360,7 +357,7 @@ void UseStdNumbersCheck::check(const MatchFinder::MatchResult &Result) {
};
auto MatchedLiterals =
- llvm::SmallVector<std::tuple<std::string, double, const Expr *>>{};
+ SmallVector<std::tuple<std::string, double, const Expr *>>{};
const auto &SM = *Result.SourceManager;
const auto &LO = Result.Context->getLangOpts();
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 51af54eaa3513..0f612471497a7 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -69,8 +69,8 @@ void UseStdPrintCheck::registerPPCallbacks(const SourceManager &SM,
this->PP = PP;
}
-static clang::ast_matchers::StatementMatcher unusedReturnValue(
- const clang::ast_matchers::StatementMatcher &MatchedCallExpr) {
+static StatementMatcher
+unusedReturnValue(const StatementMatcher &MatchedCallExpr) {
auto UnusedInCompoundStmt =
compoundStmt(forEach(MatchedCallExpr),
// The checker can't currently
diff erentiate between the
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStringViewCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStringViewCheck.cpp
index 1dc4cc9856549..f5a51c0baba33 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStringViewCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStringViewCheck.cpp
@@ -100,8 +100,8 @@ void UseStringViewCheck::check(const MatchFinder::MatchResult &Result) {
assert(MatchedDecl);
bool ShouldAKA = false;
const std::string DesugaredTypeStr =
- clang::desugarForDiagnostic(
- *Result.Context, QualType(MatchedDecl->getReturnType()), ShouldAKA)
+ desugarForDiagnostic(*Result.Context,
+ QualType(MatchedDecl->getReturnType()), ShouldAKA)
.getAsString();
const StringRef DestReturnTypeStr = toStringViewTypeStr(DesugaredTypeStr);
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp
index 8dd6bbfa3d2ab..ee1474d9eade1 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp
@@ -100,7 +100,7 @@ enum TransferType : uint8_t {
/// Matches a Stmt whose parent is a CompoundStmt, and which is directly
/// following two VarDecls matching the inner matcher.
AST_MATCHER_P(Stmt, hasPreTwoVarDecl,
- llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
+ SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
InnerMatchers) {
const DynTypedNodeList Parents = Finder->getASTContext().getParents(Node);
if (Parents.size() != 1)
@@ -119,7 +119,7 @@ AST_MATCHER_P(Stmt, hasPreTwoVarDecl,
/// Matches a Stmt whose parent is a CompoundStmt, and which is directly
/// followed by two VarDecls matching the inner matcher.
AST_MATCHER_P(Stmt, hasNextTwoVarDecl,
- llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
+ SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
InnerMatchers) {
const DynTypedNodeList Parents = Finder->getASTContext().getParents(Node);
if (Parents.size() != 1)
@@ -138,7 +138,7 @@ AST_MATCHER_P(Stmt, hasNextTwoVarDecl,
/// Matches a CompoundStmt which has two VarDecls matching the inner matcher in
/// the beginning.
AST_MATCHER_P(CompoundStmt, hasFirstTwoVarDecl,
- llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
+ SmallVector<ast_matchers::internal::Matcher<VarDecl>>,
InnerMatchers) {
return matchNVarDeclStartingWith(Node.body_begin(), Node.body_end(),
InnerMatchers, Finder, Builder);
@@ -253,7 +253,7 @@ void UseStructuredBindingCheck::registerMatchers(MatchFinder *Finder) {
hasRHS(expr(hasType(PairType))))
.bind(StdTieAssignStmtName)),
hasPreTwoVarDecl(
- llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>{
+ SmallVector<ast_matchers::internal::Matcher<VarDecl>>{
varDecl(equalsBoundNode(std::string(FirstVarDeclName))),
varDecl(equalsBoundNode(std::string(SecondVarDeclName)))}),
hasParent(compoundStmt(UnlessFirstVarOrSecondVarIsCapturedByLambda)
@@ -274,7 +274,7 @@ void UseStructuredBindingCheck::registerMatchers(MatchFinder *Finder) {
expr().bind(InitExprName))))
.bind(PairDeclName)),
hasNextTwoVarDecl(
- llvm::SmallVector<ast_matchers::internal::Matcher<VarDecl>>{
+ SmallVector<ast_matchers::internal::Matcher<VarDecl>>{
VarInitWithFirstMember, VarInitWithSecondMember}),
hasParent(compoundStmt(UnlessFirstVarOrSecondVarIsCapturedByLambda)
.bind(ScopeBlockName))),
@@ -293,13 +293,12 @@ void UseStructuredBindingCheck::registerMatchers(MatchFinder *Finder) {
hasInitializer(ignoringCopyCtorAndImplicitCast(
expr().bind(InitExprName))))
.bind(PairDeclName)),
- hasBody(
- compoundStmt(
- hasFirstTwoVarDecl(llvm::SmallVector<
- ast_matchers::internal::Matcher<VarDecl>>{
- VarInitWithFirstMember, VarInitWithSecondMember}),
- UnlessFirstVarOrSecondVarIsCapturedByLambda)
- .bind(ScopeBlockName)))
+ hasBody(compoundStmt(
+ hasFirstTwoVarDecl(
+ SmallVector<ast_matchers::internal::Matcher<VarDecl>>{
+ VarInitWithFirstMember, VarInitWithSecondMember}),
+ UnlessFirstVarOrSecondVarIsCapturedByLambda)
+ .bind(ScopeBlockName)))
.bind(ForRangeStmtName),
this);
}
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 4d9b5ee568d80..aaba2d56389f8 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -17,14 +17,16 @@
#include <string>
using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
namespace {
-AST_MATCHER(clang::LinkageSpecDecl, isExternCLinkage) {
- return Node.getLanguage() == clang::LinkageSpecLanguageIDs::C;
+AST_MATCHER(LinkageSpecDecl, isExternCLinkage) {
+ return Node.getLanguage() == LinkageSpecLanguageIDs::C;
}
-} // namespace
-namespace clang::tidy::modernize {
+} // namespace
static constexpr StringRef ExternCDeclName = "extern-c-decl";
static constexpr StringRef ParentDeclName = "parent-decl";
diff --git a/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp b/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
index 632185295b12f..347059e65f453 100644
--- a/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
+++ b/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
@@ -83,7 +83,7 @@ void BufferDerefCheck::checkBuffers(ArrayRef<const Type *> BufferTypes,
for (size_t I = 0; I < BufferTypes.size(); ++I) {
unsigned IndirectionCount = 0;
const Type *BufferType = BufferTypes[I];
- llvm::SmallVector<IndirectionType, 1> Indirections;
+ SmallVector<IndirectionType, 1> Indirections;
// Capture the depth and types of indirections for the passed buffer.
while (true) {
diff --git a/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
index a9e6a4b9ea9bb..688dd57cde1d4 100644
--- a/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
@@ -46,7 +46,7 @@ void AssertEqualsCheck::check(
diag(MacroCallsite,
(Twine("use ") + TargetName + " for comparing objects").str())
<< FixItHint::CreateReplacement(
- clang::CharSourceRange::getCharRange(
+ CharSourceRange::getCharRange(
MacroCallsite,
MacroCallsite.getLocWithOffset(CurrName.size())),
TargetName);
diff --git a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
index e8c49eed190f3..0080a389ce9cb 100644
--- a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -40,7 +40,7 @@ static FixItHint generateFixItHint(const ObjCPropertyDecl *Decl,
size_t Index = 0;
if (Style == CategoryProperty) {
const size_t UnderScorePos = Name.find_first_of('_');
- if (UnderScorePos != llvm::StringRef::npos) {
+ if (UnderScorePos != StringRef::npos) {
Index = UnderScorePos + 1;
NewName.replace(0, Index - 1, Name.substr(0, Index - 1).lower());
}
@@ -50,7 +50,7 @@ static FixItHint generateFixItHint(const ObjCPropertyDecl *Decl,
if (NewName != Name) {
return FixItHint::CreateReplacement(
CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
- llvm::StringRef(NewName));
+ StringRef(NewName));
}
}
return {};
@@ -78,19 +78,19 @@ static std::string validPropertyNameRegex(bool UsedInMatcher) {
return StartMatcher + "([a-z]|[A-Z][A-Z0-9])[a-z0-9A-Z]*$";
}
-static bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
+static bool hasCategoryPropertyPrefix(StringRef PropertyName) {
auto RegexExp =
llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
return RegexExp.match(PropertyName);
}
-static bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
+static bool prefixedPropertyNameValid(StringRef PropertyName) {
const size_t Start = PropertyName.find_first_of('_');
- assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
+ assert(Start != StringRef::npos && Start + 1 < PropertyName.size());
auto Prefix = PropertyName.substr(0, Start);
if (Prefix.lower() != Prefix)
return false;
- auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+ auto RegexExp = llvm::Regex(StringRef(validPropertyNameRegex(false)));
return RegexExp.match(PropertyName.substr(Start + 1));
}
@@ -108,7 +108,7 @@ void PropertyDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
Result.Nodes.getNodeAs<ObjCPropertyDecl>("property");
assert(!MatchedDecl->getName().empty());
auto *DeclContext = MatchedDecl->getDeclContext();
- auto *CategoryDecl = llvm::dyn_cast<ObjCCategoryDecl>(DeclContext);
+ auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(DeclContext);
if (CategoryDecl != nullptr &&
hasCategoryPropertyPrefix(MatchedDecl->getName())) {
diff --git a/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp
index 3801fc0f420e5..7d0160c384140 100644
--- a/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp
@@ -20,7 +20,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
RawIgnoredExceptions(Options.get("IgnoredExceptions", "")) {
- llvm::SmallVector<StringRef, 8> IgnoredExceptionsVec;
+ SmallVector<StringRef, 8> IgnoredExceptionsVec;
llvm::StringSet<> IgnoredExceptions;
RawIgnoredExceptions.split(IgnoredExceptionsVec, ",", -1, false);
diff --git a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
index 0a3596e94e5d8..4433cdf5ac0db 100644
--- a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
@@ -41,7 +41,7 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) {
// 'std::cout << "Hi" << std::endl;' into
// 'std::cout << "Hi\n"';
- if (llvm::isa<DeclRefExpr>(Expression)) {
+ if (isa<DeclRefExpr>(Expression)) {
// Handle the more common streaming '... << std::endl' case
const CharSourceRange TokenRange =
CharSourceRange::getTokenRange(Expression->getSourceRange());
@@ -56,7 +56,7 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) {
Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'");
} else {
// Handle the less common function call 'std::endl(...)' case
- const auto *CallExpression = llvm::cast<CallExpr>(Expression);
+ const auto *CallExpression = cast<CallExpr>(Expression);
assert(CallExpression->getNumArgs() == 1);
StringRef SourceText = Lexer::getSourceText(
diff --git a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
index b57fdb2b3ffee..0f896f3816f57 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -65,7 +65,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
Result.Nodes.getNodeAs<ClassTemplateSpecializationDecl>("IneffContPtr");
PtrToContainer = true;
}
- const llvm::StringRef IneffContName = IneffCont->getName();
+ const StringRef IneffContName = IneffCont->getName();
const bool Unordered = IneffContName.contains("unordered");
const bool Maplike = IneffContName.contains("map");
diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
index 8029349891327..d073f00878020 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
@@ -229,14 +229,14 @@ void InefficientVectorOperationCheck::check(
if (VectorAppendCall != nullptr) {
PartialReserveStmt = ".reserve";
} else {
- llvm::StringRef FieldName = ProtoAddFieldCall->getMethodDecl()->getName();
+ StringRef FieldName = ProtoAddFieldCall->getMethodDecl()->getName();
FieldName.consume_front("add_");
const std::string MutableFieldName = ("mutable_" + FieldName).str();
PartialReserveStmt = "." + MutableFieldName +
"()->Reserve"; // e.g., ".mutable_xxx()->Reserve"
}
- const llvm::StringRef VarName = Lexer::getSourceText(
+ const StringRef VarName = Lexer::getSourceText(
CharSourceRange::getTokenRange(
AppendCall->getImplicitObjectArgument()->getSourceRange()),
SM, Context->getLangOpts());
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
index d4566bc59b7e5..279e83d0f9f71 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
@@ -16,10 +16,9 @@
#include "clang/Basic/Diagnostic.h"
#include <optional>
-namespace clang::tidy::performance {
+using namespace clang::ast_matchers;
-using namespace ::clang::ast_matchers;
-using llvm::StringRef;
+namespace clang::tidy::performance {
using utils::decl_ref_expr::allDeclRefExprs;
using utils::decl_ref_expr::isOnlyUsedAsConst;
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h
index 89957a5ed09e7..9395a1c01b44f 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h
@@ -42,7 +42,7 @@ class UnnecessaryCopyInitializationCheck : public ClangTidyCheck {
const VarDecl &Var;
const Stmt &BlockStmt;
const DeclStmt &VarDeclStmt;
- clang::ASTContext &ASTCtx;
+ ASTContext &ASTCtx;
const bool IssueFix;
const bool IsVarUnused;
const bool IsVarOnlyUsedAsConst;
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
index ffb2a81b862f6..f126dbe678238 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -149,7 +149,7 @@ void UnnecessaryValueParamCheck::handleConstRefFix(const FunctionDecl &Function,
// 1. the ParmVarDecl is in a macro, since we cannot place them correctly
// 2. the function is virtual as it might break overrides
// 3. the function is an explicit template/ specialization.
- const auto *Method = llvm::dyn_cast<CXXMethodDecl>(&Function);
+ const auto *Method = dyn_cast<CXXMethodDecl>(&Function);
if (Param.getBeginLoc().isMacroID() || (Method && Method->isVirtual()) ||
Function.getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
return;
diff --git a/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
index 902579f1bf9e9..bfcc52d3c8c3f 100644
--- a/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
@@ -23,7 +23,7 @@ class PragmaOnceCallbacks : public PPCallbacks {
: Check(Check), SM(SM) {}
void PragmaDirective(SourceLocation Loc,
PragmaIntroducerKind Introducer) override {
- auto Str = llvm::StringRef(SM.getCharacterData(Loc));
+ auto Str = StringRef(SM.getCharacterData(Loc));
if (!Str.consume_front("#"))
return;
Str = Str.trim();
diff --git a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
index d66149aceae91..6a68c58bb60a5 100644
--- a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
+++ b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.h
@@ -70,7 +70,7 @@ class RestrictedIncludesPPCallbacks : public PPCallbacks {
bool IsInMainFile; // Whether or not the include is in the main file
};
- using FileIncludes = llvm::SmallVector<IncludeDirective, 8>;
+ using FileIncludes = SmallVector<IncludeDirective, 8>;
llvm::SmallDenseMap<FileID, FileIncludes> IncludeDirectives;
RestrictSystemIncludesCheck &Check;
diff --git a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.h b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.h
index addcecbcb9370..2553a0c76a96c 100644
--- a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.h
+++ b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.h
@@ -31,7 +31,7 @@ class SIMDIntrinsicsCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- llvm::SmallString<32> Std;
+ SmallString<32> Std;
const bool Suggest;
};
diff --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
index cfdf0e9c4a331..405174ee0209b 100644
--- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -60,16 +60,16 @@ struct CheckResult {
CharSourceRange ConstRange;
// FixItHints associated with the definition being checked.
- llvm::SmallVector<clang::FixItHint, 4> Hints;
+ SmallVector<FixItHint, 4> Hints;
// Locations of any declarations that could not be fixed.
- llvm::SmallVector<clang::SourceLocation, 4> DeclLocs;
+ SmallVector<SourceLocation, 4> DeclLocs;
};
} // namespace
// Does the actual work of the check.
-static CheckResult checkDef(const clang::FunctionDecl *Def,
+static CheckResult checkDef(const FunctionDecl *Def,
const MatchFinder::MatchResult &MatchResult) {
CheckResult Result;
std::optional<Token> Tok = findConstToRemove(Def, MatchResult);
diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index 780a965778551..7c777638e0e59 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -94,7 +94,7 @@ AST_MATCHER(QualType, isIntegralType) {
}
AST_MATCHER_P(UserDefinedLiteral, hasLiteral,
- clang::ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
+ ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
const UserDefinedLiteral::LiteralOperatorKind LOK =
Node.getLiteralOperatorKind();
if (LOK == UserDefinedLiteral::LOK_Template ||
@@ -107,8 +107,7 @@ AST_MATCHER_P(UserDefinedLiteral, hasLiteral,
}
AST_MATCHER_P(CXXMethodDecl, hasCanonicalDecl,
- clang::ast_matchers::internal::Matcher<CXXMethodDecl>,
- InnerMatcher) {
+ ast_matchers::internal::Matcher<CXXMethodDecl>, InnerMatcher) {
return InnerMatcher.matches(*Node.getCanonicalDecl(), Finder, Builder);
}
@@ -300,9 +299,9 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
ReplacementText);
} else if (BinaryOp) { // Determine the correct transformation.
const auto *LiteralLHS =
- llvm::dyn_cast<IntegerLiteral>(BinaryOp->getLHS()->IgnoreImpCasts());
+ dyn_cast<IntegerLiteral>(BinaryOp->getLHS()->IgnoreImpCasts());
const auto *LiteralRHS =
- llvm::dyn_cast<IntegerLiteral>(BinaryOp->getRHS()->IgnoreImpCasts());
+ dyn_cast<IntegerLiteral>(BinaryOp->getRHS()->IgnoreImpCasts());
const bool ContainerIsLHS = !LiteralLHS;
uint64_t Value = 0;
diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
index 35ef18430378b..6d984d29ada66 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h
@@ -37,7 +37,7 @@ class ContainerSizeEmptyCheck : public ClangTidyCheck {
}
private:
- std::vector<llvm::StringRef> ExcludedComparisonTypes;
+ std::vector<StringRef> ExcludedComparisonTypes;
};
} // namespace clang::tidy::readability
diff --git a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
index 0ca65d3663e53..4bca9686e94e1 100644
--- a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
@@ -42,8 +42,8 @@ AST_MATCHER(CXXMethodDecl, isDependentContext) {
AST_MATCHER(CXXMethodDecl, isInsideMacroDefinition) {
const ASTContext &Ctxt = Finder->getASTContext();
- return clang::Lexer::makeFileCharRange(
- clang::CharSourceRange::getCharRange(
+ return Lexer::makeFileCharRange(
+ CharSourceRange::getCharRange(
Node.getTypeSourceInfo()->getTypeLoc().getSourceRange()),
Ctxt.getSourceManager(), Ctxt.getLangOpts())
.isInvalid();
diff --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index 74221163f3efa..b0e10aa6930d5 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -93,7 +93,7 @@ static const DeclRefExpr *checkInitDeclUsageInElse(const IfStmt *If) {
assert(isa<VarDecl>(InitDecl) && "SingleDecl must be a VarDecl");
return findUsage(If->getElse(), InitDecl->getID());
}
- llvm::SmallVector<int64_t, 4> DeclIdentifiers;
+ SmallVector<int64_t, 4> DeclIdentifiers;
for (const Decl *ChildDecl : InitDeclStmt->decls()) {
assert(isa<VarDecl>(ChildDecl) && "Init Decls must be a VarDecl");
DeclIdentifiers.push_back(ChildDecl->getID());
@@ -135,7 +135,7 @@ static void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
Remap(LBrace).getLocWithOffset(TokLen(LBrace) + 1);
const SourceLocation RangeEnd = Remap(RBrace).getLocWithOffset(-1);
- const llvm::StringRef Repl = Lexer::getSourceText(
+ const StringRef Repl = Lexer::getSourceText(
CharSourceRange::getTokenRange(RangeStart, RangeEnd),
Context.getSourceManager(), Context.getLangOpts());
Diag << tooling::fixit::createReplacement(CS->getSourceRange(), Repl);
@@ -143,7 +143,7 @@ static void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
const SourceLocation ElseExpandedLoc = Remap(ElseLoc);
const SourceLocation EndLoc = Remap(Else->getEndLoc());
- const llvm::StringRef Repl = Lexer::getSourceText(
+ const StringRef Repl = Lexer::getSourceText(
CharSourceRange::getTokenRange(
ElseExpandedLoc.getLocWithOffset(TokLen(ElseLoc) + 1), EndLoc),
Context.getSourceManager(), Context.getLangOpts());
@@ -277,7 +277,7 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) {
Diag << tooling::fixit::createReplacement(
SourceRange(If->getIfLoc()),
(tooling::fixit::getText(*If->getInit(), *Result.Context) +
- llvm::StringRef("\n"))
+ StringRef("\n"))
.str())
<< tooling::fixit::createRemoval(If->getInit()->getSourceRange());
}
@@ -285,7 +285,7 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) {
const VarDecl *VDecl = If->getConditionVariable();
const std::string Repl =
(tooling::fixit::getText(*VDeclStmt, *Result.Context) +
- llvm::StringRef(";\n") +
+ StringRef(";\n") +
tooling::fixit::getText(If->getIfLoc(), *Result.Context))
.str();
Diag << tooling::fixit::createReplacement(SourceRange(If->getIfLoc()),
diff --git a/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp
index d99143c875729..4612d94f3663b 100644
--- a/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp
@@ -181,7 +181,7 @@ void EnumInitialValueCheck::check(const MatchFinder::MatchResult &Result) {
ECD->getLocation(), 0, *Result.SourceManager, getLangOpts());
if (EndLoc.isMacroID())
continue;
- llvm::SmallString<8> Str{" = "};
+ SmallString<8> Str{" = "};
ECD->getInitVal().toString(Str);
Diag << FixItHint::CreateInsertion(EndLoc, Str);
}
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 83fc3727cb5c8..17fbfcf1fb181 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -242,8 +242,7 @@ IdentifierNamingCheck::NamingStyle::NamingStyle(
: Case(Case), Prefix(Prefix), Suffix(Suffix),
IgnoredRegexpStr(IgnoredRegexpStr), HPType(HPType) {
if (!IgnoredRegexpStr.empty()) {
- IgnoredRegexp =
- llvm::Regex(llvm::SmallString<128>({"^", IgnoredRegexpStr, "$"}));
+ IgnoredRegexp = llvm::Regex(SmallString<128>({"^", IgnoredRegexpStr, "$"}));
if (!IgnoredRegexp.isValid())
llvm::errs() << "Invalid IgnoredRegexp regular expression: "
<< IgnoredRegexpStr;
@@ -634,7 +633,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getDataTypePrefix(
return PrefixStr;
}
-llvm::StringRef IdentifierNamingCheck::HungarianNotation::getClassPrefix(
+StringRef IdentifierNamingCheck::HungarianNotation::getClassPrefix(
const CXXRecordDecl *CRD,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const {
if (CRD->isUnion())
@@ -1440,7 +1439,7 @@ IdentifierNamingCheck::getStyleForFile(StringRef FileName) const {
if (Iter != NamingStylesCache.end())
return Iter->getValue();
- const llvm::StringRef CheckName = getID();
+ const StringRef CheckName = getID();
ClangTidyOptions Options = Context->getOptionsForFile(RealFileName);
if (Options.Checks && GlobList(*Options.Checks).contains(CheckName)) {
auto It = NamingStylesCache.try_emplace(
diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
index b016556cc2ab8..0afc7e2246816 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
@@ -116,7 +116,7 @@ class IdentifierNamingCheck final : public RenamerClangTidyCheck {
StringRef TypeName, const NamedDecl *ND,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const;
- llvm::StringRef getClassPrefix(
+ StringRef getClassPrefix(
const CXXRecordDecl *CRD,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const;
diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
index e406532d78a01..eb7bb6f14e382 100644
--- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
@@ -39,7 +39,7 @@ struct DifferingParamInfo {
bool GenerateFixItHint;
};
-using DifferingParamsContainer = llvm::SmallVector<DifferingParamInfo, 10>;
+using DifferingParamsContainer = SmallVector<DifferingParamInfo, 10>;
struct InconsistentDeclarationInfo {
InconsistentDeclarationInfo(SourceLocation DeclarationLocation,
@@ -52,7 +52,7 @@ struct InconsistentDeclarationInfo {
};
using InconsistentDeclarationsContainer =
- llvm::SmallVector<InconsistentDeclarationInfo, 2>;
+ SmallVector<InconsistentDeclarationInfo, 2>;
} // namespace
@@ -195,7 +195,7 @@ getParameterSourceDeclaration(const FunctionDecl *OriginalDeclaration) {
static std::string joinParameterNames(
const DifferingParamsContainer &DifferingParams,
llvm::function_ref<StringRef(const DifferingParamInfo &)> ChooseParamName) {
- llvm::SmallString<40> Str;
+ SmallString<40> Str;
bool First = true;
for (const DifferingParamInfo &ParamInfo : DifferingParams) {
if (First)
diff --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index fb4690bd8c76b..acf9503f265fe 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -232,7 +232,7 @@ bool MagicNumbersCheck::isSyntheticValue(const SourceManager *SourceManager,
}
bool MagicNumbersCheck::isBitFieldWidth(
- const clang::ast_matchers::MatchFinder::MatchResult &Result,
+ const ast_matchers::MatchFinder::MatchResult &Result,
const IntegerLiteral &Literal) const {
return IgnoreBitFieldsWidths &&
llvm::any_of(Result.Context->getParents(Literal),
@@ -242,8 +242,8 @@ bool MagicNumbersCheck::isBitFieldWidth(
}
bool MagicNumbersCheck::isUserDefinedLiteral(
- const clang::ast_matchers::MatchFinder::MatchResult &Result,
- const clang::Expr &Literal) const {
+ const ast_matchers::MatchFinder::MatchResult &Result,
+ const Expr &Literal) const {
const DynTypedNodeList Parents = Result.Context->getParents(Literal);
if (Parents.empty())
return false;
diff --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
index 53954535ebe86..ca64880c030cf 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h
@@ -28,31 +28,29 @@ class MagicNumbersCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- bool isConstant(const clang::ast_matchers::MatchFinder::MatchResult &Result,
- const clang::Expr &ExprResult) const;
+ bool isConstant(const ast_matchers::MatchFinder::MatchResult &Result,
+ const Expr &ExprResult) const;
bool isIgnoredValue(const IntegerLiteral *Literal) const;
bool isIgnoredValue(const FloatingLiteral *Literal) const;
- bool isSyntheticValue(const clang::SourceManager *,
- const FloatingLiteral *) const {
+ bool isSyntheticValue(const SourceManager *, const FloatingLiteral *) const {
return false;
}
- bool isSyntheticValue(const clang::SourceManager *SourceManager,
+ bool isSyntheticValue(const SourceManager *SourceManager,
const IntegerLiteral *Literal) const;
- bool isBitFieldWidth(const clang::ast_matchers::MatchFinder::MatchResult &,
+ bool isBitFieldWidth(const ast_matchers::MatchFinder::MatchResult &,
const FloatingLiteral &) const {
return false;
}
- bool
- isBitFieldWidth(const clang::ast_matchers::MatchFinder::MatchResult &Result,
- const IntegerLiteral &Literal) const;
+ bool isBitFieldWidth(const ast_matchers::MatchFinder::MatchResult &Result,
+ const IntegerLiteral &Literal) const;
- bool isUserDefinedLiteral(
- const clang::ast_matchers::MatchFinder::MatchResult &Result,
- const clang::Expr &Literal) const;
+ bool
+ isUserDefinedLiteral(const ast_matchers::MatchFinder::MatchResult &Result,
+ const Expr &Literal) const;
template <typename L>
void checkBoundMatch(const ast_matchers::MatchFinder::MatchResult &Result,
@@ -103,11 +101,11 @@ class MagicNumbersCheck : public ClangTidyCheck {
constexpr static llvm::APFloat::roundingMode DefaultRoundingMode =
llvm::APFloat::rmNearestTiesToEven;
- llvm::SmallVector<int64_t, SensibleNumberOfMagicValueExceptions>
+ SmallVector<int64_t, SensibleNumberOfMagicValueExceptions>
IgnoredIntegerValues;
- llvm::SmallVector<float, SensibleNumberOfMagicValueExceptions>
+ SmallVector<float, SensibleNumberOfMagicValueExceptions>
IgnoredFloatingPointValues;
- llvm::SmallVector<double, SensibleNumberOfMagicValueExceptions>
+ SmallVector<double, SensibleNumberOfMagicValueExceptions>
IgnoredDoublePointValues;
};
diff --git a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
index 7564806464d34..e8875d014fe21 100644
--- a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
@@ -37,8 +37,8 @@ AST_MATCHER(CXXMethodDecl, isDependentContext) {
AST_MATCHER(CXXMethodDecl, isInsideMacroDefinition) {
const ASTContext &Ctxt = Finder->getASTContext();
- return clang::Lexer::makeFileCharRange(
- clang::CharSourceRange::getCharRange(
+ return Lexer::makeFileCharRange(
+ CharSourceRange::getCharRange(
Node.getTypeSourceInfo()->getTypeLoc().getSourceRange()),
Ctxt.getSourceManager(), Ctxt.getLangOpts())
.isInvalid();
diff --git a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
index 1d52aaa6de008..a9c1b6a688d98 100644
--- a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
@@ -49,9 +49,8 @@ static int getPrecedence(const BinaryOperator *BinOp) {
}
}
static void addParentheses(const Expr *E, const BinaryOperator *ParentBinOp,
- ClangTidyCheck *Check,
- const clang::SourceManager &SM,
- const clang::LangOptions &LangOpts) {
+ ClangTidyCheck *Check, const SourceManager &SM,
+ const LangOptions &LangOpts) {
if (const auto *Paren = dyn_cast<ParenExpr>(E)) {
addParentheses(Paren->getSubExpr()->IgnoreImpCasts(), nullptr, Check, SM,
LangOpts);
@@ -67,9 +66,9 @@ static void addParentheses(const Expr *E, const BinaryOperator *ParentBinOp,
if (ParentBinOp != nullptr && Precedence1 != Precedence2 && Precedence1 > 0 &&
Precedence2 > 0) {
- const clang::SourceLocation StartLoc = BinOp->getBeginLoc();
- const clang::SourceLocation EndLoc =
- clang::Lexer::getLocForEndOfToken(BinOp->getEndLoc(), 0, SM, LangOpts);
+ const SourceLocation StartLoc = BinOp->getBeginLoc();
+ const SourceLocation EndLoc =
+ Lexer::getLocForEndOfToken(BinOp->getEndLoc(), 0, SM, LangOpts);
auto Diag =
Check->diag(StartLoc,
@@ -95,7 +94,7 @@ void MathMissingParenthesesCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *BinOp = Result.Nodes.getNodeAs<BinaryOperator>("binOp");
const SourceManager &SM = *Result.SourceManager;
- const clang::LangOptions &LO = Result.Context->getLangOpts();
+ const LangOptions &LO = Result.Context->getLangOpts();
addParentheses(BinOp, nullptr, this, SM, LO);
}
diff --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
index 46f11027c970e..c457d682a1787 100644
--- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
@@ -67,7 +67,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) {
continue;
// Skip gmock testing::Unused parameters.
- if (const auto *Typedef = Parm->getType()->getAs<clang::TypedefType>())
+ if (const auto *Typedef = Parm->getType()->getAs<TypedefType>())
if (Typedef->getDecl()->getQualifiedNameAsString() == "testing::Unused")
continue;
diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h
index fe5736fad0d15..68902428e9bab 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h
@@ -35,7 +35,7 @@ class NamespaceCommentCheck : public ClangTidyCheck {
const unsigned ShortNamespaceLines;
const unsigned SpacesBeforeComments;
const bool AllowOmittingNamespaceComments;
- llvm::SmallVector<SourceLocation, 4> Ends;
+ SmallVector<SourceLocation, 4> Ends;
};
} // namespace clang::tidy::readability
diff --git a/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp b/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
index db1fb0aa3c834..82fba056f1de2 100644
--- a/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
@@ -36,8 +36,7 @@ static StringRef getOperatorSpelling(SourceLocation Loc, ASTContext &Context) {
namespace {
AST_MATCHER_P2(BinaryOperator, hasInvalidBinaryOperatorRepresentation,
- BinaryOperatorKind, Kind, llvm::StringRef,
- ExpectedRepresentation) {
+ BinaryOperatorKind, Kind, StringRef, ExpectedRepresentation) {
if (Node.getOpcode() != Kind || ExpectedRepresentation.empty())
return false;
@@ -47,8 +46,7 @@ AST_MATCHER_P2(BinaryOperator, hasInvalidBinaryOperatorRepresentation,
}
AST_MATCHER_P2(UnaryOperator, hasInvalidUnaryOperatorRepresentation,
- UnaryOperatorKind, Kind, llvm::StringRef,
- ExpectedRepresentation) {
+ UnaryOperatorKind, Kind, StringRef, ExpectedRepresentation) {
if (Node.getOpcode() != Kind || ExpectedRepresentation.empty())
return false;
@@ -58,7 +56,7 @@ AST_MATCHER_P2(UnaryOperator, hasInvalidUnaryOperatorRepresentation,
}
AST_MATCHER_P2(CXXOperatorCallExpr, hasInvalidOverloadedOperatorRepresentation,
- OverloadedOperatorKind, Kind, llvm::StringRef,
+ OverloadedOperatorKind, Kind, StringRef,
ExpectedRepresentation) {
if (Node.getOperator() != Kind || ExpectedRepresentation.empty())
return false;
@@ -70,10 +68,10 @@ AST_MATCHER_P2(CXXOperatorCallExpr, hasInvalidOverloadedOperatorRepresentation,
} // namespace
-constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 2U>
- UnaryRepresentation{{{"!", "not"}, {"~", "compl"}}};
+constexpr std::array<std::pair<StringRef, StringRef>, 2U> UnaryRepresentation{
+ {{"!", "not"}, {"~", "compl"}}};
-constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 9U>
+constexpr std::array<std::pair<StringRef, StringRef>, 9U>
OperatorsRepresentation{{{"&&", "and"},
{"||", "or"},
{"^", "xor"},
@@ -84,7 +82,7 @@ constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 9U>
{"!=", "not_eq"},
{"^=", "xor_eq"}}};
-static llvm::StringRef translate(llvm::StringRef Value) {
+static StringRef translate(StringRef Value) {
for (const auto &[Traditional, Alternative] : UnaryRepresentation) {
if (Value == Traditional)
return Alternative;
@@ -101,16 +99,16 @@ static llvm::StringRef translate(llvm::StringRef Value) {
return {};
}
-static bool isNotOperatorStr(llvm::StringRef Value) {
+static bool isNotOperatorStr(StringRef Value) {
return translate(Value).empty();
}
static bool isSeparator(char C) noexcept {
- constexpr llvm::StringRef Separators(" \t\r\n\0()<>{};,");
+ constexpr StringRef Separators(" \t\r\n\0()<>{};,");
return Separators.contains(C);
}
-static bool needEscaping(llvm::StringRef Operator) {
+static bool needEscaping(StringRef Operator) {
switch (Operator[0]) {
case '&':
case '|':
@@ -123,9 +121,9 @@ static bool needEscaping(llvm::StringRef Operator) {
}
}
-static llvm::StringRef
-getRepresentation(const std::vector<llvm::StringRef> &Config,
- llvm::StringRef Traditional, llvm::StringRef Alternative) {
+static StringRef getRepresentation(const std::vector<StringRef> &Config,
+ StringRef Traditional,
+ StringRef Alternative) {
if (llvm::is_contained(Config, Traditional))
return Traditional;
if (llvm::is_contained(Config, Alternative))
@@ -134,7 +132,7 @@ getRepresentation(const std::vector<llvm::StringRef> &Config,
}
template <typename T>
-static bool isAnyOperatorEnabled(const std::vector<llvm::StringRef> &Config,
+static bool isAnyOperatorEnabled(const std::vector<StringRef> &Config,
const T &Operators) {
return llvm::any_of(Operators, [&](const auto &Op) {
return !getRepresentation(Config, Op.first, Op.second).empty();
diff --git a/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.h b/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.h
index 2ce8ac0161bf9..1bbe5712aed02 100644
--- a/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.h
@@ -33,8 +33,8 @@ class OperatorsRepresentationCheck : public ClangTidyCheck {
void registerUnaryOperatorMatcher(ast_matchers::MatchFinder *Finder);
void registerOverloadedOperatorMatcher(ast_matchers::MatchFinder *Finder);
- std::vector<llvm::StringRef> BinaryOperators;
- std::vector<llvm::StringRef> OverloadedOperators;
+ std::vector<StringRef> BinaryOperators;
+ std::vector<StringRef> OverloadedOperators;
};
} // namespace clang::tidy::readability
diff --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
index afb8c800a70e2..4ba80541ad565 100644
--- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
@@ -120,7 +120,7 @@ void QualifiedAutoCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
auto ExplicitSingleVarDecl =
[](const ast_matchers::internal::Matcher<VarDecl> &InnerMatcher,
- llvm::StringRef ID) {
+ StringRef ID) {
return declStmt(
unless(isInTemplateInstantiation()),
hasSingleDecl(
@@ -128,7 +128,7 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
};
auto ExplicitSingleVarDeclInTemplate =
[](const ast_matchers::internal::Matcher<VarDecl> &InnerMatcher,
- llvm::StringRef ID) {
+ StringRef ID) {
return declStmt(
isInTemplateInstantiation(),
hasSingleDecl(
@@ -197,7 +197,7 @@ void QualifiedAutoCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- llvm::SmallVector<SourceRange, 4> RemoveQualifiersRange;
+ SmallVector<SourceRange, 4> RemoveQualifiersRange;
auto CheckQualifier = [&](bool IsPresent, Qualifier Qual) {
if (IsPresent) {
std::optional<Token> Token = findQualToken(Var, Qual, Result);
diff --git a/clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp b/clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp
index 3700bdce2ba4e..7a74651b454b3 100644
--- a/clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp
@@ -32,13 +32,13 @@ struct NotExtendedByDeclBoundToPredicate {
}
StringRef ID;
- ::clang::DynTypedNode Node;
+ DynTypedNode Node;
};
AST_MATCHER_P(MaterializeTemporaryExpr, isExtendedByDeclBoundTo, StringRef,
ID) {
- const NotExtendedByDeclBoundToPredicate Predicate{
- ID, ::clang::DynTypedNode::create(Node)};
+ const NotExtendedByDeclBoundToPredicate Predicate{ID,
+ DynTypedNode::create(Node)};
return Builder->removeBindings(Predicate);
}
diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index 040f6fb8c843c..b0e95c0afc184 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -806,7 +806,7 @@ void SimplifyBooleanExprCheck::replaceWithAssignment(const ASTContext &Context,
}
/// Swaps a \c BinaryOperator opcode from `&&` to `||` or vice-versa.
-static bool flipDemorganOperator(llvm::SmallVectorImpl<FixItHint> &Output,
+static bool flipDemorganOperator(SmallVectorImpl<FixItHint> &Output,
const BinaryOperator *BO) {
assert(BO->isLogicalOp());
if (BO->getOperatorLoc().isMacroID())
diff --git a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
index 6255bbd9e5778..d8145700f5a9d 100644
--- a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
@@ -25,7 +25,7 @@ AST_MATCHER(IfStmt, isIfInMacro) {
} // namespace
-static const llvm::StringRef AlgorithmHeader("<algorithm>");
+static constexpr StringRef AlgorithmHeader = "<algorithm>";
static bool minCondition(const BinaryOperator::Opcode Op, const Expr *CondLhs,
const Expr *CondRhs, const Expr *AssignLhs,
@@ -85,9 +85,9 @@ static QualType getReplacementCastType(const Expr *CondLhs, const Expr *CondRhs,
RhsType.getCanonicalType().getNonReferenceType().getUnqualifiedType();
QualType GlobalImplicitCastType;
if (LhsCanonicalType != RhsCanonicalType) {
- if (llvm::isa<IntegerLiteral>(CondRhs))
+ if (isa<IntegerLiteral>(CondRhs))
GlobalImplicitCastType = getNonTemplateAlias(LhsType);
- else if (llvm::isa<IntegerLiteral>(CondLhs))
+ else if (isa<IntegerLiteral>(CondLhs))
GlobalImplicitCastType = getNonTemplateAlias(RhsType);
else
GlobalImplicitCastType = getNonTemplateAlias(ComparedType);
@@ -100,11 +100,11 @@ createReplacement(const Expr *CondLhs, const Expr *CondRhs,
const Expr *AssignLhs, const SourceManager &Source,
const LangOptions &LO, StringRef FunctionName,
const BinaryOperator *BO, StringRef Comment = "") {
- const llvm::StringRef CondLhsStr = Lexer::getSourceText(
+ const StringRef CondLhsStr = Lexer::getSourceText(
Source.getExpansionRange(CondLhs->getSourceRange()), Source, LO);
- const llvm::StringRef CondRhsStr = Lexer::getSourceText(
+ const StringRef CondRhsStr = Lexer::getSourceText(
Source.getExpansionRange(CondRhs->getSourceRange()), Source, LO);
- const llvm::StringRef AssignLhsStr = Lexer::getSourceText(
+ const StringRef AssignLhsStr = Lexer::getSourceText(
Source.getExpansionRange(AssignLhs->getSourceRange()), Source, LO);
const QualType GlobalImplicitCastType =
@@ -159,21 +159,21 @@ void UseStdMinMaxCheck::registerPPCallbacks(const SourceManager &SM,
void UseStdMinMaxCheck::check(const MatchFinder::MatchResult &Result) {
const auto *If = Result.Nodes.getNodeAs<IfStmt>("if");
- const clang::LangOptions &LO = Result.Context->getLangOpts();
+ const LangOptions &LO = Result.Context->getLangOpts();
const auto *CondLhs = Result.Nodes.getNodeAs<Expr>("CondLhs");
const auto *CondRhs = Result.Nodes.getNodeAs<Expr>("CondRhs");
const auto *AssignLhs = Result.Nodes.getNodeAs<Expr>("AssignLhs");
const auto *AssignRhs = Result.Nodes.getNodeAs<Expr>("AssignRhs");
const auto *BinaryOp = Result.Nodes.getNodeAs<BinaryOperator>("binaryOp");
- const clang::BinaryOperatorKind BinaryOpcode = BinaryOp->getOpcode();
+ const BinaryOperatorKind BinaryOpcode = BinaryOp->getOpcode();
const SourceLocation IfLocation = If->getIfLoc();
const SourceLocation ThenLocation = If->getEndLoc();
- auto ReplaceAndDiagnose = [&](const llvm::StringRef FunctionName) {
+ auto ReplaceAndDiagnose = [&](const StringRef FunctionName) {
const SourceManager &Source = *Result.SourceManager;
- llvm::SmallString<64> Comment;
+ SmallString<64> Comment;
- const auto AppendNormalized = [&](llvm::StringRef Text) {
+ const auto AppendNormalized = [&](StringRef Text) {
Text = Text.ltrim();
if (!Text.empty()) {
if (!Comment.empty())
@@ -210,16 +210,13 @@ void UseStdMinMaxCheck::check(const MatchFinder::MatchResult &Result) {
// Captures:
// if (cond) { x = y; // Comment C }
// if (cond) { x = y; /* Comment C */ }
- llvm::StringRef PostInner =
- GetSourceText(Inner->getEndLoc(), CS->getEndLoc());
+ StringRef PostInner = GetSourceText(Inner->getEndLoc(), CS->getEndLoc());
// Strip the trailing semicolon to avoid fixes like:
// x = std::min(x, y);; // comment
const size_t Semi = PostInner.find(';');
- if (Semi != llvm::StringRef::npos &&
- PostInner.take_front(Semi).trim().empty()) {
+ if (Semi != StringRef::npos && PostInner.take_front(Semi).trim().empty())
PostInner = PostInner.drop_front(Semi + 1);
- }
AppendNormalized(PostInner);
}
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 85e4cf6256dd3..f61e2f40ed03b 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -531,7 +531,7 @@ static bool verifyChecks(const StringSet<> &AllChecks, StringRef CheckGlob,
llvm::raw_ostream &Output =
llvm::WithColor::warning(llvm::errs(), Source)
<< "unknown check '" << Item.Text << '\'';
- const llvm::StringRef Closest = closest(Item.Text, AllChecks);
+ const StringRef Closest = closest(Item.Text, AllChecks);
if (!Closest.empty())
Output << "; did you mean '" << Closest << '\'';
Output << VerifyConfigWarningEnd;
@@ -571,7 +571,7 @@ static bool verifyOptions(const llvm::StringSet<> &ValidOptions,
AnyInvalid = true;
auto &Output = llvm::WithColor::warning(llvm::errs(), Source)
<< "unknown check option '" << Key << '\'';
- const llvm::StringRef Closest = closest(Key, ValidOptions);
+ const StringRef Closest = closest(Key, ValidOptions);
if (!Closest.empty())
Output << "; did you mean '" << Closest << '\'';
Output << VerifyConfigWarningEnd;
@@ -579,7 +579,7 @@ static bool verifyOptions(const llvm::StringSet<> &ValidOptions,
return AnyInvalid;
}
-static SmallString<256> makeAbsolute(llvm::StringRef Input) {
+static SmallString<256> makeAbsolute(StringRef Input) {
if (Input.empty())
return {};
SmallString<256> AbsolutePath(Input);
@@ -660,8 +660,8 @@ int clangTidyMain(int argc, const char **argv) {
if (ExplainConfig) {
// FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
- std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
- RawOptions = OptionsProvider->getRawOptions(FilePath);
+ std::vector<ClangTidyOptionsProvider::OptionsSource> RawOptions =
+ OptionsProvider->getRawOptions(FilePath);
for (const std::string &Check : EnabledChecks) {
for (const auto &[Opts, Source] : llvm::reverse(RawOptions)) {
if (Opts.Checks && GlobList(*Opts.Checks).contains(Check)) {
diff --git a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
index c8d59a9c63c14..4baef7539008a 100644
--- a/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
@@ -100,8 +100,8 @@ bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt,
if (isa<Expr>(FirstStmt) && isa<Expr>(SecondStmt)) {
// If we have errors in expressions, we will be unable
// to accurately profile and compute hashes for each statements.
- if (llvm::cast<Expr>(FirstStmt)->containsErrors() ||
- llvm::cast<Expr>(SecondStmt)->containsErrors())
+ if (cast<Expr>(FirstStmt)->containsErrors() ||
+ cast<Expr>(SecondStmt)->containsErrors())
return false;
}
diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index 3510b3546bbba..fbcdd1004cec0 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -181,7 +181,7 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, Indirections) {
int Indirections;
};
- llvm::SmallVector<StackEntry, 4> Stack;
+ SmallVector<StackEntry, 4> Stack;
Stack.emplace_back(&Node, Indirections);
ASTContext &Ctx = Finder->getASTContext();
diff --git a/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp b/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp
index e22ae8a5095be..908a1b5ec4e09 100644
--- a/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.cpp
@@ -20,7 +20,7 @@
namespace clang::tidy::utils {
/// Returns true if Name is reserved, like _Foo or __Vector_base.
-static inline bool isReservedName(llvm::StringRef Name) {
+static inline bool isReservedName(StringRef Name) {
// This doesn't catch all cases, but the most common.
return Name.size() >= 2 && Name[0] == '_' &&
(isUppercase(Name[1]) || Name[1] == '_');
@@ -47,7 +47,7 @@ class AggregateDesignatorNames {
Valid = true;
FieldsIt = RD->field_begin();
FieldsEnd = RD->field_end();
- if (const auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
+ if (const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
BasesIt = CRD->bases_begin();
BasesEnd = CRD->bases_end();
Valid = CRD->isAggregate();
@@ -80,7 +80,7 @@ class AggregateDesignatorNames {
if (BasesIt != BasesEnd)
return false; // Bases can't be designated. Should we make one up?
if (FieldsIt != FieldsEnd) {
- llvm::StringRef FieldName;
+ StringRef FieldName;
if (const IdentifierInfo *II = FieldsIt->getIdentifier())
FieldName = II->getName();
@@ -148,10 +148,10 @@ static void collectDesignators(
});
// Skip for a broken initializer or if it is a "hole" in a subobject that
// was not explicitly initialized.
- if (!Init || llvm::isa<ImplicitValueInitExpr>(Init))
+ if (!Init || isa<ImplicitValueInitExpr>(Init))
continue;
- const auto *BraceElidedSubobject = llvm::dyn_cast<InitListExpr>(Init);
+ const auto *BraceElidedSubobject = dyn_cast<InitListExpr>(Init);
if (BraceElidedSubobject &&
NestedBraces.contains(BraceElidedSubobject->getLBraceLoc()))
BraceElidedSubobject = nullptr; // there were braces!
@@ -180,7 +180,7 @@ getUnwrittenDesignators(const InitListExpr *Syn) {
// Instead, record where braces of sub-init-lists occur in the syntactic form.
llvm::DenseSet<SourceLocation> NestedBraces;
for (const Expr *Init : Syn->inits())
- if (auto *Nested = llvm::dyn_cast<InitListExpr>(Init))
+ if (auto *Nested = dyn_cast<InitListExpr>(Init))
NestedBraces.insert(Nested->getLBraceLoc());
// Traverse the semantic form to find the designators.
diff --git a/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.h b/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.h
index 1960eabf074c5..e1dca2bdf65df 100644
--- a/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.h
+++ b/clang-tools-extra/clang-tidy/utils/DesignatedInitializers.h
@@ -39,8 +39,8 @@ namespace clang::tidy::utils {
/// It also considers structs with fields of record types like
/// `struct T { S s; };`. In this case, there would be designators of the
/// form `.s.i` and `.s.j` in the returned map.
-llvm::DenseMap<clang::SourceLocation, std::string>
-getUnwrittenDesignators(const clang::InitListExpr *Syn);
+llvm::DenseMap<SourceLocation, std::string>
+getUnwrittenDesignators(const InitListExpr *Syn);
} // namespace clang::tidy::utils
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 60dade82e6155..2a54de88dc4d6 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -357,7 +357,7 @@ static bool canThrow(const FunctionDecl *Func) {
ExceptionAnalyzer::ExceptionInfo::Throwables
ExceptionAnalyzer::ExceptionInfo::filterByCatch(const Type *HandlerTy,
const ASTContext &Context) {
- llvm::SmallVector<const Type *, 8> TypesToDelete;
+ SmallVector<const Type *, 8> TypesToDelete;
for (const auto &ThrownException : ThrownExceptions) {
const Type *ExceptionTy = ThrownException.getFirst();
const CanQualType ExceptionCanTy =
@@ -427,7 +427,7 @@ ExceptionAnalyzer::ExceptionInfo::filterByCatch(const Type *HandlerTy,
ExceptionAnalyzer::ExceptionInfo &
ExceptionAnalyzer::ExceptionInfo::filterIgnoredExceptions(
const llvm::StringSet<> &IgnoredTypes, bool IgnoreBadAlloc) {
- llvm::SmallVector<const Type *, 8> TypesToDelete;
+ SmallVector<const Type *, 8> TypesToDelete;
// Note: Using a 'SmallSet' with 'llvm::remove_if()' is not possible.
// Therefore this slightly hacky implementation is required.
for (const auto &ThrownException : ThrownExceptions) {
diff --git a/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp b/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
index 699b6b7d083f2..e75782ed6795a 100644
--- a/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
@@ -67,9 +67,9 @@ static bool isDescendantOfArgs(const Stmt *Descendant, const CallExpr *Call,
});
}
-static llvm::SmallVector<const InitListExpr *>
+static SmallVector<const InitListExpr *>
getAllInitListForms(const InitListExpr *InitList) {
- llvm::SmallVector<const InitListExpr *> Result = {InitList};
+ SmallVector<const InitListExpr *> Result = {InitList};
if (const InitListExpr *AltForm = InitList->getSyntacticForm())
Result.push_back(AltForm);
if (const InitListExpr *AltForm = InitList->getSemanticForm())
diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
index 9eca12fe19bf1..9624148411eac 100644
--- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -235,11 +235,10 @@ bool areParensNeededForStatement(const Stmt &Node) {
if (isa<ParenExpr>(&Node))
return false;
- if (isa<clang::BinaryOperator>(&Node) || isa<UnaryOperator>(&Node))
+ if (isa<BinaryOperator, UnaryOperator>(&Node))
return true;
- if (isa<clang::ConditionalOperator>(&Node) ||
- isa<BinaryConditionalOperator>(&Node))
+ if (isa<ConditionalOperator, BinaryConditionalOperator>(&Node))
return true;
if (const auto *Op = dyn_cast<CXXOperatorCallExpr>(&Node))
@@ -268,10 +267,8 @@ bool areParensNeededForStatement(const Stmt &Node) {
// prefix unary operator, e.g. when it is a binary or ternary operator
// syntactically.
static bool needParensAfterUnaryOperator(const Expr &ExprNode) {
- if (isa<clang::BinaryOperator>(&ExprNode) ||
- isa<clang::ConditionalOperator>(&ExprNode)) {
+ if (isa<BinaryOperator, ConditionalOperator>(&ExprNode))
return true;
- }
if (const auto *Op = dyn_cast<CXXOperatorCallExpr>(&ExprNode)) {
return Op->getNumArgs() == 2 && Op->getOperator() != OO_PlusPlus &&
Op->getOperator() != OO_MinusMinus && Op->getOperator() != OO_Call &&
@@ -283,7 +280,7 @@ static bool needParensAfterUnaryOperator(const Expr &ExprNode) {
// Format a pointer to an expression: prefix with '*' but simplify
// when it already begins with '&'. Return empty string on failure.
std::string formatDereference(const Expr &ExprNode, const ASTContext &Context) {
- if (const auto *Op = dyn_cast<clang::UnaryOperator>(&ExprNode)) {
+ if (const auto *Op = dyn_cast<UnaryOperator>(&ExprNode)) {
if (Op->getOpcode() == UO_AddrOf) {
// Strip leading '&'.
return std::string(
diff --git a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
index 1f6614141196a..070a286fdebc4 100644
--- a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
@@ -32,10 +32,10 @@ using clang::analyze_format_string::ConversionSpecifier;
/// Is the passed type the actual "char" type, whether that be signed or
/// unsigned, rather than explicit signed char or unsigned char types.
-static bool isRealCharType(const clang::QualType &Ty) {
+static bool isRealCharType(const QualType &Ty) {
using namespace clang;
const Type *DesugaredType = Ty->getUnqualifiedDesugaredType();
- if (const auto *BT = llvm::dyn_cast<BuiltinType>(DesugaredType))
+ if (const auto *BT = dyn_cast<BuiltinType>(DesugaredType))
return (BT->getKind() == BuiltinType::Char_U ||
BT->getKind() == BuiltinType::Char_S);
return false;
@@ -45,10 +45,10 @@ static bool isRealCharType(const clang::QualType &Ty) {
/// passed integer type. If the passed type is already signed then its name is
/// just returned. Only supports BuiltinTypes.
static std::optional<std::string>
-getCorrespondingSignedTypeName(const clang::QualType &QT) {
+getCorrespondingSignedTypeName(const QualType &QT) {
using namespace clang;
const auto UQT = QT.getUnqualifiedType();
- if (const auto *BT = llvm::dyn_cast<BuiltinType>(UQT)) {
+ if (const auto *BT = dyn_cast<BuiltinType>(UQT)) {
switch (BT->getKind()) {
case BuiltinType::UChar:
case BuiltinType::Char_U:
@@ -97,10 +97,10 @@ getCorrespondingSignedTypeName(const clang::QualType &QT) {
/// the passed integer type. If the passed type is already unsigned then its
/// name is just returned. Only supports BuiltinTypes.
static std::optional<std::string>
-getCorrespondingUnsignedTypeName(const clang::QualType &QT) {
+getCorrespondingUnsignedTypeName(const QualType &QT) {
using namespace clang;
const auto UQT = QT.getUnqualifiedType();
- if (const auto *BT = llvm::dyn_cast<BuiltinType>(UQT)) {
+ if (const auto *BT = dyn_cast<BuiltinType>(UQT)) {
switch (BT->getKind()) {
case BuiltinType::SChar:
case BuiltinType::Char_S:
@@ -148,16 +148,15 @@ getCorrespondingUnsignedTypeName(const clang::QualType &QT) {
}
static std::optional<std::string>
-castTypeForArgument(ConversionSpecifier::Kind ArgKind,
- const clang::QualType &QT) {
+castTypeForArgument(ConversionSpecifier::Kind ArgKind, const QualType &QT) {
if (ArgKind == ConversionSpecifier::Kind::uArg)
return getCorrespondingUnsignedTypeName(QT);
return getCorrespondingSignedTypeName(QT);
}
static bool isMatchingSignedness(ConversionSpecifier::Kind ArgKind,
- const clang::QualType &ArgType) {
- if (const auto *BT = llvm::dyn_cast<BuiltinType>(ArgType)) {
+ const QualType &ArgType) {
+ if (const auto *BT = dyn_cast<BuiltinType>(ArgType)) {
// Unadorned char never matches any expected signedness since it
// could be signed or unsigned.
const auto ArgTypeKind = BT->getKind();
@@ -172,9 +171,7 @@ static bool isMatchingSignedness(ConversionSpecifier::Kind ArgKind,
}
namespace {
-AST_MATCHER(clang::QualType, isRealChar) {
- return clang::tidy::utils::isRealCharType(Node);
-}
+AST_MATCHER(QualType, isRealChar) { return utils::isRealCharType(Node); }
} // namespace
static bool castMismatchedIntegerTypes(const CallExpr *Call, bool StrictMode) {
@@ -207,7 +204,7 @@ FormatStringConverter::FormatStringConverter(
Args(Call->getArgs()), NumArgs(Call->getNumArgs()),
ArgsOffset(FormatArgOffset + 1), LangOpts(LO) {
assert(ArgsOffset <= NumArgs);
- FormatExpr = llvm::dyn_cast<StringLiteral>(
+ FormatExpr = dyn_cast<StringLiteral>(
Args[FormatArgOffset]->IgnoreUnlessSpelledInSource());
assert(FormatExpr && FormatExpr->isOrdinary());
@@ -450,7 +447,7 @@ void FormatStringConverter::emitStringArgument(unsigned ArgIndex,
bool FormatStringConverter::emitIntegerArgument(
ConversionSpecifier::Kind ArgKind, const Expr *Arg, unsigned ArgIndex,
std::string &FormatSpec) {
- const clang::QualType &ArgType = Arg->getType();
+ const QualType &ArgType = Arg->getType();
if (ArgType->isBooleanType()) {
// std::format will print bool as either "true" or "false" by default,
// but printf prints them as "0" or "1". Be compatible with printf by
@@ -521,7 +518,7 @@ bool FormatStringConverter::emitType(const PrintfSpecifier &FS, const Expr *Arg,
return false;
break;
case ConversionSpecifier::Kind::pArg: {
- const clang::QualType &ArgType = Arg->getType();
+ const QualType &ArgType = Arg->getType();
// std::format knows how to format void pointers and nullptrs
if (!ArgType->isNullPtrType() && !ArgType->isVoidPointerType())
ArgFixes.emplace_back(FS.getArgIndex() + ArgsOffset,
diff --git a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
index 209741fac276c..e413b9f4c79f0 100644
--- a/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
+++ b/clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
@@ -65,8 +65,7 @@ class FormatStringConverter
StringRef PrintfFormatString;
/// Lazily-created c_str() call matcher
- std::optional<clang::ast_matchers::StatementMatcher>
- StringCStrCallExprMatcher;
+ std::optional<ast_matchers::StatementMatcher> StringCStrCallExprMatcher;
const StringLiteral *FormatExpr;
std::string StandardFormatString;
@@ -82,7 +81,7 @@ class FormatStringConverter
};
std::vector<ArgumentFix> ArgFixes;
- std::vector<clang::ast_matchers::BoundNodes> ArgCStrRemovals;
+ std::vector<ast_matchers::BoundNodes> ArgCStrRemovals;
// Argument rotations to cope with the fact that std::print puts the value to
// be formatted first and the width and precision afterwards whereas printf
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
index 81bb8dec57a74..1ba5d96d06e4b 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -68,7 +68,7 @@ IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) {
}
std::optional<FixItHint>
-IncludeInserter::createIncludeInsertion(FileID FileID, llvm::StringRef Header) {
+IncludeInserter::createIncludeInsertion(FileID FileID, StringRef Header) {
const bool IsAngled = Header.consume_front("<");
if (IsAngled != Header.consume_back(">"))
return std::nullopt;
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
index 9dbf2a76369cd..95e497aed0e1e 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ b/clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -72,15 +72,14 @@ class IncludeInserter {
/// Returns ``std::nullopt`` on error or if the inclusion directive already
/// exists.
std::optional<FixItHint> createIncludeInsertion(FileID FileID,
- llvm::StringRef Header);
+ StringRef Header);
/// Creates a \p Header inclusion directive fixit in the main file.
/// When \p Header is enclosed in angle brackets, uses angle brackets in the
/// inclusion directive, otherwise uses quotes.
/// Returns ``std::nullopt`` on error or if the inclusion directive already
/// exists.
- std::optional<FixItHint>
- createMainFileIncludeInsertion(llvm::StringRef Header);
+ std::optional<FixItHint> createMainFileIncludeInsertion(StringRef Header);
IncludeSorter::IncludeStyle getStyle() const { return Style; }
diff --git a/clang-tools-extra/clang-tidy/utils/Matchers.cpp b/clang-tools-extra/clang-tidy/utils/Matchers.cpp
index b1591fb8e3619..89cf09a28a1b6 100644
--- a/clang-tools-extra/clang-tidy/utils/Matchers.cpp
+++ b/clang-tools-extra/clang-tidy/utils/Matchers.cpp
@@ -12,7 +12,7 @@
namespace clang::tidy::matchers {
bool NotIdenticalStatementsPredicate::operator()(
- const clang::ast_matchers::internal::BoundNodesMap &Nodes) const {
+ const ast_matchers::internal::BoundNodesMap &Nodes) const {
return !utils::areStatementsIdentical(Node.get<Stmt>(),
Nodes.getNodeAs<Stmt>(ID), *Context);
}
diff --git a/clang-tools-extra/clang-tidy/utils/Matchers.h b/clang-tools-extra/clang-tidy/utils/Matchers.h
index 4637809c17c81..674f871493dfd 100644
--- a/clang-tools-extra/clang-tidy/utils/Matchers.h
+++ b/clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -82,9 +82,8 @@ class MatchesAnyListedRegexNameMatcher
public:
explicit MatchesAnyListedRegexNameMatcher(
llvm::ArrayRef<StringRef> NameList) {
- llvm::transform(
- NameList, std::back_inserter(NameMatchers),
- [](const llvm::StringRef Name) { return NameMatcher(Name); });
+ llvm::transform(NameList, std::back_inserter(NameMatchers),
+ [](const StringRef Name) { return NameMatcher(Name); });
}
class NameMatcher {
@@ -103,7 +102,7 @@ class MatchesAnyListedRegexNameMatcher
MatchMode Mode;
public:
- NameMatcher(const llvm::StringRef Regex)
+ NameMatcher(const StringRef Regex)
: Regex(Regex), Mode(determineMatchMode(Regex)) {}
bool match(const NamedDecl &ND) const {
@@ -120,7 +119,7 @@ class MatchesAnyListedRegexNameMatcher
}
private:
- MatchMode determineMatchMode(llvm::StringRef Regex) {
+ MatchMode determineMatchMode(StringRef Regex) {
if (Regex.starts_with(":") || Regex.starts_with("^:"))
return MatchMode::MatchFullyQualified;
return Regex.contains(":") ? MatchMode::MatchQualified
diff --git a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.h b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.h
index fbf0ade3b0cc7..6a8eab4bbd132 100644
--- a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.h
+++ b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.h
@@ -28,14 +28,13 @@ class NamespaceAliaser {
// Statement. Picks the first available name from \p Abbreviations.
// Returns ``std::nullopt`` if an alias already exists or there is an error.
std::optional<FixItHint>
- createAlias(ASTContext &Context, const Stmt &Statement,
- llvm::StringRef Namespace,
+ createAlias(ASTContext &Context, const Stmt &Statement, StringRef Namespace,
const std::vector<std::string> &Abbreviations);
// Get an alias name for \p Namespace valid at \p Statement. Returns \p
// Namespace if there is no alias.
std::string getNamespaceName(ASTContext &Context, const Stmt &Statement,
- llvm::StringRef Namespace) const;
+ StringRef Namespace) const;
private:
const SourceManager &SourceMgr;
diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 5ad96a5e4c0f2..0e4a6f49116da 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -153,7 +153,7 @@ static NameLookup findDeclInBases(const CXXRecordDecl &Parent,
if (!Record && AggressiveTemplateLookup) {
if (const auto *TST =
Base.getType()->getAs<TemplateSpecializationType>()) {
- if (const auto *TD = llvm::dyn_cast_or_null<ClassTemplateDecl>(
+ if (const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(
TST->getTemplateName().getAsTemplateDecl()))
Record = TD->getTemplatedDecl();
}
diff --git a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
index 30fbfffd9981c..1a1b0e1dba629 100644
--- a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
@@ -110,9 +110,9 @@ void UseRangesCheck::registerMatchers(MatchFinder *Finder) {
auto Replaces = getReplacerMap();
ReverseDescriptor = getReverseDescriptor();
auto BeginEndNames = getFreeBeginEndMethods();
- const llvm::SmallVector<StringRef, 4> BeginNames{
+ const SmallVector<StringRef, 4> BeginNames{
llvm::make_first_range(BeginEndNames)};
- const llvm::SmallVector<StringRef, 4> EndNames{
+ const SmallVector<StringRef, 4> EndNames{
llvm::make_second_range(BeginEndNames)};
Replacers.clear();
llvm::DenseSet<Replacer *> SeenRepl;
@@ -163,7 +163,7 @@ void UseRangesCheck::registerMatchers(MatchFinder *Finder) {
static void removeFunctionArgs(DiagnosticBuilder &Diag, const CallExpr &Call,
ArrayRef<unsigned> Indexes,
const ASTContext &Ctx) {
- llvm::SmallVector<unsigned> Sorted(Indexes);
+ SmallVector<unsigned> Sorted(Indexes);
llvm::sort(Sorted);
// Keep track of commas removed
llvm::SmallBitVector Commas(Call.getNumArgs());
@@ -233,7 +233,7 @@ void UseRangesCheck::check(const MatchFinder::MatchResult &Result) {
if (auto Include = Replacer->getHeaderInclusion(*Function))
Diag << Inserter.createIncludeInsertion(
Result.SourceManager->getFileID(Call->getBeginLoc()), *Include);
- llvm::SmallVector<unsigned, 3> ToRemove;
+ SmallVector<unsigned, 3> ToRemove;
for (const auto &[First, Second, Replace] : Sig) {
auto ArgNode = ArgName + std::to_string(First);
if (const auto *ArgExpr = Result.Nodes.getNodeAs<Expr>(ArgNode)) {
diff --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.h b/clang-tools-extra/clang-tidy/utils/UsingInserter.h
index 3e943569047ae..f39009a7db6e4 100644
--- a/clang-tools-extra/clang-tidy/utils/UsingInserter.h
+++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.h
@@ -27,14 +27,14 @@ class UsingInserter {
// Creates a \p using declaration fixit. Returns ``std::nullopt`` on error
// or if the using declaration already exists.
- std::optional<FixItHint>
- createUsingDeclaration(ASTContext &Context, const Stmt &Statement,
- llvm::StringRef QualifiedName);
+ std::optional<FixItHint> createUsingDeclaration(ASTContext &Context,
+ const Stmt &Statement,
+ StringRef QualifiedName);
// Returns the unqualified version of the name if there is an
// appropriate using declaration and the qualified name otherwise.
- llvm::StringRef getShortName(ASTContext &Context, const Stmt &Statement,
- llvm::StringRef QualifiedName);
+ StringRef getShortName(ASTContext &Context, const Stmt &Statement,
+ StringRef QualifiedName);
private:
using NameInFunction = std::pair<const FunctionDecl *, std::string>;
More information about the cfe-commits
mailing list