Skip to content
Snippets Groups Projects
Commit c10f9e73 authored by Michael Gördes's avatar Michael Gördes
Browse files

Prevent basic blocks without name

parent 8cc4834d
No related branches found
No related tags found
No related merge requests found
...@@ -293,6 +293,15 @@ void Value::setNameImpl(const Twine &NewName) { ...@@ -293,6 +293,15 @@ void Value::setNameImpl(const Twine &NewName) {
} }
void Value::setName(const Twine &NewName) { void Value::setName(const Twine &NewName) {
// Prevent basic blocks without name
if (BasicBlock *BB = dyn_cast<BasicBlock>(this))
if (NewName.isTriviallyEmpty()) {
static int unnamedCounter = 0;
std::string bbName = "unnamed_BB_" + std::to_string(unnamedCounter++);
setNameImpl(bbName);
return; // Asumption: we are not a function if we are a basic block
}
setNameImpl(NewName); setNameImpl(NewName);
if (Function *F = dyn_cast<Function>(this)) if (Function *F = dyn_cast<Function>(this))
F->recalculateIntrinsicID(); F->recalculateIntrinsicID();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment