Skip to content

Commit e280047

Browse files
author
Erich Keane
committed
Merge from 'master' to 'sycl-web' (#4)
CONFLICT (content): Merge conflict in clang/test/SemaOpenCLCXX/address-space-lambda.cl
2 parents de9ec72 + 6976fef commit e280047

File tree

1,644 files changed

+37398
-23021
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,644 files changed

+37398
-23021
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ struct StrCatCheckResult {
4747
};
4848

4949
void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) {
50+
if (Call->getNumArgs() == 0)
51+
return;
5052
// Remove 'Foo('
5153
CheckResult->Hints.push_back(
5254
FixItHint::CreateRemoval(CharSourceRange::getCharRange(

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ void RedundantBranchConditionCheck::check(const MatchFinder::MatchResult &Result
8282

8383
// For standalone condition variables and for "or" binary operations we simply
8484
// remove the inner `if`.
85-
const auto *BinOpCond = dyn_cast<BinaryOperator>(InnerIf->getCond());
85+
const auto *BinOpCond =
86+
dyn_cast<BinaryOperator>(InnerIf->getCond()->IgnoreParenImpCasts());
87+
8688
if (isa<DeclRefExpr>(InnerIf->getCond()->IgnoreParenImpCasts()) ||
8789
(BinOpCond && BinOpCond->getOpcode() == BO_LOr)) {
8890
SourceLocation IfBegin = InnerIf->getBeginLoc();
@@ -129,7 +131,8 @@ void RedundantBranchConditionCheck::check(const MatchFinder::MatchResult &Result
129131
// For "and" binary operations we remove the "and" operation with the
130132
// condition variable from the inner if.
131133
} else {
132-
const auto *CondOp = cast<BinaryOperator>(InnerIf->getCond());
134+
const auto *CondOp =
135+
cast<BinaryOperator>(InnerIf->getCond()->IgnoreParenImpCasts());
133136
const auto *LeftDRE =
134137
dyn_cast<DeclRefExpr>(CondOp->getLHS()->IgnoreParenImpCasts());
135138
if (LeftDRE && LeftDRE->getDecl() == CondVar) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
5959
extractNodesByIdTo(Matches, "declRef", DeclRefs);
6060
auto ConstReferenceOrValue =
6161
qualType(anyOf(referenceType(pointee(qualType(isConstQualified()))),
62-
unless(anyOf(referenceType(), pointerType()))));
62+
unless(anyOf(referenceType(), pointerType(),
63+
substTemplateTypeParmType()))));
64+
auto ConstReferenceOrValueOrReplaced = qualType(anyOf(
65+
ConstReferenceOrValue,
66+
substTemplateTypeParmType(hasReplacementType(ConstReferenceOrValue))));
6367
auto UsedAsConstRefOrValueArg = forEachArgumentWithParam(
64-
DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValue)));
68+
DeclRefToVar, parmVarDecl(hasType(ConstReferenceOrValueOrReplaced)));
6569
Matches = match(findAll(callExpr(UsedAsConstRefOrValueArg)), Stmt, Context);
6670
extractNodesByIdTo(Matches, "declRef", DeclRefs);
6771
Matches =

clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct AlphaNum {
121121
AlphaNum &operator=(const AlphaNum &);
122122
};
123123

124+
string StrCat();
124125
string StrCat(const AlphaNum &A);
125126
string StrCat(const AlphaNum &A, const AlphaNum &B);
126127
string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
@@ -154,9 +155,11 @@ using absl::StrCat;
154155
void Positives() {
155156
string S = StrCat(1, StrCat("A", StrCat(1.1)));
156157
// CHECK-MESSAGES: [[@LINE-1]]:14: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
158+
// CHECK-FIXES: string S = StrCat(1, "A", 1.1);
157159

158160
S = StrCat(StrCat(StrCat(StrCat(StrCat(1)))));
159161
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
162+
// CHECK-FIXES: S = StrCat(1);
160163

161164
// TODO: should trigger. The issue here is that in the current
162165
// implementation we ignore any StrCat with StrCat ancestors. Therefore
@@ -166,9 +169,11 @@ void Positives() {
166169

167170
StrAppend(&S, 001, StrCat(1, 2, "3"), StrCat("FOO"));
168171
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
172+
// CHECK-FIXES: StrAppend(&S, 001, 1, 2, "3", "FOO");
169173

170174
StrAppend(&S, 001, StrCat(StrCat(1, 2), "3"), StrCat("FOO"));
171175
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
176+
// CHECK-FIXES: StrAppend(&S, 001, 1, 2, "3", "FOO");
172177

173178
// Too many args. Ignore for now.
174179
S = StrCat(1, 2, StrCat(3, 4, 5, 6, 7), 8, 9, 10,
@@ -177,6 +182,10 @@ void Positives() {
177182
// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
178183
StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
179184
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
185+
// CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
186+
187+
StrCat(1, StrCat());
188+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
180189
}
181190

182191
void Negatives() {

clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,34 @@ void positive_comma_after_condition() {
10731073
}
10741074
}
10751075

1076+
// ExprWithCleanups doesn't crash
1077+
int positive_expr_with_cleanups() {
1078+
class RetT {
1079+
public:
1080+
RetT(const int _code) : code_(_code) {}
1081+
bool Ok() const { return code_ == 0; }
1082+
static RetT Test(bool &_isSet) { return 0; }
1083+
1084+
private:
1085+
int code_;
1086+
};
1087+
1088+
bool isSet = false;
1089+
if (RetT::Test(isSet).Ok() && isSet) {
1090+
if (RetT::Test(isSet).Ok() && isSet) {
1091+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' [bugprone-redundant-branch-condition]
1092+
// CHECK-FIXES: if (RetT::Test(isSet).Ok() ) {
1093+
}
1094+
}
1095+
if (isSet) {
1096+
if ((RetT::Test(isSet).Ok() && isSet)) {
1097+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' [bugprone-redundant-branch-condition]
1098+
// CHECK-FIXES: if ((RetT::Test(isSet).Ok() )) {
1099+
}
1100+
}
1101+
return 0;
1102+
}
1103+
10761104
//===--- Special Negatives ------------------------------------------------===//
10771105

10781106
// Aliasing

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,12 @@ inline namespace __1 {
411411

412412
template <class>
413413
class function;
414-
template <class R, class... Args>
415-
class function<R(Args...)> {
414+
template <class R, class... ArgTypes>
415+
class function<R(ArgTypes...)> {
416416
public:
417417
function();
418-
function(const function &other);
419-
R operator()(Args &&...args) const;
418+
function(const function &Other);
419+
R operator()(ArgTypes... Args) const;
420420
};
421421

422422
} // namespace __1
@@ -460,3 +460,19 @@ void positiveFakeStdFunction(std::function<void(int)> F) {
460460
}
461461

462462
} // namespace fake
463+
464+
void positiveInvokedOnStdFunction(
465+
std::function<void(const ExpensiveToCopyType &)> Update,
466+
const ExpensiveToCopyType Orig) {
467+
auto Copy = Orig.reference();
468+
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'Copy' is copy-constructed from a const reference
469+
// CHECK-FIXES: const auto& Copy = Orig.reference();
470+
Update(Copy);
471+
}
472+
473+
void negativeInvokedOnStdFunction(
474+
std::function<void(ExpensiveToCopyType &)> Update,
475+
const ExpensiveToCopyType Orig) {
476+
auto Copy = Orig.reference();
477+
Update(Copy);
478+
}

clang/cmake/caches/CrossWinToARMLinux.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@ set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LLVM_PROJECT_DIR}/libcxxabi/inclu
100100
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
101101
set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
102102

103-
set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
104-
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
103+
# Set up RPATH for the target runtime/builtin libraries.
104+
# See some details here: https://reviews.llvm.org/D91099
105+
if (NOT DEFINED RUNTIMES_INSTALL_RPATH)
106+
set(RUNTIMES_INSTALL_RPATH "\$ORIGIN/../lib;${CMAKE_INSTALL_PREFIX}/lib")
107+
endif()
108+
109+
set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR};-DCMAKE_INSTALL_RPATH=${RUNTIMES_INSTALL_RPATH};-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" CACHE STRING "")
110+
set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR};-DCMAKE_INSTALL_RPATH=${RUNTIMES_INSTALL_RPATH};-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" CACHE STRING "")
105111

106112
find_package(Python3 COMPONENTS Interpreter)
107113

clang/docs/DiagnosticsReference.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7977,15 +7977,6 @@ This diagnostic is enabled by default.
79777977
+------------------------------------------------------------------------------------------------+
79787978

79797979

7980-
-Wmisexpect
7981-
-----------
7982-
**Diagnostic text:**
7983-
7984-
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
7985-
|:warning:`warning:` |nbsp| :diagtext:`Potential performance regression from use of \_\_builtin\_expect(): Annotation was correct on` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of profiled executions.`|
7986-
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
7987-
7988-
79897980
-Wmisleading-indentation
79907981
------------------------
79917982
**Diagnostic text:**

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ Modified Compiler Flags
114114
It produces ``SHF_COMPRESSED`` style compression of debug information. GNU
115115
binutils 2.26 or newer, or lld is required to link produced object files. Use
116116
``-gz=zlib-gnu`` to get the old behavior.
117+
- Now that `this` pointers are tagged with `nonnull` and `dereferenceable(N)`,
118+
`-fno-delete-null-pointer-checks` has gained the power to remove the
119+
`nonnull` attribute on `this` for configurations that need it to be nullable.
117120

118121
New Pragmas in Clang
119122
--------------------

clang/include/clang/AST/Decl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ class FunctionDecl : public DeclaratorDecl,
19791979
SourceLocation NLoc, DeclarationName N, QualType T,
19801980
TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = false,
19811981
bool hasWrittenPrototype = true,
1982-
ConstexprSpecKind ConstexprKind = CSK_unspecified,
1982+
ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified,
19831983
Expr *TrailingRequiresClause = nullptr) {
19841984
DeclarationNameInfo NameInfo(N, NLoc);
19851985
return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC,
@@ -2231,19 +2231,19 @@ class FunctionDecl : public DeclaratorDecl,
22312231

22322232
/// Whether this is a (C++11) constexpr function or constexpr constructor.
22332233
bool isConstexpr() const {
2234-
return FunctionDeclBits.ConstexprKind != CSK_unspecified;
2234+
return getConstexprKind() != ConstexprSpecKind::Unspecified;
22352235
}
22362236
void setConstexprKind(ConstexprSpecKind CSK) {
2237-
FunctionDeclBits.ConstexprKind = CSK;
2237+
FunctionDeclBits.ConstexprKind = static_cast<uint64_t>(CSK);
22382238
}
22392239
ConstexprSpecKind getConstexprKind() const {
22402240
return static_cast<ConstexprSpecKind>(FunctionDeclBits.ConstexprKind);
22412241
}
22422242
bool isConstexprSpecified() const {
2243-
return FunctionDeclBits.ConstexprKind == CSK_constexpr;
2243+
return getConstexprKind() == ConstexprSpecKind::Constexpr;
22442244
}
22452245
bool isConsteval() const {
2246-
return FunctionDeclBits.ConstexprKind == CSK_consteval;
2246+
return getConstexprKind() == ConstexprSpecKind::Consteval;
22472247
}
22482248

22492249
/// Whether the instantiation of this function is pending.

0 commit comments

Comments
 (0)