[PATCH] D156482: [clang][CGExprConstant] handle FunctionToPointerDecay
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 27 13:35:44 PDT 2023
nickdesaulniers updated this revision to Diff 544909.
nickdesaulniers added a comment.
- update
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156482/new/
https://reviews.llvm.org/D156482
Files:
clang/lib/CodeGen/CGExprConstant.cpp
Index: clang/lib/CodeGen/CGExprConstant.cpp
===================================================================
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1122,9 +1122,10 @@
}
case CK_AtomicToNonAtomic:
- case CK_NonAtomicToAtomic:
- case CK_NoOp:
case CK_ConstructorConversion:
+ case CK_FunctionToPointerDecay:
+ case CK_NoOp:
+ case CK_NonAtomicToAtomic:
return Visit(subExpr, destType);
case CK_ArrayToPointerDecay:
@@ -1189,7 +1190,6 @@
case CK_CPointerToObjCPointerCast:
case CK_BlockPointerToObjCPointerCast:
case CK_AnyPointerToBlockPointerCast:
- case CK_FunctionToPointerDecay:
case CK_BaseToDerived:
case CK_DerivedToBase:
case CK_UncheckedDerivedToBase:
@@ -1241,6 +1241,13 @@
return llvm::ConstantInt::get(CGM.getLLVMContext(), I->getValue());
}
+ llvm::Constant *VisitDeclRefExpr(DeclRefExpr *D, QualType T) {
+ ValueDecl *VD = D->getDecl();
+ if (isa<FunctionDecl>(VD))
+ return CGM.getModule().getNamedValue(VD->getName());
+ return nullptr;
+ }
+
llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
assert(CAT && "can't emit array init for non-constant-bound array");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156482.544909.patch
Type: text/x-patch
Size: 1336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230727/8223cf1e/attachment.bin>
More information about the cfe-commits
mailing list