[PATCH] D86447: [AST] Change return type of getTypeInfoInChars to a proper struct instead of std::pair.

2020-10-13 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG101309fe048e: [AST] Change return type of getTypeInfoInChars 
to a proper struct instead of… (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86447/new/

https://reviews.llvm.org/D86447

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -248,8 +248,9 @@
   FieldInfo RetVal;
   RetVal.Field = FD;
   auto  = FD->getASTContext();
-  std::tie(RetVal.Size, RetVal.Align) =
-  Ctx.getTypeInfoInChars(FD->getType());
+  auto Info = Ctx.getTypeInfoInChars(FD->getType());
+  RetVal.Size = Info.Width;
+  RetVal.Align = Info.Align;
   assert(llvm::isPowerOf2_64(RetVal.Align.getQuantity()));
   if (auto Max = FD->getMaxAlignment())
 RetVal.Align = std::max(Ctx.toCharUnitsFromBits(Max), RetVal.Align);
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -359,7 +359,7 @@
 ///   leaving one or more empty slots behind as padding.
 static Address emitVoidPtrVAArg(CodeGenFunction , Address VAListAddr,
 QualType ValueTy, bool IsIndirect,
-std::pair ValueInfo,
+TypeInfoChars ValueInfo,
 CharUnits SlotSizeAndAlign,
 bool AllowHigherAlign) {
   // The size and alignment of the value that was passed directly.
@@ -368,8 +368,8 @@
 DirectSize = CGF.getPointerSize();
 DirectAlign = CGF.getPointerAlign();
   } else {
-DirectSize = ValueInfo.first;
-DirectAlign = ValueInfo.second;
+DirectSize = ValueInfo.Width;
+DirectAlign = ValueInfo.Align;
   }
 
   // Cast the address we've calculated to the right type.
@@ -383,7 +383,7 @@
 AllowHigherAlign);
 
   if (IsIndirect) {
-Addr = Address(CGF.Builder.CreateLoad(Addr), ValueInfo.second);
+Addr = Address(CGF.Builder.CreateLoad(Addr), ValueInfo.Align);
   }
 
   return Addr;
@@ -656,7 +656,7 @@
 "Unexpected IndirectRealign seen in arginfo in generic VAArg emitter!");
 
 auto TyInfo = CGF.getContext().getTypeInfoInChars(Ty);
-CharUnits TyAlignForABI = TyInfo.second;
+CharUnits TyAlignForABI = TyInfo.Align;
 
 llvm::Type *BaseTy =
 llvm::PointerType::getUnqual(CGF.ConvertTypeForMem(Ty));
@@ -2062,8 +2062,8 @@
   //
   // Just messing with TypeInfo like this works because we never pass
   // anything indirectly.
-  TypeInfo.second = CharUnits::fromQuantity(
-getTypeStackAlignInBytes(Ty, TypeInfo.second.getQuantity()));
+  TypeInfo.Align = CharUnits::fromQuantity(
+getTypeStackAlignInBytes(Ty, TypeInfo.Align.getQuantity()));
 
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect*/ false,
   TypeInfo, CharUnits::fromQuantity(4),
@@ -4067,10 +4067,9 @@
 RegAddr = CGF.Builder.CreateElementBitCast(RegAddr, LTy);
 
 // Copy to a temporary if necessary to ensure the appropriate alignment.
-std::pair SizeAlign =
-getContext().getTypeInfoInChars(Ty);
-uint64_t TySize = SizeAlign.first.getQuantity();
-CharUnits TyAlign = SizeAlign.second;
+auto TInfo = getContext().getTypeInfoInChars(Ty);
+uint64_t TySize = TInfo.Width.getQuantity();
+CharUnits TyAlign = TInfo.Align;
 
 // Copy into a temporary if the type is more aligned than the
 // register save area.
@@ -4573,7 +4572,7 @@
 llvm::report_fatal_error("vector type is not supported on AIX yet");
 
   auto TypeInfo = getContext().getTypeInfoInChars(Ty);
-  TypeInfo.second = getParamTypeAlignment(Ty);
+  TypeInfo.Align = getParamTypeAlignment(Ty);
 
   CharUnits SlotSize = CharUnits::fromQuantity(PtrByteSize);
 
@@ -4692,7 +4691,7 @@
   QualType Ty) const {
   if (getTarget().getTriple().isOSDarwin()) {
 auto TI = getContext().getTypeInfoInChars(Ty);
-TI.second = getParamTypeAlignment(Ty);
+TI.Align = getParamTypeAlignment(Ty);
 
 CharUnits SlotSize 

[PATCH] D86447: [AST] Change return type of getTypeInfoInChars to a proper struct instead of std::pair.

2020-10-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM.  Sorry I forgot about this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86447/new/

https://reviews.llvm.org/D86447

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86447: [AST] Change return type of getTypeInfoInChars to a proper struct instead of std::pair.

2020-08-24 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan created this revision.
ebevhan added a reviewer: efriedma.
Herald added subscribers: bjope, martong, jfb.
Herald added a project: clang.
ebevhan requested review of this revision.

Followup to D85191 .

This changes getTypeInfoInChars to return a TypeInfoChars
struct instead of a std::pair of CharUnits. This lets the
interface match getTypeInfo more closely.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86447

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -248,8 +248,9 @@
   FieldInfo RetVal;
   RetVal.Field = FD;
   auto  = FD->getASTContext();
-  std::tie(RetVal.Size, RetVal.Align) =
-  Ctx.getTypeInfoInChars(FD->getType());
+  auto Info = Ctx.getTypeInfoInChars(FD->getType());
+  RetVal.Size = Info.Width;
+  RetVal.Align = Info.Align;
   assert(llvm::isPowerOf2_64(RetVal.Align.getQuantity()));
   if (auto Max = FD->getMaxAlignment())
 RetVal.Align = std::max(Ctx.toCharUnitsFromBits(Max), RetVal.Align);
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -359,7 +359,7 @@
 ///   leaving one or more empty slots behind as padding.
 static Address emitVoidPtrVAArg(CodeGenFunction , Address VAListAddr,
 QualType ValueTy, bool IsIndirect,
-std::pair ValueInfo,
+TypeInfoChars ValueInfo,
 CharUnits SlotSizeAndAlign,
 bool AllowHigherAlign) {
   // The size and alignment of the value that was passed directly.
@@ -368,8 +368,8 @@
 DirectSize = CGF.getPointerSize();
 DirectAlign = CGF.getPointerAlign();
   } else {
-DirectSize = ValueInfo.first;
-DirectAlign = ValueInfo.second;
+DirectSize = ValueInfo.Width;
+DirectAlign = ValueInfo.Align;
   }
 
   // Cast the address we've calculated to the right type.
@@ -383,7 +383,7 @@
 AllowHigherAlign);
 
   if (IsIndirect) {
-Addr = Address(CGF.Builder.CreateLoad(Addr), ValueInfo.second);
+Addr = Address(CGF.Builder.CreateLoad(Addr), ValueInfo.Align);
   }
 
   return Addr;
@@ -656,7 +656,7 @@
 "Unexpected IndirectRealign seen in arginfo in generic VAArg emitter!");
 
 auto TyInfo = CGF.getContext().getTypeInfoInChars(Ty);
-CharUnits TyAlignForABI = TyInfo.second;
+CharUnits TyAlignForABI = TyInfo.Align;
 
 llvm::Type *BaseTy =
 llvm::PointerType::getUnqual(CGF.ConvertTypeForMem(Ty));
@@ -2062,8 +2062,8 @@
   //
   // Just messing with TypeInfo like this works because we never pass
   // anything indirectly.
-  TypeInfo.second = CharUnits::fromQuantity(
-getTypeStackAlignInBytes(Ty, TypeInfo.second.getQuantity()));
+  TypeInfo.Align = CharUnits::fromQuantity(
+getTypeStackAlignInBytes(Ty, TypeInfo.Align.getQuantity()));
 
   return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect*/ false,
   TypeInfo, CharUnits::fromQuantity(4),
@@ -4063,10 +4063,9 @@
 RegAddr = CGF.Builder.CreateElementBitCast(RegAddr, LTy);
 
 // Copy to a temporary if necessary to ensure the appropriate alignment.
-std::pair SizeAlign =
-getContext().getTypeInfoInChars(Ty);
-uint64_t TySize = SizeAlign.first.getQuantity();
-CharUnits TyAlign = SizeAlign.second;
+auto TInfo = getContext().getTypeInfoInChars(Ty);
+uint64_t TySize = TInfo.Width.getQuantity();
+CharUnits TyAlign = TInfo.Align;
 
 // Copy into a temporary if the type is more aligned than the
 // register save area.
@@ -4572,7 +4571,7 @@
 llvm::report_fatal_error("vector type is not supported on AIX yet");
 
   auto TypeInfo = getContext().getTypeInfoInChars(Ty);
-  TypeInfo.second = getParamTypeAlignment(Ty);
+  TypeInfo.Align = getParamTypeAlignment(Ty);
 
   CharUnits SlotSize = CharUnits::fromQuantity(PtrByteSize);
 
@@ -4691,7 +4690,7 @@
   QualType Ty) const {
   if (getTarget().getTriple().isOSDarwin()) {
 auto TI = getContext().getTypeInfoInChars(Ty);
-TI.second =