Skip to content

Commit aaebed8

Browse files
committed
Merge remote-tracking branch 'upstream/master' into apple/master
Conflicts: clang/lib/Driver/ToolChains/Arch/AArch64.cpp llvm/include/llvm/Support/AArch64TargetParser.def llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/unittests/Support/TargetParserTest.cpp
2 parents 7a04af0 + 903e5c3 commit aaebed8

File tree

1,026 files changed

+37547
-17473
lines changed

Some content is hidden

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

1,026 files changed

+37547
-17473
lines changed

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
207207
// FIXME: This will report conflicts by pair using a file+offset format
208208
// which is not so much human readable.
209209
// A first improvement could be to translate offset to line+col. For
210-
// this and without loosing error message some modifications arround
210+
// this and without loosing error message some modifications around
211211
// `tooling::ReplacementError` are need (access to
212212
// `getReplacementErrString`).
213213
// A better strategy could be to add a pretty printer methods for

clang-tools-extra/clang-doc/BitcodeReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ClangDocBitcodeReader {
6161
// or block to be read.
6262
Cursor skipUntilRecordOrBlock(unsigned &BlockOrRecordID);
6363

64-
// Helper function to set up the approriate type of Info.
64+
// Helper function to set up the appropriate type of Info.
6565
llvm::Expected<std::unique_ptr<Info>> readBlockToInfo(unsigned ID);
6666

6767
llvm::BitstreamCursor &Stream;

clang-tools-extra/clang-doc/Representation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct Reference {
135135
bool mergeable(const Reference &Other);
136136
void merge(Reference &&I);
137137

138-
SymbolID USR = SymbolID(); // Unique identifer for referenced decl
138+
SymbolID USR = SymbolID(); // Unique identifier for referenced decl
139139
SmallString<16> Name; // Name of type (possibly unresolved).
140140
InfoType RefType = InfoType::IT_default; // Indicates the type of this
141141
// Reference (namespace, record,

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
3232
// A function to extract the appropriate relative path for a given info's
3333
// documentation. The path returned is a composite of the parent namespaces.
3434
//
35-
// Example: Given the below, the diretory path for class C info will be
35+
// Example: Given the below, the directory path for class C info will be
3636
// <root>/A/B
3737
//
3838
// namespace A {

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This tool for generating C and C++ documenation from source code
9+
// This tool for generating C and C++ documentation from source code
1010
// and comments. Generally, it runs a LibTooling FrontendAction on source files,
1111
// mapping each declaration in those files to its USR and serializing relevant
1212
// information into LLVM bitcode. It then runs a pass over the collected

clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::string createQualifiedNameForReplacement(
2626
llvm::StringRef RawSymbolName,
2727
llvm::StringRef SymbolScopedQualifiersName,
2828
const find_all_symbols::SymbolInfo &MatchedSymbol) {
29-
// No need to add missing qualifiers if SymbolIndentifer has a global scope
29+
// No need to add missing qualifiers if SymbolIdentifier has a global scope
3030
// operator "::".
3131
if (RawSymbolName.startswith("::"))
3232
return RawSymbolName;

clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ buffer as only argument."
110110
nil)
111111

112112
(defun clang-include-fixer--make-process (callback args)
113-
"Start a new clang-incude-fixer process using `make-process'.
113+
"Start a new clang-include-fixer process using `make-process'.
114114
CALLBACK is called after the process finishes successfully; it is
115115
called with a single argument, the buffer where standard output
116116
has been inserted. ARGS is a list of additional command line
@@ -129,7 +129,7 @@ arguments. Return the new process object."
129129
:stderr stderr)))
130130

131131
(defun clang-include-fixer--start-process (callback args)
132-
"Start a new clang-incude-fixer process using `start-file-process'.
132+
"Start a new clang-include-fixer process using `start-file-process'.
133133
CALLBACK is called after the process finishes successfully; it is
134134
called with a single argument, the buffer where standard output
135135
has been inserted. ARGS is a list of additional command line

clang-tools-extra/clang-move/tool/ClangMove.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- ClangMove.cpp - move defintion to new file --------------*- C++ -*-===//
1+
//===-- ClangMove.cpp - move definition to new file -------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {
6565
expr(ignoringParenCasts(stringLiteral(lengthIsOne()).bind("Literal")));
6666

6767
// Binds to a string_view (either absl or std) that was passed by value and
68-
// contructed from string literal.
68+
// constructed from string literal.
6969
auto StringViewArg = ignoringElidableConstructorCall(ignoringImpCasts(
7070
cxxConstructExpr(hasType(recordDecl(hasName("::absl::string_view"))),
7171
hasArgument(0, ignoringParenImpCasts(SingleChar)))));

clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
168168
!InsideMacroDefinition(Result, MaybeCallArg->getSourceRange())) {
169169
// Handle the case where the matched expression is inside a call which
170170
// converts it from the inverse to a Duration. In this case, we replace
171-
// the outer with just the subtraction expresison, which gives the right
171+
// the outer with just the subtraction expression, which gives the right
172172
// type and scale, taking care again about parenthesis.
173173
bool NeedParens = parensRequired(Result, MaybeCallArg);
174174

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "NotNullTerminatedResultCheck.h"
3737
#include "ParentVirtualCallCheck.h"
3838
#include "PosixReturnCheck.h"
39+
#include "SignedCharMisuseCheck.h"
3940
#include "SizeofContainerCheck.h"
4041
#include "SizeofExpressionCheck.h"
4142
#include "StringConstructorCheck.h"
@@ -119,6 +120,8 @@ class BugproneModule : public ClangTidyModule {
119120
"bugprone-parent-virtual-call");
120121
CheckFactories.registerCheck<PosixReturnCheck>(
121122
"bugprone-posix-return");
123+
CheckFactories.registerCheck<SignedCharMisuseCheck>(
124+
"bugprone-signed-char-misuse");
122125
CheckFactories.registerCheck<SizeofContainerCheck>(
123126
"bugprone-sizeof-container");
124127
CheckFactories.registerCheck<SizeofExpressionCheck>(

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_clang_library(clangTidyBugproneModule
2828
NotNullTerminatedResultCheck.cpp
2929
ParentVirtualCallCheck.cpp
3030
PosixReturnCheck.cpp
31+
SignedCharMisuseCheck.cpp
3132
SizeofContainerCheck.cpp
3233
SizeofExpressionCheck.cpp
3334
StringConstructorCheck.cpp

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void ForwardDeclarationNamespaceCheck::check(
6363
const auto *Decl = Result.Nodes.getNodeAs<FriendDecl>("friend_decl");
6464
assert(Decl && "Decl is neither record_decl nor friend decl!");
6565

66-
// Classes used in friend delarations are not marked referenced in AST,
66+
// Classes used in friend declarations are not marked referenced in AST,
6767
// so we need to check classes used in friend declarations manually to
6868
// reduce the rate of false positive.
6969
// For example, in
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
//===--- SignedCharMisuseCheck.cpp - clang-tidy ---------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "SignedCharMisuseCheck.h"
10+
#include "../utils/OptionsUtils.h"
11+
#include "clang/AST/ASTContext.h"
12+
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
14+
using namespace clang::ast_matchers;
15+
using namespace clang::ast_matchers::internal;
16+
17+
namespace clang {
18+
namespace tidy {
19+
namespace bugprone {
20+
21+
static Matcher<TypedefDecl> hasAnyListedName(const std::string &Names) {
22+
const std::vector<std::string> NameList =
23+
utils::options::parseStringList(Names);
24+
return hasAnyName(std::vector<StringRef>(NameList.begin(), NameList.end()));
25+
}
26+
27+
SignedCharMisuseCheck::SignedCharMisuseCheck(StringRef Name,
28+
ClangTidyContext *Context)
29+
: ClangTidyCheck(Name, Context),
30+
CharTypdefsToIgnoreList(Options.get("CharTypdefsToIgnore", "")) {}
31+
32+
void SignedCharMisuseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
33+
Options.store(Opts, "CharTypdefsToIgnore", CharTypdefsToIgnoreList);
34+
}
35+
36+
void SignedCharMisuseCheck::registerMatchers(MatchFinder *Finder) {
37+
// We can ignore typedefs which are some kind of integer types
38+
// (e.g. typedef char sal_Int8). In this case, we don't need to
39+
// worry about the misinterpretation of char values.
40+
const auto IntTypedef = qualType(
41+
hasDeclaration(typedefDecl(hasAnyListedName(CharTypdefsToIgnoreList))));
42+
43+
const auto SignedCharType = expr(hasType(qualType(
44+
allOf(isAnyCharacter(), isSignedInteger(), unless(IntTypedef)))));
45+
46+
const auto IntegerType = qualType(allOf(isInteger(), unless(isAnyCharacter()),
47+
unless(booleanType())))
48+
.bind("integerType");
49+
50+
// We are interested in signed char -> integer conversion.
51+
const auto ImplicitCastExpr =
52+
implicitCastExpr(hasSourceExpression(SignedCharType),
53+
hasImplicitDestinationType(IntegerType))
54+
.bind("castExpression");
55+
56+
const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
57+
const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
58+
const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
59+
60+
// We catch any type of casts to an integer. We need to have these cast
61+
// expressions explicitly to catch only those casts which are direct children
62+
// of an assignment/declaration.
63+
const auto CastExpr = expr(anyOf(ImplicitCastExpr, CStyleCastExpr,
64+
StaticCastExpr, FunctionalCastExpr));
65+
66+
// Catch assignments with the suspicious type conversion.
67+
const auto AssignmentOperatorExpr = expr(binaryOperator(
68+
hasOperatorName("="), hasLHS(hasType(IntegerType)), hasRHS(CastExpr)));
69+
70+
Finder->addMatcher(AssignmentOperatorExpr, this);
71+
72+
// Catch declarations with the suspicious type conversion.
73+
const auto Declaration =
74+
varDecl(isDefinition(), hasType(IntegerType), hasInitializer(CastExpr));
75+
76+
Finder->addMatcher(Declaration, this);
77+
}
78+
79+
void SignedCharMisuseCheck::check(const MatchFinder::MatchResult &Result) {
80+
const auto *CastExpression =
81+
Result.Nodes.getNodeAs<ImplicitCastExpr>("castExpression");
82+
const auto *IntegerType = Result.Nodes.getNodeAs<QualType>("integerType");
83+
assert(CastExpression);
84+
assert(IntegerType);
85+
86+
// Ignore the match if we know that the value is not negative.
87+
// The potential misinterpretation happens for negative values only.
88+
Expr::EvalResult EVResult;
89+
if (!CastExpression->isValueDependent() &&
90+
CastExpression->getSubExpr()->EvaluateAsInt(EVResult, *Result.Context)) {
91+
llvm::APSInt Value1 = EVResult.Val.getInt();
92+
if (Value1.isNonNegative())
93+
return;
94+
}
95+
96+
diag(CastExpression->getBeginLoc(),
97+
"'signed char' to %0 conversion; "
98+
"consider casting to 'unsigned char' first.")
99+
<< *IntegerType;
100+
}
101+
102+
} // namespace bugprone
103+
} // namespace tidy
104+
} // namespace clang
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//===--- SignedCharMisuseCheck.h - clang-tidy -------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace bugprone {
17+
18+
/// Finds ``signed char`` -> integer conversions which might indicate a programming
19+
/// error. The basic problem with the ``signed char``, that it might store the
20+
/// non-ASCII characters as negative values. The human programmer probably
21+
/// expects that after an integer conversion the converted value matches with the
22+
/// character code (a value from [0..255]), however, the actual value is in
23+
/// [-128..127] interval. This also applies to the plain ``char`` type on
24+
/// those implementations which represent ``char`` similar to ``signed char``.
25+
///
26+
/// For the user-facing documentation see:
27+
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-signed-char-misuse.html
28+
class SignedCharMisuseCheck : public ClangTidyCheck {
29+
public:
30+
SignedCharMisuseCheck(StringRef Name, ClangTidyContext *Context);
31+
32+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
33+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35+
36+
private:
37+
const std::string CharTypdefsToIgnoreList;
38+
};
39+
40+
} // namespace bugprone
41+
} // namespace tidy
42+
} // namespace clang
43+
44+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ AST_MATCHER(StringLiteral, containsNul) {
2727

2828
void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
2929
// Match a string that contains embedded NUL character. Extra-checks are
30-
// applied in |check| to find incorectly escaped characters.
30+
// applied in |check| to find incorrectly escaped characters.
3131
Finder->addMatcher(stringLiteral(containsNul()).bind("strlit"), this);
3232

3333
// The remaining checks only apply to C++.

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
3131
}
3232

3333
// Iterate over all the fields in a record type, both direct and indirect (e.g.
34-
// if the record contains an anonmyous struct).
34+
// if the record contains an anonymous struct).
3535
template <typename T, typename Func>
3636
void forEachField(const RecordDecl &Record, const T &Fields, Func &&Fn) {
3737
for (const FieldDecl *F : Fields) {
@@ -424,7 +424,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
424424
}
425425

426426
// Collect all fields in order, both direct fields and indirect fields from
427-
// anonmyous record types.
427+
// anonymous record types.
428428
SmallVector<const FieldDecl *, 16> OrderedFields;
429429
forEachField(ClassDecl, ClassDecl.fields(),
430430
[&](const FieldDecl *F) { OrderedFields.push_back(F); });

clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void SlicingCheck::registerMatchers(MatchFinder *Finder) {
4545
const auto IsWithinDerivedCtor =
4646
hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl"))));
4747

48-
// Assignement slicing: "a = b;" and "a = std::move(b);" variants.
48+
// Assignment slicing: "a = b;" and "a = std::move(b);" variants.
4949
const auto SlicesObjectInAssignment =
5050
callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
5151
isMoveAssignmentOperator()),

clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void GlobalNamesInHeadersCheck::check(const MatchFinder::MatchResult &Result) {
6161

6262
if (const auto *UsingDirective = dyn_cast<UsingDirectiveDecl>(D)) {
6363
if (UsingDirective->getNominatedNamespace()->isAnonymousNamespace()) {
64-
// Anynoumous namespaces inject a using directive into the AST to import
64+
// Anonymous namespaces inject a using directive into the AST to import
6565
// the names into the containing namespace.
6666
// We should not have them in headers, but there is another warning for
6767
// that.

clang-tools-extra/clang-tidy/google/IntegerTypesCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace runtime {
2424
/// Finds uses of `short`, `long` and `long long` and suggest replacing them
2525
/// with `u?intXX(_t)?`.
2626
///
27-
/// Correspondig cpplint.py check: 'runtime/int'.
27+
/// Corresponding cpplint.py check: 'runtime/int'.
2828
class IntegerTypesCheck : public ClangTidyCheck {
2929
public:
3030
IntegerTypesCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace tidy {
4343
namespace modernize {
4444

4545
void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) {
46-
// std::array<> is avaliable since C++11.
46+
// std::array<> is available since C++11.
4747
if (!getLangOpts().CPlusPlus11)
4848
return;
4949

clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
376376
// struct S { S(std::initializer_list<int>); };
377377
// struct S2 { S2(S, int); };
378378
// smart_ptr<S>(new S{1, 2, 3}); // C++11 direct list-initialization
379-
// smart_ptr<S>(new S{}); // use initializer-list consturctor
379+
// smart_ptr<S>(new S{}); // use initializer-list constructor
380380
// smart_ptr<S2>()new S2{ {1,2}, 3 }; // have a list-initialized arg
381381
// The above cases have to be replaced with:
382382
// std::make_smart_ptr<S>(std::initializer_list<int>({1, 2, 3}));

clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {
359359
}
360360

361361
if (const auto *NestedConstruct = dyn_cast<CXXConstructExpr>(E)) {
362-
// If we ran into an implicit conversion contructor, can't convert.
362+
// If we ran into an implicit conversion constructor, can't convert.
363363
//
364364
// FIXME: The following only checks if the constructor can be used
365365
// implicitly, not if it actually was. Cases where the converting

clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ AST_MATCHER(Type, sugaredNullptrType) {
3333
/// Create a matcher that finds implicit casts as well as the head of a
3434
/// sequence of zero or more nested explicit casts that have an implicit cast
3535
/// to null within.
36-
/// Finding sequences of explict casts is necessary so that an entire sequence
36+
/// Finding sequences of explicit casts is necessary so that an entire sequence
3737
/// can be replaced instead of just the inner-most implicit cast.
3838
StatementMatcher makeCastSequenceMatcher() {
3939
StatementMatcher ImplicitCastToNull = implicitCastExpr(

0 commit comments

Comments
 (0)