Skip to content

Commit 6907d58

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-min-iters-check
2 parents 1ae4d5f + 93c9684 commit 6907d58

File tree

76 files changed

+2021
-895
lines changed

Some content is hidden

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

76 files changed

+2021
-895
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
194194
return;
195195
if (SM.isWrittenInCommandLineFile(MacroNameTok.getLocation()))
196196
return;
197+
if (SM.isInSystemHeader(MacroNameTok.getLocation()))
198+
return;
197199
Check->checkMacro(MacroNameTok, Info, SM);
198200
}
199201

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Changes in existing checks
163163

164164
- Improved :doc:`bugprone-reserved-identifier
165165
<clang-tidy/checks/bugprone/reserved-identifier>` check by ignoring
166-
declarations in system headers.
166+
declarations and macros in system headers.
167167

168168
- Improved :doc:`bugprone-signed-char-misuse
169169
<clang-tidy/checks/bugprone/signed-char-misuse>` check by fixing
@@ -229,8 +229,8 @@ Changes in existing checks
229229

230230
- Improved :doc:`readability-identifier-naming
231231
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
232-
declarations in system headers. The documentation is also improved to
233-
differentiate the general options from the specific ones.
232+
declarations and macros in system headers. The documentation is also improved
233+
to differentiate the general options from the specific ones.
234234

235235
- Improved :doc:`readability-qualified-auto
236236
<clang-tidy/checks/readability/qualified-auto>` check by adding the option

clang/docs/AutomaticReferenceCounting.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ following rules apply:
740740

741741
* If the qualifier is so applied at a position in the declaration
742742
where the next-innermost declarator is a function declarator, and
743-
there is an block declarator within that function declarator, then
743+
there is a block declarator within that function declarator, then
744744
the qualifier applies instead to that block declarator and this rule
745745
is considered afresh beginning from the new position.
746746

@@ -924,7 +924,7 @@ not support ``__weak`` references.
924924

925925
A class may indicate that it does not support weak references by providing the
926926
``objc_arc_weak_reference_unavailable`` attribute on the class's interface declaration. A
927-
retainable object pointer type is **weak-unavailable** if
927+
retainable object pointer type is **weak-unavailable** if it
928928
is a pointer to an (optionally protocol-qualified) Objective-C class ``T`` where
929929
``T`` or one of its superclasses has the ``objc_arc_weak_reference_unavailable``
930930
attribute. A program is ill-formed if it applies the ``__weak`` ownership
@@ -1129,7 +1129,7 @@ be the same for identical code.
11291129
C and C++ while still automatically managing memory. While it is
11301130
usually simpler and more idiomatic to use Objective-C objects for
11311131
secondary data structures, doing so can introduce extra allocation
1132-
and message-send overhead, which can cause to unacceptable
1132+
and message-send overhead, which can cause unacceptable
11331133
performance. Using structs can resolve some of this tension.
11341134

11351135
``__autoreleasing`` is forbidden because it is treacherous to rely
@@ -1446,7 +1446,7 @@ ill-formed.
14461446
Template arguments
14471447
^^^^^^^^^^^^^^^^^^
14481448

1449-
If a template argument for a template type parameter is an retainable object
1449+
If a template argument for a template type parameter is a retainable object
14501450
owner type that does not have an explicit ownership qualifier, it is adjusted
14511451
to have ``__strong`` qualification. This adjustment occurs regardless of
14521452
whether the template argument was deduced or explicitly specified.
@@ -2064,7 +2064,7 @@ You can test if your compiler has support for ``objc_externally_retained`` with
20642064
``self``
20652065
--------
20662066
2067-
The ``self`` parameter variable of an non-init Objective-C method is considered
2067+
The ``self`` parameter variable of a non-init Objective-C method is considered
20682068
:ref:`externally-retained <arc.misc.externally_retained>` by the implementation.
20692069
It is undefined behavior, or at least dangerous, to cause an object to be
20702070
deallocated during a message send to that object. In an init method, ``self``
@@ -2334,7 +2334,7 @@ emit, which are described in the remainder of this section.
23342334
23352335
* the machine code to do so is significantly smaller,
23362336
* it is much easier to recognize the C functions in the ARC optimizer, and
2337-
* a sufficient sophisticated runtime may be able to avoid the message send in
2337+
* a sufficiently sophisticated runtime may be able to avoid the message send in
23382338
common cases.
23392339
23402340
Several other of these functions are "fused" operations which can be

clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,11 @@ void CGRecordLowering::fillOutputFields() {
10271027
if (Member.FD)
10281028
Fields[Member.FD->getCanonicalDecl()] = FieldTypes.size() - 1;
10291029
// A field without storage must be a bitfield.
1030-
if (!Member.Data)
1030+
if (!Member.Data) {
1031+
assert(Member.FD &&
1032+
"Member.Data is a nullptr so Member.FD should not be");
10311033
setBitFieldInfo(Member.FD, Member.Offset, FieldTypes.back());
1034+
}
10321035
} else if (Member.Kind == MemberInfo::Base)
10331036
NonVirtualBases[Member.RD] = FieldTypes.size() - 1;
10341037
else if (Member.Kind == MemberInfo::VBase)

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ void RISCVABIInfo::createCoercedStore(llvm::Value *Val, Address Dst,
955955
cast<llvm::FixedVectorType>(EltTy), Val, uint64_t(0));
956956
auto *I = CGF.Builder.CreateStore(Coerced, Dst, DestIsVolatile);
957957
CGF.addInstToCurrentSourceAtom(I, Val);
958-
return;
959958
}
960959

961960
namespace {

clang/lib/Driver/Driver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4672,7 +4672,6 @@ void Driver::BuildDriverManagedModuleBuildActions(
46724672
Compilation &C, llvm::opt::DerivedArgList &Args, const InputList &Inputs,
46734673
ActionList &Actions) const {
46744674
Diags.Report(diag::remark_performing_driver_managed_module_build);
4675-
return;
46764675
}
46774676

46784677
/// Returns the canonical name for the offloading architecture when using a HIP

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ void getSpirvExtOperand(StringRef SpvExtensionArg, raw_ostream &out) {
215215
return;
216216
}
217217
out << SpvExtensionArg;
218-
return;
219218
}
220219

221220
SmallString<1024> getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) {

clang/lib/Sema/SemaExpr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11808,12 +11808,6 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
1180811808
return ResultTy;
1180911809
}
1181011810

11811-
// C++0x: Don't allow scoped enums. FIXME: Use something better than
11812-
// hasIntegerRepresentation() above instead of this.
11813-
if (isScopedEnumerationType(LHSType) ||
11814-
isScopedEnumerationType(RHSType)) {
11815-
return InvalidOperands(Loc, LHS, RHS);
11816-
}
1181711811
DiagnoseBadShiftValues(*this, LHS, RHS, Loc, Opc, LHSType);
1181811812

1181911813
// "The type of the result is that of the promoted left operand."

clang/unittests/Analysis/FlowSensitive/FormulaTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ using namespace dataflow;
2222
using ::llvm::Failed;
2323
using ::llvm::HasValue;
2424
using ::llvm::Succeeded;
25-
using ::testing::ElementsAre;
26-
using ::testing::IsEmpty;
2725

2826
class SerializeFormulaTest : public ::testing::Test {
2927
protected:

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "interception/interception.h"
1717
#include "sanitizer_common/sanitizer_allocator_dlsym.h"
18+
#include "sanitizer_common/sanitizer_glibc_version.h"
1819
#include "sanitizer_common/sanitizer_platform_interceptors.h"
1920

2021
#include "interception/interception.h"
@@ -46,12 +47,41 @@
4647

4748
using namespace __sanitizer;
4849

50+
DECLARE_REAL_AND_INTERCEPTOR(void *, malloc, usize size)
51+
DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr)
52+
4953
namespace {
5054
struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
5155
static bool UseImpl() { return !__rtsan_is_initialized(); }
5256
};
5357
} // namespace
5458

59+
// See note in tsan as to why this is necessary
60+
static pthread_cond_t *init_cond(pthread_cond_t *c, bool force = false) {
61+
if (!common_flags()->legacy_pthread_cond)
62+
return c;
63+
64+
atomic_uintptr_t *p = (atomic_uintptr_t *)c;
65+
uptr cond = atomic_load(p, memory_order_acquire);
66+
if (!force && cond != 0)
67+
return (pthread_cond_t *)cond;
68+
void *newcond = WRAP(malloc)(sizeof(pthread_cond_t));
69+
internal_memset(newcond, 0, sizeof(pthread_cond_t));
70+
if (atomic_compare_exchange_strong(p, &cond, (uptr)newcond,
71+
memory_order_acq_rel))
72+
return (pthread_cond_t *)newcond;
73+
WRAP(free)(newcond);
74+
return (pthread_cond_t *)cond;
75+
}
76+
77+
static void destroy_cond(pthread_cond_t *cond) {
78+
if (common_flags()->legacy_pthread_cond) {
79+
// Free our aux cond and zero the pointer to not leave dangling pointers.
80+
WRAP(free)(cond);
81+
atomic_store((atomic_uintptr_t *)cond, 0, memory_order_relaxed);
82+
}
83+
}
84+
5585
// Filesystem
5686

5787
INTERCEPTOR(int, open, const char *path, int oflag, ...) {
@@ -766,26 +796,45 @@ INTERCEPTOR(int, pthread_join, pthread_t thread, void **value_ptr) {
766796
return REAL(pthread_join)(thread, value_ptr);
767797
}
768798

799+
INTERCEPTOR(int, pthread_cond_init, pthread_cond_t *cond,
800+
const pthread_condattr_t *a) {
801+
__rtsan_notify_intercepted_call("pthread_cond_init");
802+
pthread_cond_t *c = init_cond(cond, true);
803+
return REAL(pthread_cond_init)(c, a);
804+
}
805+
769806
INTERCEPTOR(int, pthread_cond_signal, pthread_cond_t *cond) {
770807
__rtsan_notify_intercepted_call("pthread_cond_signal");
771-
return REAL(pthread_cond_signal)(cond);
808+
pthread_cond_t *c = init_cond(cond);
809+
return REAL(pthread_cond_signal)(c);
772810
}
773811

774812
INTERCEPTOR(int, pthread_cond_broadcast, pthread_cond_t *cond) {
775813
__rtsan_notify_intercepted_call("pthread_cond_broadcast");
776-
return REAL(pthread_cond_broadcast)(cond);
814+
pthread_cond_t *c = init_cond(cond);
815+
return REAL(pthread_cond_broadcast)(c);
777816
}
778817

779818
INTERCEPTOR(int, pthread_cond_wait, pthread_cond_t *cond,
780819
pthread_mutex_t *mutex) {
781820
__rtsan_notify_intercepted_call("pthread_cond_wait");
782-
return REAL(pthread_cond_wait)(cond, mutex);
821+
pthread_cond_t *c = init_cond(cond);
822+
return REAL(pthread_cond_wait)(c, mutex);
783823
}
784824

785825
INTERCEPTOR(int, pthread_cond_timedwait, pthread_cond_t *cond,
786826
pthread_mutex_t *mutex, const timespec *ts) {
787827
__rtsan_notify_intercepted_call("pthread_cond_timedwait");
788-
return REAL(pthread_cond_timedwait)(cond, mutex, ts);
828+
pthread_cond_t *c = init_cond(cond);
829+
return REAL(pthread_cond_timedwait)(c, mutex, ts);
830+
}
831+
832+
INTERCEPTOR(int, pthread_cond_destroy, pthread_cond_t *cond) {
833+
__rtsan_notify_intercepted_call("pthread_cond_destroy");
834+
pthread_cond_t *c = init_cond(cond);
835+
int res = REAL(pthread_cond_destroy)(c);
836+
destroy_cond(c);
837+
return res;
789838
}
790839

791840
INTERCEPTOR(int, pthread_rwlock_rdlock, pthread_rwlock_t *lock) {
@@ -1641,10 +1690,26 @@ void __rtsan::InitializeInterceptors() {
16411690
INTERCEPT_FUNCTION(pthread_mutex_lock);
16421691
INTERCEPT_FUNCTION(pthread_mutex_unlock);
16431692
INTERCEPT_FUNCTION(pthread_join);
1693+
1694+
// See the comment in tsan_interceptors_posix.cpp.
1695+
#if SANITIZER_GLIBC && !__GLIBC_PREREQ(2, 36) && \
1696+
(defined(__x86_64__) || defined(__mips__) || SANITIZER_PPC64V1 || \
1697+
defined(__s390x__))
1698+
INTERCEPT_FUNCTION_VER(pthread_cond_init, "GLIBC_2.3.2");
1699+
INTERCEPT_FUNCTION_VER(pthread_cond_signal, "GLIBC_2.3.2");
1700+
INTERCEPT_FUNCTION_VER(pthread_cond_broadcast, "GLIBC_2.3.2");
1701+
INTERCEPT_FUNCTION_VER(pthread_cond_wait, "GLIBC_2.3.2");
1702+
INTERCEPT_FUNCTION_VER(pthread_cond_timedwait, "GLIBC_2.3.2");
1703+
INTERCEPT_FUNCTION_VER(pthread_cond_destroy, "GLIBC_2.3.2");
1704+
#else
1705+
INTERCEPT_FUNCTION(pthread_cond_init);
16441706
INTERCEPT_FUNCTION(pthread_cond_signal);
16451707
INTERCEPT_FUNCTION(pthread_cond_broadcast);
16461708
INTERCEPT_FUNCTION(pthread_cond_wait);
16471709
INTERCEPT_FUNCTION(pthread_cond_timedwait);
1710+
INTERCEPT_FUNCTION(pthread_cond_destroy);
1711+
#endif
1712+
16481713
INTERCEPT_FUNCTION(pthread_rwlock_rdlock);
16491714
INTERCEPT_FUNCTION(pthread_rwlock_unlock);
16501715
INTERCEPT_FUNCTION(pthread_rwlock_wrlock);

0 commit comments

Comments
 (0)