Simplify. Suggestion by Sean Silva.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165885 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nico Weber 2012-10-13 21:56:05 +00:00
Родитель e5a934d3c8
Коммит 43085815b1
1 изменённых файлов: 3 добавлений и 11 удалений

Просмотреть файл

@ -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);
}