Skip to content

Commit 4328ea3

Browse files
committed
[ORC] clang-format the ThreadSafeModule code.
Evidently I forgot to do this before committing r343055. llvm-svn: 343288
1 parent f7d1510 commit 4328ea3

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

llvm/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,24 @@ namespace orc {
2929
/// the context to prevent concurrent access by other threads.
3030
class ThreadSafeContext {
3131
private:
32-
3332
struct State {
34-
State(std::unique_ptr<LLVMContext> Ctx)
35-
: Ctx(std::move(Ctx)) {}
33+
State(std::unique_ptr<LLVMContext> Ctx) : Ctx(std::move(Ctx)) {}
3634

3735
std::unique_ptr<LLVMContext> Ctx;
3836
std::recursive_mutex Mutex;
3937
};
4038

4139
public:
42-
4340
// RAII based lock for ThreadSafeContext.
4441
class LLVM_NODISCARD Lock {
4542
private:
4643
using UnderlyingLock = std::lock_guard<std::recursive_mutex>;
47-
public:
4844

45+
public:
4946
Lock(std::shared_ptr<State> S)
50-
: S(std::move(S)),
51-
L(llvm::make_unique<UnderlyingLock>(this->S->Mutex)) {}
47+
: S(std::move(S)),
48+
L(llvm::make_unique<UnderlyingLock>(this->S->Mutex)) {}
49+
5250
private:
5351
std::shared_ptr<State> S;
5452
std::unique_ptr<UnderlyingLock> L;
@@ -66,9 +64,7 @@ class ThreadSafeContext {
6664

6765
/// Returns a pointer to the LLVMContext that was used to construct this
6866
/// instance, or null if the instance was default constructed.
69-
LLVMContext* getContext() {
70-
return S ? S->Ctx.get() : nullptr;
71-
}
67+
LLVMContext *getContext() { return S ? S->Ctx.get() : nullptr; }
7268

7369
Lock getLock() {
7470
assert(S && "Can not lock an empty ThreadSafeContext");
@@ -88,7 +84,7 @@ class ThreadSafeModule {
8884

8985
ThreadSafeModule(ThreadSafeModule &&Other) = default;
9086

91-
ThreadSafeModule& operator=(ThreadSafeModule &&Other) {
87+
ThreadSafeModule &operator=(ThreadSafeModule &&Other) {
9288
// We have to explicitly define this move operator to copy the fields in
9389
// reverse order (i.e. module first) to ensure the dependencies are
9490
// protected: The old module that is being overwritten must be destroyed
@@ -124,10 +120,10 @@ class ThreadSafeModule {
124120
}
125121

126122
/// Get the module wrapped by this ThreadSafeModule.
127-
Module* getModule() { return M.get(); }
123+
Module *getModule() { return M.get(); }
128124

129125
/// Get the module wrapped by this ThreadSafeModule.
130-
const Module* getModule() const { return M.get(); }
126+
const Module *getModule() const { return M.get(); }
131127

132128
/// Take out a lock on the ThreadSafeContext for this module.
133129
ThreadSafeContext::Lock getContextLock() { return TSCtx.getLock(); }
@@ -136,7 +132,8 @@ class ThreadSafeModule {
136132
/// wraps a non-null module.
137133
explicit operator bool() {
138134
if (M) {
139-
assert(TSCtx.getContext() && "Non-null module must have non-null context");
135+
assert(TSCtx.getContext() &&
136+
"Non-null module must have non-null context");
140137
return true;
141138
}
142139
return false;
@@ -147,8 +144,8 @@ class ThreadSafeModule {
147144
ThreadSafeContext TSCtx;
148145
};
149146

150-
using GVPredicate = std::function<bool(const GlobalValue&)>;
151-
using GVModifier = std::function<void(GlobalValue&)>;
147+
using GVPredicate = std::function<bool(const GlobalValue &)>;
148+
using GVModifier = std::function<void(GlobalValue &)>;
152149

153150
/// Clones the given module on to a new context.
154151
ThreadSafeModule

llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//===-- ThreadSafeModule.cpp - Thread safe Module, Context, and Utilities h-===//
1+
//===-- ThreadSafeModule.cpp - Thread safe Module, Context, and Utilities
2+
//h-===//
23
//
34
// The LLVM Compiler Infrastructure
45
//
@@ -21,7 +22,7 @@ ThreadSafeModule cloneToNewContext(ThreadSafeModule &TSM,
2122
assert(TSM && "Can not clone null module");
2223

2324
if (!ShouldCloneDef)
24-
ShouldCloneDef = [](const GlobalValue&) { return true; };
25+
ShouldCloneDef = [](const GlobalValue &) { return true; };
2526

2627
auto Lock = TSM.getContextLock();
2728

@@ -30,8 +31,7 @@ ThreadSafeModule cloneToNewContext(ThreadSafeModule &TSM,
3031
{
3132
std::vector<GlobalValue *> ClonedDefsInSrc;
3233
ValueToValueMapTy VMap;
33-
auto Tmp = CloneModule(*TSM.getModule(), VMap,
34-
[&](const GlobalValue *GV) {
34+
auto Tmp = CloneModule(*TSM.getModule(), VMap, [&](const GlobalValue *GV) {
3535
if (ShouldCloneDef(*GV)) {
3636
ClonedDefsInSrc.push_back(const_cast<GlobalValue *>(GV));
3737
return true;

llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ TEST(ThreadSafeModuleTest, ContextOwnershipSharedByTwoModules) {
3232
// ThreadSafeModule.
3333
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
3434

35-
auto M1 =llvm::make_unique<Module>("M1", *TSCtx.getContext());
35+
auto M1 = llvm::make_unique<Module>("M1", *TSCtx.getContext());
3636
ThreadSafeModule TSM1(std::move(M1), TSCtx);
3737

38-
auto M2 =llvm::make_unique<Module>("M2", *TSCtx.getContext());
38+
auto M2 = llvm::make_unique<Module>("M2", *TSCtx.getContext());
3939
ThreadSafeModule TSM2(std::move(M2), std::move(TSCtx));
4040
}
4141

@@ -68,7 +68,7 @@ TEST(ThreadSafeModuleTest, ThreadSafeModuleMoveAssignment) {
6868
TEST(ThreadSafeModuleTest, BasicContextLockAPI) {
6969
// Test that basic lock API calls work.
7070
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
71-
auto M =llvm::make_unique<Module>("M", *TSCtx.getContext());
71+
auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
7272
ThreadSafeModule TSM(std::move(M), TSCtx);
7373

7474
{ auto L = TSCtx.getLock(); }

0 commit comments

Comments
 (0)