From 4fab7454c5480bc68732ba456bb3aff3ffdedfa0 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 11 Sep 2016 01:25:15 +0000 Subject: [PATCH] CodeGen: remove unnecessary else case Refactor the assignment so that its much more clear that the if-clause contains the lookup, and once cached is directly used. NFC. llvm-svn: 281150 --- clang/lib/CodeGen/CodeGenModule.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index dad49f5..1b6f5c3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3152,7 +3152,6 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); llvm::Constant *Zeros[] = { Zero, Zero }; - llvm::Value *V; // If we don't already have it, get __CFConstantStringClassReference. if (!CFConstantStringClassRef) { @@ -3182,10 +3181,8 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { } // Decay array -> ptr - V = llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); - CFConstantStringClassRef = V; - } else { - V = CFConstantStringClassRef; + CFConstantStringClassRef = + llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); } QualType CFTy = getContext().getCFConstantStringType(); @@ -3195,7 +3192,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { llvm::Constant *Fields[4]; // Class pointer. - Fields[0] = cast(V); + Fields[0] = cast(CFConstantStringClassRef); // Flags. llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy); -- 2.7.4