summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfoMetadata.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-11-28 00:57:51 +0000
committerAdrian Prantl <aprantl@apple.com>2017-11-28 00:57:51 +0000
commit3e0e1d093435d753f66c51820f49528b91522743 (patch)
treeaf3cd554481fa4d61b80080a7176a7be86b9148f /llvm/lib/IR/DebugInfoMetadata.cpp
parent8b9cd03824419bb84aa633d697613947aa69c786 (diff)
downloadbcm5719-llvm-3e0e1d093435d753f66c51820f49528b91522743.tar.gz
bcm5719-llvm-3e0e1d093435d753f66c51820f49528b91522743.zip
Move getVariableSize from Verifier.cpp into DIVariable::getSize() (NFC)
llvm-svn: 319125
Diffstat (limited to 'llvm/lib/IR/DebugInfoMetadata.cpp')
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index ae02392ea14..940c4d1f366 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -614,6 +614,29 @@ DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope,
DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
}
+Optional<uint64_t> DIVariable::getSizeInBits() const {
+ // This is used by the Verifier so be mindful of broken types.
+ const Metadata *RawType = getRawType();
+ while (RawType) {
+ // Try to get the size directly.
+ if (auto *T = dyn_cast<DIType>(RawType))
+ if (uint64_t Size = T->getSizeInBits())
+ return Size;
+
+ if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
+ // Look at the base type.
+ RawType = DT->getRawBaseType();
+ continue;
+ }
+
+ // Missing type or size.
+ break;
+ }
+
+ // Fail gracefully.
+ return None;
+}
+
DIExpression *DIExpression::getImpl(LLVMContext &Context,
ArrayRef<uint64_t> Elements,
StorageType Storage, bool ShouldCreate) {
OpenPOWER on IntegriCloud