Skip to content

Commit e9cae4f

Browse files
committed
Merge from '"main"' to '"sycl-web"' (3 commits)
CONFLICT (content): Merge conflict in clang/test/CodeGenSYCL/unique_stable_name.cpp CONFLICT (content): Merge conflict in clang/test/CodeGenSYCL/address-space-mangling.cpp
2 parents a4d1cad + f193bcc commit e9cae4f

File tree

1,624 files changed

+78138
-55511
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,624 files changed

+78138
-55511
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,29 @@ namespace clang {
1919
namespace tidy {
2020
namespace cppcoreguidelines {
2121

22+
AST_MATCHER(CXXRecordDecl, hasPublicVirtualOrProtectedNonVirtualDestructor) {
23+
// We need to call Node.getDestructor() instead of matching a
24+
// CXXDestructorDecl. Otherwise, tests will fail for class templates, since
25+
// the primary template (not the specialization) always gets a non-virtual
26+
// CXXDestructorDecl in the AST. https://bugs.llvm.org/show_bug.cgi?id=51912
27+
const CXXDestructorDecl *Destructor = Node.getDestructor();
28+
if (!Destructor)
29+
return false;
30+
31+
return (((Destructor->getAccess() == AccessSpecifier::AS_public) &&
32+
Destructor->isVirtual()) ||
33+
((Destructor->getAccess() == AccessSpecifier::AS_protected) &&
34+
!Destructor->isVirtual()));
35+
}
36+
2237
void VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
2338
ast_matchers::internal::Matcher<CXXRecordDecl> InheritsVirtualMethod =
2439
hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual())))));
2540

2641
Finder->addMatcher(
2742
cxxRecordDecl(
2843
anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
29-
unless(anyOf(
30-
has(cxxDestructorDecl(isPublic(), isVirtual())),
31-
has(cxxDestructorDecl(isProtected(), unless(isVirtual()))))))
44+
unless(hasPublicVirtualOrProtectedNonVirtualDestructor()))
3245
.bind("ProblematicClassOrStruct"),
3346
this);
3447
}

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,73 @@ struct NonOverridingDerivedStruct : ProtectedNonVirtualBaseStruct {
202202
void m();
203203
};
204204
// inherits virtual method
205+
206+
namespace Bugzilla_51912 {
207+
// Fixes https://bugs.llvm.org/show_bug.cgi?id=51912
208+
209+
// Forward declarations
210+
// CHECK-MESSAGES-NOT: :[[@LINE+1]]:8: warning: destructor of 'ForwardDeclaredStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
211+
struct ForwardDeclaredStruct;
212+
213+
struct ForwardDeclaredStruct : PublicVirtualBaseStruct {
214+
};
215+
216+
// Normal Template
217+
// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'TemplatedDerived' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
218+
template <typename T>
219+
struct TemplatedDerived : PublicVirtualBaseStruct {
220+
};
221+
222+
TemplatedDerived<int> InstantiationWithInt;
223+
224+
// Derived from template, base has virtual dtor
225+
// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'DerivedFromTemplateVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
226+
template <typename T>
227+
struct DerivedFromTemplateVirtualBaseStruct : T {
228+
virtual void foo();
229+
};
230+
231+
DerivedFromTemplateVirtualBaseStruct<PublicVirtualBaseStruct> InstantiationWithPublicVirtualBaseStruct;
232+
233+
// Derived from template, base has *not* virtual dtor
234+
// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
235+
// CHECK-MESSAGES: :[[@LINE+7]]:8: note: make it public and virtual
236+
// CHECK-MESSAGES: :[[@LINE+6]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct<PublicNonVirtualBaseStruct>' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
237+
// CHECK-FIXES: struct DerivedFromTemplateNonVirtualBaseStruct : T {
238+
// CHECK-FIXES-NEXT: virtual ~DerivedFromTemplateNonVirtualBaseStruct() = default;
239+
// CHECK-FIXES-NEXT: virtual void foo();
240+
// CHECK-FIXES-NEXT: };
241+
template <typename T>
242+
struct DerivedFromTemplateNonVirtualBaseStruct : T {
243+
virtual void foo();
244+
};
245+
246+
DerivedFromTemplateNonVirtualBaseStruct<PublicNonVirtualBaseStruct> InstantiationWithPublicNonVirtualBaseStruct;
247+
248+
// Derived from template, base has virtual dtor, to be used in a typedef
249+
// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'DerivedFromTemplateVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
250+
template <typename T>
251+
struct DerivedFromTemplateVirtualBaseStruct2 : T {
252+
virtual void foo();
253+
};
254+
255+
using DerivedFromTemplateVirtualBaseStruct2Typedef = DerivedFromTemplateVirtualBaseStruct2<PublicVirtualBaseStruct>;
256+
DerivedFromTemplateVirtualBaseStruct2Typedef InstantiationWithPublicVirtualBaseStruct2;
257+
258+
// Derived from template, base has *not* virtual dtor, to be used in a typedef
259+
// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
260+
// CHECK-MESSAGES: :[[@LINE+7]]:8: note: make it public and virtual
261+
// CHECK-MESSAGES: :[[@LINE+6]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct2<PublicNonVirtualBaseStruct>' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
262+
// CHECK-FIXES: struct DerivedFromTemplateNonVirtualBaseStruct2 : T {
263+
// CHECK-FIXES-NEXT: virtual ~DerivedFromTemplateNonVirtualBaseStruct2() = default;
264+
// CHECK-FIXES-NEXT: virtual void foo();
265+
// CHECK-FIXES-NEXT: };
266+
template <typename T>
267+
struct DerivedFromTemplateNonVirtualBaseStruct2 : T {
268+
virtual void foo();
269+
};
270+
271+
using DerivedFromTemplateNonVirtualBaseStruct2Typedef = DerivedFromTemplateNonVirtualBaseStruct2<PublicNonVirtualBaseStruct>;
272+
DerivedFromTemplateNonVirtualBaseStruct2Typedef InstantiationWithPublicNonVirtualBaseStruct2;
273+
274+
} // namespace Bugzilla_51912

