aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/lib/FileCheck/FileCheck.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index 5706afc..931a4d3 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -386,15 +386,12 @@ Expected<std::unique_ptr<NumericVariableUse>> Pattern::parseNumericVariableUse(
// that happens, we create a dummy variable so that parsing can continue. All
// uses of undefined variables, whether string or numeric, are then diagnosed
// in printNoMatch() after failing to match.
- auto VarTableIter = Context->GlobalNumericVariableTable.find(Name);
- NumericVariable *NumericVariable;
- if (VarTableIter != Context->GlobalNumericVariableTable.end())
- NumericVariable = VarTableIter->second;
- else {
- NumericVariable = Context->makeNumericVariable(
+ auto [VarTableIter, Inserted] =
+ Context->GlobalNumericVariableTable.try_emplace(Name);
+ if (Inserted)
+ VarTableIter->second = Context->makeNumericVariable(
Name, ExpressionFormat(ExpressionFormat::Kind::Unsigned));
- Context->GlobalNumericVariableTable[Name] = NumericVariable;
- }
+ NumericVariable *NumericVariable = VarTableIter->second;
std::optional<size_t> DefLineNumber = NumericVariable->getDefLineNumber();
if (DefLineNumber && LineNumber && *DefLineNumber == *LineNumber)