From: Peter Collingbourne Date: Fri, 16 Dec 2016 22:10:52 +0000 (+0000) Subject: IRGen: Fix assertion failure when creating debug info for an integer constant wider... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0dd752d8bd7d523b134d571d2b7882d0ebfc08fc;p=clang IRGen: Fix assertion failure when creating debug info for an integer constant wider than 64 bits. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289996 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 9b53152fac..2bce804331 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -3759,12 +3759,15 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, const APValue &Init) { if (GV) return; llvm::DIExpression *InitExpr = nullptr; - if (Init.isInt()) - InitExpr = - DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); - else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64) - InitExpr = DBuilder.createConstantValueExpression( - Init.getFloat().bitcastToAPInt().getZExtValue()); + if (CGM.getContext().getTypeSize(VD->getType()) <= 64) { + // FIXME: Add a representation for integer constants wider than 64 bits. + if (Init.isInt()) + InitExpr = + DBuilder.createConstantValueExpression(Init.getInt().getExtValue()); + else if (Init.isFloat()) + InitExpr = DBuilder.createConstantValueExpression( + Init.getFloat().bitcastToAPInt().getZExtValue()); + } GV.reset(DBuilder.createGlobalVariable( DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty, true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD), diff --git a/test/CodeGen/dbg-const-int128.c b/test/CodeGen/dbg-const-int128.c new file mode 100644 index 0000000000..5fe8e04436 --- /dev/null +++ b/test/CodeGen/dbg-const-int128.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s +// CHECK: !DIGlobalVariable({{.*}} +// CHECK-NOT: expr: + +static const __uint128_t ro = 18446744073709551615; + +void bar(__uint128_t); +void foo() { bar(ro); }