aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bolt/include/bolt/Core/BinaryContext.h2
-rw-r--r--bolt/include/bolt/Core/BinaryFunction.h28
-rw-r--r--bolt/lib/Core/BinaryContext.cpp11
-rw-r--r--bolt/lib/Rewrite/RewriteInstance.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidy.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp12
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp20
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp18
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp32
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp5
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp5
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp3
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp40
-rw-r--r--clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt2
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp (renamed from clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccess.cpp)15
-rw-r--r--clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h (renamed from clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccess.h)16
-rw-r--r--clang-tools-extra/clang-tidy/misc/CMakeLists.txt6
-rw-r--r--clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp (renamed from clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp)2
-rw-r--r--clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.h (renamed from clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h)10
-rw-r--r--clang-tools-extra/clang-tidy/misc/MisleadingIdentifierCheck.cpp (renamed from clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp)2
-rw-r--r--clang-tools-extra/clang-tidy/misc/MisleadingIdentifierCheck.h (renamed from clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h)12
-rw-r--r--clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp (renamed from clang-tools-extra/clang-tidy/misc/NonCopyableObjects.cpp)2
-rw-r--r--clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.h (renamed from clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h)11
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp10
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp10
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp27
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp31
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp5
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp2
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp51
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp6
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp7
-rw-r--r--clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp (renamed from clang-tools-extra/clang-tidy/objc/AssertEquals.cpp)7
-rw-r--r--clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.h (renamed from clang-tools-extra/clang-tidy/objc/AssertEquals.h)12
-rw-r--r--clang-tools-extra/clang-tidy/objc/CMakeLists.txt2
-rw-r--r--clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/performance/CMakeLists.txt2
-rw-r--r--clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp4
-rw-r--r--clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp (renamed from clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp)20
-rw-r--r--clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h (renamed from clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h)13
-rw-r--r--clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp (renamed from clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp)10
-rw-r--r--clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.h (renamed from clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h)13
-rw-r--r--clang-tools-extra/clang-tidy/readability/CMakeLists.txt4
-rw-r--r--clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp (renamed from clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp)7
-rw-r--r--clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.h (renamed from clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.h)12
-rw-r--r--clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp1
-rw-r--r--clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp8
-rw-r--r--clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp26
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/assignment-in-if-condition.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/derived-method-shadowing-base-method.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-shared-from-this.rst10
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-realloc-usage.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/bugprone/unsafe-functions.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst3
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.rst8
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-static-over-anonymous-namespace.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/llvm/use-ranges.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc/misleading-bidirectional.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst5
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/min-max-use-initializer-list.rst8
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/objc/nsdate-formatter.rst52
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/portability/template-virtual-member-function.rst10
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability/ambiguous-smartptr-reset-call.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability/math-missing-parentheses.rst4
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst2
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability/redundant-parentheses.rst2
-rw-r--r--clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp53
-rw-r--r--clang/docs/ReleaseNotes.rst1
-rw-r--r--clang/lib/CodeGen/Targets/AArch64.cpp9
-rw-r--r--clang/lib/Headers/avx512cdintrin.h4
-rw-r--r--clang/lib/Headers/avx512vlcdintrin.h12
-rw-r--r--clang/test/CodeGen/AArch64/args.cpp20
-rw-r--r--clang/test/CodeGen/AArch64/struct-coerce-using-ptr.cpp10
-rw-r--r--clang/test/CodeGen/arm64-microsoft-arguments.cpp4
-rw-r--r--clang/test/CodeGenCXX/aarch64-arguments.cpp2
-rw-r--r--clang/test/CodeGenCXX/arm64-darwinpcs.cpp2
-rw-r--r--libc/include/llvm-libc-macros/netinet-in-macros.h9
-rw-r--r--lldb/include/lldb/lldb-private-interfaces.h1
-rw-r--r--llvm/benchmarks/CMakeLists.txt2
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp3
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp133
-rw-r--r--llvm/test/Transforms/InstCombine/binop-select.ll29
-rw-r--r--llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll4
-rw-r--r--llvm/test/Transforms/SimplifyCFG/switch-transformations-no-lut.ll5
-rw-r--r--llvm/test/Transforms/SimplifyCFG/switch_create.ll130
-rw-r--r--utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel1
125 files changed, 823 insertions, 445 deletions
diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h
index 57d4515..2af1d33 100644
--- a/bolt/include/bolt/Core/BinaryContext.h
+++ b/bolt/include/bolt/Core/BinaryContext.h
@@ -497,7 +497,7 @@ public:
///
/// As we fold identical functions, multiple symbols can point
/// to the same BinaryFunction.
- std::unordered_map<const MCSymbol *, BinaryFunction *> SymbolToFunctionMap;
+ DenseMap<const MCSymbol *, BinaryFunction *> SymbolToFunctionMap;
/// A mutex that is used to control parallel accesses to SymbolToFunctionMap
mutable llvm::sys::RWMutex SymbolToFunctionMapMutex;
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index b215a15..a720c6a 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -281,6 +281,14 @@ private:
/// goto labels.
std::set<uint64_t> ExternallyReferencedOffsets;
+ /// Relocations from data sections targeting internals of this function, i.e.
+ /// some code not at an entry point. These include, but are not limited to,
+ /// jump table relocations and computed goto tables.
+ ///
+ /// Since relocations can be removed/deallocated, we store relocation offsets
+ /// instead of pointers.
+ DenseSet<uint64_t> InternalRefDataRelocations;
+
/// Offsets of indirect branches with unknown destinations.
std::set<uint64_t> UnknownIndirectBranchOffsets;
@@ -640,6 +648,20 @@ private:
Islands->CodeOffsets.emplace(Offset);
}
+ /// Register a relocation from data section referencing code at a non-zero
+ /// offset in this function.
+ void registerInternalRefDataRelocation(uint64_t FuncOffset,
+ uint64_t RelOffset) {
+ assert(FuncOffset != 0 && "Relocation should reference function internals");
+ registerReferencedOffset(FuncOffset);
+ InternalRefDataRelocations.insert(RelOffset);
+ const MCSymbol *ReferencedSymbol =
+ getOrCreateLocalLabel(getAddress() + FuncOffset);
+
+ // Track the symbol mapping since it's used in relocation handling.
+ BC.setSymbolToFunctionMap(ReferencedSymbol, this);
+ }
+
/// Register an internal offset in a function referenced from outside.
void registerReferencedOffset(uint64_t Offset) {
ExternallyReferencedOffsets.emplace(Offset);
@@ -1299,6 +1321,12 @@ public:
void addRelocation(uint64_t Address, MCSymbol *Symbol, uint32_t RelType,
uint64_t Addend, uint64_t Value);
+ /// Return locations (offsets) of data section relocations targeting internals
+ /// of this functions.
+ const DenseSet<uint64_t> &getInternalRefDataRelocations() const {
+ return InternalRefDataRelocations;
+ }
+
/// Return the name of the section this function originated from.
std::optional<StringRef> getOriginSectionName() const {
if (!OriginSection)
diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index b478925..6a285f5 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -1520,6 +1520,17 @@ void BinaryContext::foldFunction(BinaryFunction &ChildBF,
}
ChildBF.getSymbols().clear();
+ // Reset function mapping for local symbols.
+ for (uint64_t RelOffset : ChildBF.getInternalRefDataRelocations()) {
+ const Relocation *Rel = getRelocationAt(RelOffset);
+ if (!Rel || !Rel->Symbol)
+ continue;
+
+ WriteSymbolMapLock.lock();
+ SymbolToFunctionMap[Rel->Symbol] = nullptr;
+ WriteSymbolMapLock.unlock();
+ }
+
// Move other names the child function is known under.
llvm::move(ChildBF.Aliases, std::back_inserter(ParentBF.Aliases));
ChildBF.Aliases.clear();
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index ab3431e..5769577 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2954,8 +2954,10 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
// if-condition above) so we're handling a relocation from a function
// to itself. RISC-V uses such relocations for branches, for example.
// These should not be registered as externally references offsets.
- if (!ContainingBF)
- ReferencedBF->registerReferencedOffset(RefFunctionOffset);
+ if (!ContainingBF && !ReferencedBF->isInConstantIsland(Address)) {
+ ReferencedBF->registerInternalRefDataRelocation(RefFunctionOffset,
+ Rel.getOffset());
+ }
}
if (opts::Verbosity > 1 &&
BinarySection(*BC, RelocatedSection).isWritable())
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 76243e9..870f516 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -356,7 +356,7 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
if (Context.canExperimentalCustomChecks() && custom::RegisterCustomChecks)
custom::RegisterCustomChecks(Context.getOptions(), *CheckFactories);
#endif
- for (ClangTidyModuleRegistry::entry const E :
+ for (const ClangTidyModuleRegistry::entry E :
ClangTidyModuleRegistry::entries()) {
std::unique_ptr<ClangTidyModule> Module = E.instantiate();
Module->addCheckFactories(*CheckFactories);
diff --git a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
index 93a55ef54..8454fd1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -129,7 +129,7 @@ void StringIntegerAssignmentCheck::check(
const auto *Argument = Result.Nodes.getNodeAs<Expr>("expr");
const auto CharType =
Result.Nodes.getNodeAs<QualType>("type")->getCanonicalType();
- SourceLocation Loc = Argument->getBeginLoc();
+ const SourceLocation Loc = Argument->getBeginLoc();
// Try to detect a few common expressions to reduce false positives.
if (CharExpressionDetector(CharType, *Result.Context)
@@ -145,7 +145,7 @@ void StringIntegerAssignmentCheck::check(
if (Loc.isMacroID())
return;
- bool IsWideCharType = CharType->isWideCharType();
+ const bool IsWideCharType = CharType->isWideCharType();
if (!CharType->isCharType() && !IsWideCharType)
return;
bool IsOneDigit = false;
@@ -155,7 +155,7 @@ void StringIntegerAssignmentCheck::check(
IsLiteral = true;
}
- SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Argument->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
if (IsOneDigit) {
Diag << FixItHint::CreateInsertion(Loc, IsWideCharType ? "L'" : "'")
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
index 8dbe1c0..ef7f0b5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
@@ -54,7 +54,7 @@ static int enumLength(const EnumDecl *EnumDec) {
static bool hasDisjointValueRange(const EnumDecl *Enum1,
const EnumDecl *Enum2) {
- ValueRange Range1(Enum1), Range2(Enum2);
+ const ValueRange Range1(Enum1), Range2(Enum2);
return llvm::APSInt::compareValues(Range1.MaxVal, Range2.MinVal) < 0 ||
llvm::APSInt::compareValues(Range2.MaxVal, Range1.MinVal) < 0;
}
@@ -94,9 +94,9 @@ static int countNonPowOfTwoLiteralNum(const EnumDecl *EnumDec) {
/// last enumerator is the sum of the lesser values (and initialized by a
/// literal) or when it could contain consecutive values.
static bool isPossiblyBitMask(const EnumDecl *EnumDec) {
- ValueRange VR(EnumDec);
- int EnumLen = enumLength(EnumDec);
- int NonPowOfTwoCounter = countNonPowOfTwoLiteralNum(EnumDec);
+ const ValueRange VR(EnumDec);
+ const int EnumLen = enumLength(EnumDec);
+ const int NonPowOfTwoCounter = countNonPowOfTwoLiteralNum(EnumDec);
return NonPowOfTwoCounter >= 1 && NonPowOfTwoCounter <= 2 &&
NonPowOfTwoCounter < EnumLen / 2 &&
(VR.MaxVal - VR.MinVal != EnumLen - 1) &&
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
index aaf0594..5abbada 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -66,7 +66,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective(
if (!Check.IgnoredRegexString.empty() && Check.IgnoredRegex.match(FileName))
return;
- SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
+ const SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
const std::optional<StringRef> IFE =
utils::getFileExtension(FileName, Check.ImplementationFileExtensions);
@@ -81,7 +81,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective(
llvm::sys::path::replace_extension(GuessedFileName,
(!HFE.empty() ? "." : "") + HFE);
- OptionalFileEntryRef File =
+ const OptionalFileEntryRef File =
PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
if (File) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
index d1df2a8..7890afb 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
@@ -44,10 +44,10 @@ void SuspiciousMemoryComparisonCheck::check(
for (unsigned int ArgIndex = 0; ArgIndex < 2; ++ArgIndex) {
const Expr *ArgExpr = CE->getArg(ArgIndex);
- QualType ArgType = ArgExpr->IgnoreImplicit()->getType();
+ const QualType ArgType = ArgExpr->IgnoreImplicit()->getType();
const Type *PointeeType = ArgType->getPointeeOrArrayElementType();
assert(PointeeType != nullptr && "PointeeType should always be available.");
- QualType PointeeQualifiedType(PointeeType, 0);
+ const QualType PointeeQualifiedType(PointeeType, 0);
if (PointeeType->isRecordType()) {
if (const RecordDecl *RD =
@@ -65,7 +65,7 @@ void SuspiciousMemoryComparisonCheck::check(
}
if (!PointeeType->isIncompleteType()) {
- uint64_t PointeeSize = Ctx.getTypeSize(PointeeType);
+ const uint64_t PointeeSize = Ctx.getTypeSize(PointeeType);
if (ComparedBits && *ComparedBits >= PointeeSize &&
!Ctx.hasUniqueObjectRepresentations(PointeeQualifiedType)) {
diag(CE->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
index b1d12ba..51ae132 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
@@ -60,7 +60,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
// Case 1: fill_char of memset() is a character '0'. Probably an
// integer zero was intended.
- SourceRange CharRange = CharZeroFill->getSourceRange();
+ const SourceRange CharRange = CharZeroFill->getSourceRange();
auto Diag =
diag(CharZeroFill->getBeginLoc(), "memset fill value is char '0', "
"potentially mistaken for int 0");
@@ -82,7 +82,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
if (!NumFill->EvaluateAsInt(EVResult, *Result.Context))
return;
- llvm::APSInt NumValue = EVResult.Val.getInt();
+ const llvm::APSInt NumValue = EVResult.Val.getInt();
if (NumValue >= 0 && NumValue <= UCharMax)
return;
@@ -110,7 +110,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
Expr::EvalResult EVResult;
if (!FillChar->isValueDependent() &&
FillChar->EvaluateAsInt(EVResult, *Result.Context)) {
- llvm::APSInt Value1 = EVResult.Val.getInt();
+ const llvm::APSInt Value1 = EVResult.Val.getInt();
if (Value1 == 0 || Value1.isNegative())
return;
}
@@ -120,8 +120,10 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
// and fix-its to swap the arguments.
auto D = diag(Call->getBeginLoc(),
"memset of size zero, potentially swapped arguments");
- StringRef RHSString = tooling::fixit::getText(*ByteCount, *Result.Context);
- StringRef LHSString = tooling::fixit::getText(*FillChar, *Result.Context);
+ const StringRef RHSString =
+ tooling::fixit::getText(*ByteCount, *Result.Context);
+ const StringRef LHSString =
+ tooling::fixit::getText(*FillChar, *Result.Context);
if (LHSString.empty() || RHSString.empty())
return;
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
index a41f650..cf8bc97 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
@@ -19,7 +19,7 @@ static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
// String literals surrounded by parentheses are assumed to be on purpose.
// i.e.: const char* Array[] = { ("a" "b" "c"), "d", [...] };
- TraversalKindScope RAII(*Ctx, TK_AsIs);
+ const TraversalKindScope RAII(*Ctx, TK_AsIs);
auto Parents = Ctx->getParents(*Lit);
if (Parents.size() == 1 && Parents[0].get<ParenExpr>() != nullptr)
return true;
@@ -35,15 +35,15 @@ static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
// };
const SourceManager &SM = Ctx->getSourceManager();
bool IndentedCorrectly = true;
- SourceLocation FirstToken = Lit->getStrTokenLoc(0);
- FileID BaseFID = SM.getFileID(FirstToken);
- unsigned int BaseIndent = SM.getSpellingColumnNumber(FirstToken);
- unsigned int BaseLine = SM.getSpellingLineNumber(FirstToken);
+ const SourceLocation FirstToken = Lit->getStrTokenLoc(0);
+ const FileID BaseFID = SM.getFileID(FirstToken);
+ const unsigned int BaseIndent = SM.getSpellingColumnNumber(FirstToken);
+ const unsigned int BaseLine = SM.getSpellingLineNumber(FirstToken);
for (unsigned int TokNum = 1; TokNum < Lit->getNumConcatenated(); ++TokNum) {
- SourceLocation Token = Lit->getStrTokenLoc(TokNum);
- FileID FID = SM.getFileID(Token);
- unsigned int Indent = SM.getSpellingColumnNumber(Token);
- unsigned int Line = SM.getSpellingLineNumber(Token);
+ const SourceLocation Token = Lit->getStrTokenLoc(TokNum);
+ const FileID FID = SM.getFileID(Token);
+ const unsigned int Indent = SM.getSpellingColumnNumber(Token);
+ const unsigned int Line = SM.getSpellingLineNumber(Token);
if (FID != BaseFID || Line != BaseLine + TokNum || Indent <= BaseIndent) {
IndentedCorrectly = false;
break;
@@ -100,7 +100,7 @@ void SuspiciousMissingCommaCheck::check(
assert(InitializerList && ConcatenatedLiteral);
// Skip small arrays as they often generate false-positive.
- unsigned int Size = InitializerList->getNumInits();
+ const unsigned int Size = InitializerList->getNumInits();
if (Size < SizeThreshold)
return;
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp
index b5da801..7cc3630 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp
@@ -44,7 +44,7 @@ public:
return false;
if (!check(E1->getBase(), E2->getBase()))
return false;
- DeclAccessPair FD = E1->getFoundDecl();
+ const DeclAccessPair FD = E1->getFoundDecl();
return isa<FieldDecl>(FD.getDecl()) && FD == E2->getFoundDecl();
}
@@ -145,7 +145,7 @@ void SuspiciousReallocUsageCheck::check(
if (FindAssignToVarBefore{Var, DeclRef, SM}.Visit(Func->getBody()))
return;
- StringRef CodeOfAssignedExpr = Lexer::getSourceText(
+ const StringRef CodeOfAssignedExpr = Lexer::getSourceText(
CharSourceRange::getTokenRange(PtrResultExpr->getSourceRange()), SM,
getLangOpts());
diag(Call->getBeginLoc(), "'%0' may be set to null if 'realloc' fails, which "
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
index 543d312..9d37fc1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -31,7 +31,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
return;
const auto *Semicolon = Result.Nodes.getNodeAs<NullStmt>("semi");
- SourceLocation LocStart = Semicolon->getBeginLoc();
+ const SourceLocation LocStart = Semicolon->getBeginLoc();
if (LocStart.isMacroID())
return;
@@ -40,7 +40,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
auto Token = utils::lexer::getPreviousToken(LocStart, Ctxt.getSourceManager(),
Ctxt.getLangOpts());
auto &SM = *Result.SourceManager;
- unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart);
+ const unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart);
const auto *Statement = Result.Nodes.getNodeAs<Stmt>("stmt");
const bool IsIfStmt = isa<IfStmt>(Statement);
@@ -49,18 +49,20 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
SM.getSpellingLineNumber(Token.getLocation()) != SemicolonLine)
return;
- SourceLocation LocEnd = Semicolon->getEndLoc();
- FileID FID = SM.getFileID(LocEnd);
- llvm::MemoryBufferRef Buffer = SM.getBufferOrFake(FID, LocEnd);
+ const SourceLocation LocEnd = Semicolon->getEndLoc();
+ const FileID FID = SM.getFileID(LocEnd);
+ const llvm::MemoryBufferRef Buffer = SM.getBufferOrFake(FID, LocEnd);
Lexer Lexer(SM.getLocForStartOfFile(FID), Ctxt.getLangOpts(),
Buffer.getBufferStart(), SM.getCharacterData(LocEnd) + 1,
Buffer.getBufferEnd());
if (Lexer.LexFromRawLexer(Token))
return;
- unsigned BaseIndent = SM.getSpellingColumnNumber(Statement->getBeginLoc());
- unsigned NewTokenIndent = SM.getSpellingColumnNumber(Token.getLocation());
- unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation());
+ const unsigned BaseIndent =
+ SM.getSpellingColumnNumber(Statement->getBeginLoc());
+ const unsigned NewTokenIndent =
+ SM.getSpellingColumnNumber(Token.getLocation());
+ const unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation());
if (!IsIfStmt && NewTokenIndent <= BaseIndent &&
Token.getKind() != tok::l_brace && NewTokenLine != SemicolonLine)
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
index 7519685..5da9240 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
@@ -88,7 +88,7 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
// Add the list of known string compare-like functions and add user-defined
// functions.
- std::vector<StringRef> FunctionNames = utils::options::parseListPair(
+ const std::vector<StringRef> FunctionNames = utils::options::parseListPair(
KnownStringCompareFunctions, StringCompareLikeFunctions);
// Match a call to a string compare functions.
@@ -163,7 +163,7 @@ void SuspiciousStringCompareCheck::check(
assert(Decl != nullptr && Call != nullptr);
if (Result.Nodes.getNodeAs<Stmt>("missing-comparison")) {
- SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Call->getRParenLoc(), 0, Result.Context->getSourceManager(),
getLangOpts());
@@ -173,10 +173,10 @@ void SuspiciousStringCompareCheck::check(
}
if (const auto *E = Result.Nodes.getNodeAs<Expr>("logical-not-comparison")) {
- SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Call->getRParenLoc(), 0, Result.Context->getSourceManager(),
getLangOpts());
- SourceLocation NotLoc = E->getBeginLoc();
+ const SourceLocation NotLoc = E->getBeginLoc();
diag(Call->getBeginLoc(),
"function %0 is compared using logical not operator")
diff --git a/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp
index bcedff5..152c0cb 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp
@@ -70,7 +70,7 @@ static bool areArgumentsPotentiallySwapped(const QualType LTo,
if (LTo == RFrom && REq)
return true;
- bool LEq = areTypesSemiEqual(LTo, RFrom);
+ const bool LEq = areTypesSemiEqual(LTo, RFrom);
if (RTo == LFrom && LEq)
return true;
diff --git a/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp
index 56ec5a5..80905e2 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp
@@ -44,7 +44,7 @@ void ThrowingStaticInitializationCheck::check(
"duration may throw an exception that cannot be caught")
<< VD << (VD->getStorageDuration() == SD_Static ? 0 : 1);
- SourceLocation FuncLocation = Func->getLocation();
+ const SourceLocation FuncLocation = Func->getLocation();
if (FuncLocation.isValid()) {
diag(FuncLocation,
"possibly throwing %select{constructor|function}0 declared here",
diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
index 536b680..71b785f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp
@@ -67,21 +67,21 @@ void TooSmallLoopVariableCheck::storeOptions(
/// LoopName: The entire for loop (as a ForStmt)
///
void TooSmallLoopVariableCheck::registerMatchers(MatchFinder *Finder) {
- StatementMatcher LoopVarMatcher =
+ const StatementMatcher LoopVarMatcher =
expr(ignoringParenImpCasts(
anyOf(declRefExpr(to(varDecl(hasType(isInteger())))),
memberExpr(member(fieldDecl(hasType(isInteger())))))))
.bind(LoopVarName);
// We need to catch only those comparisons which contain any integer cast.
- StatementMatcher LoopVarConversionMatcher = traverse(
+ const StatementMatcher LoopVarConversionMatcher = traverse(
TK_AsIs, implicitCastExpr(hasImplicitDestinationType(isInteger()),
has(ignoringParenImpCasts(LoopVarMatcher)))
.bind(LoopVarCastName));
// We are interested in only those cases when the loop bound is a variable
// value (not const, enum, etc.).
- StatementMatcher LoopBoundMatcher =
+ const StatementMatcher LoopBoundMatcher =
expr(ignoringParenImpCasts(allOf(
hasType(isInteger()), unless(integerLiteral()),
unless(allOf(
@@ -94,7 +94,7 @@ void TooSmallLoopVariableCheck::registerMatchers(MatchFinder *Finder) {
// We use the loop increment expression only to make sure we found the right
// loop variable.
- StatementMatcher IncrementMatcher =
+ const StatementMatcher IncrementMatcher =
expr(ignoringParenImpCasts(hasType(isInteger()))).bind(LoopIncrementName);
Finder->addMatcher(
@@ -121,14 +121,14 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context,
const Expr *IntExpr) {
assert(IntExprType->isIntegerType());
- unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U;
+ const unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U;
if (const auto *BitField = IntExpr->getSourceBitField()) {
- unsigned BitFieldWidth = BitField->getBitWidthValue();
+ const unsigned BitFieldWidth = BitField->getBitWidthValue();
return {BitFieldWidth - SignedBits, BitFieldWidth};
}
- unsigned IntWidth = Context.getIntWidth(IntExprType);
+ const unsigned IntWidth = Context.getIntWidth(IntExprType);
return {IntWidth - SignedBits, 0U};
}
@@ -143,18 +143,18 @@ calcUpperBoundMagnitudeBits(const ASTContext &Context, const Expr *UpperBound,
const Expr *RHSE = BinOperator->getRHS()->IgnoreParenImpCasts();
const Expr *LHSE = BinOperator->getLHS()->IgnoreParenImpCasts();
- QualType RHSEType = RHSE->getType();
- QualType LHSEType = LHSE->getType();
+ const QualType RHSEType = RHSE->getType();
+ const QualType LHSEType = LHSE->getType();
if (!RHSEType->isIntegerType() || !LHSEType->isIntegerType())
return {};
- bool RHSEIsConstantValue = RHSEType->isEnumeralType() ||
- RHSEType.isConstQualified() ||
- isa<IntegerLiteral>(RHSE);
- bool LHSEIsConstantValue = LHSEType->isEnumeralType() ||
- LHSEType.isConstQualified() ||
- isa<IntegerLiteral>(LHSE);
+ const bool RHSEIsConstantValue = RHSEType->isEnumeralType() ||
+ RHSEType.isConstQualified() ||
+ isa<IntegerLiteral>(RHSE);
+ const bool LHSEIsConstantValue = LHSEType->isEnumeralType() ||
+ LHSEType.isConstQualified() ||
+ isa<IntegerLiteral>(LHSE);
// Avoid false positives produced by two constant values.
if (RHSEIsConstantValue && LHSEIsConstantValue)
@@ -193,7 +193,7 @@ void TooSmallLoopVariableCheck::check(const MatchFinder::MatchResult &Result) {
if (LoopVar->getType() != LoopIncrement->getType())
return;
- ASTContext &Context = *Result.Context;
+ const ASTContext &Context = *Result.Context;
const QualType LoopVarType = LoopVar->getType();
const MagnitudeBits LoopVarMagnitudeBits =
diff --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
index d0bf72b..b82c9d3 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp
@@ -76,7 +76,8 @@ static ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
// Get the conversion specifier and use it to determine the conversion
// kind.
- analyze_scanf::ScanfConversionSpecifier SCS = FS.getConversionSpecifier();
+ const analyze_scanf::ScanfConversionSpecifier SCS =
+ FS.getConversionSpecifier();
if (SCS.isIntArg()) {
switch (FS.getLengthModifier().getKind()) {
case analyze_scanf::LengthModifier::AsLongLong:
@@ -194,7 +195,7 @@ void UncheckedStringToNumberConversionCheck::check(
// The format string comes from the call expression and depends on which
// flavor of scanf is called.
// Index 0: scanf, vscanf, Index 1: fscanf, sscanf, vfscanf, vsscanf.
- unsigned Idx =
+ const unsigned Idx =
(FFD->getName() == "scanf" || FFD->getName() == "vscanf") ? 0 : 1;
// Given the index, see if the call expression argument at that index is
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
index bf30753..340b136 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
@@ -16,7 +16,8 @@ namespace {
AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
ast_matchers::internal::Matcher<QualType>, InnerMatcher) {
- for (unsigned NH = Node.getNumHandlers(), I = 0; I < NH; ++I) {
+ const unsigned NH = Node.getNumHandlers();
+ for (unsigned I = 0; I < NH; ++I) {
const CXXCatchStmt *CatchS = Node.getHandler(I);
// Check for generic catch handler (match anything).
if (CatchS->getCaughtType().isNull())
@@ -31,7 +32,7 @@ AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
}
AST_MATCHER(CXXNewExpr, mayThrow) {
- FunctionDecl *OperatorNew = Node.getOperatorNew();
+ const FunctionDecl *OperatorNew = Node.getOperatorNew();
if (!OperatorNew)
return false;
return !OperatorNew->getType()->castAs<FunctionProtoType>()->isNothrow();
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
index bce4657..e10b17c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp
@@ -80,17 +80,17 @@ void UnintendedCharOstreamOutputCheck::check(
const Expr *Value = Call->getArg(1);
const SourceRange SourceRange = Value->getSourceRange();
- DiagnosticBuilder Builder =
+ const DiagnosticBuilder Builder =
diag(Call->getOperatorLoc(),
"%0 passed to 'operator<<' outputs as character instead of integer. "
"cast to 'unsigned int' to print numeric value or cast to 'char' to "
"print as character")
<< Value->getType() << SourceRange;
- QualType T = Value->getType();
+ const QualType T = Value->getType();
const Type *UnqualifiedDesugaredType = T->getUnqualifiedDesugaredType();
- llvm::StringRef CastType = CastTypeName.value_or(
+ const llvm::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 61ccd26..5524c4b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -141,7 +141,7 @@ parseCheckedFunctions(StringRef Option, ClangTidyContext *Context) {
std::vector<UnsafeFunctionsCheck::CheckedFunction> Result;
Result.reserve(Functions.size());
- for (StringRef Function : Functions) {
+ for (const StringRef Function : Functions) {
if (Function.empty())
continue;
@@ -301,7 +301,7 @@ void UnsafeFunctionsCheck::check(const MatchFinder::MatchResult &Result) {
if (Custom) {
for (const auto &Entry : CustomFunctions) {
if (Entry.Pattern.match(*FuncDecl)) {
- StringRef Reason =
+ const StringRef Reason =
Entry.Reason.empty() ? "is marked as unsafe" : Entry.Reason.c_str();
if (Entry.Replacement.empty()) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
index c2fc4af..6fbd392 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -25,7 +25,8 @@ namespace {
// member function are matched directly with InnerMatcher.
AST_MATCHER_P(FunctionDecl, isInstantiatedFrom, Matcher<FunctionDecl>,
InnerMatcher) {
- FunctionDecl *InstantiatedFrom = Node.getInstantiatedFromMemberFunction();
+ const FunctionDecl *InstantiatedFrom =
+ Node.getInstantiatedFromMemberFunction();
return InnerMatcher.matches(InstantiatedFrom ? *InstantiatedFrom : Node,
Finder, Builder);
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index efb5ec6..6d134a0 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -255,7 +255,7 @@ static bool isStandardSmartPointer(const ValueDecl *VD) {
if (!ID)
return false;
- StringRef Name = ID->getName();
+ const StringRef Name = ID->getName();
if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
return false;
@@ -369,7 +369,7 @@ void UseAfterMoveFinder::getReinits(
if (!S)
continue;
- SmallVector<BoundNodes, 1> Matches =
+ const SmallVector<BoundNodes, 1> Matches =
match(findAll(ReinitMatcher), *S->getStmt(), *Context);
for (const auto &Match : Matches) {
@@ -506,7 +506,7 @@ void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
if (ContainingCtorInit) {
// Collect the constructor initializer expressions.
bool BeforeMove{true};
- for (CXXCtorInitializer *Init : ContainingCtor->inits()) {
+ for (const CXXCtorInitializer *Init : ContainingCtor->inits()) {
if (BeforeMove && Init->getInit()->IgnoreImplicit() ==
ContainingCtorInit->IgnoreImplicit())
BeforeMove = false;
diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
index cef8b4d..0d69b9f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
@@ -37,14 +37,14 @@ static bool isOverrideMethod(const CXXMethodDecl *MD) {
static bool checkOverridingFunctionReturnType(const ASTContext *Context,
const CXXMethodDecl *BaseMD,
const CXXMethodDecl *DerivedMD) {
- QualType BaseReturnTy = BaseMD->getType()
- ->castAs<FunctionType>()
- ->getReturnType()
- .getCanonicalType();
- QualType DerivedReturnTy = DerivedMD->getType()
- ->castAs<FunctionType>()
- ->getReturnType()
- .getCanonicalType();
+ const QualType BaseReturnTy = BaseMD->getType()
+ ->castAs<FunctionType>()
+ ->getReturnType()
+ .getCanonicalType();
+ const QualType DerivedReturnTy = DerivedMD->getType()
+ ->castAs<FunctionType>()
+ ->getReturnType()
+ .getCanonicalType();
if (DerivedReturnTy->isDependentType() || BaseReturnTy->isDependentType())
return false;
@@ -63,8 +63,8 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
/// BTy is the class type in return type of BaseMD. For example,
/// B* Base::md()
/// While BRD is the declaration of B.
- QualType DTy = DerivedReturnTy->getPointeeType().getCanonicalType();
- QualType BTy = BaseReturnTy->getPointeeType().getCanonicalType();
+ const QualType DTy = DerivedReturnTy->getPointeeType().getCanonicalType();
+ const QualType BTy = BaseReturnTy->getPointeeType().getCanonicalType();
const CXXRecordDecl *DRD = DTy->getAsCXXRecordDecl();
const CXXRecordDecl *BRD = BTy->getAsCXXRecordDecl();
@@ -94,7 +94,7 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
// Check accessibility.
// FIXME: We currently only support checking if B is accessible base class
// of D, or D is the same class which DerivedMD is in.
- bool IsItself =
+ const bool IsItself =
DRD->getCanonicalDecl() == DerivedMD->getParent()->getCanonicalDecl();
bool HasPublicAccess = false;
for (const auto &Path : Paths) {
@@ -129,8 +129,8 @@ static QualType getDecayedType(QualType Type) {
/// \returns true if the param types are the same.
static bool checkParamTypes(const CXXMethodDecl *BaseMD,
const CXXMethodDecl *DerivedMD) {
- unsigned NumParamA = BaseMD->getNumParams();
- unsigned NumParamB = DerivedMD->getNumParams();
+ const unsigned NumParamA = BaseMD->getNumParams();
+ const unsigned NumParamB = DerivedMD->getNumParams();
if (NumParamA != NumParamB)
return false;
@@ -184,10 +184,10 @@ bool VirtualNearMissCheck::isPossibleToBeOverridden(
if (!Inserted)
return Iter->second;
- bool IsPossible = !BaseMD->isImplicit() && !isa<CXXConstructorDecl>(BaseMD) &&
- !isa<CXXDestructorDecl>(BaseMD) && BaseMD->isVirtual() &&
- !BaseMD->isOverloadedOperator() &&
- !isa<CXXConversionDecl>(BaseMD);
+ const bool IsPossible =
+ !BaseMD->isImplicit() && !isa<CXXConstructorDecl>(BaseMD) &&
+ !isa<CXXDestructorDecl>(BaseMD) && BaseMD->isVirtual() &&
+ !BaseMD->isOverloadedOperator() && !isa<CXXConversionDecl>(BaseMD);
Iter->second = IsPossible;
return IsPossible;
}
@@ -241,7 +241,7 @@ void VirtualNearMissCheck::check(const MatchFinder::MatchResult &Result) {
if (isOverriddenByDerivedClass(BaseMD, DerivedRD))
continue;
- unsigned EditDistance = BaseMD->getName().edit_distance(
+ const unsigned EditDistance = BaseMD->getName().edit_distance(
DerivedMD->getName(), EditDistanceThreshold);
if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
@@ -249,8 +249,8 @@ void VirtualNearMissCheck::check(const MatchFinder::MatchResult &Result) {
auto Range = CharSourceRange::getTokenRange(
SourceRange(DerivedMD->getLocation()));
- bool ApplyFix = !BaseMD->isTemplateInstantiation() &&
- !DerivedMD->isTemplateInstantiation();
+ const bool ApplyFix = !BaseMD->isTemplateInstantiation() &&
+ !DerivedMD->isTemplateInstantiation();
auto Diag =
diag(DerivedMD->getBeginLoc(),
"method '%0' has a similar name and the same signature as "
diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
index b0799da..2f6fc4d 100644
--- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
@@ -31,7 +31,7 @@
#include "../concurrency/ThreadCanceltypeAsynchronousCheck.h"
#include "../google/UnnamedNamespaceInHeaderCheck.h"
#include "../misc/NewDeleteOverloadsCheck.h"
-#include "../misc/NonCopyableObjects.h"
+#include "../misc/NonCopyableObjectsCheck.h"
#include "../misc/StaticAssertCheck.h"
#include "../misc/ThrowByValueCatchByReferenceCheck.h"
#include "../modernize/AvoidSetjmpLongjmpCheck.h"
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index 0abb000..4b3330d 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -21,7 +21,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule STATIC
OwningMemoryCheck.cpp
PreferMemberInitializerCheck.cpp
ProBoundsArrayToPointerDecayCheck.cpp
- ProBoundsAvoidUncheckedContainerAccess.cpp
+ ProBoundsAvoidUncheckedContainerAccessCheck.cpp
ProBoundsConstantArrayIndexCheck.cpp
ProBoundsPointerArithmeticCheck.cpp
ProTypeConstCastCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
index 5f4c9b4..6663955 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -36,7 +36,7 @@
#include "OwningMemoryCheck.h"
#include "PreferMemberInitializerCheck.h"
#include "ProBoundsArrayToPointerDecayCheck.h"
-#include "ProBoundsAvoidUncheckedContainerAccess.h"
+#include "ProBoundsAvoidUncheckedContainerAccessCheck.h"
#include "ProBoundsConstantArrayIndexCheck.h"
#include "ProBoundsPointerArithmeticCheck.h"
#include "ProTypeConstCastCheck.h"
@@ -108,7 +108,7 @@ public:
"cppcoreguidelines-prefer-member-initializer");
CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
"cppcoreguidelines-pro-bounds-array-to-pointer-decay");
- CheckFactories.registerCheck<ProBoundsAvoidUncheckedContainerAccess>(
+ CheckFactories.registerCheck<ProBoundsAvoidUncheckedContainerAccessCheck>(
"cppcoreguidelines-pro-bounds-avoid-unchecked-container-access");
CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(
"cppcoreguidelines-pro-bounds-constant-array-index");
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccess.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
index dd7b2b5..83803a3 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccess.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ProBoundsAvoidUncheckedContainerAccess.h"
+#include "ProBoundsAvoidUncheckedContainerAccessCheck.h"
#include "../utils/Matchers.h"
#include "../utils/OptionsUtils.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -19,8 +19,9 @@ namespace clang::tidy::cppcoreguidelines {
static constexpr llvm::StringRef DefaultExclusionStr =
"::std::map;::std::unordered_map;::std::flat_map";
-ProBoundsAvoidUncheckedContainerAccess::ProBoundsAvoidUncheckedContainerAccess(
- StringRef Name, ClangTidyContext *Context)
+ProBoundsAvoidUncheckedContainerAccessCheck::
+ ProBoundsAvoidUncheckedContainerAccessCheck(StringRef Name,
+ ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
ExcludedClasses(utils::options::parseStringList(
Options.get("ExcludeClasses", DefaultExclusionStr))),
@@ -28,7 +29,7 @@ ProBoundsAvoidUncheckedContainerAccess::ProBoundsAvoidUncheckedContainerAccess(
FixFunction(Options.get("FixFunction", "gsl::at")),
FixFunctionEmptyArgs(Options.get("FixFunctionEmptyArgs", FixFunction)) {}
-void ProBoundsAvoidUncheckedContainerAccess::storeOptions(
+void ProBoundsAvoidUncheckedContainerAccessCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "ExcludeClasses",
utils::options::serializeStringList(ExcludedClasses));
@@ -86,7 +87,7 @@ findAlternativeAt(const CXXMethodDecl *MatchedOperator) {
return nullptr;
}
-void ProBoundsAvoidUncheckedContainerAccess::registerMatchers(
+void ProBoundsAvoidUncheckedContainerAccessCheck::registerMatchers(
MatchFinder *Finder) {
Finder->addMatcher(
mapAnyOf(cxxOperatorCallExpr, cxxMemberCallExpr)
@@ -100,7 +101,7 @@ void ProBoundsAvoidUncheckedContainerAccess::registerMatchers(
this);
}
-void ProBoundsAvoidUncheckedContainerAccess::check(
+void ProBoundsAvoidUncheckedContainerAccessCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("caller");
@@ -251,7 +252,7 @@ void ProBoundsAvoidUncheckedContainerAccess::check(
} // namespace clang::tidy::cppcoreguidelines
namespace clang::tidy {
-using P = cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess;
+using P = cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck;
llvm::ArrayRef<std::pair<P::FixModes, StringRef>>
OptionEnumMapping<P::FixModes>::getEnumMapping() {
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccess.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h
index 2462e7a..85b5a93 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccess.h
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESS_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESSCHECK_H
#include "../ClangTidyCheck.h"
@@ -20,10 +20,10 @@ namespace clang::tidy::cppcoreguidelines {
/// https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slcon3-avoid-bounds-errors
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.html
-class ProBoundsAvoidUncheckedContainerAccess : public ClangTidyCheck {
+class ProBoundsAvoidUncheckedContainerAccessCheck : public ClangTidyCheck {
public:
- ProBoundsAvoidUncheckedContainerAccess(StringRef Name,
- ClangTidyContext *Context);
+ ProBoundsAvoidUncheckedContainerAccessCheck(StringRef Name,
+ ClangTidyContext *Context);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
@@ -46,11 +46,11 @@ private:
namespace clang::tidy {
template <>
struct OptionEnumMapping<
- cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess::FixModes> {
+ cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck::FixModes> {
static ArrayRef<std::pair<
- cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess::FixModes,
+ cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck::FixModes,
StringRef>>
getEnumMapping();
};
} // namespace clang::tidy
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESS_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index 2cfee5f..6214ee9 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -25,12 +25,12 @@ add_clang_library(clangTidyMiscModule STATIC
HeaderIncludeCycleCheck.cpp
IncludeCleanerCheck.cpp
MiscTidyModule.cpp
- MisleadingBidirectional.cpp
- MisleadingIdentifier.cpp
+ MisleadingBidirectionalCheck.cpp
+ MisleadingIdentifierCheck.cpp
MisplacedConstCheck.cpp
NewDeleteOverloadsCheck.cpp
NoRecursionCheck.cpp
- NonCopyableObjects.cpp
+ NonCopyableObjectsCheck.cpp
NonPrivateMemberVariablesInClassesCheck.cpp
OverrideWithDifferentVisibilityCheck.cpp
RedundantExpressionCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
index 6f4af6c..347fa2a 100644
--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -15,12 +15,12 @@
#include "DefinitionsInHeadersCheck.h"
#include "HeaderIncludeCycleCheck.h"
#include "IncludeCleanerCheck.h"
-#include "MisleadingBidirectional.h"
-#include "MisleadingIdentifier.h"
+#include "MisleadingBidirectionalCheck.h"
+#include "MisleadingIdentifierCheck.h"
#include "MisplacedConstCheck.h"
#include "NewDeleteOverloadsCheck.h"
#include "NoRecursionCheck.h"
-#include "NonCopyableObjects.h"
+#include "NonCopyableObjectsCheck.h"
#include "NonPrivateMemberVariablesInClassesCheck.h"
#include "OverrideWithDifferentVisibilityCheck.h"
#include "RedundantExpressionCheck.h"
diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp
index db5bc61..4807567 100644
--- a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "MisleadingBidirectional.h"
+#include "MisleadingBidirectionalCheck.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"
diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.h
index 50e70cb..7c7577f 100644
--- a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h
+++ b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.h
@@ -6,13 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONAL_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONAL_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
+/// Warns about unterminated bidirectional unicode sequence.
+///
+/// For the user-facing documentation see:
+/// https://clang.llvm.org/extra/clang-tidy/checks/misc/misleading-bidirectional.html
class MisleadingBidirectionalCheck : public ClangTidyCheck {
public:
MisleadingBidirectionalCheck(StringRef Name, ClangTidyContext *Context);
@@ -31,4 +35,4 @@ private:
} // namespace clang::tidy::misc
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONAL_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp b/clang-tools-extra/clang-tidy/misc/MisleadingIdentifierCheck.cpp
index 3c8a03a..335fffc 100644
--- a/clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MisleadingIdentifierCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "MisleadingIdentifier.h"
+#include "MisleadingIdentifierCheck.h"
#include "llvm/Support/ConvertUTF.h"
diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h b/clang-tools-extra/clang-tidy/misc/MisleadingIdentifierCheck.h
index 5c184f8..9f8eb40 100644
--- a/clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
+++ b/clang-tools-extra/clang-tidy/misc/MisleadingIdentifierCheck.h
@@ -6,13 +6,19 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIER_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIER_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
+/// Finds identifiers that contain Unicode characters with right-to-left
+/// direction, which can be confusing as they may change the understanding of a
+/// whole statement line.
+///
+/// For the user-facing documentation see:
+/// https://clang.llvm.org/extra/clang-tidy/checks/misc/misleading-identifier.html
class MisleadingIdentifierCheck : public ClangTidyCheck {
public:
MisleadingIdentifierCheck(StringRef Name, ClangTidyContext *Context);
@@ -24,4 +30,4 @@ public:
} // namespace clang::tidy::misc
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIER_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
diff --git a/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.cpp b/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp
index b33e266..bfeb5fa 100644
--- a/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "NonCopyableObjects.h"
+#include "NonCopyableObjectsCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
diff --git a/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h b/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.h
index 2fcbf41..608e078 100644
--- a/clang-tools-extra/clang-tidy/misc/NonCopyableObjects.h
+++ b/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.h
@@ -6,15 +6,18 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTSCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
-/// The check flags dereferences and non-pointer declarations of objects that
+/// Flags dereferences and non-pointer declarations of objects that
/// are not meant to be passed by value, such as C FILE objects.
+///
+/// For the user-facing documentation see:
+/// https://clang.llvm.org/extra/clang-tidy/checks/misc/non-copyable-objects.html
class NonCopyableObjectsCheck : public ClangTidyCheck {
public:
NonCopyableObjectsCheck(StringRef Name, ClangTidyContext *Context)
@@ -25,4 +28,4 @@ public:
} // namespace clang::tidy::misc
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index 0d2c3a7..cc6b7bf 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -163,7 +163,7 @@ static bool isZero(const Expr *E) {
case Stmt::IntegerLiteralClass:
return !cast<IntegerLiteral>(E)->getValue();
case Stmt::FloatingLiteralClass: {
- llvm::APFloat Value = cast<FloatingLiteral>(E)->getValue();
+ const llvm::APFloat Value = cast<FloatingLiteral>(E)->getValue();
return Value.isZero() && !Value.isNegative();
}
default:
@@ -297,16 +297,16 @@ void UseDefaultMemberInitCheck::checkDefaultInit(
}) > 1)
return;
- SourceLocation StartLoc = Field->getBeginLoc();
+ const SourceLocation StartLoc = Field->getBeginLoc();
if (StartLoc.isMacroID() && IgnoreMacros)
return;
- SourceLocation FieldEnd =
+ const SourceLocation FieldEnd =
Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
*Result.SourceManager, getLangOpts());
- SourceLocation LParenEnd = Lexer::getLocForEndOfToken(
+ const SourceLocation LParenEnd = Lexer::getLocForEndOfToken(
Init->getLParenLoc(), 0, *Result.SourceManager, getLangOpts());
- CharSourceRange InitRange =
+ const CharSourceRange InitRange =
CharSourceRange::getCharRange(LParenEnd, Init->getRParenLoc());
const Expr *InitExpression = Init->getInit();
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
index c1094b1..2cc3ce1 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp
@@ -152,7 +152,7 @@ void UseDesignatedInitializersCheck::check(
if (IgnoreMacros && InitList->getBeginLoc().isMacroID())
return;
{
- DiagnosticBuilder Diag =
+ const DiagnosticBuilder Diag =
diag(InitList->getLBraceLoc(),
"use designated initializer list to initialize %0");
Diag << InitList->getType() << InitList->getSourceRange();
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
index d6ddbb6..fde9c73 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -200,7 +200,7 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context,
/// Returns false if the body has any non-whitespace character.
static bool bodyEmpty(const ASTContext *Context, const CompoundStmt *Body) {
bool Invalid = false;
- StringRef Text = Lexer::getSourceText(
+ const StringRef Text = Lexer::getSourceText(
CharSourceRange::getCharRange(Body->getLBracLoc().getLocWithOffset(1),
Body->getRBracLoc()),
Context->getSourceManager(), Context->getLangOpts(), &Invalid);
@@ -306,8 +306,8 @@ void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult &Result) {
return;
// If there are comments inside the body, don't do the change.
- bool ApplyFix = SpecialFunctionDecl->isCopyAssignmentOperator() ||
- bodyEmpty(Result.Context, Body);
+ const bool ApplyFix = SpecialFunctionDecl->isCopyAssignmentOperator() ||
+ bodyEmpty(Result.Context, Body);
std::vector<FixItHint> RemoveInitializers;
unsigned MemberType = 0;
@@ -345,14 +345,14 @@ void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult &Result) {
Diag << MemberType;
if (ApplyFix) {
- SourceLocation UnifiedEnd = utils::lexer::getUnifiedEndLoc(
+ const SourceLocation UnifiedEnd = utils::lexer::getUnifiedEndLoc(
*Body, Result.Context->getSourceManager(),
Result.Context->getLangOpts());
// Skipping comments, check for a semicolon after Body->getSourceRange()
std::optional<Token> Token = utils::lexer::findNextTokenSkippingComments(
UnifiedEnd, Result.Context->getSourceManager(),
Result.Context->getLangOpts());
- StringRef Replacement =
+ const StringRef Replacement =
Token && Token->is(tok::semi) ? "= default" : "= default;";
Diag << FixItHint::CreateReplacement(Body->getSourceRange(), Replacement)
<< RemoveInitializers;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
index ab2d41a..a19d2ec 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -74,7 +74,7 @@ void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
void UseEqualsDeleteCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *Func =
Result.Nodes.getNodeAs<CXXMethodDecl>(SpecialFunction)) {
- SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
if (IgnoreMacros && Func->getLocation().isMacroID())
diff --git a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index 35320e8..574cbea 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -146,7 +146,7 @@ void UseIntegerSignComparisonCheck::check(
R3.setBegin(Lexer::getLocForEndOfToken(
SubExprRHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
}
- DiagnosticBuilder Diag =
+ const DiagnosticBuilder Diag =
diag(BinaryOp->getBeginLoc(),
"comparison between 'signed' and 'unsigned' integers");
StringRef CmpNamespace;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
index d22c993..7e8d982 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
@@ -110,11 +110,11 @@ void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) {
void UseNodiscardCheck::check(const MatchFinder::MatchResult &Result) {
const auto *MatchedDecl = Result.Nodes.getNodeAs<CXXMethodDecl>("no_discard");
// Don't make replacements if the location is invalid or in a macro.
- SourceLocation Loc = MatchedDecl->getLocation();
+ const SourceLocation Loc = MatchedDecl->getLocation();
if (Loc.isInvalid() || Loc.isMacroID())
return;
- SourceLocation RetLoc = MatchedDecl->getInnerLocStart();
+ const SourceLocation RetLoc = MatchedDecl->getInnerLocStart();
ASTContext &Context = *Result.Context;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
index d1388dc..6bd5485 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -81,12 +81,12 @@ void UseNoexceptCheck::check(const MatchFinder::MatchResult &Result) {
assert(Range.isValid() && "Exception Source Range is invalid.");
- CharSourceRange CRange = Lexer::makeFileCharRange(
+ const CharSourceRange CRange = Lexer::makeFileCharRange(
CharSourceRange::getTokenRange(Range), *Result.SourceManager,
Result.Context->getLangOpts());
- bool IsNoThrow = FnTy->isNothrow();
- StringRef ReplacementStr =
+ const bool IsNoThrow = FnTy->isNothrow();
+ const StringRef ReplacementStr =
IsNoThrow ? NoexceptMacro.empty() ? "noexcept" : NoexceptMacro
: NoexceptMacro.empty()
? (DtorOrOperatorDel || UseNoexceptFalse) ? "noexcept(false)" : ""
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index b6834c6..928a007 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -92,12 +92,13 @@ static bool isReplaceableRange(SourceLocation StartLoc, SourceLocation EndLoc,
/// Returns true if and only if a replacement was made.
static void replaceWithNullptr(ClangTidyCheck &Check, SourceManager &SM,
SourceLocation StartLoc, SourceLocation EndLoc) {
- CharSourceRange Range(SourceRange(StartLoc, EndLoc), true);
+ const CharSourceRange Range(SourceRange(StartLoc, EndLoc), true);
// Add a space if nullptr follows an alphanumeric character. This happens
// whenever there is an c-style explicit cast to nullptr not surrounded by
// parentheses and right beside a return statement.
- SourceLocation PreviousLocation = StartLoc.getLocWithOffset(-1);
- bool NeedsSpace = isAlphanumeric(*SM.getCharacterData(PreviousLocation));
+ const SourceLocation PreviousLocation = StartLoc.getLocWithOffset(-1);
+ const bool NeedsSpace =
+ isAlphanumeric(*SM.getCharacterData(PreviousLocation));
Check.diag(Range.getBegin(), "use nullptr") << FixItHint::CreateReplacement(
Range, NeedsSpace ? " nullptr" : "nullptr");
}
@@ -136,7 +137,7 @@ public:
}
bool TraverseStmt(Stmt *S) {
- bool VisitedPreviously = Visited;
+ const bool VisitedPreviously = Visited;
if (!RecursiveASTVisitor<MacroArgUsageVisitor>::TraverseStmt(S))
return false;
@@ -258,8 +259,8 @@ public:
// If the location comes from a macro body expansion, check to see if its
// coming from one of the allowed 'NULL' macros.
if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
- SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
- FileLocEnd = SM.getFileLoc(EndLoc);
+ const SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
+ FileLocEnd = SM.getFileLoc(EndLoc);
SourceLocation ImmediateMacroArgLoc, MacroLoc;
// Skip NULL macros used in macro.
if (!getMacroAndArgLocations(StartLoc, ImmediateMacroArgLoc, MacroLoc) ||
@@ -274,7 +275,7 @@ public:
}
if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) {
- StringRef OutermostMacroName =
+ const StringRef OutermostMacroName =
getOutermostMacroName(StartLoc, SM, Context.getLangOpts());
// Check to see if the user wants to replace the macro being expanded.
@@ -302,7 +303,7 @@ private:
/// Tests that all expansions of a macro arg, one of which expands to
/// result in \p CE, yield NullTo(Member)Pointer casts.
bool allArgUsesValid(const CastExpr *CE) {
- SourceLocation CastLoc = CE->getBeginLoc();
+ const SourceLocation CastLoc = CE->getBeginLoc();
// Step 1: Get location of macro arg and location of the macro the arg was
// provided to.
@@ -348,17 +349,17 @@ private:
// Find the location of the immediate macro expansion.
while (true) {
- std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(ArgLoc);
+ const std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(ArgLoc);
const SrcMgr::SLocEntry *E = &SM.getSLocEntry(LocInfo.first);
const SrcMgr::ExpansionInfo &Expansion = E->getExpansion();
- SourceLocation OldArgLoc = ArgLoc;
+ const SourceLocation OldArgLoc = ArgLoc;
ArgLoc = Expansion.getExpansionLocStart();
if (!Expansion.isMacroArgExpansion()) {
if (!MacroLoc.isFileID())
return false;
- StringRef Name =
+ const StringRef Name =
Lexer::getImmediateMacroName(OldArgLoc, SM, Context.getLangOpts());
return llvm::is_contained(NullMacros, Name);
}
@@ -371,7 +372,7 @@ private:
// If spelling location resides in the same FileID as macro expansion
// location, it means there is no inner macro.
- FileID MacroFID = SM.getFileID(MacroLoc);
+ const FileID MacroFID = SM.getFileID(MacroLoc);
if (SM.isInFileID(ArgLoc, MacroFID)) {
// Don't transform this case. If the characters that caused the
// null-conversion come from within a macro, they can't be changed.
@@ -401,7 +402,7 @@ private:
SourceLocation Loc = TestLoc, MacroLoc;
while (true) {
- std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
+ const std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
const SrcMgr::SLocEntry *E = &SM.getSLocEntry(LocInfo.first);
const SrcMgr::ExpansionInfo &Expansion = E->getExpansion();
diff --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
index 6a19183..62a2de2 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -55,9 +55,9 @@ void UseOverrideCheck::registerMatchers(MatchFinder *Finder) {
static SmallVector<Token, 16>
parseTokens(CharSourceRange Range, const MatchFinder::MatchResult &Result) {
const SourceManager &Sources = *Result.SourceManager;
- std::pair<FileID, unsigned> LocInfo =
+ const std::pair<FileID, unsigned> LocInfo =
Sources.getDecomposedLoc(Range.getBegin());
- StringRef File = Sources.getBufferData(LocInfo.first);
+ const StringRef File = Sources.getBufferData(LocInfo.first);
const char *TokenBegin = File.data() + LocInfo.second;
Lexer RawLexer(Sources.getLocForStartOfFile(LocInfo.first),
Result.Context->getLangOpts(), File.begin(), TokenBegin,
@@ -103,12 +103,12 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
Method->isOutOfLine())
return;
- bool HasVirtual = Method->isVirtualAsWritten();
- bool HasOverride = Method->getAttr<OverrideAttr>();
- bool HasFinal = Method->getAttr<FinalAttr>();
+ const bool HasVirtual = Method->isVirtualAsWritten();
+ const bool HasOverride = Method->getAttr<OverrideAttr>();
+ const bool HasFinal = Method->getAttr<FinalAttr>();
- bool OnlyVirtualSpecified = HasVirtual && !HasOverride && !HasFinal;
- unsigned KeywordCount = HasVirtual + HasOverride + HasFinal;
+ const bool OnlyVirtualSpecified = HasVirtual && !HasOverride && !HasFinal;
+ const unsigned KeywordCount = HasVirtual + HasOverride + HasFinal;
if ((!OnlyVirtualSpecified && KeywordCount == 1) ||
(!HasVirtual && HasOverride && HasFinal && AllowOverrideAndFinal))
@@ -120,12 +120,12 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
} else if (KeywordCount == 0) {
Message = "annotate this function with '%0' or (rarely) '%1'";
} else {
- StringRef Redundant =
+ const StringRef Redundant =
HasVirtual ? (HasOverride && HasFinal && !AllowOverrideAndFinal
? "'virtual' and '%0' are"
: "'virtual' is")
: "'%0' is";
- StringRef Correct = HasFinal ? "'%1'" : "'%0'";
+ const StringRef Correct = HasFinal ? "'%1'" : "'%0'";
Message = (llvm::Twine(Redundant) +
" redundant since the function is already declared " + Correct)
@@ -135,7 +135,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
auto Diag = diag(Method->getLocation(), Message)
<< OverrideSpelling << FinalSpelling;
- CharSourceRange FileRange = Lexer::makeFileCharRange(
+ const CharSourceRange FileRange = Lexer::makeFileCharRange(
CharSourceRange::getTokenRange(Method->getSourceRange()), Sources,
getLangOpts());
@@ -151,9 +151,9 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
if (!HasFinal && !HasOverride) {
SourceLocation InsertLoc;
std::string ReplacementText = (OverrideSpelling + " ").str();
- SourceLocation MethodLoc = Method->getLocation();
+ const SourceLocation MethodLoc = Method->getLocation();
- for (Token T : Tokens) {
+ for (const Token T : Tokens) {
if (T.is(tok::kw___attribute) &&
!Sources.isBeforeInTranslationUnit(T.getLocation(), MethodLoc)) {
InsertLoc = T.getLocation();
@@ -164,7 +164,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
if (Method->hasAttrs()) {
for (const clang::Attr *A : Method->getAttrs()) {
if (!A->isImplicit() && !A->isInherited()) {
- SourceLocation Loc =
+ const SourceLocation Loc =
Sources.getExpansionLoc(A->getRange().getBegin());
if ((!InsertLoc.isValid() ||
Sources.isBeforeInTranslationUnit(Loc, InsertLoc)) &&
@@ -221,13 +221,14 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
}
if (HasFinal && HasOverride && !AllowOverrideAndFinal) {
- SourceLocation OverrideLoc = Method->getAttr<OverrideAttr>()->getLocation();
+ const SourceLocation OverrideLoc =
+ Method->getAttr<OverrideAttr>()->getLocation();
Diag << FixItHint::CreateRemoval(
CharSourceRange::getTokenRange(OverrideLoc, OverrideLoc));
}
if (HasVirtual) {
- for (Token Tok : Tokens) {
+ for (const Token Tok : Tokens) {
if (Tok.is(tok::kw_virtual)) {
std::optional<Token> NextToken =
utils::lexer::findNextTokenIncludingComments(
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
index 9bf3169..8849c33 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
@@ -74,7 +74,8 @@ findLocksInCompoundStmt(const CompoundStmt *Block,
for (const Stmt *Stmt : Block->body()) {
if (const auto *DS = dyn_cast<DeclStmt>(Stmt)) {
- llvm::SmallVector<const VarDecl *> LockGuards = getLockGuardsFromDecl(DS);
+ const llvm::SmallVector<const VarDecl *> LockGuards =
+ getLockGuardsFromDecl(DS);
if (!LockGuards.empty()) {
CurrentLockGuardGroup.append(LockGuards);
@@ -176,7 +177,7 @@ void UseScopedLockCheck::registerMatchers(MatchFinder *Finder) {
void UseScopedLockCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *DS = Result.Nodes.getNodeAs<DeclStmt>("lock-decl-single")) {
- llvm::SmallVector<const VarDecl *> Decls = getLockGuardsFromDecl(DS);
+ const llvm::SmallVector<const VarDecl *> Decls = getLockGuardsFromDecl(DS);
diagOnMultipleLocks({Decls}, Result);
return;
}
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
index 414aa86..47ff9ff 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
@@ -307,7 +307,7 @@ UseStdNumbersCheck::UseStdNumbersCheck(const StringRef Name,
void UseStdNumbersCheck::registerMatchers(MatchFinder *const Finder) {
const auto Matches = MatchBuilder{DiffThreshold};
- std::vector<Matcher<clang::Stmt>> ConstantMatchers = {
+ const std::vector<Matcher<clang::Stmt>> ConstantMatchers = {
Matches.matchLog2Euler(), Matches.matchLog10Euler(),
Matches.matchEulerTopLevel(), Matches.matchEgamma(),
Matches.matchInvSqrtPi(), Matches.matchInvPi(),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index d623ec4..3c828c4 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -55,7 +55,7 @@ public:
bool visitUnqualName(StringRef UnqualName) {
// Check for collisions with function arguments.
- for (ParmVarDecl *Param : F.parameters())
+ for (const ParmVarDecl *Param : F.parameters())
if (const IdentifierInfo *Ident = Param->getIdentifier())
if (Ident->getName() == UnqualName) {
Collision = true;
@@ -126,7 +126,7 @@ public:
}
bool VisitDeclRefExpr(DeclRefExpr *S) {
- DeclarationName Name = S->getNameInfo().getName();
+ const DeclarationName Name = S->getNameInfo().getName();
return S->getQualifierLoc() || Name.isEmpty() || !Name.isIdentifier() ||
!visitUnqualName(Name.getAsIdentifierInfo()->getName());
}
@@ -159,14 +159,14 @@ static SourceLocation findTrailingReturnTypeSourceLocation(
const FunctionDecl &F, const FunctionTypeLoc &FTL, const ASTContext &Ctx,
const SourceManager &SM, const LangOptions &LangOpts) {
// We start with the location of the closing parenthesis.
- SourceRange ExceptionSpecRange = F.getExceptionSpecSourceRange();
+ const SourceRange ExceptionSpecRange = F.getExceptionSpecSourceRange();
if (ExceptionSpecRange.isValid())
return Lexer::getLocForEndOfToken(ExceptionSpecRange.getEnd(), 0, SM,
LangOpts);
// If the function argument list ends inside of a macro, it is dangerous to
// start lexing from here - bail out.
- SourceLocation ClosingParen = FTL.getRParenLoc();
+ const SourceLocation ClosingParen = FTL.getRParenLoc();
if (ClosingParen.isMacroID())
return {};
@@ -174,8 +174,8 @@ static SourceLocation findTrailingReturnTypeSourceLocation(
Lexer::getLocForEndOfToken(ClosingParen, 0, SM, LangOpts);
// Skip subsequent CV and ref qualifiers.
- std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(Result);
- StringRef File = SM.getBufferData(Loc.first);
+ const std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(Result);
+ const StringRef File = SM.getBufferData(Loc.first);
const char *TokenBegin = File.data() + Loc.second;
Lexer Lexer(SM.getLocForStartOfFile(Loc.first), LangOpts, File.begin(),
TokenBegin, File.end());
@@ -220,7 +220,7 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) {
Token End;
End.startToken();
End.setKind(tok::eof);
- SmallVector<Token, 2> Stream{Tok, End};
+ const SmallVector<Token, 2> Stream{Tok, End};
// FIXME: do not report these token to Preprocessor.TokenWatcher.
PP.EnterTokenStream(Stream, false, /*IsReinject=*/false);
@@ -230,8 +230,8 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) {
if (T.is(tok::eof))
break;
- bool Qual = isCvr(T);
- bool Spec = isSpecifier(T);
+ const bool Qual = isCvr(T);
+ const bool Spec = isSpecifier(T);
CT.IsQualifier &= Qual;
CT.IsSpecifier &= Spec;
ContainsQualifiers |= Qual;
@@ -252,12 +252,12 @@ classifyTokensBeforeFunctionName(const FunctionDecl &F, const ASTContext &Ctx,
const SourceManager &SM,
const LangOptions &LangOpts,
Preprocessor *PP) {
- SourceLocation BeginF = expandIfMacroId(F.getBeginLoc(), SM);
- SourceLocation BeginNameF = expandIfMacroId(F.getLocation(), SM);
+ const SourceLocation BeginF = expandIfMacroId(F.getBeginLoc(), SM);
+ const SourceLocation BeginNameF = expandIfMacroId(F.getLocation(), SM);
// Create tokens for everything before the name of the function.
- std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(BeginF);
- StringRef File = SM.getBufferData(Loc.first);
+ const std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(BeginF);
+ const StringRef File = SM.getBufferData(Loc.first);
const char *TokenBegin = File.data() + Loc.second;
Lexer Lexer(SM.getLocForStartOfFile(Loc.first), LangOpts, File.begin(),
TokenBegin, File.end());
@@ -369,9 +369,9 @@ static SourceLocation findLambdaTrailingReturnInsertLoc(
else
ParamEndLoc = Method->getParametersSourceRange().getEnd();
- std::pair<FileID, unsigned> ParamEndLocInfo =
+ const std::pair<FileID, unsigned> ParamEndLocInfo =
SM.getDecomposedLoc(ParamEndLoc);
- StringRef Buffer = SM.getBufferData(ParamEndLocInfo.first);
+ const StringRef Buffer = SM.getBufferData(ParamEndLocInfo.first);
Lexer Lexer(SM.getLocForStartOfFile(ParamEndLocInfo.first), LangOpts,
Buffer.begin(), Buffer.data() + ParamEndLocInfo.second,
@@ -421,11 +421,11 @@ static void keepSpecifiers(std::string &ReturnType, std::string &Auto,
return;
// Find specifiers, remove them from the return type, add them to 'auto'.
- unsigned int ReturnTypeBeginOffset =
+ const unsigned int ReturnTypeBeginOffset =
SM.getDecomposedLoc(ReturnTypeCVRange.getBegin()).second;
- size_t InitialAutoLength = Auto.size();
+ const size_t InitialAutoLength = Auto.size();
unsigned int DeletedChars = 0;
- for (ClassifiedToken CT : *MaybeTokens) {
+ for (const ClassifiedToken CT : *MaybeTokens) {
if (SM.isBeforeInTranslationUnit(CT.T.getLocation(),
ReturnTypeCVRange.getBegin()) ||
SM.isBeforeInTranslationUnit(ReturnTypeCVRange.getEnd(),
@@ -436,10 +436,11 @@ static void keepSpecifiers(std::string &ReturnType, std::string &Auto,
// Add the token to 'auto' and remove it from the return type, including
// any whitespace following the token.
- unsigned int TOffset = SM.getDecomposedLoc(CT.T.getLocation()).second;
+ const unsigned int TOffset = SM.getDecomposedLoc(CT.T.getLocation()).second;
assert(TOffset >= ReturnTypeBeginOffset &&
"Token location must be after the beginning of the return type");
- unsigned int TOffsetInRT = TOffset - ReturnTypeBeginOffset - DeletedChars;
+ const unsigned int TOffsetInRT =
+ TOffset - ReturnTypeBeginOffset - DeletedChars;
unsigned int TLengthWithWS = CT.T.getLength();
while (TOffsetInRT + TLengthWithWS < ReturnType.size() &&
llvm::isSpace(ReturnType[TOffsetInRT + TLengthWithWS]))
@@ -548,7 +549,7 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- SourceLocation InsertionLoc =
+ const SourceLocation InsertionLoc =
findTrailingReturnTypeSourceLocation(*F, FTL, Ctx, SM, LangOpts);
if (InsertionLoc.isInvalid()) {
diag(F->getLocation(), ErrorMessageOnFunction);
@@ -558,7 +559,7 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
// Using the declared return type via F->getDeclaredReturnType().getAsString()
// discards user formatting and order of const, volatile, type, whitespace,
// space before & ... .
- SourceRange ReturnTypeCVRange = findReturnTypeAndCVSourceRange(
+ const SourceRange ReturnTypeCVRange = findReturnTypeAndCVSourceRange(
*F, FTL.getReturnLoc(), Ctx, SM, LangOpts, PP);
if (ReturnTypeCVRange.isInvalid()) {
diag(F->getLocation(), ErrorMessageOnFunction);
@@ -580,13 +581,13 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- SourceLocation ReturnTypeEnd =
+ const SourceLocation ReturnTypeEnd =
Lexer::getLocForEndOfToken(ReturnTypeCVRange.getEnd(), 0, SM, LangOpts);
- StringRef CharAfterReturnType = Lexer::getSourceText(
+ const StringRef CharAfterReturnType = Lexer::getSourceText(
CharSourceRange::getCharRange(ReturnTypeEnd,
ReturnTypeEnd.getLocWithOffset(1)),
SM, LangOpts);
- bool NeedSpaceAfterAuto =
+ const bool NeedSpaceAfterAuto =
CharAfterReturnType.empty() || !llvm::isSpace(CharAfterReturnType[0]);
std::string Auto = NeedSpaceAfterAuto ? "auto " : "auto";
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
index 03ecec9..e3672f8 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
@@ -96,7 +96,7 @@ void UseTransparentFunctorsCheck::check(
FunctorParentType->template_arguments()[ArgNum];
if (Arg.getKind() != TemplateArgument::Type)
continue;
- QualType ParentArgType = Arg.getAsType();
+ const QualType ParentArgType = Arg.getAsType();
if (ParentArgType->isRecordType() &&
ParentArgType->getAsCXXRecordDecl() ==
Functor->getAsType()->getAsCXXRecordDecl())
@@ -105,13 +105,13 @@ void UseTransparentFunctorsCheck::check(
// Functor is a default template argument.
if (ArgNum == FunctorParentType->template_arguments().size())
return;
- TemplateArgumentLoc FunctorLoc = FunctorParentLoc.getArgLoc(ArgNum);
+ const TemplateArgumentLoc FunctorLoc = FunctorParentLoc.getArgLoc(ArgNum);
auto FunctorTypeLoc = getInnerTypeLocAs<TemplateSpecializationTypeLoc>(
FunctorLoc.getTypeSourceInfo()->getTypeLoc());
if (FunctorTypeLoc.isNull())
return;
- SourceLocation ReportLoc = FunctorLoc.getLocation();
+ const SourceLocation ReportLoc = FunctorLoc.getLocation();
if (ReportLoc.isInvalid())
return;
diag(ReportLoc, Message) << FuncClass->getName()
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
index eef9d39..08c40d4 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
@@ -15,7 +15,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::modernize {
void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) {
- std::string MatchText = "::std::uncaught_exception";
+ const std::string MatchText = "::std::uncaught_exception";
// Using declaration: warning and fix-it.
Finder->addMatcher(
@@ -78,7 +78,7 @@ void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) {
*Result.SourceManager, getLangOpts());
Text.consume_back("()");
- int TextLength = Text.size();
+ const int TextLength = Text.size();
if (WarnOnly) {
return;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 7267375..38b3689 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -114,7 +114,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
if (ExternCDecl && IgnoreExternC)
return;
- SourceLocation StartLoc = MatchedDecl->getBeginLoc();
+ const SourceLocation StartLoc = MatchedDecl->getBeginLoc();
if (StartLoc.isMacroID() && IgnoreMacros)
return;
@@ -172,7 +172,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
.str(),
ExtraReference.str()};
}();
- StringRef Name = MatchedDecl->getName();
+ const StringRef Name = MatchedDecl->getName();
SourceRange ReplaceRange = MatchedDecl->getSourceRange();
// typedefs with multiple comma-separated definitions produce multiple
@@ -223,7 +223,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- std::string Replacement = (Using + Name + " = " + Type + QualifierStr).str();
+ const std::string Replacement =
+ (Using + Name + " = " + Type + QualifierStr).str();
Diag << FixItHint::CreateReplacement(ReplaceRange, Replacement);
}
} // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/objc/AssertEquals.cpp b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
index 9d274ee..a9e6a4b 100644
--- a/clang-tools-extra/clang-tidy/objc/AssertEquals.cpp
+++ b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "AssertEquals.h"
+#include "AssertEqualsCheck.h"
#include "llvm/ADT/StringMap.h"
#include <string>
@@ -21,7 +21,7 @@ static const llvm::StringMap<StringRef> NameMap{
{"XCTAssertNotEqual", "XCTAssertNotEqualObjects"},
};
-void AssertEquals::registerMatchers(MatchFinder *Finder) {
+void AssertEqualsCheck::registerMatchers(MatchFinder *Finder) {
for (const auto &[CurrName, _] : NameMap) {
Finder->addMatcher(
binaryOperator(anyOf(hasOperatorName("!="), hasOperatorName("==")),
@@ -35,7 +35,8 @@ void AssertEquals::registerMatchers(MatchFinder *Finder) {
}
}
-void AssertEquals::check(const ast_matchers::MatchFinder::MatchResult &Result) {
+void AssertEqualsCheck::check(
+ const ast_matchers::MatchFinder::MatchResult &Result) {
for (const auto &[CurrName, TargetName] : NameMap) {
if (const auto *Root = Result.Nodes.getNodeAs<BinaryOperator>(CurrName)) {
const SourceManager *Sm = Result.SourceManager;
diff --git a/clang-tools-extra/clang-tidy/objc/AssertEquals.h b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.h
index 1405065..237daba 100644
--- a/clang-tools-extra/clang-tidy/objc/AssertEquals.h
+++ b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.h
@@ -6,22 +6,22 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALS_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALSCHECK_H
#include "../ClangTidyCheck.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
namespace clang::tidy::objc {
-/// Warn if XCTAssertEqual() or XCTAssertNotEqual() is used with at least one
+/// Warns if XCTAssertEqual() or XCTAssertNotEqual() is used with at least one
/// operands of type NSString*.
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/objc/assert-equals.html
-class AssertEquals final : public ClangTidyCheck {
+class AssertEqualsCheck final : public ClangTidyCheck {
public:
- AssertEquals(StringRef Name, ClangTidyContext *Context)
+ AssertEqualsCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.ObjC;
@@ -32,4 +32,4 @@ public:
} // namespace clang::tidy::objc
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALS_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
index e28d25d..2908d11 100644
--- a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt
@@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
)
add_clang_library(clangTidyObjCModule STATIC
- AssertEquals.cpp
+ AssertEqualsCheck.cpp
AvoidNSErrorInitCheck.cpp
DeallocInCategoryCheck.cpp
ForbiddenSubclassingCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp b/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
index c21b459..411d252 100644
--- a/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
@@ -9,7 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
-#include "AssertEquals.h"
+#include "AssertEqualsCheck.h"
#include "AvoidNSErrorInitCheck.h"
#include "DeallocInCategoryCheck.h"
#include "ForbiddenSubclassingCheck.h"
@@ -29,7 +29,7 @@ public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
"objc-avoid-nserror-init");
- CheckFactories.registerCheck<AssertEquals>("objc-assert-equals");
+ CheckFactories.registerCheck<AssertEqualsCheck>("objc-assert-equals");
CheckFactories.registerCheck<DeallocInCategoryCheck>(
"objc-dealloc-in-category");
diff --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
index c6e547c..9a2f900 100644
--- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
@@ -23,7 +23,7 @@ add_clang_library(clangTidyPerformanceModule STATIC
PerformanceTidyModule.cpp
TriviallyDestructibleCheck.cpp
TypePromotionInMathFnCheck.cpp
- UnnecessaryCopyInitialization.cpp
+ UnnecessaryCopyInitializationCheck.cpp
UnnecessaryValueParamCheck.cpp
LINK_LIBS
diff --git a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
index ae15208..3497ea7 100644
--- a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
@@ -26,7 +26,7 @@
#include "NoexceptSwapCheck.h"
#include "TriviallyDestructibleCheck.h"
#include "TypePromotionInMathFnCheck.h"
-#include "UnnecessaryCopyInitialization.h"
+#include "UnnecessaryCopyInitializationCheck.h"
#include "UnnecessaryValueParamCheck.h"
namespace clang::tidy {
@@ -66,7 +66,7 @@ public:
"performance-trivially-destructible");
CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
"performance-type-promotion-in-math-fn");
- CheckFactories.registerCheck<UnnecessaryCopyInitialization>(
+ CheckFactories.registerCheck<UnnecessaryCopyInitializationCheck>(
"performance-unnecessary-copy-initialization");
CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
"performance-unnecessary-value-param");
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
index fec4c14..e6fe857 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "UnnecessaryCopyInitialization.h"
+#include "UnnecessaryCopyInitializationCheck.h"
#include "../utils/DeclRefExprUtils.h"
#include "../utils/FixItHintUtils.h"
#include "../utils/LexerUtils.h"
@@ -227,7 +227,7 @@ static QualType constructorArgumentType(const VarDecl *OldVar,
return MethodDecl->getReturnType();
}
-UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
+UnnecessaryCopyInitializationCheck::UnnecessaryCopyInitializationCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
AllowedTypes(
@@ -235,7 +235,7 @@ UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
ExcludedContainerTypes(utils::options::parseStringList(
Options.get("ExcludedContainerTypes", ""))) {}
-void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
+void UnnecessaryCopyInitializationCheck::registerMatchers(MatchFinder *Finder) {
auto LocalVarCopiedFrom =
[this](const ast_matchers::internal::Matcher<Expr> &CopyCtorArg) {
return compoundStmt(
@@ -276,7 +276,7 @@ void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
this);
}
-void UnnecessaryCopyInitialization::check(
+void UnnecessaryCopyInitializationCheck::check(
const MatchFinder::MatchResult &Result) {
const auto &NewVar = *Result.Nodes.getNodeAs<VarDecl>("newVarDecl");
const auto &BlockStmt = *Result.Nodes.getNodeAs<Stmt>("blockStmt");
@@ -325,7 +325,7 @@ void UnnecessaryCopyInitialization::check(
}
}
-void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
+void UnnecessaryCopyInitializationCheck::handleCopyFromMethodReturn(
const CheckContext &Ctx, const VarDecl *ObjectArg) {
const bool IsConstQualified = Ctx.Var.getType().isConstQualified();
if (!IsConstQualified && !Ctx.IsVarOnlyUsedAsConst)
@@ -337,7 +337,7 @@ void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
diagnoseCopyFromMethodReturn(Ctx);
}
-void UnnecessaryCopyInitialization::handleCopyFromLocalVar(
+void UnnecessaryCopyInitializationCheck::handleCopyFromLocalVar(
const CheckContext &Ctx, const VarDecl &OldVar) {
if (!Ctx.IsVarOnlyUsedAsConst ||
!isInitializingVariableImmutable(OldVar, Ctx.BlockStmt, Ctx.ASTCtx,
@@ -346,7 +346,7 @@ void UnnecessaryCopyInitialization::handleCopyFromLocalVar(
diagnoseCopyFromLocalVar(Ctx, OldVar);
}
-void UnnecessaryCopyInitialization::diagnoseCopyFromMethodReturn(
+void UnnecessaryCopyInitializationCheck::diagnoseCopyFromMethodReturn(
const CheckContext &Ctx) {
auto Diagnostic =
diag(Ctx.Var.getLocation(),
@@ -360,7 +360,7 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromMethodReturn(
maybeIssueFixes(Ctx, Diagnostic);
}
-void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
+void UnnecessaryCopyInitializationCheck::diagnoseCopyFromLocalVar(
const CheckContext &Ctx, const VarDecl &OldVar) {
auto Diagnostic =
diag(Ctx.Var.getLocation(),
@@ -372,7 +372,7 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
maybeIssueFixes(Ctx, Diagnostic);
}
-void UnnecessaryCopyInitialization::maybeIssueFixes(
+void UnnecessaryCopyInitializationCheck::maybeIssueFixes(
const CheckContext &Ctx, DiagnosticBuilder &Diagnostic) {
if (Ctx.IssueFix) {
if (Ctx.IsVarUnused)
@@ -382,7 +382,7 @@ void UnnecessaryCopyInitialization::maybeIssueFixes(
}
}
-void UnnecessaryCopyInitialization::storeOptions(
+void UnnecessaryCopyInitializationCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "AllowedTypes",
utils::options::serializeStringList(AllowedTypes));
diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h
index 5edc744..89957a5 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATION_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATION_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATIONCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATIONCHECK_H
#include "../ClangTidyCheck.h"
#include "clang/AST/Decl.h"
@@ -22,9 +22,12 @@ namespace clang::tidy::performance {
// The check currently only understands a subset of variables that are
// guaranteed to outlive the const reference returned, namely: const variables,
// const references, and const pointers to const.
-class UnnecessaryCopyInitialization : public ClangTidyCheck {
+//
+// For the user-facing documentation see:
+// https://clang.llvm.org/extra/clang-tidy/checks/performance/unnecessary-copy-initialization.html
+class UnnecessaryCopyInitializationCheck : public ClangTidyCheck {
public:
- UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext *Context);
+ UnnecessaryCopyInitializationCheck(StringRef Name, ClangTidyContext *Context);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
@@ -64,4 +67,4 @@ private:
} // namespace clang::tidy::performance
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATION_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATIONCHECK_H
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp
index 02fe913..0e1c389 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "AvoidConstParamsInDecls.h"
+#include "AvoidConstParamsInDeclsCheck.h"
#include "../utils/LexerUtils.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -38,11 +38,12 @@ findConstToRemove(const ParmVarDecl &Param,
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
}
-void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+void AvoidConstParamsInDeclsCheck::storeOptions(
+ ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "IgnoreMacros", IgnoreMacros);
}
-void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
+void AvoidConstParamsInDeclsCheck::registerMatchers(MatchFinder *Finder) {
const auto ConstParamDecl =
parmVarDecl(hasType(qualType(isConstQualified()))).bind("param");
Finder->addMatcher(functionDecl(unless(isDefinition()),
@@ -51,7 +52,8 @@ void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
this);
}
-void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
+void AvoidConstParamsInDeclsCheck::check(
+ const MatchFinder::MatchResult &Result) {
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func");
const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("param");
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.h
index 6490508..467a9a4 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLS_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLSCHECK_H
#include "../ClangTidyCheck.h"
@@ -15,9 +15,12 @@ namespace clang::tidy::readability {
// Detect function declarations that have const value parameters and discourage
// them.
-class AvoidConstParamsInDecls : public ClangTidyCheck {
+//
+// For the user-facing documentation see:
+// https://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-const-params-in-decls.html
+class AvoidConstParamsInDeclsCheck : public ClangTidyCheck {
public:
- AvoidConstParamsInDecls(StringRef Name, ClangTidyContext *Context)
+ AvoidConstParamsInDeclsCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IgnoreMacros(Options.get("IgnoreMacros", true)) {}
@@ -34,4 +37,4 @@ private:
} // namespace clang::tidy::readability
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLS_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLSCHECK_H
diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 91e9354..161a0d9 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
add_clang_library(clangTidyReadabilityModule STATIC
AmbiguousSmartptrResetCallCheck.cpp
- AvoidConstParamsInDecls.cpp
+ AvoidConstParamsInDeclsCheck.cpp
AvoidNestedConditionalOperatorCheck.cpp
AvoidReturnWithVoidValueCheck.cpp
AvoidUnconditionalPreprocessorIfCheck.cpp
@@ -14,7 +14,7 @@ add_clang_library(clangTidyReadabilityModule STATIC
ContainerContainsCheck.cpp
ContainerDataPointerCheck.cpp
ContainerSizeEmptyCheck.cpp
- ConvertMemberFunctionsToStatic.cpp
+ ConvertMemberFunctionsToStaticCheck.cpp
DeleteNullPointerCheck.cpp
DuplicateIncludeCheck.cpp
ElseAfterReturnCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
index 6da4cf7..1383e3b 100644
--- a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ConvertMemberFunctionsToStatic.h"
+#include "ConvertMemberFunctionsToStaticCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
@@ -78,7 +78,8 @@ AST_MATCHER(CXXMethodDecl, usesThis) {
} // namespace
-void ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
+void ConvertMemberFunctionsToStaticCheck::registerMatchers(
+ MatchFinder *Finder) {
Finder->addMatcher(
cxxMethodDecl(
isDefinition(), isUserProvided(),
@@ -131,7 +132,7 @@ static SourceRange getLocationOfConst(const TypeSourceInfo *TSI,
return {Start, Start.getLocWithOffset(strlen("const") - 1)};
}
-void ConvertMemberFunctionsToStatic::check(
+void ConvertMemberFunctionsToStaticCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *Definition = Result.Nodes.getNodeAs<CXXMethodDecl>("x");
diff --git a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.h b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.h
index 20cb7f2..4f8a1a9 100644
--- a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.h
+++ b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATIC_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATIC_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATICCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATICCHECK_H
#include "../ClangTidyCheck.h"
@@ -18,10 +18,10 @@ namespace clang::tidy::readability {
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/
-/// readability-convert-member-functions-to-static.html
-class ConvertMemberFunctionsToStatic : public ClangTidyCheck {
+/// readability/convert-member-functions-to-static.html
+class ConvertMemberFunctionsToStaticCheck : public ClangTidyCheck {
public:
- ConvertMemberFunctionsToStatic(StringRef Name, ClangTidyContext *Context)
+ ConvertMemberFunctionsToStaticCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
@@ -32,4 +32,4 @@ public:
} // namespace clang::tidy::readability
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATIC_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATICCHECK_H
diff --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
index 942a0a8..a8a6d35 100644
--- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
@@ -146,7 +146,6 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
return qualType(anyOf(qualType(pointerType(pointee(InnerMatchers...))),
qualType(substTemplateTypeParmType(hasReplacementType(
pointerType(pointee(InnerMatchers...)))))));
-
};
auto IsAutoDeducedToPointer =
diff --git a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
index 569302e..afb6357 100644
--- a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -10,7 +10,7 @@
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "AmbiguousSmartptrResetCallCheck.h"
-#include "AvoidConstParamsInDecls.h"
+#include "AvoidConstParamsInDeclsCheck.h"
#include "AvoidNestedConditionalOperatorCheck.h"
#include "AvoidReturnWithVoidValueCheck.h"
#include "AvoidUnconditionalPreprocessorIfCheck.h"
@@ -19,7 +19,7 @@
#include "ContainerContainsCheck.h"
#include "ContainerDataPointerCheck.h"
#include "ContainerSizeEmptyCheck.h"
-#include "ConvertMemberFunctionsToStatic.h"
+#include "ConvertMemberFunctionsToStaticCheck.h"
#include "DeleteNullPointerCheck.h"
#include "DuplicateIncludeCheck.h"
#include "ElseAfterReturnCheck.h"
@@ -74,7 +74,7 @@ public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<AmbiguousSmartptrResetCallCheck>(
"readability-ambiguous-smartptr-reset-call");
- CheckFactories.registerCheck<AvoidConstParamsInDecls>(
+ CheckFactories.registerCheck<AvoidConstParamsInDeclsCheck>(
"readability-avoid-const-params-in-decls");
CheckFactories.registerCheck<AvoidNestedConditionalOperatorCheck>(
"readability-avoid-nested-conditional-operator");
@@ -92,7 +92,7 @@ public:
"readability-container-data-pointer");
CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
"readability-container-size-empty");
- CheckFactories.registerCheck<ConvertMemberFunctionsToStatic>(
+ CheckFactories.registerCheck<ConvertMemberFunctionsToStaticCheck>(
"readability-convert-member-functions-to-static");
CheckFactories.registerCheck<DeleteNullPointerCheck>(
"readability-delete-null-pointer");
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 5fd1b73..8ead264 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -562,17 +562,6 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
}
}
Results.merge(Uncaught);
- } else if (const auto *Call = dyn_cast<CallExpr>(St)) {
- if (const FunctionDecl *Func = Call->getDirectCallee()) {
- const ExceptionInfo Excs =
- throwsException(Func, Caught, CallStack, Call->getBeginLoc());
- Results.merge(Excs);
- }
- } else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
- const ExceptionInfo Excs =
- throwsException(Construct->getConstructor(), Caught, CallStack,
- Construct->getBeginLoc());
- Results.merge(Excs);
} else if (const auto *DefaultInit = dyn_cast<CXXDefaultInitExpr>(St)) {
const ExceptionInfo Excs =
throwsException(DefaultInit->getExpr(), Caught, CallStack);
@@ -602,10 +591,25 @@ ExceptionAnalyzer::throwsException(const Stmt *St,
Results.merge(Excs);
}
} else {
+ // Check whether any of this node's subexpressions throws.
for (const Stmt *Child : St->children()) {
const ExceptionInfo Excs = throwsException(Child, Caught, CallStack);
Results.merge(Excs);
}
+
+ // If this node is a call to a function or constructor, also check
+ // whether the call itself throws.
+ if (const auto *Call = dyn_cast<CallExpr>(St)) {
+ if (const FunctionDecl *Func = Call->getDirectCallee()) {
+ ExceptionInfo Excs =
+ throwsException(Func, Caught, CallStack, Call->getBeginLoc());
+ Results.merge(Excs);
+ }
+ } else if (const auto *Construct = dyn_cast<CXXConstructExpr>(St)) {
+ ExceptionInfo Excs = throwsException(Construct->getConstructor(), Caught,
+ CallStack, Construct->getBeginLoc());
+ Results.merge(Excs);
+ }
}
return Results;
}
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 92a2d33..666865c 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -300,7 +300,9 @@ Changes in existing checks
- Improved :doc:`bugprone-exception-escape
<clang-tidy/checks/bugprone/exception-escape>` check's handling of lambdas:
exceptions from captures are now diagnosed, exceptions in the bodies of
- lambdas that aren't actually invoked are not.
+ lambdas that aren't actually invoked are not. Additionally, fixed an issue
+ where the check wouldn't diagnose throws in arguments to functions or
+ constructors.
- Improved :doc:`bugprone-infinite-loop
<clang-tidy/checks/bugprone/infinite-loop>` check by adding detection for
diff --git a/clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst b/clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst
index 01b0024..6cf5434 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/boost/use-ranges.rst
@@ -146,7 +146,7 @@ If calls are made using reverse iterators on containers, The code will be
fixed using the ``boost::adaptors::reverse`` adaptor.
.. code-block:: c++
-
+
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
std::crbegin(Items2), std::crend(Items2));
@@ -166,7 +166,7 @@ Options
is `llvm`.
.. option:: IncludeBoostSystem
-
+
If `true` (default value) the boost headers are included as system headers
with angle brackets (`#include <boost.hpp>`), otherwise quotes are used
(`#include "boost.hpp"`).
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/assignment-in-if-condition.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/assignment-in-if-condition.rst
index 9fa37c0..691b6e4 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/assignment-in-if-condition.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/assignment-in-if-condition.rst
@@ -8,7 +8,7 @@ Such assignments are bug-prone because they may have been intended as equality t
This check finds all assignments within `if` conditions, including ones that are not flagged
by `-Wparentheses` due to an extra set of parentheses, and including assignments that call
-an overloaded `operator=()`. The identified assignments violate
+an overloaded `operator=()`. The identified assignments violate
`BARR group "Rule 8.2.c" <https://barrgroup.com/embedded-systems/books/embedded-c-coding-standard/statement-rules/if-else-statements>`_.
.. code-block:: c++
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
index dfc2ca1..1017462 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
@@ -30,7 +30,7 @@ Possible fixes:
- marking copy and move constructors and assignment operators deleted.
- using class member method instead of class member variable with function
object types.
- - passing ``this`` pointer as parameter
+ - passing ``this`` pointer as parameter.
Options
-------
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
index f24abfd..53082f4 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
@@ -6,7 +6,7 @@ bugprone-crtp-constructor-accessibility
Detects error-prone Curiously Recurring Template Pattern usage, when the CRTP
can be constructed outside itself and the derived class.
-The CRTP is an idiom, in which a class derives from a template class, where
+The CRTP is an idiom, in which a class derives from a template class, where
itself is the template argument. It should be ensured that if a class is
intended to be a base class in this idiom, it can only be instantiated if
the derived class is its template argument.
@@ -23,7 +23,7 @@ Example:
class Derived : CRTP<Derived> {};
-Below can be seen some common mistakes that will allow the breaking of the
+Below can be seen some common mistakes that will allow the breaking of the
idiom.
If the constructor of a class intended to be used in a CRTP is public, then
@@ -62,7 +62,7 @@ Example:
class Bad : CRTP<Good> {};
Bad BadInstance;
-To ensure that no accidental instantiation happens, the best practice is to
+To ensure that no accidental instantiation happens, the best practice is to
make the constructor private and declare the derived class as friend. Note
that as a tradeoff, this also gives the derived class access to every other
private members of the CRTP. However, constructors can still be public or
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/derived-method-shadowing-base-method.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/derived-method-shadowing-base-method.rst
index f544abc..aff3e1e6 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/derived-method-shadowing-base-method.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/derived-method-shadowing-base-method.rst
@@ -7,7 +7,7 @@ Finds derived class methods that shadow a (non-virtual) base class method.
In order to be considered "shadowing", methods must have the same signature
(i.e. the same name, same number of parameters, same parameter types, etc).
-Only checks public, non-templated methods.
+Only checks public, non-templated methods.
The below example is bugprone because consumers of the ``Derived`` class will
expect the ``reset`` method to do the work of ``Base::reset()`` in addition to extra
@@ -27,4 +27,4 @@ This is also a violation of the Liskov Substitution Principle.
struct Derived : public Base {
void reset() {/* reset the derived class, but not the base class */};
- }; \ No newline at end of file
+ };
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-shared-from-this.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-shared-from-this.rst
index cc9e7be..968340a 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-shared-from-this.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-shared-from-this.rst
@@ -3,8 +3,8 @@
bugprone-incorrect-enable-shared-from-this
==========================================
-Detect classes or structs that do not publicly inherit from
-``std::enable_shared_from_this``, because unintended behavior will
+Detect classes or structs that do not publicly inherit from
+``std::enable_shared_from_this``, because unintended behavior will
otherwise occur when calling ``shared_from_this``.
Consider the following code:
@@ -15,7 +15,7 @@ Consider the following code:
// private inheritance
class BadExample : std::enable_shared_from_this<BadExample> {
-
+
// ``shared_from_this``` unintended behaviour
// `libstdc++` implementation returns uninitialized ``weak_ptr``
public:
@@ -29,6 +29,6 @@ Consider the following code:
b_ex->bar();
}
-Using `libstdc++` implementation, ``shared_from_this`` will throw
-``std::bad_weak_ptr``. When ``using_not_public()`` is called, this code will
+Using `libstdc++` implementation, ``shared_from_this`` will throw
+``std::bad_weak_ptr``. When ``using_not_public()`` is called, this code will
crash without exception handling.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst
index 95509ef..2641cfe 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/pointer-arithmetic-on-polymorphic-object.rst
@@ -54,7 +54,7 @@ Options
Default: `false`.
.. code-block:: c++
-
+
void bar(Base b[], Derived d[]) {
b += 1; // warning, as Base declares a virtual destructor
d += 1; // warning only if IgnoreVirtualDeclarationsOnly is set to false
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type.rst
index 0ce7f80..db38444 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/raw-memory-call-on-non-trivial-type.rst
@@ -16,17 +16,17 @@ Options
.. option:: MemSetNames
- Specify extra functions to flag that act similarly to ``memset``. Specify
+ Specify extra functions to flag that act similarly to ``memset``. Specify
names in a semicolon-delimited list. Default is an empty string.
.. option:: MemCpyNames
- Specify extra functions to flag that act similarly to ``memcpy``. Specify
+ Specify extra functions to flag that act similarly to ``memcpy``. Specify
names in a semicolon-delimited list. Default is an empty string.
.. option:: MemCmpNames
- Specify extra functions to flag that act similarly to ``memcmp``. Specify
+ Specify extra functions to flag that act similarly to ``memcmp``. Specify
names in a semicolon-delimited list. Default is an empty string.
This check corresponds to the CERT C++ Coding Standard rule
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
index 325a0a2..00759a2 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst
@@ -22,7 +22,7 @@ Example
S(int);
~S();
};
-
+
const S &fn(const S &a) {
return a;
}
@@ -35,7 +35,7 @@ This issue can be resolved by declaring an overload of the problematic function
where the ``const &`` parameter is instead declared as ``&&``. The developer has
to ensure that the implementation of that function does not produce a
use-after-free, the exact error that this check is warning against.
-Marking such an ``&&`` overload as ``deleted``, will silence the warning as
+Marking such an ``&&`` overload as ``deleted``, will silence the warning as
well. In the case of different ``const &`` parameters being returned depending
on the control flow of the function, an overload where all problematic
``const &`` parameters have been declared as ``&&`` will resolve the issue.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst
index 658b6555..848fb66 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst
@@ -44,7 +44,7 @@ Options
Selects which set of functions is considered as asynchronous-safe
(and therefore allowed in signal handlers). It can be set to the following values:
-
+
``minimal``
Selects a minimal set that is defined in the CERT SIG30-C rule.
and includes functions ``abort()``, ``_Exit()``, ``quick_exit()`` and
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
index a0bd1d7..ad4ed89 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/string-constructor.rst
@@ -36,7 +36,7 @@ Examples:
std::string_view("test", 0);
Passing an invalid first character position parameter to constructor will
-cause ``std::out_of_range`` exception at runtime.
+cause ``std::out_of_range`` exception at runtime.
Examples:
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-realloc-usage.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-realloc-usage.rst
index 67e416b..25a0d88 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-realloc-usage.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-realloc-usage.rst
@@ -10,7 +10,7 @@ The problem with this construct is that if ``realloc`` fails it returns a
null pointer but does not deallocate the original memory. If no other variable
is pointing to it, the original memory block is not available any more for the
program to use or free. In either case ``p = realloc(p, size);`` indicates bad
-coding style and can be replaced by ``q = realloc(p, size);``.
+coding style and can be replaced by ``q = realloc(p, size);``.
The pointer expression (used at ``realloc``) can be a variable or a field member
of a data structure, but can not contain function calls or unresolved types.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
index 072b5a3..a3469dc 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
@@ -9,7 +9,7 @@ different from the number of data members inside the union.
A struct or a class is considered to be a tagged union if it has
exactly one union data member and exactly one enum data member and
any number of other data members that are neither unions or enums.
-Furthermore, the types of the union and the enum members must
+Furthermore, the types of the union and the enum members must
not come from system header files nor the ``std`` namespace.
Example:
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unsafe-functions.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unsafe-functions.rst
index 317db9c..6937c517 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unsafe-functions.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unsafe-functions.rst
@@ -86,7 +86,7 @@ checked. The format is the following, without newlines:
.. code::
bugprone-unsafe-functions.CustomFunctions="
- functionRegex1[, replacement1[, reason1]];
+ functionRegex1[, replacement1[, reason1]];
functionRegex2[, replacement2[, reason2]];
...
"
@@ -104,7 +104,7 @@ As an example, the configuration `^original$, replacement, is deprecated;`
will produce the following diagnostic message.
.. code:: c
-
+
original(); // warning: function 'original' is deprecated; 'replacement' should be used instead.
::std::original(); // no-warning
original_function(); // no-warning
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst
index aeaaad7..9eaa12f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cert/fio38-c.rst
@@ -8,3 +8,6 @@ cert-fio38-c
The `cert-fio38-c` check is an alias, please see
:doc:`misc-non-copyable-objects <../misc/non-copyable-objects>` for more
information.
+
+This check corresponds to CERT C++ Coding Standard rule `FIO38-C. Do not copy a FILE object
+<https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.rst
index 1ecdcdb..f45bca6 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.rst
@@ -42,11 +42,11 @@ Options
Semicolon-separated list of regular expressions matching class names that
overwrites the default exclusion list. The default is:
`::std::map;::std::unordered_map;::std::flat_map`.
-
+
.. option:: FixMode
- Determines what fixes are suggested. Either `none`, `at` (use
- ``a.at(index)`` if a fitting function exists) or `function` (use a
+ Determines what fixes are suggested. Either `none`, `at` (use
+ ``a.at(index)`` if a fitting function exists) or `function` (use a
function ``f(a, index)``). The default is `none`.
.. option:: FixFunction
@@ -54,7 +54,7 @@ Options
The function to use in the `function` mode. For C++23 and beyond, the
passed function must support the empty subscript operator, i.e., the case
where ``a[]`` becomes ``f(a)``. :option:`FixFunctionEmptyArgs` can be
- used to override the suggested function in that case. The default is `gsl::at`.
+ used to override the suggested function in that case. The default is `gsl::at`.
.. option:: FixFunctionEmptyArgs
diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-static-over-anonymous-namespace.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-static-over-anonymous-namespace.rst
index 85579ca..79179ce 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-static-over-anonymous-namespace.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-static-over-anonymous-namespace.rst
@@ -37,7 +37,7 @@ For example non-compliant code:
Should become:
.. code-block:: c++
-
+
// Small anonymous namespace for class declaration
namespace {
@@ -48,7 +48,7 @@ Should become:
};
}
-
+
// placed method definition outside of the anonymous namespace
bool StringSort::operator<(const char *RHS) const {}
@@ -70,4 +70,4 @@ Options
.. option:: AllowMemberFunctionsInClass
When `true`, only methods defined in anonymous namespace outside of the
- corresponding class will be warned. Default value is `true`. \ No newline at end of file
+ corresponding class will be warned. Default value is `true`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm/use-ranges.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm/use-ranges.rst
index fffa2ff..1a04547 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/llvm/use-ranges.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm/use-ranges.rst
@@ -12,7 +12,7 @@ Example
.. code-block:: c++
auto it = std::find(vec.begin(), vec.end(), value);
- bool all = std::all_of(vec.begin(), vec.end(),
+ bool all = std::all_of(vec.begin(), vec.end(),
[](int x) { return x > 0; });
Transforms to:
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
index 93a5762..18ec10b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst
@@ -99,7 +99,7 @@ Options
.. option:: AnalyzePointers
Enable or disable the analysis of pointers variables, like
- ``int *ptr = &i;``. For specific checks, see
+ ``int *ptr = &i;``. For specific checks, see
:option:`WarnPointersAsValues` and :option:`WarnPointersAsPointers`.
Default is `true`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst
index 34833a3..4364610 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst
@@ -10,7 +10,7 @@ Findings correspond to https://clangd.llvm.org/design/include-cleaner.
Example:
.. code-block:: c++
-
+
// foo.h
class Foo{};
// bar.h
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-bidirectional.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-bidirectional.rst
index 16ffc97..e9bc19a 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-bidirectional.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-bidirectional.rst
@@ -3,7 +3,7 @@
misc-misleading-bidirectional
=============================
-Warn about unterminated bidirectional unicode sequence, detecting potential attack
+Warns about unterminated bidirectional unicode sequence, detecting potential attack
as described in the `Trojan Source <https://www.trojansource.codes>`_ attack.
Example:
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst
index d1f7bba..d3190e1 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/non-copyable-objects.rst
@@ -5,9 +5,12 @@ misc-non-copyable-objects
`cert-fio38-c` redirects here as an alias for this check.
-The check flags dereferences and non-pointer declarations of objects that are
+Flags dereferences and non-pointer declarations of objects that are
not meant to be passed by value, such as C FILE objects or POSIX
``pthread_mutex_t`` objects.
+References
+----------
+
This check corresponds to CERT C++ Coding Standard rule `FIO38-C. Do not copy a FILE object
<https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object>`_.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst
index 310bfe2..24be51b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst
@@ -20,7 +20,7 @@ the ``using`` keyword is not considered as visibility change by this check.
private:
virtual void f_priv();
};
-
+
class B: public A {
public:
void f_priv(); // warning: changed visibility from private to public
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/min-max-use-initializer-list.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/min-max-use-initializer-list.rst
index d6721a2..157c447 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/min-max-use-initializer-list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/min-max-use-initializer-list.rst
@@ -3,7 +3,7 @@
modernize-min-max-use-initializer-list
======================================
-Replaces nested ``std::min`` and ``std::max`` calls with an initializer list
+Replaces nested ``std::min`` and ``std::max`` calls with an initializer list
where applicable.
For instance, consider the following code:
@@ -21,8 +21,8 @@ The check will transform the above code to:
Performance Considerations
==========================
-While this check simplifies the code and makes it more readable, it may cause
-performance degradation for non-trivial types due to the need to copy objects
+While this check simplifies the code and makes it more readable, it may cause
+performance degradation for non-trivial types due to the need to copy objects
into the initializer list.
To avoid this, it is recommended to use `std::ref` or `std::cref` for
@@ -47,4 +47,4 @@ Options
.. option:: IgnoreTrivialTypesOfSizeAbove
An integer specifying the size (in bytes) above which trivial types are
- ignored. Default is `32`. \ No newline at end of file
+ ignored. Default is `32`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
index 91be4fb..c0cffde 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
@@ -37,7 +37,7 @@ Options
#define IS_SIGNED(T) std::is_signed<T>::value
- Defaults to `false`.
+ Defaults to `false`.
Limitations
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
index 912b42b3..98779d8 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
@@ -114,7 +114,7 @@ If calls are made using reverse iterators on containers, The code will be
fixed using the ``std::views::reverse`` adaptor.
.. code-block:: c++
-
+
auto AreSame = std::equal(Items1.rbegin(), Items1.rend(),
std::crbegin(Items2), std::crend(Items2));
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst
index 7cf24b4..9235d42 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst
@@ -93,9 +93,9 @@ Options
template <typename T>
using Lock = std::lock_guard<T>; // warning: use 'std::scoped_lock' instead of 'std::lock_guard'
-
+
using LockMutex = std::lock_guard<std::mutex>; // warning: use 'std::scoped_lock' instead of 'std::lock_guard'
-
+
typedef std::lock_guard<std::mutex> LockDef; // warning: use 'std::scoped_lock' instead of 'std::lock_guard'
- using std::lock_guard; // warning: use 'std::scoped_lock' instead of 'std::lock_guard' \ No newline at end of file
+ using std::lock_guard; // warning: use 'std::scoped_lock' instead of 'std::lock_guard'
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst
index 1babc2d..fd89b78 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst
@@ -4,7 +4,7 @@ modernize-use-starts-ends-with
==============================
Checks for common roundabout ways to express ``starts_with`` and ``ends_with``
-and suggests replacing with the simpler method when it is available. Notably,
+and suggests replacing with the simpler method when it is available. Notably,
this will work with ``std::string`` and ``std::string_view``.
Covered scenarios:
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst
index 7038e7b..21bb254 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst
@@ -62,7 +62,7 @@ Options
.. option:: StrFormatLikeFunctions
- A semicolon-separated list of regular expressions matching the
+ A semicolon-separated list of regular expressions matching the
(fully qualified) names of functions to replace, with the requirement that
the first parameter contains the printf-style format string and the
arguments to be formatted follow immediately afterwards. Qualified member
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
index eb2159b..3005708 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -122,7 +122,7 @@ Options
.. option:: PrintfLikeFunctions
- A semicolon-separated list of regular expressions matching the
+ A semicolon-separated list of regular expressions matching the
(fully qualified) names of functions to replace, with the requirement
that the first parameter contains the printf-style format string and the
arguments to be formatted follow immediately afterwards. Qualified member
@@ -134,13 +134,13 @@ Options
.. option:: FprintfLikeFunctions
- A semicolon-separated list of regular expressions matching the
+ A semicolon-separated list of regular expressions matching the
(fully qualified) names of functions to replace, with the requirement
that the first parameter is retained, the second parameter contains the
printf-style format string and the arguments to be formatted follow
immediately afterwards. Qualified member function names are supported,
but the replacement function name must be unqualified. If neither this
- option nor `PrintfLikeFunctions` are set then the default value is
+ option nor `PrintfLikeFunctions` are set then the default value is
`fprintf;absl::FPrintF`, otherwise it is the empty string.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/objc/nsdate-formatter.rst b/clang-tools-extra/docs/clang-tidy/checks/objc/nsdate-formatter.rst
index cff493b..b5a1386 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/objc/nsdate-formatter.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/objc/nsdate-formatter.rst
@@ -10,64 +10,64 @@ despite being legal. See http://www.unicode.org/reports/tr35/tr35-dates.html#Dat
This checker reports as warnings the following string patterns in a date format specifier:
#. yyyy + ww : Calendar year specified with week of a week year (unless YYYY is also specified).
-
- * | **Example 1:** Input Date: `29 December 2014` ; Format String: `yyyy-ww`;
+
+ * | **Example 1:** Input Date: `29 December 2014` ; Format String: `yyyy-ww`;
| Output string: `2014-01` (Wrong because it’s not the first week of 2014)
-
- * | **Example 2:** Input Date: `29 December 2014` ; Format String: `dd-MM-yyyy (ww-YYYY)`;
+
+ * | **Example 2:** Input Date: `29 December 2014` ; Format String: `dd-MM-yyyy (ww-YYYY)`;
| Output string: `29-12-2014 (01-2015)` (This is correct)
-
+
#. F without ee/EE : Numeric day of week in a month without actual day.
-
- * | **Example:** Input Date: `29 December 2014` ; Format String: `F-MM`;
+
+ * | **Example:** Input Date: `29 December 2014` ; Format String: `F-MM`;
| Output string: `5-12` (Wrong because it reads as *5th ___ of Dec* in English)
-
+
#. F without MM : Numeric day of week in a month without month.
-
+
* | **Example:** Input Date: `29 December 2014` ; Format String: `F-EE`
| Output string: `5-Mon` (Wrong because it reads as *5th Mon of ___* in English)
-
+
#. WW without MM : Week of the month without the month.
-
+
* | **Example:** Input Date: `29 December 2014` ; Format String: `WW-yyyy`
| Output string: `05-2014` (Wrong because it reads as *5th Week of ___* in English)
-
+
#. YYYY + QQ : Week year specified with quarter of normal year (unless yyyy is also specified).
-
+
* | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-QQ`
| Output string: `2015-04` (Wrong because it’s not the 4th quarter of 2015)
-
+
* | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (QQ-yyyy)`
| Output string: `01-2015 (04-2014)` (This is correct)
-
+
#. YYYY + MM : Week year specified with Month of a calendar year (unless yyyy is also specified).
-
+
* | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-MM`
| Output string: `2015-12` (Wrong because it’s not the 12th month of 2015)
-
+
* | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (MM-yyyy)`
| Output string: `01-2015 (12-2014)` (This is correct)
-
+
#. YYYY + DD : Week year with day of a calendar year (unless yyyy is also specified).
-
+
* | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-DD`
| Output string: `2015-363` (Wrong because it’s not the 363rd day of 2015)
-
+
* | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (DD-yyyy)`
| Output string: `01-2015 (363-2014)` (This is correct)
-
+
#. YYYY + WW : Week year with week of a calendar year (unless yyyy is also specified).
-
+
* | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-WW`
| Output string: `2015-05` (Wrong because it’s not the 5th week of 2015)
-
+
* | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (WW-MM-yyyy)`
| Output string: `01-2015 (05-12-2014)` (This is correct)
-
+
#. YYYY + F : Week year with day of week in a calendar month (unless yyyy is also specified).
-
+
* | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-ww-F-EE`
| Output string: `2015-01-5-Mon` (Wrong because it’s not the 5th Monday of January in 2015)
-
+
* | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (F-EE-MM-yyyy)`
| Output string: `01-2015 (5-Mon-12-2014)` (This is correct)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/portability/template-virtual-member-function.rst b/clang-tools-extra/docs/clang-tidy/checks/portability/template-virtual-member-function.rst
index aa3ed66..913b20f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/portability/template-virtual-member-function.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/portability/template-virtual-member-function.rst
@@ -3,11 +3,11 @@
portability-template-virtual-member-function
============================================
-Finds cases when an uninstantiated virtual member function in a template class causes
+Finds cases when an uninstantiated virtual member function in a template class causes
cross-compiler incompatibility.
-Upon instantiating a template class, non-virtual member functions don't have to be
-instantiated unless they are used. Virtual member function instantiation on the other hand
+Upon instantiating a template class, non-virtual member functions don't have to be
+instantiated unless they are used. Virtual member function instantiation on the other hand
is unspecified and depends on the implementation of the compiler.
In the following snippets the virtual member function is not instantiated by GCC and Clang,
@@ -19,7 +19,7 @@ it is rejected by the latter.
template<typename T>
struct CrossPlatformError {
virtual ~CrossPlatformError() = default;
-
+
static void used() {}
virtual void unused() {
@@ -33,5 +33,5 @@ it is rejected by the latter.
}
Cross-platform projects that need to support MSVC on Windows might see compiler errors
-because certain virtual member functions are instantiated, which are not instantiated
+because certain virtual member functions are instantiated, which are not instantiated
by other compilers on other platforms. This check highlights such virtual member functions.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/ambiguous-smartptr-reset-call.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/ambiguous-smartptr-reset-call.rst
index cf73839..f8df02d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/ambiguous-smartptr-reset-call.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/ambiguous-smartptr-reset-call.rst
@@ -40,14 +40,14 @@ other smart pointers or other classes use the :option:`SmartPointers` option.
.. note::
-
+
The check may emit invalid fix-its and misleading warning messages when
specifying custom smart pointers or other classes in the
:option:`SmartPointers` option. For example, ``boost::scoped_ptr`` does not
have an ``operator=`` which makes fix-its invalid.
.. note::
-
+
Automatic fix-its are enabled only if :program:`clang-tidy` is invoked with
the `--fix-notes` option.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/math-missing-parentheses.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/math-missing-parentheses.rst
index 21d66da..59f17eb 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/math-missing-parentheses.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/math-missing-parentheses.rst
@@ -9,7 +9,7 @@ of different priorities.
Parentheses in mathematical expressions clarify the order
of operations, especially with different-priority operators. Lengthy or multiline
expressions can obscure this order, leading to coding errors. IDEs can aid clarity
-by highlighting parentheses. Explicitly using parentheses also clarifies what the
+by highlighting parentheses. Explicitly using parentheses also clarifies what the
developer had in mind when writing the expression. Ensuring their presence reduces
ambiguity and errors, promoting clearer and more maintainable code.
@@ -24,4 +24,4 @@ After:
.. code-block:: c++
- int x = 1 + (2 * 3) - (4 / 5); \ No newline at end of file
+ int x = 1 + (2 * 3) - (4 / 5);
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst
index c33c05b..5ae80d5 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst
@@ -15,7 +15,7 @@ In the example above the keyword ``inline`` is redundant since constexpr
functions are implicitly inlined
.. code-block:: c++
-
+
class MyClass {
inline void myMethod() {}
};
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-parentheses.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-parentheses.rst
index 20e3891..b9c50c5 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-parentheses.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/redundant-parentheses.rst
@@ -36,7 +36,7 @@ Options
Semicolon-separated list of regular expressions matching names of declarations
to ignore when the parentheses are around. Declarations can include variables
or functions. The default is an `std::max;std::min`.
-
+
Some STL library functions may have the same name as widely used function-like
macro. For example, ``std::max`` and ``max`` macro. A workaround to distinguish
them is adding parentheses around functions to prevent function-like macro.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
index a52bbe2..140c93f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -948,7 +948,7 @@ const auto throw_in_noexcept_lambda = [] () noexcept { throw 42; };
// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: an exception may be thrown in function 'operator()' which should not throw exceptions
// CHECK-MESSAGES: :[[@LINE-2]]:56: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
-void thrower() {
+int thrower() {
throw 42;
}
@@ -956,3 +956,54 @@ const auto indirect_throw_in_noexcept_lambda = [] () noexcept { thrower(); };
// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: an exception may be thrown in function 'operator()' which should not throw exceptions
// CHECK-MESSAGES: :[[@LINE-5]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here
// CHECK-MESSAGES: :[[@LINE-3]]:65: note: frame #1: function 'operator()' calls function 'thrower' here
+
+int f(int);
+void throw_in_function_arg() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_function_arg' which should not throw exceptions
+ f(false ? 0 : throw 1);
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:17: note: frame #0: unhandled exception of type 'int' may be thrown in function 'throw_in_function_arg' here
+
+int g(int, int, int);
+void throw_in_last_function_arg() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_last_function_arg' which should not throw exceptions
+ g(42, 67, false ? 0 : throw 1);
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:25: note: frame #0: unhandled exception of type 'int' may be thrown in function 'throw_in_last_function_arg' here
+
+void indirect_throw_in_function_arg() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_throw_in_function_arg' which should not throw exceptions
+ f(thrower());
+}
+// CHECK-MESSAGES: :[[@LINE-26]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here
+// CHECK-MESSAGES: :[[@LINE-3]]:5: note: frame #1: function 'indirect_throw_in_function_arg' calls function 'thrower' here
+
+void indirect_throw_from_lambda_in_function_arg() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_throw_from_lambda_in_function_arg' which should not throw exceptions
+ f([] { throw 1; return 0; }());
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:10: note: frame #0: unhandled exception of type 'int' may be thrown in function 'operator()' here
+// CHECK-MESSAGES: :[[@LINE-3]]:30: note: frame #1: function 'indirect_throw_from_lambda_in_function_arg' calls function 'operator()' here
+
+struct S {
+ S(int) noexcept {}
+};
+
+void throw_in_constructor_arg() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_in_constructor_arg' which should not throw exceptions
+ S s(false ? 0 : throw 1);
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:19: note: frame #0: unhandled exception of type 'int' may be thrown in function 'throw_in_constructor_arg' here
+
+void indirect_throw_in_constructor_arg() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'indirect_throw_in_constructor_arg' which should not throw exceptions
+ S s = thrower();
+}
+// CHECK-MESSAGES: :[[@LINE-50]]:3: note: frame #0: unhandled exception of type 'int' may be thrown in function 'thrower' here
+// CHECK-MESSAGES: :[[@LINE-3]]:9: note: frame #1: function 'indirect_throw_in_constructor_arg' calls function 'thrower' here
+
+void weird_throw_in_call_subexpression() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'weird_throw_in_call_subexpression' which should not throw exceptions
+ (false ? []{} : throw 1)();
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:19: note: frame #0: unhandled exception of type 'int' may be thrown in function 'weird_throw_in_call_subexpression' here
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3a4e1fc..6b396e7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -119,6 +119,7 @@ C++ Specific Potentially Breaking Changes
ABI Changes in This Version
---------------------------
+- Fix AArch64 argument passing for C++ empty classes with large explicitly specified alignment.
AST Dumping Potentially Breaking Changes
----------------------------------------
diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp
index bb41a14..d42fcd8 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -422,6 +422,12 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
}
// Empty records:
+ // AAPCS64 does not say that empty records are ignored as arguments,
+ // but other compilers do so in certain situations, and we copy that behavior.
+ // Those situations are in fact language-mode-specific, which seems really
+ // unfortunate, but it's something we just have to accept. If this doesn't
+ // apply, just fall through to the standard argument-handling path.
+ // Darwin overrides the psABI here to ignore all empty records in all modes.
uint64_t Size = getContext().getTypeSize(Ty);
bool IsEmpty = isEmptyRecord(getContext(), Ty, true);
if (!Ty->isSVESizelessBuiltinType() && (IsEmpty || Size == 0)) {
@@ -434,9 +440,6 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn,
// behaviour here.
if (Size == 0)
return ABIArgInfo::getIgnore();
-
- // Otherwise, they are passed as if they have a size of 1 byte.
- return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()));
}
// Homogeneous Floating-point Aggregates (HFAs) need to be expanded.
diff --git a/clang/lib/Headers/avx512cdintrin.h b/clang/lib/Headers/avx512cdintrin.h
index fb6dcb6..f9de207 100644
--- a/clang/lib/Headers/avx512cdintrin.h
+++ b/clang/lib/Headers/avx512cdintrin.h
@@ -17,8 +17,8 @@
/* Define the default attributes for the functions in this file. */
#if defined(__cplusplus) && (__cplusplus >= 201103L)
#define __DEFAULT_FN_ATTRS \
- constexpr __attribute__((__always_inline__, __nodebug__, \
- __target__("avx512cd"), __min_vector_width__(512)))
+ __attribute__((__always_inline__, __nodebug__, __target__("avx512cd"), \
+ __min_vector_width__(512))) constexpr
#else
#define __DEFAULT_FN_ATTRS \
__attribute__((__always_inline__, __nodebug__, __target__("avx512cd"), \
diff --git a/clang/lib/Headers/avx512vlcdintrin.h b/clang/lib/Headers/avx512vlcdintrin.h
index 7719680f..df66e1d 100644
--- a/clang/lib/Headers/avx512vlcdintrin.h
+++ b/clang/lib/Headers/avx512vlcdintrin.h
@@ -16,13 +16,13 @@
/* Define the default attributes for the functions in this file. */
#if defined(__cplusplus) && (__cplusplus >= 201103L)
#define __DEFAULT_FN_ATTRS128 \
- constexpr __attribute__((__always_inline__, __nodebug__, \
- __target__("avx512vl,avx512cd"), \
- __min_vector_width__(128)))
+ __attribute__((__always_inline__, __nodebug__, \
+ __target__("avx512vl,avx512cd"), \
+ __min_vector_width__(128))) constexpr
#define __DEFAULT_FN_ATTRS256 \
- constexpr __attribute__((__always_inline__, __nodebug__, \
- __target__("avx512vl,avx512cd"), \
- __min_vector_width__(256)))
+ __attribute__((__always_inline__, __nodebug__, \
+ __target__("avx512vl,avx512cd"), \
+ __min_vector_width__(256))) constexpr
#else
#define __DEFAULT_FN_ATTRS128 \
__attribute__((__always_inline__, __nodebug__, \
diff --git a/clang/test/CodeGen/AArch64/args.cpp b/clang/test/CodeGen/AArch64/args.cpp
index 3cb62d3..c284316 100644
--- a/clang/test/CodeGen/AArch64/args.cpp
+++ b/clang/test/CodeGen/AArch64/args.cpp
@@ -17,11 +17,29 @@ struct Empty {};
// DARWIN: define{{.*}} i32 @empty_arg(i32 noundef %a)
// C: define{{.*}} i32 @empty_arg(i32 noundef %a)
-// CXX: define{{.*}} i32 @empty_arg(i8 %e.coerce, i32 noundef %a)
+// CXX: define{{.*}} i32 @empty_arg(i64 %e.coerce, i32 noundef %a)
EXTERNC int empty_arg(struct Empty e, int a) {
return a;
}
+// CXX: define{{.*}} i32 @empty_align8_arg(i64 %a.coerce, i32 noundef %b)
+struct EmptyAlign8 { int __attribute__((aligned(8))) : 0; };
+EXTERNC int empty_align8_arg(struct EmptyAlign8 a, int b) {
+ return b;
+}
+
+// CXX: define{{.*}} i32 @empty_align16_arg(i128 %a.coerce, i32 noundef %b)
+struct EmptyAlign16 { long long int __attribute__((aligned(16))) : 0; };
+EXTERNC int empty_align16_arg(struct EmptyAlign16 a, int b) {
+ return b;
+}
+
+// CXX: define{{.*}} i32 @empty_align32_arg(ptr dead_on_return noundef %a, i32 noundef %b)
+struct EmptyAlign32 { long long int __attribute__((aligned(32))) : 0; };
+EXTERNC int empty_align32_arg(struct EmptyAlign32 a, int b) {
+ return b;
+}
+
// DARWIN: define{{.*}} void @empty_ret()
// C: define{{.*}} void @empty_ret()
// CXX: define{{.*}} void @empty_ret()
diff --git a/clang/test/CodeGen/AArch64/struct-coerce-using-ptr.cpp b/clang/test/CodeGen/AArch64/struct-coerce-using-ptr.cpp
index f0c9ef2..97fdd0c 100644
--- a/clang/test/CodeGen/AArch64/struct-coerce-using-ptr.cpp
+++ b/clang/test/CodeGen/AArch64/struct-coerce-using-ptr.cpp
@@ -575,19 +575,21 @@ void TSpp_align16(SSpp_align16 s) { *s.a.x = 1; }
struct Sempty {
};
// CHECK-A64-LABEL: define dso_local void @_Z6Tempty6Sempty(
-// CHECK-A64-SAME: i8 [[S_COERCE:%.*]]) #[[ATTR0]] {
+// CHECK-A64-SAME: i64 [[S_COERCE:%.*]]) #[[ATTR0]] {
// CHECK-A64-NEXT: [[ENTRY:.*:]]
// CHECK-A64-NEXT: [[S:%.*]] = alloca [[STRUCT_SEMPTY:%.*]], align 1
// CHECK-A64-NEXT: [[COERCE_DIVE:%.*]] = getelementptr inbounds nuw [[STRUCT_SEMPTY]], ptr [[S]], i32 0, i32 0
-// CHECK-A64-NEXT: store i8 [[S_COERCE]], ptr [[COERCE_DIVE]], align 1
+// CHECK-A64-NEXT: [[COERCE_VAL_II:%.*]] = trunc i64 [[S_COERCE]] to i8
+// CHECK-A64-NEXT: store i8 [[COERCE_VAL_II]], ptr [[COERCE_DIVE]], align 1
// CHECK-A64-NEXT: ret void
//
// CHECK-A64_32-LABEL: define void @_Z6Tempty6Sempty(
-// CHECK-A64_32-SAME: i8 [[S_COERCE:%.*]]) #[[ATTR0]] {
+// CHECK-A64_32-SAME: i64 [[S_COERCE:%.*]]) #[[ATTR0]] {
// CHECK-A64_32-NEXT: [[ENTRY:.*:]]
// CHECK-A64_32-NEXT: [[S:%.*]] = alloca [[STRUCT_SEMPTY:%.*]], align 1
// CHECK-A64_32-NEXT: [[COERCE_DIVE:%.*]] = getelementptr inbounds nuw [[STRUCT_SEMPTY]], ptr [[S]], i32 0, i32 0
-// CHECK-A64_32-NEXT: store i8 [[S_COERCE]], ptr [[COERCE_DIVE]], align 1
+// CHECK-A64_32-NEXT: [[COERCE_VAL_II:%.*]] = trunc i64 [[S_COERCE]] to i8
+// CHECK-A64_32-NEXT: store i8 [[COERCE_VAL_II]], ptr [[COERCE_DIVE]], align 1
// CHECK-A64_32-NEXT: ret void
//
void Tempty(Sempty s) { }
diff --git a/clang/test/CodeGen/arm64-microsoft-arguments.cpp b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
index a0a81be..f7eb0cc 100644
--- a/clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -57,7 +57,7 @@ S4 f4() {
// Pass and return from instance method called from instance method.
// CHECK: define {{.*}} void @{{.*}}bar@Q1{{.*}}(ptr {{[^,]*}} %this, ptr dead_on_unwind inreg noalias writable sret(%class.P1) align 1 %agg.result)
-// CHECK: call void {{.*}}foo@P1{{.*}}(ptr noundef{{[^,]*}} %ref.tmp, ptr dead_on_unwind inreg writable sret(%class.P1) align 1 %agg.result, i8 %0)
+// CHECK: call void {{.*}}foo@P1{{.*}}(ptr noundef{{[^,]*}} %ref.tmp, ptr dead_on_unwind inreg writable sret(%class.P1) align 1 %agg.result, i64 %coerce.val.ii)
class P1 {
public:
@@ -76,7 +76,7 @@ P1 Q1::bar() {
// Pass and return from instance method called from free function.
// CHECK: define {{.*}} void {{.*}}bar{{.*}}()
-// CHECK: call void {{.*}}foo@P2{{.*}}(ptr noundef{{[^,]*}} %ref.tmp, ptr dead_on_unwind inreg writable sret(%class.P2) align 1 %retval, i8 %0)
+// CHECK: call void {{.*}}foo@P2{{.*}}(ptr noundef{{[^,]*}} %ref.tmp, ptr dead_on_unwind inreg writable sret(%class.P2) align 1 %retval, i64 %coerce.val.ii)
class P2 {
public:
P2 foo(P2 x);
diff --git a/clang/test/CodeGenCXX/aarch64-arguments.cpp b/clang/test/CodeGenCXX/aarch64-arguments.cpp
index ffb0caf..3206e38 100644
--- a/clang/test/CodeGenCXX/aarch64-arguments.cpp
+++ b/clang/test/CodeGenCXX/aarch64-arguments.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple arm64-none-linux -emit-llvm -w -o - %s | FileCheck -check-prefix=PCS %s
-// PCS: define{{.*}} void @{{.*}}(i8 %a
+// PCS: define{{.*}} void @{{.*}}(i64 %a.coerce)
struct s0 {};
void f0(s0 a) {}
diff --git a/clang/test/CodeGenCXX/arm64-darwinpcs.cpp b/clang/test/CodeGenCXX/arm64-darwinpcs.cpp
index a0b0d9e..ef0e2da 100644
--- a/clang/test/CodeGenCXX/arm64-darwinpcs.cpp
+++ b/clang/test/CodeGenCXX/arm64-darwinpcs.cpp
@@ -7,7 +7,7 @@ void test_extensions(bool a, char b, short c) {}
struct Empty {};
void test_empty(Empty e) {}
-// CHECK: define{{.*}} void @_Z10test_empty5Empty(i8
+// CHECK: define{{.*}} void @_Z10test_empty5Empty(i64 %e.coerce)
// CHECK-DARWIN: define{{.*}} void @_Z10test_empty5Empty()
struct HFA {
diff --git a/libc/include/llvm-libc-macros/netinet-in-macros.h b/libc/include/llvm-libc-macros/netinet-in-macros.h
index fb7564ce..2011c34 100644
--- a/libc/include/llvm-libc-macros/netinet-in-macros.h
+++ b/libc/include/llvm-libc-macros/netinet-in-macros.h
@@ -9,6 +9,9 @@
#ifndef LLVM_LIBC_MACROS_NETINET_IN_MACROS_H
#define LLVM_LIBC_MACROS_NETINET_IN_MACROS_H
+#include "../llvm-libc-types/in_addr_t.h"
+#include "__llvm-libc-common.h"
+
#define IPPROTO_IP 0
#define IPPROTO_ICMP 1
#define IPPROTO_TCP 6
@@ -24,4 +27,10 @@
#define IPV6_LEAVE_GROUP 21
#define IPV6_V6ONLY 26
+#define INADDR_ANY __LLVM_LIBC_CAST(static_cast, in_addr_t, 0x00000000)
+#define INADDR_BROADCAST __LLVM_LIBC_CAST(static_cast, in_addr_t, 0xffffffff)
+
+#define INET_ADDRSTRLEN 16
+#define INET6_ADDRSTRLEN 46
+
#endif // LLVM_LIBC_MACROS_NETINET_IN_MACROS_H
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index 2fe3af7..5fc5c14 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -15,6 +15,7 @@
#include "lldb/lldb-types.h"
#include <memory>
#include <set>
+#include <vector>
namespace llvm {
namespace json {
diff --git a/llvm/benchmarks/CMakeLists.txt b/llvm/benchmarks/CMakeLists.txt
index e411ed4..6581f47 100644
--- a/llvm/benchmarks/CMakeLists.txt
+++ b/llvm/benchmarks/CMakeLists.txt
@@ -22,7 +22,7 @@ if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
get_host_tool_path(llvm-nm LLVM_NM llvm_nm_exe llvm_nm_target)
get_host_tool_path(llc LLC llc_exe llc_target)
- if(${llc_exe} AND ${llvm_nm_exe})
+ if(llc_exe AND llvm_nm_exe)
# Extract the list of symbols in a random utility as sample data.
set(SYMBOL_TEST_DATA_FILE "sample_symbol_list.txt")
set(SYMBOL_TEST_DATA_SOURCE_BINARY ${llc_exe})
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index b158e0f..27ec6c6 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1758,6 +1758,9 @@ static Value *simplifyOperationIntoSelectOperand(Instruction &I, SelectInst *SI,
m_Specific(Op), m_Value(V))) &&
isGuaranteedNotToBeUndefOrPoison(V)) {
// Pass
+ } else if (match(Op, m_ZExt(m_Specific(SI->getCondition())))) {
+ V = IsTrueArm ? ConstantInt::get(Op->getType(), 1)
+ : ConstantInt::getNullValue(Op->getType());
} else {
V = Op;
}
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 37c048f..ed2a5c29 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -302,7 +302,9 @@ class SimplifyCFGOpt {
bool tryToSimplifyUncondBranchWithICmpInIt(ICmpInst *ICI,
IRBuilder<> &Builder);
-
+ bool tryToSimplifyUncondBranchWithICmpSelectInIt(ICmpInst *ICI,
+ SelectInst *Select,
+ IRBuilder<> &Builder);
bool hoistCommonCodeFromSuccessors(Instruction *TI, bool AllInstsEqOnly);
bool hoistSuccIdenticalTerminatorToSwitchOrIf(
Instruction *TI, Instruction *I1,
@@ -5023,16 +5025,65 @@ bool SimplifyCFGOpt::simplifyIndirectBrOnSelect(IndirectBrInst *IBI,
/// the PHI, merging the third icmp into the switch.
bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpInIt(
ICmpInst *ICI, IRBuilder<> &Builder) {
+ // Select == nullptr means we assume that there is a hidden no-op select
+ // instruction of `_ = select %icmp, true, false` after `%icmp = icmp ...`
+ return tryToSimplifyUncondBranchWithICmpSelectInIt(ICI, nullptr, Builder);
+}
+
+/// Similar to tryToSimplifyUncondBranchWithICmpInIt, but handle a more generic
+/// case. This is called when we find an icmp instruction (a seteq/setne with a
+/// constant) and its following select instruction as the only TWO instructions
+/// in a block that ends with an uncond branch. We are looking for a very
+/// specific pattern that occurs when "
+/// if (A == 1) return C1;
+/// if (A == 2) return C2;
+/// if (A < 3) return C3;
+/// return C4;
+/// " gets simplified. In this case, we merge the first two "branches of icmp"
+/// into a switch, but then the default value goes to an uncond block with a lt
+/// icmp and select in it, as InstCombine can not simplify "A < 3" as "A == 2".
+/// After SimplifyCFG and other subsequent optimizations (e.g., SCCP), we might
+/// get something like:
+///
+/// case1:
+/// switch i8 %A, label %DEFAULT [ i8 0, label %end i8 1, label %case2 ]
+/// case2:
+/// br label %end
+/// DEFAULT:
+/// %tmp = icmp eq i8 %A, 2
+/// %val = select i1 %tmp, i8 C3, i8 C4
+/// br label %end
+/// end:
+/// _ = phi i8 [ C1, %case1 ], [ C2, %case2 ], [ %val, %DEFAULT ]
+///
+/// We prefer to split the edge to 'end' so that there are TWO entries of V3/V4
+/// to the PHI, merging the icmp & select into the switch, as follows:
+///
+/// case1:
+/// switch i8 %A, label %DEFAULT [
+/// i8 0, label %end
+/// i8 1, label %case2
+/// i8 2, label %case3
+/// ]
+/// case2:
+/// br label %end
+/// case3:
+/// br label %end
+/// DEFAULT:
+/// br label %end
+/// end:
+/// _ = phi i8 [ C1, %case1 ], [ C2, %case2 ], [ C3, %case2 ], [ C4, %DEFAULT]
+bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpSelectInIt(
+ ICmpInst *ICI, SelectInst *Select, IRBuilder<> &Builder) {
BasicBlock *BB = ICI->getParent();
- // If the block has any PHIs in it or the icmp has multiple uses, it is too
- // complex.
- if (isa<PHINode>(BB->begin()) || !ICI->hasOneUse())
+ // If the block has any PHIs in it or the icmp/select has multiple uses, it is
+ // too complex.
+ /// TODO: support multi-phis in succ BB of select's BB.
+ if (isa<PHINode>(BB->begin()) || !ICI->hasOneUse() ||
+ (Select && !Select->hasOneUse()))
return false;
- Value *V = ICI->getOperand(0);
- ConstantInt *Cst = cast<ConstantInt>(ICI->getOperand(1));
-
// The pattern we're looking for is where our only predecessor is a switch on
// 'V' and this block is the default case for the switch. In this case we can
// fold the compared value into the switch to simplify things.
@@ -5040,8 +5091,36 @@ bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpInIt(
if (!Pred || !isa<SwitchInst>(Pred->getTerminator()))
return false;
+ Value *IcmpCond;
+ ConstantInt *NewCaseVal;
+ CmpPredicate Predicate;
+
+ // Match icmp X, C
+ if (!match(ICI,
+ m_ICmp(Predicate, m_Value(IcmpCond), m_ConstantInt(NewCaseVal))))
+ return false;
+
+ Value *SelectCond, *SelectTrueVal, *SelectFalseVal;
+ Instruction *User;
+ if (!Select) {
+ // If Select == nullptr, we can assume that there is a hidden no-op select
+ // just after icmp
+ SelectCond = ICI;
+ SelectTrueVal = Builder.getTrue();
+ SelectFalseVal = Builder.getFalse();
+ User = ICI->user_back();
+ } else {
+ SelectCond = Select->getCondition();
+ // Check if the select condition is the same as the icmp condition.
+ if (SelectCond != ICI)
+ return false;
+ SelectTrueVal = Select->getTrueValue();
+ SelectFalseVal = Select->getFalseValue();
+ User = Select->user_back();
+ }
+
SwitchInst *SI = cast<SwitchInst>(Pred->getTerminator());
- if (SI->getCondition() != V)
+ if (SI->getCondition() != IcmpCond)
return false;
// If BB is reachable on a non-default case, then we simply know the value of
@@ -5063,9 +5142,9 @@ bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpInIt(
// Ok, the block is reachable from the default dest. If the constant we're
// comparing exists in one of the other edges, then we can constant fold ICI
// and zap it.
- if (SI->findCaseValue(Cst) != SI->case_default()) {
+ if (SI->findCaseValue(NewCaseVal) != SI->case_default()) {
Value *V;
- if (ICI->getPredicate() == ICmpInst::ICMP_EQ)
+ if (Predicate == ICmpInst::ICMP_EQ)
V = ConstantInt::getFalse(BB->getContext());
else
V = ConstantInt::getTrue(BB->getContext());
@@ -5076,25 +5155,30 @@ bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpInIt(
return requestResimplify();
}
- // The use of the icmp has to be in the 'end' block, by the only PHI node in
+ // The use of the select has to be in the 'end' block, by the only PHI node in
// the block.
BasicBlock *SuccBlock = BB->getTerminator()->getSuccessor(0);
- PHINode *PHIUse = dyn_cast<PHINode>(ICI->user_back());
+ PHINode *PHIUse = dyn_cast<PHINode>(User);
if (PHIUse == nullptr || PHIUse != &SuccBlock->front() ||
isa<PHINode>(++BasicBlock::iterator(PHIUse)))
return false;
- // If the icmp is a SETEQ, then the default dest gets false, the new edge gets
- // true in the PHI.
- Constant *DefaultCst = ConstantInt::getTrue(BB->getContext());
- Constant *NewCst = ConstantInt::getFalse(BB->getContext());
+ // If the icmp is a SETEQ, then the default dest gets SelectFalseVal, the new
+ // edge gets SelectTrueVal in the PHI.
+ Value *DefaultCst = SelectFalseVal;
+ Value *NewCst = SelectTrueVal;
- if (ICI->getPredicate() == ICmpInst::ICMP_EQ)
+ if (ICI->getPredicate() == ICmpInst::ICMP_NE)
std::swap(DefaultCst, NewCst);
- // Replace ICI (which is used by the PHI for the default value) with true or
- // false depending on if it is EQ or NE.
- ICI->replaceAllUsesWith(DefaultCst);
+ // Replace Select (which is used by the PHI for the default value) with
+ // SelectFalseVal or SelectTrueVal depending on if ICI is EQ or NE.
+ if (Select) {
+ Select->replaceAllUsesWith(DefaultCst);
+ Select->eraseFromParent();
+ } else {
+ ICI->replaceAllUsesWith(DefaultCst);
+ }
ICI->eraseFromParent();
SmallVector<DominatorTree::UpdateType, 2> Updates;
@@ -5111,7 +5195,7 @@ bool SimplifyCFGOpt::tryToSimplifyUncondBranchWithICmpInIt(
NewW = ((uint64_t(*W0) + 1) >> 1);
SIW.setSuccessorWeight(0, *NewW);
}
- SIW.addCase(Cst, NewBB, NewW);
+ SIW.addCase(NewCaseVal, NewBB, NewW);
if (DTU)
Updates.push_back({DominatorTree::Insert, Pred, NewBB});
}
@@ -8302,13 +8386,18 @@ bool SimplifyCFGOpt::simplifyUncondBranch(BranchInst *BI,
// If the only instruction in the block is a seteq/setne comparison against a
// constant, try to simplify the block.
- if (ICmpInst *ICI = dyn_cast<ICmpInst>(I))
+ if (ICmpInst *ICI = dyn_cast<ICmpInst>(I)) {
if (ICI->isEquality() && isa<ConstantInt>(ICI->getOperand(1))) {
++I;
if (I->isTerminator() &&
tryToSimplifyUncondBranchWithICmpInIt(ICI, Builder))
return true;
+ if (isa<SelectInst>(I) && I->getNextNode()->isTerminator() &&
+ tryToSimplifyUncondBranchWithICmpSelectInIt(ICI, cast<SelectInst>(I),
+ Builder))
+ return true;
}
+ }
// See if we can merge an empty landing pad block with another which is
// equivalent.
diff --git a/llvm/test/Transforms/InstCombine/binop-select.ll b/llvm/test/Transforms/InstCombine/binop-select.ll
index fe1ec90..9e336ad 100644
--- a/llvm/test/Transforms/InstCombine/binop-select.ll
+++ b/llvm/test/Transforms/InstCombine/binop-select.ll
@@ -406,10 +406,7 @@ define i32 @ashr_sel_op1_use(i1 %b) {
define i8 @commonArgWithOr0(i1 %arg0) {
; CHECK-LABEL: @commonArgWithOr0(
-; CHECK-NEXT: [[V0:%.*]] = zext i1 [[ARG0:%.*]] to i8
-; CHECK-NEXT: [[V1:%.*]] = select i1 [[ARG0]], i8 0, i8 8
-; CHECK-NEXT: [[V2:%.*]] = or disjoint i8 [[V1]], [[V0]]
-; CHECK-NEXT: [[V3:%.*]] = or disjoint i8 [[V2]], 16
+; CHECK-NEXT: [[V3:%.*]] = select i1 [[ARG0:%.*]], i8 17, i8 24
; CHECK-NEXT: ret i8 [[V3]]
;
%v0 = zext i1 %arg0 to i8
@@ -433,10 +430,7 @@ define i8 @commonArgWithOr1(i1 %arg0) {
define i8 @commonArgWithOr2(i1 %arg0) {
; CHECK-LABEL: @commonArgWithOr2(
-; CHECK-NEXT: [[V0:%.*]] = zext i1 [[ARG0:%.*]] to i8
-; CHECK-NEXT: [[V1:%.*]] = select i1 [[ARG0]], i8 5, i8 42
-; CHECK-NEXT: [[V2:%.*]] = or i8 [[V1]], [[V0]]
-; CHECK-NEXT: [[V3:%.*]] = or disjoint i8 [[V2]], 16
+; CHECK-NEXT: [[V3:%.*]] = select i1 [[ARG0:%.*]], i8 21, i8 58
; CHECK-NEXT: ret i8 [[V3]]
;
%v0 = zext i1 %arg0 to i8
@@ -496,10 +490,7 @@ define i8 @commonArgWithAnd3(i1 %arg0) {
define i8 @commonArgWithXor0(i1 %arg0) {
; CHECK-LABEL: @commonArgWithXor0(
-; CHECK-NEXT: [[V0:%.*]] = zext i1 [[ARG0:%.*]] to i8
-; CHECK-NEXT: [[V1:%.*]] = select i1 [[ARG0]], i8 0, i8 8
-; CHECK-NEXT: [[V2:%.*]] = or disjoint i8 [[V1]], [[V0]]
-; CHECK-NEXT: [[V3:%.*]] = or disjoint i8 [[V2]], 16
+; CHECK-NEXT: [[V3:%.*]] = select i1 [[ARG0:%.*]], i8 17, i8 24
; CHECK-NEXT: ret i8 [[V3]]
;
%v0 = zext i1 %arg0 to i8
@@ -511,9 +502,7 @@ define i8 @commonArgWithXor0(i1 %arg0) {
define i8 @commonArgWithXor1(i1 %arg0) {
; CHECK-LABEL: @commonArgWithXor1(
-; CHECK-NEXT: [[V0:%.*]] = zext i1 [[ARG0:%.*]] to i8
-; CHECK-NEXT: [[V1:%.*]] = select i1 [[ARG0]], i8 9, i8 1
-; CHECK-NEXT: [[V2:%.*]] = xor i8 [[V1]], [[V0]]
+; CHECK-NEXT: [[V2:%.*]] = select i1 [[ARG0:%.*]], i8 8, i8 1
; CHECK-NEXT: ret i8 [[V2]]
;
%v0 = zext i1 %arg0 to i8
@@ -524,10 +513,7 @@ define i8 @commonArgWithXor1(i1 %arg0) {
define i8 @commonArgWithXor2(i1 %arg0) {
; CHECK-LABEL: @commonArgWithXor2(
-; CHECK-NEXT: [[V0:%.*]] = zext i1 [[ARG0:%.*]] to i8
-; CHECK-NEXT: [[V1:%.*]] = select i1 [[ARG0]], i8 1, i8 7
-; CHECK-NEXT: [[V2:%.*]] = xor i8 [[V1]], [[V0]]
-; CHECK-NEXT: [[V3:%.*]] = or disjoint i8 [[V2]], 16
+; CHECK-NEXT: [[V3:%.*]] = select i1 [[ARG0:%.*]], i8 16, i8 23
; CHECK-NEXT: ret i8 [[V3]]
;
%v0 = zext i1 %arg0 to i8
@@ -539,10 +525,7 @@ define i8 @commonArgWithXor2(i1 %arg0) {
define i8 @commonArgWithXor3(i1 %arg0) {
; CHECK-LABEL: @commonArgWithXor3(
-; CHECK-NEXT: [[V0:%.*]] = zext i1 [[ARG0:%.*]] to i8
-; CHECK-NEXT: [[V1:%.*]] = select i1 [[ARG0]], i8 5, i8 45
-; CHECK-NEXT: [[V2:%.*]] = xor i8 [[V1]], [[V0]]
-; CHECK-NEXT: [[V3:%.*]] = or disjoint i8 [[V2]], 16
+; CHECK-NEXT: [[V3:%.*]] = select i1 [[ARG0:%.*]], i8 20, i8 61
; CHECK-NEXT: ret i8 [[V3]]
;
%v0 = zext i1 %arg0 to i8
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
index 6def8f4..a51b816 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
@@ -15,8 +15,8 @@
; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @c1, ptr @c2, ptr @c3]
; ENABLE: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @g1, ptr @g2, ptr @g3]
; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @g1, ptr @g2, ptr @g3]
-; ENABLE: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @f1, ptr @f2, ptr @f3]
-; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @f1, ptr @f2, ptr @f3]
+; ENABLE: @{{.*}} = private unnamed_addr constant [4 x ptr] [ptr @f1, ptr @f2, ptr @f3, ptr @f4]
+; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [4 x ptr] [ptr @f1, ptr @f2, ptr @f3, ptr @f4]
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7a--none-eabi"
diff --git a/llvm/test/Transforms/SimplifyCFG/switch-transformations-no-lut.ll b/llvm/test/Transforms/SimplifyCFG/switch-transformations-no-lut.ll
index 25267dc..48be76c 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch-transformations-no-lut.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch-transformations-no-lut.ll
@@ -410,13 +410,12 @@ define i1 @single_value_with_mask(i32 %x) {
; OPTNOLUT-NEXT: i32 21, label %[[END]]
; OPTNOLUT-NEXT: i32 48, label %[[END]]
; OPTNOLUT-NEXT: i32 16, label %[[END]]
+; OPTNOLUT-NEXT: i32 80, label %[[END]]
; OPTNOLUT-NEXT: ]
; OPTNOLUT: [[DEFAULT]]:
-; OPTNOLUT-NEXT: [[CMP:%.*]] = icmp eq i32 [[X]], 80
-; OPTNOLUT-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i1 false, i1 true
; OPTNOLUT-NEXT: br label %[[END]]
; OPTNOLUT: [[END]]:
-; OPTNOLUT-NEXT: [[RES:%.*]] = phi i1 [ false, %[[ENTRY]] ], [ false, %[[ENTRY]] ], [ false, %[[ENTRY]] ], [ false, %[[ENTRY]] ], [ [[SEL]], %[[DEFAULT]] ]
+; OPTNOLUT-NEXT: [[RES:%.*]] = phi i1 [ false, %[[ENTRY]] ], [ false, %[[ENTRY]] ], [ false, %[[ENTRY]] ], [ false, %[[ENTRY]] ], [ true, %[[DEFAULT]] ], [ false, %[[ENTRY]] ]
; OPTNOLUT-NEXT: ret i1 [[RES]]
;
; TTINOLUT-LABEL: define i1 @single_value_with_mask(
diff --git a/llvm/test/Transforms/SimplifyCFG/switch_create.ll b/llvm/test/Transforms/SimplifyCFG/switch_create.ll
index ef5aee6..64016f3 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_create.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch_create.ll
@@ -1314,6 +1314,136 @@ if.end:
ret void
}
+define i32 @switch_with_icmp_select_after_it(i32 %x) {
+; CHECK-LABEL: @switch_with_icmp_select_after_it(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 [[X:%.*]], label [[DEFAULT:%.*]] [
+; CHECK-NEXT: i32 18, label [[END:%.*]]
+; CHECK-NEXT: i32 21, label [[END]]
+; CHECK-NEXT: i32 48, label [[END]]
+; CHECK-NEXT: i32 16, label [[END]]
+; CHECK-NEXT: i32 80, label [[SWITCH_EDGE:%.*]]
+; CHECK-NEXT: ]
+; CHECK: switch.edge:
+; CHECK-NEXT: br label [[END]]
+; CHECK: default:
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[RES:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ 3, [[DEFAULT]] ], [ 2, [[SWITCH_EDGE]] ]
+; CHECK-NEXT: ret i32 [[RES]]
+;
+entry:
+ switch i32 %x, label %default [
+ i32 18, label %end
+ i32 21, label %end
+ i32 48, label %end
+ i32 16, label %end
+ ]
+default:
+ %cmp = icmp eq i32 %x, 80
+ ; Create a new switch case BB for case 80.
+ %sel = select i1 %cmp, i32 2, i32 3
+ br label %end
+end:
+ %res = phi i32 [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ %sel, %default ]
+ ret i32 %res
+}
+
+define i32 @switch_with_icmp_select_after_it2(i32 %x) {
+; CHECK-LABEL: @switch_with_icmp_select_after_it2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 [[X:%.*]], label [[DEFAULT:%.*]] [
+; CHECK-NEXT: i32 18, label [[END:%.*]]
+; CHECK-NEXT: i32 21, label [[END]]
+; CHECK-NEXT: i32 48, label [[END]]
+; CHECK-NEXT: i32 16, label [[END]]
+; CHECK-NEXT: i32 80, label [[END]]
+; CHECK-NEXT: ]
+; CHECK: default:
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[RES:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ 3, [[DEFAULT]] ], [ 1, [[ENTRY]] ]
+; CHECK-NEXT: ret i32 [[RES]]
+;
+entry:
+ switch i32 %x, label %default [
+ i32 18, label %end
+ i32 21, label %end
+ i32 48, label %end
+ i32 16, label %end
+ ]
+default:
+ %cmp = icmp eq i32 %x, 80
+ ; Should not create new case BB
+ %sel = select i1 %cmp, i32 1, i32 3
+ br label %end
+end:
+ %res = phi i32 [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ %sel, %default ]
+ ret i32 %res
+}
+
+define i32 @switch_with_icmp_select_after_it3(i32 %x) {
+; CHECK-LABEL: @switch_with_icmp_select_after_it3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 80
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 3, i32 1
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+entry:
+ switch i32 %x, label %default [
+ i32 18, label %end
+ i32 21, label %end
+ i32 48, label %end
+ i32 16, label %end
+ ]
+default:
+ %cmp = icmp eq i32 %x, 80
+ ; Should not create new case BB
+ %sel = select i1 %cmp, i32 3, i32 1
+ br label %end
+end:
+ %res = phi i32 [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ %sel, %default ]
+ ret i32 %res
+}
+
+; TODO: support this case (multi-phis).
+define i32 @switch_with_icmp_select_after_it_multi_phis(i32 %x) {
+; CHECK-LABEL: @switch_with_icmp_select_after_it_multi_phis(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 [[X:%.*]], label [[DEFAULT:%.*]] [
+; CHECK-NEXT: i32 18, label [[END:%.*]]
+; CHECK-NEXT: i32 21, label [[END]]
+; CHECK-NEXT: i32 48, label [[END]]
+; CHECK-NEXT: i32 16, label [[END]]
+; CHECK-NEXT: ]
+; CHECK: default:
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X]], 80
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 2, i32 3
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[RES1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ 0, [[ENTRY]] ], [ 0, [[ENTRY]] ], [ 0, [[ENTRY]] ], [ 100, [[DEFAULT]] ]
+; CHECK-NEXT: [[RES2:%.*]] = phi i32 [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ 1, [[ENTRY]] ], [ [[SEL]], [[DEFAULT]] ]
+; CHECK-NEXT: [[RES:%.*]] = xor i32 [[RES1]], [[RES2]]
+; CHECK-NEXT: ret i32 [[RES]]
+;
+entry:
+ switch i32 %x, label %default [
+ i32 18, label %end
+ i32 21, label %end
+ i32 48, label %end
+ i32 16, label %end
+ ]
+default:
+ %cmp = icmp eq i32 %x, 80
+ %sel = select i1 %cmp, i32 2, i32 3
+ br label %end
+end:
+ %res1 = phi i32 [ 0, %entry ], [ 0, %entry ], [ 0, %entry ], [ 0, %entry ], [ 100, %default ]
+ %res2 = phi i32 [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ 1, %entry ], [ %sel, %default ]
+ %res = xor i32 %res1, %res2
+ ret i32 %res
+}
+
!0 = !{!"function_entry_count", i32 100}
!1 = !{!"branch_weights", i32 6, i32 10}
;.
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel
index fd4389e..8d30869 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel
@@ -174,6 +174,7 @@ libc_test_library(
deps = [
"//libc:__support_cpp_type_traits",
"//libc:__support_fputil_fp_bits",
+ "//libc:__support_macros_properties_architectures",
"//libc/test/UnitTest:LibcUnitTest",
],
)