summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-08-09 09:27:04 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-08-09 09:27:04 +0000
commit94fbbf712e906464f5f3abbeabcfcbc05d5352ec (patch)
treea16d5256e02d4081ae70a2c185490fca6ab3135a
parentaf1744cd6e8a1435cfc68e99da22bb2d95f37de1 (diff)
downloadbcm5719-llvm-94fbbf712e906464f5f3abbeabcfcbc05d5352ec.tar.gz
bcm5719-llvm-94fbbf712e906464f5f3abbeabcfcbc05d5352ec.zip
[lldb] Refactor guard variable checks in IRForTarget
Not NFC as this will probably fix a wrong guard variable check on Windows. Not sure though what Windows test can now be safely enabled. llvm-svn: 368417
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index d5772dc3055..1edeac44a5b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -153,6 +153,12 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(GlobalValue *global_val) {
return DeclForGlobal(global_val, m_module);
}
+/// Returns true iff the mangled symbol is for a static guard variable.
+static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol) {
+ return mangled_symbol.startswith("_ZGV") || // Itanium ABI guard variable
+ mangled_symbol.startswith("@4IA"); // Microsoft ABI guard variable
+}
+
bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
lldb_private::Log *log(
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -171,14 +177,14 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
result_name = value_symbol.first();
if (result_name.contains("$__lldb_expr_result_ptr") &&
- !result_name.startswith("_ZGV")) {
+ !isGuardVariableSymbol(result_name)) {
found_result = true;
m_result_is_pointer = true;
break;
}
if (result_name.contains("$__lldb_expr_result") &&
- !result_name.startswith("_ZGV")) {
+ !isGuardVariableSymbol(result_name)) {
found_result = true;
m_result_is_pointer = false;
break;
@@ -1529,14 +1535,12 @@ bool IRForTarget::ResolveExternals(Function &llvm_function) {
}
static bool isGuardVariableRef(Value *V) {
- Constant *Old = nullptr;
+ Constant *Old = dyn_cast<Constant>(V);
- if (!(Old = dyn_cast<Constant>(V)))
+ if (!Old)
return false;
- ConstantExpr *CE = nullptr;
-
- if ((CE = dyn_cast<ConstantExpr>(V))) {
+ if (auto CE = dyn_cast<ConstantExpr>(V)) {
if (CE->getOpcode() != Instruction::BitCast)
return false;
@@ -1545,12 +1549,8 @@ static bool isGuardVariableRef(Value *V) {
GlobalVariable *GV = dyn_cast<GlobalVariable>(Old);
- if (!GV || !GV->hasName() ||
- (!GV->getName().startswith("_ZGV") && // Itanium ABI guard variable
- !GV->getName().endswith("@4IA"))) // Microsoft ABI guard variable
- {
+ if (!GV || !GV->hasName() || !isGuardVariableSymbol(GV->getName()))
return false;
- }
return true;
}
OpenPOWER on IntegriCloud