From 43085815b1b377dc30176afab2b96d6b807d42de Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sat, 13 Oct 2012 21:56:05 +0000 Subject: [PATCH] Simplify. Suggestion by Sean Silva. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165885 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index c799e4aaac..0d70968b9d 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -2814,16 +2814,7 @@ llvm::Constant *CodeGenModule::EmitUuidofInitializer(StringRef Uuid, llvm::APInt Field0(32, StringRef(Uuidstr , 8), 16); llvm::APInt Field1(16, StringRef(Uuidstr + 9, 4), 16); llvm::APInt Field2(16, StringRef(Uuidstr + 14, 4), 16); - llvm::APInt Field3Values[] = { - llvm::APInt(8, StringRef(Uuidstr + 19, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 21, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 24, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 26, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 28, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 30, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 32, 2), 16), - llvm::APInt(8, StringRef(Uuidstr + 34, 2), 16), - }; + int Field3ValueOffsets[] = { 19, 21, 24, 26, 28, 30, 32, 34 }; APValue InitStruct(APValue::UninitStruct(), /*NumBases=*/0, /*NumFields=*/4); InitStruct.getStructField(0) = APValue(llvm::APSInt(Field0)); @@ -2832,7 +2823,8 @@ llvm::Constant *CodeGenModule::EmitUuidofInitializer(StringRef Uuid, APValue& Arr = InitStruct.getStructField(3); Arr = APValue(APValue::UninitArray(), 8, 8); for (int t = 0; t < 8; ++t) - Arr.getArrayInitializedElt(t) = APValue(llvm::APSInt(Field3Values[t])); + Arr.getArrayInitializedElt(t) = APValue(llvm::APSInt( + llvm::APInt(8, StringRef(Uuidstr + Field3ValueOffsets[t], 2), 16))); return EmitConstantValue(InitStruct, GuidType); }