[PATCH] D60473: [LLVM-C] Use dyn_cast instead of unwrap in LLVMGetDebugLoc functions
whitequark via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 06:29:40 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359093: [LLVM-C] Use dyn_cast instead of unwrap in LLVMGetDebugLoc functions (authored by whitequark, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60473/new/
https://reviews.llvm.org/D60473
Files:
llvm/trunk/lib/IR/Core.cpp
Index: llvm/trunk/lib/IR/Core.cpp
===================================================================
--- llvm/trunk/lib/IR/Core.cpp
+++ llvm/trunk/lib/IR/Core.cpp
@@ -1199,15 +1199,17 @@
const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length) {
if (!Length) return nullptr;
StringRef S;
- if (const auto *I = unwrap<Instruction>(Val)) {
- S = I->getDebugLoc()->getDirectory();
- } else if (const auto *GV = unwrap<GlobalVariable>(Val)) {
+ if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
+ if (const auto &DL = I->getDebugLoc()) {
+ S = DL->getDirectory();
+ }
+ } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
SmallVector<DIGlobalVariableExpression *, 1> GVEs;
GV->getDebugInfo(GVEs);
if (GVEs.size())
if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
S = DGV->getDirectory();
- } else if (const auto *F = unwrap<Function>(Val)) {
+ } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
if (const DISubprogram *DSP = F->getSubprogram())
S = DSP->getDirectory();
} else {
@@ -1221,15 +1223,17 @@
const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length) {
if (!Length) return nullptr;
StringRef S;
- if (const auto *I = unwrap<Instruction>(Val)) {
- S = I->getDebugLoc()->getFilename();
- } else if (const auto *GV = unwrap<GlobalVariable>(Val)) {
+ if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
+ if (const auto &DL = I->getDebugLoc()) {
+ S = DL->getFilename();
+ }
+ } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
SmallVector<DIGlobalVariableExpression *, 1> GVEs;
GV->getDebugInfo(GVEs);
if (GVEs.size())
if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
S = DGV->getFilename();
- } else if (const auto *F = unwrap<Function>(Val)) {
+ } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
if (const DISubprogram *DSP = F->getSubprogram())
S = DSP->getFilename();
} else {
@@ -1242,15 +1246,17 @@
unsigned LLVMGetDebugLocLine(LLVMValueRef Val) {
unsigned L = 0;
- if (const auto *I = unwrap<Instruction>(Val)) {
- L = I->getDebugLoc()->getLine();
- } else if (const auto *GV = unwrap<GlobalVariable>(Val)) {
+ if (const auto *I = dyn_cast<Instruction>(unwrap(Val))) {
+ if (const auto &DL = I->getDebugLoc()) {
+ L = DL->getLine();
+ }
+ } else if (const auto *GV = dyn_cast<GlobalVariable>(unwrap(Val))) {
SmallVector<DIGlobalVariableExpression *, 1> GVEs;
GV->getDebugInfo(GVEs);
if (GVEs.size())
if (const DIGlobalVariable *DGV = GVEs[0]->getVariable())
L = DGV->getLine();
- } else if (const auto *F = unwrap<Function>(Val)) {
+ } else if (const auto *F = dyn_cast<Function>(unwrap(Val))) {
if (const DISubprogram *DSP = F->getSubprogram())
L = DSP->getLine();
} else {
@@ -1262,9 +1268,9 @@
unsigned LLVMGetDebugLocColumn(LLVMValueRef Val) {
unsigned C = 0;
- if (const auto *I = unwrap<Instruction>(Val))
- if (const auto &L = I->getDebugLoc())
- C = L->getColumn();
+ if (const auto *I = dyn_cast<Instruction>(unwrap(Val)))
+ if (const auto &DL = I->getDebugLoc())
+ C = DL->getColumn();
return C;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60473.196438.patch
Type: text/x-patch
Size: 3287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190424/111037eb/attachment.bin>
More information about the llvm-commits
mailing list