Skip to content

Commit b2b163f

Browse files
committed
Overwritten with: da5f3ad Merged master:536ba6373f0 into amd-gfx:48333f64843
Based on upstream llvm : 536ba63 [Object] Change ELFObjectFile<ELFT>::getFileFormatName() to use BFD names Local changes since 5c958c7: da5f3ad Merged master:536ba6373f0 into amd-gfx:48333f64843 48333f6 Merged master:332edcc6bd1 into amd-gfx:0e6fea325fb 0e6fea3 Revert "[codegen,amdgpu] Enhance MIR DIE and re-arrange it for AMDGPU." c9ea143 Fix up test after manual merge 5c92a0d Merged master:b1a7a245ec2 into amd-gfx:08dd4e64e34 4f0a0d6 Revert "Revert "Revert "Revert "[codegen,amdgpu] Enhance MIR DIE and re-arrange it for AMDGPU."""" 08dd4e6 Merged master:7b74b0d4e54 into amd-gfx:46601da50bc Also unreverted the changes that were reverted last time: 46601da Reinstate getSplat(unsigned NumElts, Constant *V) d8c450e Manually merged master:09c8f38924d into amd-gfx:3207753660b 3207753 Merged master:c8f0d27ef37 into amd-gfx:80e004f6b88 80e004f [AMDGPU] Add transformation of kills to demotes in simple scenarios ca9afc9 [AMDGPU] Optimize conditional discard 3df0df0 [AMDGPU] Implement unused helper cleanup and early term for demote 4b66c31 AMDGPU: Remove SI_DEMOTE_I1_TERMINATOR Added AMD modification notices and removed some GPL files. Change-Id: If426bf03fe119c8cfbccb8985ce87e29daf1b26b
2 parents 5c958c7 + da5f3ad commit b2b163f

File tree

3,162 files changed

+61244
-27985
lines changed

Some content is hidden

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

3,162 files changed

+61244
-27985
lines changed

clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "HeaderMapCollector.h"
1111
#include "PathConfig.h"
1212
#include "SymbolInfo.h"
13+
#include "clang/Basic/FileManager.h"
1314
#include "clang/Basic/IdentifierTable.h"
1415
#include "clang/Basic/SourceManager.h"
1516
#include "clang/Lex/MacroInfo.h"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ add_subdirectory(google)
5151
add_subdirectory(hicpp)
5252
add_subdirectory(linuxkernel)
5353
add_subdirectory(llvm)
54+
add_subdirectory(llvmlibc)
5455
add_subdirectory(misc)
5556
add_subdirectory(modernize)
5657
if(CLANG_ENABLE_STATIC_ANALYZER)
@@ -75,6 +76,7 @@ set(ALL_CLANG_TIDY_CHECKS
7576
clangTidyHICPPModule
7677
clangTidyLinuxKernelModule
7778
clangTidyLLVMModule
79+
clangTidyLLVMLibcModule
7880
clangTidyMiscModule
7981
clangTidyModernizeModule
8082
clangTidyObjCModule

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "clang/Tooling/Core/Diagnostic.h"
2727
#include "llvm/ADT/STLExtras.h"
2828
#include "llvm/ADT/SmallString.h"
29+
#include "llvm/Support/Regex.h"
2930
#include <tuple>
3031
#include <vector>
3132
using namespace clang;

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include "llvm/ADT/StringMap.h"
2020
#include "llvm/Support/Timer.h"
2121

22+
namespace llvm {
23+
class Regex;
24+
}
25+
2226
namespace clang {
2327

2428
class ASTContext;

clang-tools-extra/clang-tidy/ClangTidyForceLinker.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ extern volatile int LLVMModuleAnchorSource;
4545
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
4646
LLVMModuleAnchorSource;
4747

48+
// This anchor is used to force the linker to link the LLVMLibcModule.
49+
extern volatile int LLVMLibcModuleAnchorSource;
50+
static int LLVM_ATTRIBUTE_UNUSED LLVMLibcModuleAnchorDestination =
51+
LLVMLibcModuleAnchorSource;
52+
4853
// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
4954
extern volatile int CppCoreGuidelinesModuleAnchorSource;
5055
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

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

99
#include "ExpandModularHeadersPPCallbacks.h"
10+
#include "clang/Basic/FileManager.h"
11+
#include "clang/Basic/TargetInfo.h"
1012
#include "clang/Frontend/CompilerInstance.h"
1113
#include "clang/Lex/PreprocessorOptions.h"
1214
#include "clang/Serialization/ASTReader.h"

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
#include "clang/Lex/Preprocessor.h"
1414
#include "llvm/ADT/DenseSet.h"
1515

16+
namespace llvm {
17+
namespace vfs {
18+
class OverlayFileSystem;
19+
class InMemoryFileSystem;
20+
} // namespace vfs
21+
} // namespace llvm
22+
1623
namespace clang {
1724
class CompilerInstance;
1825

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

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,22 @@ void DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
5252
callee(functionDecl(hasName("::absl::FDivDuration"))),
5353
hasArgument(0, expr().bind("arg")), hasArgument(1, factory_matcher));
5454

55+
// Matcher which matches a duration argument being scaled,
56+
// e.g. `absl::ToDoubleSeconds(dur) * 2`
57+
auto scalar_matcher = ignoringImpCasts(
58+
binaryOperator(hasOperatorName("*"),
59+
hasEitherOperand(expr(ignoringParenImpCasts(
60+
callExpr(callee(functionDecl(hasAnyName(
61+
FloatConversion, IntegerConversion))),
62+
hasArgument(0, expr().bind("arg")))
63+
.bind("inner_call")))))
64+
.bind("binop"));
65+
5566
Finder->addMatcher(
5667
callExpr(callee(functionDecl(hasName(DurationFactory))),
5768
hasArgument(0, anyOf(inverse_function_matcher,
58-
division_operator_matcher, fdiv_matcher)))
69+
division_operator_matcher, fdiv_matcher,
70+
scalar_matcher)))
5971
.bind("call"),
6072
this);
6173
}
@@ -64,16 +76,41 @@ void DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
6476
void DurationUnnecessaryConversionCheck::check(
6577
const MatchFinder::MatchResult &Result) {
6678
const auto *OuterCall = Result.Nodes.getNodeAs<Expr>("call");
67-
const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
6879

6980
if (isInMacro(Result, OuterCall))
7081
return;
7182

83+
FixItHint Hint;
84+
if (const auto *Binop = Result.Nodes.getNodeAs<BinaryOperator>("binop")) {
85+
const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg");
86+
const auto *InnerCall = Result.Nodes.getNodeAs<Expr>("inner_call");
87+
const Expr *LHS = Binop->getLHS();
88+
const Expr *RHS = Binop->getRHS();
89+
90+
if (LHS->IgnoreParenImpCasts() == InnerCall) {
91+
Hint = FixItHint::CreateReplacement(
92+
OuterCall->getSourceRange(),
93+
(llvm::Twine(tooling::fixit::getText(*Arg, *Result.Context)) + " * " +
94+
tooling::fixit::getText(*RHS, *Result.Context))
95+
.str());
96+
} else {
97+
assert(RHS->IgnoreParenImpCasts() == InnerCall &&
98+
"Inner call should be find on the RHS");
99+
100+
Hint = FixItHint::CreateReplacement(
101+
OuterCall->getSourceRange(),
102+
(llvm::Twine(tooling::fixit::getText(*LHS, *Result.Context)) + " * " +
103+
tooling::fixit::getText(*Arg, *Result.Context))
104+
.str());
105+
}
106+
} else if (const auto *Arg = Result.Nodes.getNodeAs<Expr>("arg")) {
107+
Hint = FixItHint::CreateReplacement(
108+
OuterCall->getSourceRange(),
109+
tooling::fixit::getText(*Arg, *Result.Context));
110+
}
72111
diag(OuterCall->getBeginLoc(),
73112
"remove unnecessary absl::Duration conversions")
74-
<< FixItHint::CreateReplacement(
75-
OuterCall->getSourceRange(),
76-
tooling::fixit::getText(*Arg, *Result.Context));
113+
<< Hint;
77114
}
78115

79116
} // namespace abseil

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
105105

106106
// Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
107107
// whether this already exists).
108-
auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
108+
Diagnostic << IncludeInserter->CreateIncludeInsertion(
109109
Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader,
110110
false);
111-
if (IncludeHint) {
112-
Diagnostic << *IncludeHint;
113-
}
114111
}
115112

116113
void StringFindStartswithCheck::registerPPCallbacks(

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

Lines changed: 79 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace clang {
1818
namespace tidy {
1919
namespace bugprone {
2020

21+
static constexpr int UnsignedASCIIUpperBound = 127;
22+
2123
static Matcher<TypedefDecl> hasAnyListedName(const std::string &Names) {
2224
const std::vector<std::string> NameList =
2325
utils::options::parseStringList(Names);
@@ -33,70 +35,114 @@ void SignedCharMisuseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
3335
Options.store(Opts, "CharTypdefsToIgnore", CharTypdefsToIgnoreList);
3436
}
3537

36-
void SignedCharMisuseCheck::registerMatchers(MatchFinder *Finder) {
38+
// Create a matcher for char -> integer cast.
39+
BindableMatcher<clang::Stmt> SignedCharMisuseCheck::charCastExpression(
40+
bool IsSigned, const Matcher<clang::QualType> &IntegerType,
41+
const std::string &CastBindName) const {
3742
// We can ignore typedefs which are some kind of integer types
3843
// (e.g. typedef char sal_Int8). In this case, we don't need to
3944
// worry about the misinterpretation of char values.
4045
const auto IntTypedef = qualType(
4146
hasDeclaration(typedefDecl(hasAnyListedName(CharTypdefsToIgnoreList))));
4247

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");
48+
auto CharTypeExpr = expr();
49+
if (IsSigned) {
50+
CharTypeExpr = expr(hasType(
51+
qualType(isAnyCharacter(), isSignedInteger(), unless(IntTypedef))));
52+
} else {
53+
CharTypeExpr = expr(hasType(qualType(
54+
isAnyCharacter(), unless(isSignedInteger()), unless(IntTypedef))));
55+
}
4956

50-
// We are interested in signed char -> integer conversion.
5157
const auto ImplicitCastExpr =
52-
implicitCastExpr(hasSourceExpression(SignedCharType),
58+
implicitCastExpr(hasSourceExpression(CharTypeExpr),
5359
hasImplicitDestinationType(IntegerType))
54-
.bind("castExpression");
60+
.bind(CastBindName);
5561

5662
const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
5763
const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
5864
const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
5965

6066
// We catch any type of casts to an integer. We need to have these cast
6167
// 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));
68+
// of the checked expressions. (e.g. assignment, declaration).
69+
return expr(anyOf(ImplicitCastExpr, CStyleCastExpr, StaticCastExpr,
70+
FunctionalCastExpr));
71+
}
6572

66-
// Catch assignments with the suspicious type conversion.
67-
const auto AssignmentOperatorExpr = expr(binaryOperator(
68-
hasOperatorName("="), hasLHS(hasType(IntegerType)), hasRHS(CastExpr)));
73+
void SignedCharMisuseCheck::registerMatchers(MatchFinder *Finder) {
74+
const auto IntegerType =
75+
qualType(isInteger(), unless(isAnyCharacter()), unless(booleanType()))
76+
.bind("integerType");
77+
const auto SignedCharCastExpr =
78+
charCastExpression(true, IntegerType, "signedCastExpression");
79+
const auto UnSignedCharCastExpr =
80+
charCastExpression(false, IntegerType, "unsignedCastExpression");
81+
82+
// Catch assignments with singed char -> integer conversion.
83+
const auto AssignmentOperatorExpr =
84+
expr(binaryOperator(hasOperatorName("="), hasLHS(hasType(IntegerType)),
85+
hasRHS(SignedCharCastExpr)));
6986

7087
Finder->addMatcher(AssignmentOperatorExpr, this);
7188

72-
// Catch declarations with the suspicious type conversion.
73-
const auto Declaration =
74-
varDecl(isDefinition(), hasType(IntegerType), hasInitializer(CastExpr));
89+
// Catch declarations with singed char -> integer conversion.
90+
const auto Declaration = varDecl(isDefinition(), hasType(IntegerType),
91+
hasInitializer(SignedCharCastExpr));
7592

7693
Finder->addMatcher(Declaration, this);
94+
95+
// Catch signed char/unsigned char comparison.
96+
const auto CompareOperator =
97+
expr(binaryOperator(hasAnyOperatorName("==", "!="),
98+
anyOf(allOf(hasLHS(SignedCharCastExpr),
99+
hasRHS(UnSignedCharCastExpr)),
100+
allOf(hasLHS(UnSignedCharCastExpr),
101+
hasRHS(SignedCharCastExpr)))))
102+
.bind("comparison");
103+
104+
Finder->addMatcher(CompareOperator, this);
77105
}
78106

79107
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);
108+
const auto *SignedCastExpression =
109+
Result.Nodes.getNodeAs<ImplicitCastExpr>("signedCastExpression");
85110

86-
// Ignore the match if we know that the value is not negative.
111+
// Ignore the match if we know that the signed char's value is not negative.
87112
// The potential misinterpretation happens for negative values only.
88113
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())
114+
if (!SignedCastExpression->isValueDependent() &&
115+
SignedCastExpression->getSubExpr()->EvaluateAsInt(EVResult,
116+
*Result.Context)) {
117+
llvm::APSInt Value = EVResult.Val.getInt();
118+
if (Value.isNonNegative())
93119
return;
94120
}
95121

96-
diag(CastExpression->getBeginLoc(),
97-
"'signed char' to %0 conversion; "
98-
"consider casting to 'unsigned char' first.")
99-
<< *IntegerType;
122+
if (const auto *Comparison = Result.Nodes.getNodeAs<Expr>("comparison")) {
123+
const auto *UnSignedCastExpression =
124+
Result.Nodes.getNodeAs<ImplicitCastExpr>("unsignedCastExpression");
125+
126+
// We can ignore the ASCII value range also for unsigned char.
127+
Expr::EvalResult EVResult;
128+
if (!UnSignedCastExpression->isValueDependent() &&
129+
UnSignedCastExpression->getSubExpr()->EvaluateAsInt(EVResult,
130+
*Result.Context)) {
131+
llvm::APSInt Value = EVResult.Val.getInt();
132+
if (Value <= UnsignedASCIIUpperBound)
133+
return;
134+
}
135+
136+
diag(Comparison->getBeginLoc(),
137+
"comparison between 'signed char' and 'unsigned char'");
138+
} else if (const auto *IntegerType =
139+
Result.Nodes.getNodeAs<QualType>("integerType")) {
140+
diag(SignedCastExpression->getBeginLoc(),
141+
"'signed char' to %0 conversion; "
142+
"consider casting to 'unsigned char' first.")
143+
<< *IntegerType;
144+
} else
145+
llvm_unreachable("Unexpected match");
100146
}
101147

102148
} // namespace bugprone

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ namespace clang {
1515
namespace tidy {
1616
namespace bugprone {
1717

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``.
18+
/// Finds those ``signed char`` -> integer conversions which might indicate a
19+
/// programming error. The basic problem with the ``signed char``, that it might
20+
/// store the non-ASCII characters as negative values. This behavior can cause a
21+
/// misunderstanding of the written code both when an explicit and when an
22+
/// implicit conversion happens.
2523
///
2624
/// For the user-facing documentation see:
2725
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-signed-char-misuse.html
@@ -34,6 +32,11 @@ class SignedCharMisuseCheck : public ClangTidyCheck {
3432
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3533

3634
private:
35+
ast_matchers::internal::BindableMatcher<clang::Stmt> charCastExpression(
36+
bool IsSigned,
37+
const ast_matchers::internal::Matcher<clang::QualType> &IntegerType,
38+
const std::string &CastBindName) const;
39+
3740
const std::string CharTypdefsToIgnoreList;
3841
};
3942

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ void SuspiciousIncludePPCallbacks::InclusionDirective(
7474
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
7575
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
7676
SrcMgr::CharacteristicKind FileType) {
77+
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import)
78+
return;
79+
7780
SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
7881

7982
const Optional<StringRef> IFE =

clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DefaultOperatorNewAlignmentCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/Basic/TargetInfo.h"
1213

1314
using namespace clang::ast_matchers;
1415

0 commit comments

Comments
 (0)