[clang] ff18b15 - [CodeGen] Avoid unnecessary ConstantExpr cast

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 5 02:28:52 PDT 2022


Author: Nikita Popov
Date: 2022-04-05T11:28:40+02:00
New Revision: ff18b158edc4719c4b05cd04dceaedcf69a8d9c5

URL: https://github.com/llvm/llvm-project/commit/ff18b158edc4719c4b05cd04dceaedcf69a8d9c5
DIFF: https://github.com/llvm/llvm-project/commit/ff18b158edc4719c4b05cd04dceaedcf69a8d9c5.diff

LOG: [CodeGen] Avoid unnecessary ConstantExpr cast

With opaque pointers, this is not necessarily a ConstantExpr. And
we don't need one here either, just Constant is sufficient.

Added: 
    

Modified: 
    clang/lib/CodeGen/CodeGenModule.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d637ab6ec288d..4d24c33f51d02 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5407,7 +5407,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
   auto Fields = Builder.beginStruct(STy);
 
   // Class pointer.
-  Fields.add(cast<llvm::ConstantExpr>(CFConstantStringClassRef));
+  Fields.add(cast<llvm::Constant>(CFConstantStringClassRef));
 
   // Flags.
   if (IsSwiftABI) {


        


More information about the cfe-commits mailing list