Skip to content

Commit 7d8d6d7

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3410)
2 parents b1e044d + e7f5cb9 commit 7d8d6d7

File tree

17 files changed

+603
-340
lines changed

17 files changed

+603
-340
lines changed

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def print_profile_data(aggregated_data: Dict[str, float]) -> None:
236236
checkers.items(), key=lambda x: x[1]["user"] + x[1]["sys"], reverse=True
237237
)
238238

239-
def print_stderr(*args, **kwargs) -> None:
239+
def print_stderr(*args: Any, **kwargs: Any) -> None:
240240
print(*args, file=sys.stderr, **kwargs)
241241

242242
print_stderr(

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ void ThreadSafetyAnalyzer::addLock(FactSet &FSet,
13311331
FSet.removeLock(FactMan, NegC);
13321332
}
13331333
else {
1334-
if (inCurrentScope(*Entry) && !Entry->asserted())
1334+
if (inCurrentScope(*Entry) && !Entry->asserted() && !Entry->reentrant())
13351335
Handler.handleNegativeNotHeld(Entry->getKind(), Entry->toString(),
13361336
NegC.toString(), Entry->loc());
13371337
}

clang/test/SemaCXX/warn-thread-safety-negative.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ class LOCKABLE Mutex {
2121
void AssertReaderHeld() ASSERT_SHARED_LOCK();
2222
};
2323

24+
class LOCKABLE REENTRANT_CAPABILITY ReentrantMutex {
25+
public:
26+
void Lock() EXCLUSIVE_LOCK_FUNCTION();
27+
void Unlock() UNLOCK_FUNCTION();
28+
29+
// for negative capabilities
30+
const ReentrantMutex& operator!() const { return *this; }
31+
};
32+
2433
class SCOPED_LOCKABLE MutexLock {
2534
public:
2635
MutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
@@ -89,6 +98,29 @@ class Foo {
8998
}
9099
};
91100

101+
class Reentrant {
102+
ReentrantMutex mu;
103+
104+
public:
105+
void acquire() {
106+
mu.Lock(); // no warning -- reentrant mutex
107+
mu.Unlock();
108+
}
109+
110+
void requireNegative() EXCLUSIVE_LOCKS_REQUIRED(!mu) { // warning?
111+
mu.Lock();
112+
mu.Unlock();
113+
}
114+
115+
void callRequireNegative() {
116+
requireNegative(); // expected-warning{{calling function 'requireNegative' requires negative capability '!mu'}}
117+
}
118+
119+
void callHaveNegative() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
120+
requireNegative();
121+
}
122+
};
123+
92124
} // end namespace SimpleTest
93125

94126
Mutex globalMutex;

libc/shared/math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "math/atanf16.h"
3131
#include "math/atanhf.h"
3232
#include "math/atanhf16.h"
33+
#include "math/cbrt.h"
3334
#include "math/erff.h"
3435
#include "math/exp.h"
3536
#include "math/exp10.h"

libc/shared/math/cbrt.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Shared cbrt function ------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SHARED_MATH_CBRT_H
10+
#define LLVM_LIBC_SHARED_MATH_CBRT_H
11+
12+
#include "shared/libc_common.h"
13+
#include "src/__support/math/cbrt.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
namespace shared {
17+
18+
using math::cbrt;
19+
20+
} // namespace shared
21+
} // namespace LIBC_NAMESPACE_DECL
22+
23+
#endif // LLVM_LIBC_SHARED_MATH_CBRT_H

libc/src/__support/math/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ add_header_library(
331331
libc.src.__support.macros.optimization
332332
)
333333

334+
add_header_library(
335+
cbrt
336+
HDRS
337+
cbrt.h
338+
DEPENDS
339+
libc.src.__support.FPUtil.double_double
340+
libc.src.__support.FPUtil.dyadic_float
341+
libc.src.__support.FPUtil.fenv_impl
342+
libc.src.__support.FPUtil.fp_bits
343+
libc.src.__support.FPUtil.multiply_add
344+
libc.src.__support.FPUtil.polyeval
345+
libc.src.__support.macros.optimization
346+
libc.src.__support.integer_literals
347+
)
348+
334349
add_header_library(
335350
erff
336351
HDRS

0 commit comments

Comments
 (0)