Skip to content

Commit 24525f1

Browse files
committed
merge main into amd-staging
2 parents d8f3202 + c8f168c commit 24525f1

File tree

80 files changed

+544
-175
lines changed

Some content is hidden

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

80 files changed

+544
-175
lines changed

clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ void ContainerDataPointerCheck::check(const MatchFinder::MatchResult &Result) {
107107
Lexer::getSourceText(CharSourceRange::getTokenRange(SrcRange),
108108
*Result.SourceManager, getLangOpts())};
109109

110-
if (!isa<DeclRefExpr, ArraySubscriptExpr, CXXOperatorCallExpr, CallExpr,
111-
MemberExpr>(CE))
110+
const auto *OpCall = dyn_cast<CXXOperatorCallExpr>(CE);
111+
const bool NeedsParens =
112+
OpCall ? (OpCall->getOperator() != OO_Subscript)
113+
: !isa<DeclRefExpr, MemberExpr, ArraySubscriptExpr, CallExpr>(CE);
114+
if (NeedsParens)
112115
ReplacementText = "(" + ReplacementText + ")";
113116

114117
if (CE->getType()->isPointerType())

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ Changes in existing checks
462462
comparisons to ``npos``. Internal changes may cause new rare false positives
463463
in non-standard containers.
464464

465+
- Improved :doc:`readability-container-data-pointer
466+
<clang-tidy/checks/readability/container-data-pointer>` check by correctly
467+
adding parentheses when the container expression is a dereference.
468+
465469
- Improved :doc:`readability-container-size-empty
466470
<clang-tidy/checks/readability/container-size-empty>` check by correctly
467471
generating fix-it hints when size method is called from implicit ``this``,

clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ template <typename T>
3535
struct enable_if<true, T> {
3636
typedef T type;
3737
};
38+
39+
template <typename T>
40+
struct unique_ptr {
41+
T &operator*() const;
42+
T *operator->() const;
43+
};
3844
}
3945

4046
template <typename T>
@@ -144,3 +150,20 @@ int *r() {
144150
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
145151
// CHECK-FIXES: return holder.v.data();
146152
}
153+
154+
void s(std::unique_ptr<std::vector<unsigned char>> p) {
155+
f(&(*p)[0]);
156+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
157+
// CHECK-FIXES: f((*p).data());
158+
}
159+
160+
void t(std::unique_ptr<container_without_data<unsigned char>> p) {
161+
// p has no "data" member function, so no warning
162+
f(&(*p)[0]);
163+
}
164+
165+
template <typename T>
166+
void u(std::unique_ptr<T> p) {
167+
// we don't know if 'T' will always have "data" member function, so no warning
168+
f(&(*p)[0]);
169+
}

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2642,7 +2642,7 @@ class DeclContext {
26422642

26432643
using udir_iterator_base =
26442644
llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
2645-
typename lookup_iterator::iterator_category,
2645+
lookup_iterator::iterator_category,
26462646
UsingDirectiveDecl *>;
26472647

26482648
struct udir_iterator : udir_iterator_base {

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ bool IsX86_MMXType(llvm::Type *IRType) {
2727
static llvm::Type *X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
2828
StringRef Constraint,
2929
llvm::Type *Ty) {
30+
bool IsMMXCons = llvm::StringSwitch<bool>(Constraint)
31+
.Cases({"y", "&y", "^Ym"}, true)
32+
.Default(false);
33+
if (IsMMXCons && Ty->isVectorTy() &&
34+
cast<llvm::VectorType>(Ty)->getPrimitiveSizeInBits().getFixedValue() !=
35+
64)
36+
return nullptr; // Invalid MMX constraint
37+
3038
if (Constraint == "k") {
3139
llvm::Type *Int1Ty = llvm::Type::getInt1Ty(CGF.getLLVMContext());
3240
return llvm::FixedVectorType::get(Int1Ty, Ty->getScalarSizeInBits());

clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ REGISTER_LIST_WITH_PROGRAMSTATE(ActiveCritSections, CritSectionMarker)
270270
// TODO: Move these to llvm::ImmutableList when overhauling immutable data
271271
// structures for proper iterator concept support.
272272
template <>
273-
struct std::iterator_traits<
274-
typename llvm::ImmutableList<CritSectionMarker>::iterator> {
273+
struct std::iterator_traits<llvm::ImmutableList<CritSectionMarker>::iterator> {
275274
using iterator_category = std::forward_iterator_tag;
276275
using value_type = CritSectionMarker;
277276
using difference_type = std::ptrdiff_t;

clang/test/CodeGen/X86/mmx-inline-asm-error.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// RUN: %clang_cc1 -verify -triple x86_64-unknown-unknown -emit-llvm-only %s
2+
// RUN: %clang_cc1 -verify=omp -triple x86_64-unknown-unknown -emit-llvm-only -fopenmp %s
23
typedef int vec256 __attribute__((ext_vector_type(8)));
34

45
vec256 foo(vec256 in) {
56
vec256 out;
67

78
asm("something %0" : : "y"(in)); // expected-error {{invalid input size for constraint 'y'}}
9+
// omp-error@+1 {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
810
asm("something %0" : "=y"(out)); // expected-error {{invalid output size for constraint '=y'}}
11+
// omp-error@+1 {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
912
asm("something %0, %0" : "+y"(out)); // expected-error {{invalid output size for constraint '+y'}}
1013

1114
return out;
1215
}
13-

lldb/test/Shell/Recognizer/registration-unique.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
# RUN: split-file %s %t
77

8-
# RUN: %clang_host %t/main.cpp -g -o %t/cpp.out
8+
# RUN: %clangxx_host %t/main.cpp -g -o %t/cpp.out
99
# RUN: %lldb -b -s %t/commands.input %t/cpp.out | FileCheck %s
1010

11-
# RUN: %clang_host -x objective-c++ %t/main.mm -g -o %t/objcxx.out
11+
# RUN: %clangxx_host %t/main.mm -g -o %t/objcxx.out
1212
# RUN: %lldb -b -s %t/commands.input %t/objcxx.out | FileCheck %s
1313

1414
# RUN: %clang_host %t/main.c -g -o %t/c.out
1515
# RUN: %lldb -b -s %t/commands.input %t/c.out | FileCheck %s
1616

17-
# RUN: %clang_host -x objective-c %t/main.m -g -o %t/objc.out
17+
# RUN: %clang_host %t/main.m -g -o %t/objc.out
1818
# RUN: %lldb -b -s %t/commands.input %t/objc.out | FileCheck %s
1919

2020
#--- main.m

lldb/test/Shell/Recognizer/verbose_trap-objc.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: system-darwin
22
#
3-
# RUN: %clangxx_host -x objective-c -g %S/Inputs/verbose_trap.m -o %t.out
3+
# RUN: %clang_host -g %S/Inputs/verbose_trap.m -o %t.out
44
# RUN: %lldb -b -s %s %t.out | FileCheck %s
55

66
run

llvm/docs/CommandGuide/llc.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ End-user Options
129129

130130
Print statistics recorded by code-generation passes.
131131

132+
.. option:: --save-stats, --save-stats=cwd, --save-stats=obj
133+
134+
Save LLVM statistics to a file in the current directory
135+
(:option:`--save-stats`/"--save-stats=cwd") or the directory
136+
of the output file ("--save-stats=obj") in JSON format.
137+
132138
.. option:: --time-passes
133139

134140
Record the amount of time needed for each pass and print a report to standard

0 commit comments

Comments
 (0)