Skip to content

[gardening] Standardize variable capitalization in SILGenBuilder to match the rest of SILGen. NFC. #7584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SILGen/Cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Lowering {
class JumpDest;
class SILGenFunction;
class ManagedValue;
class SharedBorrowFormalEvaluation;
class SharedBorrowFormalAccess;

/// The valid states that a cleanup can be in.
enum class CleanupState {
Expand Down
22 changes: 11 additions & 11 deletions lib/SILGen/FormalEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ using namespace swift;
using namespace Lowering;

//===----------------------------------------------------------------------===//
// Formal Evaluation
// Formal Access
//===----------------------------------------------------------------------===//

void FormalEvaluation::_anchor() {}
void FormalAccess::_anchor() {}

//===----------------------------------------------------------------------===//
// Shared Borrow Formal Evaluation
//===----------------------------------------------------------------------===//

void SharedBorrowFormalEvaluation::finish(SILGenFunction &gen) {
void SharedBorrowFormalAccess::finish(SILGenFunction &gen) {
gen.B.createEndBorrow(CleanupLocation::get(loc), borrowedValue,
originalValue);
}
Expand Down Expand Up @@ -74,24 +74,24 @@ void FormalEvaluationScope::popImpl() {
// Then working down the stack until we visit unwrappedSavedDepth...
for (; iter != unwrappedSavedDepth; ++iter) {
// Grab the next evaluation...
FormalEvaluation &evaluation = *iter;
FormalAccess &access = *iter;

// and deactivate the cleanup.
gen.Cleanups.setCleanupState(evaluation.getCleanup(), CleanupState::Dead);
gen.Cleanups.setCleanupState(access.getCleanup(), CleanupState::Dead);

// Attempt to diagnose problems where obvious aliasing introduces illegal
// code. We do a simple N^2 comparison here to detect this because it is
// extremely unlikely more than a few writebacks are active at once.
if (evaluation.getKind() == FormalEvaluation::Exclusive) {
if (access.getKind() == FormalAccess::Exclusive) {
iterator j = iter;
++j;

for (; j != unwrappedSavedDepth; ++j) {
FormalEvaluation &other = *j;
if (other.getKind() != FormalEvaluation::Exclusive)
FormalAccess &other = *j;
if (other.getKind() != FormalAccess::Exclusive)
continue;
auto &lhs = static_cast<LValueWriteback &>(evaluation);
auto &rhs = static_cast<LValueWriteback &>(other);
auto &lhs = static_cast<ExclusiveBorrowFormalAccess &>(access);
auto &rhs = static_cast<ExclusiveBorrowFormalAccess &>(other);
lhs.diagnoseConflict(rhs, gen);
}
}
Expand All @@ -101,7 +101,7 @@ void FormalEvaluationScope::popImpl() {
//
// This evaluates arbitrary code, so it's best to be paranoid
// about iterators on the context.
evaluation.finish(gen);
access.finish(gen);
}

// Then check that we did not add any additional cleanups to the beginning of
Expand Down
18 changes: 9 additions & 9 deletions lib/SILGen/FormalEvaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Lowering {
class SILGenFunction;
class LogicalPathComponent;

class FormalEvaluation {
class FormalAccess {
public:
enum Kind { Shared, Exclusive };

Expand All @@ -36,12 +36,12 @@ class FormalEvaluation {
SILLocation loc;
CleanupHandle cleanup;

FormalEvaluation(unsigned allocatedSize, Kind kind, SILLocation loc,
CleanupHandle cleanup)
FormalAccess(unsigned allocatedSize, Kind kind, SILLocation loc,
CleanupHandle cleanup)
: allocatedSize(allocatedSize), kind(kind), loc(loc), cleanup(cleanup) {}

public:
virtual ~FormalEvaluation() {}
virtual ~FormalAccess() {}

// This anchor method serves three purposes: it aligns the class to
// a pointer boundary, it makes the class a primary base so that
Expand All @@ -60,14 +60,14 @@ class FormalEvaluation {
virtual void finish(SILGenFunction &gen) = 0;
};

class SharedBorrowFormalEvaluation : public FormalEvaluation {
class SharedBorrowFormalAccess : public FormalAccess {
SILValue originalValue;
SILValue borrowedValue;

public:
SharedBorrowFormalEvaluation(SILLocation loc, CleanupHandle cleanup,
SILValue originalValue, SILValue borrowedValue)
: FormalEvaluation(sizeof(*this), FormalEvaluation::Shared, loc, cleanup),
SharedBorrowFormalAccess(SILLocation loc, CleanupHandle cleanup,
SILValue originalValue, SILValue borrowedValue)
: FormalAccess(sizeof(*this), FormalAccess::Shared, loc, cleanup),
originalValue(originalValue), borrowedValue(borrowedValue) {}
void finish(SILGenFunction &gen) override;

Expand All @@ -76,7 +76,7 @@ class SharedBorrowFormalEvaluation : public FormalEvaluation {
};

class FormalEvaluationContext {
DiverseStack<FormalEvaluation, 128> stack;
DiverseStack<FormalAccess, 128> stack;

public:
using stable_iterator = decltype(stack)::stable_iterator;
Expand Down
25 changes: 14 additions & 11 deletions lib/SILGen/LValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,24 +466,27 @@ class InOutConversionScope {
~InOutConversionScope();
};

struct LLVM_LIBRARY_VISIBILITY LValueWriteback : FormalEvaluation {
struct LLVM_LIBRARY_VISIBILITY ExclusiveBorrowFormalAccess : FormalAccess {
std::unique_ptr<LogicalPathComponent> component;
ManagedValue base;
MaterializedLValue materialized;

~LValueWriteback() {}
LValueWriteback(LValueWriteback &&) = default;
LValueWriteback &operator=(LValueWriteback &&) = default;
~ExclusiveBorrowFormalAccess() {}
ExclusiveBorrowFormalAccess(ExclusiveBorrowFormalAccess &&) = default;
ExclusiveBorrowFormalAccess &
operator=(ExclusiveBorrowFormalAccess &&) = default;

LValueWriteback() = default;
LValueWriteback(SILLocation loc, std::unique_ptr<LogicalPathComponent> &&comp,
ManagedValue base, MaterializedLValue materialized,
CleanupHandle cleanup)
: FormalEvaluation(sizeof(*this), FormalEvaluation::Exclusive, loc,
cleanup),
ExclusiveBorrowFormalAccess() = default;
ExclusiveBorrowFormalAccess(SILLocation loc,
std::unique_ptr<LogicalPathComponent> &&comp,
ManagedValue base,
MaterializedLValue materialized,
CleanupHandle cleanup)
: FormalAccess(sizeof(*this), FormalAccess::Exclusive, loc, cleanup),
component(std::move(comp)), base(base), materialized(materialized) {}

void diagnoseConflict(const LValueWriteback &rhs, SILGenFunction &SGF) const {
void diagnoseConflict(const ExclusiveBorrowFormalAccess &rhs,
SILGenFunction &SGF) const {
// If the two writebacks we're comparing are of different kinds (e.g.
// ownership conversion vs a computed property) then they aren't the
// same and thus cannot conflict.
Expand Down
Loading