Skip to content

Commit 606543e

Browse files
committed
drop base pr
Created using spr 1.3.5-bogner
2 parents 3579f7d + 8cb022c commit 606543e

File tree

201 files changed

+4175
-1806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+4175
-1806
lines changed

.mailmap

Lines changed: 2 additions & 1 deletion

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
663663
const BinaryFunction *TargetBF = getBinaryFunctionContainingAddress(Value);
664664
if (!TargetBF || !areRelatedFragments(TargetBF, &BF)) {
665665
LLVM_DEBUG(printEntryDiagnostics(dbgs(), TargetBF));
666+
(void)printEntryDiagnostics;
666667
break;
667668
}
668669

@@ -843,6 +844,7 @@ BinaryContext::getOrCreateJumpTable(BinaryFunction &Function, uint64_t Address,
843844
&Function, std::placeholders::_1);
844845
assert(llvm::all_of(JT->Parents, isSibling) &&
845846
"cannot re-use jump table of a different function");
847+
(void)isSibling;
846848
if (opts::Verbosity > 2) {
847849
this->outs() << "BOLT-INFO: multiple fragments access the same jump table"
848850
<< ": " << *JT->Parents[0] << "; " << Function << '\n';

clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "UnintendedCharOstreamOutputCheck.h"
10+
#include "../utils/Matchers.h"
11+
#include "../utils/OptionsUtils.h"
1012
#include "clang/AST/Type.h"
1113
#include "clang/ASTMatchers/ASTMatchFinder.h"
1214
#include "clang/ASTMatchers/ASTMatchers.h"
@@ -35,10 +37,14 @@ AST_MATCHER(Type, isChar) {
3537

3638
UnintendedCharOstreamOutputCheck::UnintendedCharOstreamOutputCheck(
3739
StringRef Name, ClangTidyContext *Context)
38-
: ClangTidyCheck(Name, Context), CastTypeName(Options.get("CastTypeName")) {
39-
}
40+
: ClangTidyCheck(Name, Context),
41+
AllowedTypes(utils::options::parseStringList(
42+
Options.get("AllowedTypes", "unsigned char;signed char"))),
43+
CastTypeName(Options.get("CastTypeName")) {}
4044
void UnintendedCharOstreamOutputCheck::storeOptions(
4145
ClangTidyOptions::OptionMap &Opts) {
46+
Options.store(Opts, "AllowedTypes",
47+
utils::options::serializeStringList(AllowedTypes));
4248
if (CastTypeName.has_value())
4349
Options.store(Opts, "CastTypeName", CastTypeName.value());
4450
}
@@ -50,13 +56,20 @@ void UnintendedCharOstreamOutputCheck::registerMatchers(MatchFinder *Finder) {
5056
// with char / unsigned char / signed char
5157
classTemplateSpecializationDecl(
5258
hasTemplateArgument(0, refersToType(isChar()))));
59+
auto IsDeclRefExprFromAllowedTypes = declRefExpr(to(varDecl(
60+
hasType(matchers::matchesAnyListedTypeName(AllowedTypes, false)))));
61+
auto IsExplicitCastExprFromAllowedTypes = explicitCastExpr(hasDestinationType(
62+
matchers::matchesAnyListedTypeName(AllowedTypes, false)));
5363
Finder->addMatcher(
5464
cxxOperatorCallExpr(
5565
hasOverloadedOperatorName("<<"),
5666
hasLHS(hasType(hasUnqualifiedDesugaredType(
5767
recordType(hasDeclaration(cxxRecordDecl(
5868
anyOf(BasicOstream, isDerivedFrom(BasicOstream)))))))),
59-
hasRHS(hasType(hasUnqualifiedDesugaredType(isNumericChar()))))
69+
hasRHS(expr(hasType(hasUnqualifiedDesugaredType(isNumericChar())),
70+
unless(ignoringParenImpCasts(
71+
anyOf(IsDeclRefExprFromAllowedTypes,
72+
IsExplicitCastExprFromAllowedTypes))))))
6073
.bind("x"),
6174
this);
6275
}

clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class UnintendedCharOstreamOutputCheck : public ClangTidyCheck {
3030
}
3131

3232
private:
33+
const std::vector<StringRef> AllowedTypes;
3334
const std::optional<StringRef> CastTypeName;
3435
};
3536

clang-tools-extra/clang-tidy/utils/Matchers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ bool NotIdenticalStatementsPredicate::operator()(
1818
}
1919

2020
MatchesAnyListedTypeNameMatcher::MatchesAnyListedTypeNameMatcher(
21-
llvm::ArrayRef<StringRef> NameList)
22-
: NameMatchers(NameList.begin(), NameList.end()) {}
21+
llvm::ArrayRef<StringRef> NameList, bool CanonicalTypes)
22+
: NameMatchers(NameList.begin(), NameList.end()),
23+
CanonicalTypes(CanonicalTypes) {}
2324

