diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1363,6 +1363,19 @@ return Visit(E->getSubExpr(), T); } + llvm::Constant *VisitUnaryOperator(UnaryOperator *U, QualType T) { + switch (U->getOpcode()) { + default: + break; + case UO_Minus: + if (llvm::Constant *C = Visit(U->getSubExpr(), T)) + if (auto *CI = dyn_cast(C)) + return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue()); + break; + } + return nullptr; + } + // Utility methods llvm::Type *ConvertType(QualType T) { return CGM.getTypes().ConvertType(T);