[PATCH] D156378: [clang][CGExprConstant] handle unary negation on integrals
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 7 14:51:18 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG769333aeeb45: [clang][CGExprConstant] handle unary negation on integrals (authored by nickdesaulniers).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156378/new/
https://reviews.llvm.org/D156378
Files:
clang/lib/CodeGen/CGExprConstant.cpp
Index: clang/lib/CodeGen/CGExprConstant.cpp
===================================================================
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1363,6 +1363,13 @@
return Visit(E->getSubExpr(), T);
}
+ llvm::Constant *VisitUnaryMinus(UnaryOperator *U, QualType T) {
+ if (llvm::Constant *C = Visit(U->getSubExpr(), T))
+ if (auto *CI = dyn_cast<llvm::ConstantInt>(C))
+ return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue());
+ return nullptr;
+ }
+
// Utility methods
llvm::Type *ConvertType(QualType T) {
return CGM.getTypes().ConvertType(T);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156378.547959.patch
Type: text/x-patch
Size: 653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230807/3178ebf1/attachment.bin>
More information about the cfe-commits
mailing list