Created
May 26, 2023 17:46
-
-
Save nickdesaulniers/3a828007edc98d08ea411e41d58ac0b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp | |
index 05f202840186..2d0d2324cbde 100644 | |
--- a/clang/lib/CodeGen/CGExprConstant.cpp | |
+++ b/clang/lib/CodeGen/CGExprConstant.cpp | |
@@ -1654,11 +1654,6 @@ llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) { | |
QualType destType = D.getType(); | |
- // Try to emit the initializer. Note that this can allow some things that | |
- // are not allowed by tryEmitPrivateForMemory alone. | |
- if (APValue *value = D.evaluateValue()) | |
- return tryEmitPrivateForMemory(*value, destType); | |
- | |
// FIXME: Implement C++11 [basic.start.init]p2: if the initializer of a | |
// reference is a constant expression, and the reference binds to a temporary, | |
// then constant initialization is performed. ConstExprEmitter will | |
@@ -1672,9 +1667,14 @@ llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) { | |
assert(E && "No initializer to emit"); | |
QualType nonMemoryDestType = getNonMemoryType(CGM, destType); | |
- llvm::Constant *C = | |
- ConstExprEmitter(*this).Visit(const_cast<Expr *>(E), nonMemoryDestType); | |
- return C ? emitForMemory(C, destType) : nullptr; | |
+ if (llvm::Constant *C = ConstExprEmitter(*this).Visit(const_cast<Expr *>(E), nonMemoryDestType)) | |
+ return emitForMemory(C, destType); | |
+ | |
+ // Try to emit the initializer. Note that this can allow some things that | |
+ // are not allowed by tryEmitPrivateForMemory alone. | |
+ if (APValue *value = D.evaluateValue()) | |
+ return tryEmitPrivateForMemory(*value, destType); | |
+ return nullptr; | |
} | |
llvm::Constant * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment