@@ -153,6 +153,12 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(GlobalValue *global_val) {
153
153
return DeclForGlobal (global_val, m_module);
154
154
}
155
155
156
+ // / Returns true iff the mangled symbol is for a static guard variable.
157
+ static bool isGuardVariableSymbol (llvm::StringRef mangled_symbol) {
158
+ return mangled_symbol.startswith (" _ZGV" ) || // Itanium ABI guard variable
159
+ mangled_symbol.startswith (" @4IA" ); // Microsoft ABI guard variable
160
+ }
161
+
156
162
bool IRForTarget::CreateResultVariable (llvm::Function &llvm_function) {
157
163
lldb_private::Log *log (
158
164
lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -171,14 +177,14 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
171
177
result_name = value_symbol.first ();
172
178
173
179
if (result_name.contains (" $__lldb_expr_result_ptr" ) &&
174
- !result_name. startswith ( " _ZGV " )) {
180
+ !isGuardVariableSymbol (result_name )) {
175
181
found_result = true ;
176
182
m_result_is_pointer = true ;
177
183
break ;
178
184
}
179
185
180
186
if (result_name.contains (" $__lldb_expr_result" ) &&
181
- !result_name. startswith ( " _ZGV " )) {
187
+ !isGuardVariableSymbol (result_name )) {
182
188
found_result = true ;
183
189
m_result_is_pointer = false ;
184
190
break ;
@@ -1529,14 +1535,12 @@ bool IRForTarget::ResolveExternals(Function &llvm_function) {
1529
1535
}
1530
1536
1531
1537
static bool isGuardVariableRef (Value *V) {
1532
- Constant *Old = nullptr ;
1538
+ Constant *Old = dyn_cast<Constant>(V) ;
1533
1539
1534
- if (!( Old = dyn_cast<Constant>(V)) )
1540
+ if (!Old)
1535
1541
return false ;
1536
1542
1537
- ConstantExpr *CE = nullptr ;
1538
-
1539
- if ((CE = dyn_cast<ConstantExpr>(V))) {
1543
+ if (auto CE = dyn_cast<ConstantExpr>(V)) {
1540
1544
if (CE->getOpcode () != Instruction::BitCast)
1541
1545
return false ;
1542
1546
@@ -1545,12 +1549,8 @@ static bool isGuardVariableRef(Value *V) {
1545
1549
1546
1550
GlobalVariable *GV = dyn_cast<GlobalVariable>(Old);
1547
1551
1548
- if (!GV || !GV->hasName () ||
1549
- (!GV->getName ().startswith (" _ZGV" ) && // Itanium ABI guard variable
1550
- !GV->getName ().endswith (" @4IA" ))) // Microsoft ABI guard variable
1551
- {
1552
+ if (!GV || !GV->hasName () || !isGuardVariableSymbol (GV->getName ()))
1552
1553
return false ;
1553
- }
1554
1554
1555
1555
return true ;
1556
1556
}
0 commit comments