Skip to content

[SIL] NFC: "Stop being a sop" #32263

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 1 commit into from
Jun 10, 2020
Merged
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
13 changes: 6 additions & 7 deletions lib/SIL/IR/SILGlobalVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ SILGlobalVariable *SILGlobalVariable::create(SILModule &M, SILLinkage linkage,
SILType loweredType,
Optional<SILLocation> loc,
VarDecl *Decl) {
// Get a StringMapEntry for the variable. As a sop to error cases,
// allow the name to have an empty string.
// Get a StringMapEntry for the variable.
llvm::StringMapEntry<SILGlobalVariable*> *entry = nullptr;
if (!name.empty()) {
entry = &*M.GlobalVariableMap.insert(std::make_pair(name, nullptr)).first;
assert(!entry->getValue() && "global variable already exists");
name = entry->getKey();
}
assert(!name.empty() && "Name required");

entry = &*M.GlobalVariableMap.insert(std::make_pair(name, nullptr)).first;
assert(!entry->getValue() && "global variable already exists");
name = entry->getKey();

auto var = new (M) SILGlobalVariable(M, linkage, isSerialized, name,
loweredType, loc, Decl);
Expand Down