2425
MatchesAnyListedTypeNameMatcher::~MatchesAnyListedTypeNameMatcher() = default;
2526

@@ -32,7 +33,7 @@ bool MatchesAnyListedTypeNameMatcher::matches(
3233

3334
PrintingPolicy PrintingPolicyWithSuppressedTag(
3435
Finder->getASTContext().getLangOpts());
35-
PrintingPolicyWithSuppressedTag.PrintCanonicalTypes = true;
36+
PrintingPolicyWithSuppressedTag.PrintCanonicalTypes = CanonicalTypes;
3637
PrintingPolicyWithSuppressedTag.SuppressElaboration = true;
3738
PrintingPolicyWithSuppressedTag.SuppressScope = false;
3839
PrintingPolicyWithSuppressedTag.SuppressTagKeyword = true;

clang-tools-extra/clang-tidy/utils/Matchers.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,28 @@ AST_MATCHER_P(Stmt, isStatementIdenticalToBoundNode, std::string, ID) {
172172
class MatchesAnyListedTypeNameMatcher
173173
: public ast_matchers::internal::MatcherInterface<QualType> {
174174
public:
175-
explicit MatchesAnyListedTypeNameMatcher(llvm::ArrayRef<StringRef> NameList);
175+
explicit MatchesAnyListedTypeNameMatcher(llvm::ArrayRef<StringRef> NameList,
176+
bool CanonicalTypes);
176177
~MatchesAnyListedTypeNameMatcher() override;
177178
bool matches(
178179
const QualType &Node, ast_matchers::internal::ASTMatchFinder *Finder,
179180
ast_matchers::internal::BoundNodesTreeBuilder *Builder) const override;
180181

181182
private:
182183
std::vector<llvm::Regex> NameMatchers;
184+
bool CanonicalTypes;
183185
};
184186

185187
// Returns a matcher that matches QualType against a list of provided regular.
186188
inline ::clang::ast_matchers::internal::Matcher<QualType>
187-
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList) {
189+
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList,
190+
bool CanonicalTypes) {
188191
return ::clang::ast_matchers::internal::makeMatcher(
189-
new MatchesAnyListedTypeNameMatcher(NameList));
192+
new MatchesAnyListedTypeNameMatcher(NameList, CanonicalTypes));
193+
}
194+
inline ::clang::ast_matchers::internal::Matcher<QualType>
195+
matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList) {
196+
return matchesAnyListedTypeName(NameList, true);
190197
}
191198

192199
} // namespace clang::tidy::matchers

clang-tools-extra/clangd/AST.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ QualType declaredType(const TypeDecl *D) {
439439
if (const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(D))
440440
if (const auto *Args = CTSD->getTemplateArgsAsWritten())
441441
return Context.getTemplateSpecializationType(
442-
TemplateName(CTSD->getSpecializedTemplate()), Args->arguments());
442+
TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(),
443+
/*CanonicalArgs=*/std::nullopt);
443444
return Context.getTypeDeclType(D);
444445
}
445446

clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ Or cast to char to explicitly indicate that output should be a character.
4242
Options
4343
-------
4444

45+
.. option:: AllowedTypes
46+
47+
A semicolon-separated list of type names that will be treated like the ``char``
48+
type: the check will not report variables declared with with these types or
49+
explicit cast expressions to these types. Note that this distinguishes type
50+
aliases from the original type, so specifying e.g. ``unsigned char`` here
51+
will not suppress reports about ``uint8_t`` even if it is defined as a
52+
``typedef`` alias for ``unsigned char``.
53+
Default is `unsigned char;signed char`.
54+
4555
.. option:: CastTypeName
4656

4757
When `CastTypeName` is specified, the fix-it will use `CastTypeName` as the

clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,25 @@ class Calculator {
4343
* @throw std::invalid_argument if b is zero.
4444
*/
4545
double divide(int a, int b);
46-
};
46+
47+
/**
48+
* @brief Performs the mod operation on integers.
49+
*
50+
* @param a First integer.
51+
* @param b Second integer.
52+
* @return The result of a % b.
53+
*/
54+
static int mod(int a, int b) {
55+
return a % b;
56+
}
57+
58+
/**
59+
* @brief A static value.
60+
*/
61+
static constexpr int static_val = 10;
62+
63+
/**
64+
* @brief Holds a public value.
65+
*/
66+
int public_val = -1;
67+
};

clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ int Calculator::multiply(int a, int b) {
1515
double Calculator::divide(int a, int b) {
1616
return static_cast<double>(a) / b;
1717
}
18+

0 commit comments

Comments
 (0)