Skip to content

Commit 532e724

Browse files
committed
Revert "[lldb] Refactor guard variable checks in IRForTarget"
This reverts commit 94fbbf7. llvm-svn: 368616
1 parent e7daf78 commit 532e724

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,6 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(GlobalValue *global_val) {
155155
return DeclForGlobal(global_val, m_module);
156156
}
157157

158-
/// Returns true iff the mangled symbol is for a static guard variable.
159-
static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol) {
160-
return mangled_symbol.startswith("_ZGV") || // Itanium ABI guard variable
161-
mangled_symbol.startswith("@4IA"); // Microsoft ABI guard variable
162-
}
163-
164158
bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
165159
lldb_private::Log *log(
166160
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -179,14 +173,14 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
179173
result_name = value_symbol.first();
180174

181175
if (result_name.contains("$__lldb_expr_result_ptr") &&
182-
!isGuardVariableSymbol(result_name)) {
176+
!result_name.startswith("_ZGV")) {
183177
found_result = true;
184178
m_result_is_pointer = true;
185179
break;
186180
}
187181

188182
if (result_name.contains("$__lldb_expr_result") &&
189-
!isGuardVariableSymbol(result_name)) {
183+
!result_name.startswith("_ZGV")) {
190184
found_result = true;
191185
m_result_is_pointer = false;
192186
break;
@@ -1534,12 +1528,14 @@ bool IRForTarget::ResolveExternals(Function &llvm_function) {
15341528
}
15351529

15361530
static bool isGuardVariableRef(Value *V) {
1537-
Constant *Old = dyn_cast<Constant>(V);
1531+
Constant *Old = nullptr;
15381532

1539-
if (!Old)
1533+
if (!(Old = dyn_cast<Constant>(V)))
15401534
return false;
15411535

1542-
if (auto CE = dyn_cast<ConstantExpr>(V)) {
1536+
ConstantExpr *CE = nullptr;
1537+
1538+
if ((CE = dyn_cast<ConstantExpr>(V))) {
15431539
if (CE->getOpcode() != Instruction::BitCast)
15441540
return false;
15451541

@@ -1548,8 +1544,12 @@ static bool isGuardVariableRef(Value *V) {
15481544

15491545
GlobalVariable *GV = dyn_cast<GlobalVariable>(Old);
15501546

1551-
if (!GV || !GV->hasName() || !isGuardVariableSymbol(GV->getName()))
1547+
if (!GV || !GV->hasName() ||
1548+
(!GV->getName().startswith("_ZGV") && // Itanium ABI guard variable
1549+
!GV->getName().endswith("@4IA"))) // Microsoft ABI guard variable
1550+
{
15521551
return false;
1552+
}
15531553

15541554
return true;
15551555
}

0 commit comments

Comments
 (0)