clang/docs/Block-ABI-Apple.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/docs/Makefile.sphinx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ html:
5050
@# Kind of a hack, but HTML-formatted docs are on the way out anyway.
5151
@echo "Copying legacy HTML-formatted docs into $(BUILDDIR)/html"
5252
@cp -a *.html $(BUILDDIR)/html
53-
@# FIXME: What we really need is a way to specify redirects, so that
54-
@# we can just redirect to a reST'ified version of this document.
55-
@# PR14714 is tracking the issue of redirects.
56-
@cp -a Block-ABI-Apple.txt $(BUILDDIR)/html
5753
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
5854

5955
dirhtml:

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ Attribute Changes in Clang
110110
attribute is handled instead, e.g. in ``handleDeclAttribute``.
111111
(This was changed in order to better support attributes in code completion).
112112

113+
- __has_cpp_attribute, __has_c_attribute, __has_attribute, and __has_declspec
114+
will now macro expand their argument. This causes a change in behavior for
115+
code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
116+
``__has_c_attribute``) where it would previously expand to ``0`` for all
117+
attributes, but will now issue an error due to the expansion of the
118+
predefined ``__clang__`` macro.
119+
113120
Windows Support
114121
---------------
115122

@@ -122,6 +129,9 @@ Windows Support
122129
C Language Changes in Clang
123130
---------------------------
124131

132+
- The value of ``__STDC_VERSION__`` has been bumped to ``202000L`` when passing
133+
``-std=c2x`` so that it can be distinguished from C17 mode. This value is
134+
expected to change again when C23 is published.
125135
- Wide multi-characters literals such as ``L'ab'`` that would previously be interpreted as ``L'b'``
126136
are now ill-formed in all language modes. The motivation for this change is outlined in
127137
`P2362 <wg21.link/P2362>`_.

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ class BoundNodesTreeBuilder {
312312

313313
template <typename ExcludePredicate>
314314
bool removeBindings(const ExcludePredicate &Predicate) {
315-
Bindings.erase(std::remove_if(Bindings.begin(), Bindings.end(), Predicate),
316-
Bindings.end());
315+
llvm::erase_if(Bindings, Predicate);
317316
return !Bindings.empty();
318317
}
319318

clang/include/clang/Analysis/Analyses/Dominators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ struct ChildrenGetterTy<clang::CFGBlock, IsPostDom> {
202202

203203
auto Children = children<OrderedNodeTy>(N);
204204
ChildrenTy Ret{Children.begin(), Children.end()};
205-
Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
205+
llvm::erase_value(Ret, nullptr);
206206
return Ret;
207207
}
208208
};

clang/include/clang/Analysis/CloneDetection.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ class CloneConstraint {
235235
static void filterGroups(
236236
std::vector<CloneDetector::CloneGroup> &CloneGroups,
237237
llvm::function_ref<bool(const CloneDetector::CloneGroup &)> Filter) {
238-
CloneGroups.erase(
239-
std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter),
240-
CloneGroups.end());
238+
llvm::erase_if(CloneGroups, Filter);
241239
}
242240

243241
/// Splits the given CloneGroups until the given Compare function returns true

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
6464
CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0
6565
CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, experimental
6666
///< strict floating point.
67-
CODEGENOPT(DisableNoundefAttrs, 1, 0) ///< Disable emitting `noundef` attributes on IR call arguments and return values
67+
CODEGENOPT(EnableNoundefAttrs, 1, 0) ///< Enable emitting `noundef` attributes on IR call arguments and return values
6868
CODEGENOPT(LegacyPassManager, 1, 0) ///< Use the legacy pass manager.
6969
CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
7070
///< pass manager.

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ def err_opt_not_valid_without_opt : Error<
306306
"option '%0' cannot be specified without '%1'">;
307307
def err_opt_not_valid_on_target : Error<
308308
"option '%0' cannot be specified on this target">;
309+
def err_invalid_feature_combination : Error<
310+
"invalid feature combination: %0">;
309311

310312
// Source manager
311313
def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;

0 commit comments

Comments
 (0)