-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang][NFC] Format two files with CallingConv switches #138000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Sarnie, Nick <[email protected]>
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Nick Sarnie (sarnex) ChangesI'm planning on modifying this code so format it so we can pass the formatting check. Patch is 102.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/138000.diff 2 Files Affected:
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index d298f1cff73cf..59369fba2e772 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -56,17 +56,17 @@ using namespace clang;
bool Qualifiers::isStrictSupersetOf(Qualifiers Other) const {
return (*this != Other) &&
- // CVR qualifiers superset
- (((Mask & CVRMask) | (Other.Mask & CVRMask)) == (Mask & CVRMask)) &&
- // ObjC GC qualifiers superset
- ((getObjCGCAttr() == Other.getObjCGCAttr()) ||
- (hasObjCGCAttr() && !Other.hasObjCGCAttr())) &&
- // Address space superset.
- ((getAddressSpace() == Other.getAddressSpace()) ||
- (hasAddressSpace()&& !Other.hasAddressSpace())) &&
- // Lifetime qualifier superset.
- ((getObjCLifetime() == Other.getObjCLifetime()) ||
- (hasObjCLifetime() && !Other.hasObjCLifetime()));
+ // CVR qualifiers superset
+ (((Mask & CVRMask) | (Other.Mask & CVRMask)) == (Mask & CVRMask)) &&
+ // ObjC GC qualifiers superset
+ ((getObjCGCAttr() == Other.getObjCGCAttr()) ||
+ (hasObjCGCAttr() && !Other.hasObjCGCAttr())) &&
+ // Address space superset.
+ ((getAddressSpace() == Other.getAddressSpace()) ||
+ (hasAddressSpace() && !Other.hasAddressSpace())) &&
+ // Lifetime qualifier superset.
+ ((getObjCLifetime() == Other.getObjCLifetime()) ||
+ (hasObjCLifetime() && !Other.hasObjCLifetime()));
}
bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B,
@@ -105,8 +105,8 @@ bool Qualifiers::isTargetAddressSpaceSupersetOf(LangAS A, LangAS B,
Ctx.getTargetInfo().isAddressSpaceSupersetOf(A, B);
}
-const IdentifierInfo* QualType::getBaseTypeIdentifier() const {
- const Type* ty = getTypePtr();
+const IdentifierInfo *QualType::getBaseTypeIdentifier() const {
+ const Type *ty = getTypePtr();
NamedDecl *ND = nullptr;
if (ty->isPointerOrReferenceType())
return ty->getPointeeType().getBaseTypeIdentifier();
@@ -117,8 +117,9 @@ const IdentifierInfo* QualType::getBaseTypeIdentifier() const {
else if (ty->getTypeClass() == Type::Typedef)
ND = ty->castAs<TypedefType>()->getDecl();
else if (ty->isArrayType())
- return ty->castAsArrayTypeUnsafe()->
- getElementType().getBaseTypeIdentifier();
+ return ty->castAsArrayTypeUnsafe()
+ ->getElementType()
+ .getBaseTypeIdentifier();
if (ND)
return ND->getIdentifier();
@@ -147,7 +148,7 @@ bool QualType::isConstant(QualType T, const ASTContext &Ctx) {
std::optional<QualType::NonConstantStorageReason>
QualType::isNonConstantStorage(const ASTContext &Ctx, bool ExcludeCtor,
- bool ExcludeDtor) {
+ bool ExcludeDtor) {
if (!isConstant(Ctx) && !(*this)->isReferenceType())
return NonConstantStorageReason::NonConstNonReferenceType;
if (!Ctx.getLangOpts().CPlusPlus)
@@ -208,9 +209,10 @@ ConstantArrayType::Create(const ASTContext &Ctx, QualType ET, QualType Can,
ConstantArrayType(ET, Can, SzPtr, SzMod, Qual);
}
-unsigned ConstantArrayType::getNumAddressingBits(const ASTContext &Context,
- QualType ElementType,
- const llvm::APInt &NumElements) {
+unsigned
+ConstantArrayType::getNumAddressingBits(const ASTContext &Context,
+ QualType ElementType,
+ const llvm::APInt &NumElements) {
uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity();
// Fast path the common cases so we can avoid the conservative computation
@@ -234,8 +236,8 @@ unsigned ConstantArrayType::getNumAddressingBits(const ASTContext &Context,
// Otherwise, use APSInt to handle arbitrary sized values.
llvm::APSInt SizeExtended(NumElements, true);
unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType());
- SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
- SizeExtended.getBitWidth()) * 2);
+ SizeExtended = SizeExtended.extend(
+ std::max(SizeTypeBits, SizeExtended.getBitWidth()) * 2);
llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
TotalSize *= SizeExtended;
@@ -285,11 +287,9 @@ DependentSizedArrayType::DependentSizedArrayType(QualType et, QualType can,
: ArrayType(DependentSizedArray, et, can, sm, tq, e), SizeExpr((Stmt *)e) {}
void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
- const ASTContext &Context,
- QualType ET,
+ const ASTContext &Context, QualType ET,
ArraySizeModifier SizeMod,
- unsigned TypeQuals,
- Expr *E) {
+ unsigned TypeQuals, Expr *E) {
ID.AddPointer(ET.getAsOpaquePtr());
ID.AddInteger(llvm::to_underlying(SizeMod));
ID.AddInteger(TypeQuals);
@@ -329,10 +329,10 @@ DependentSizedExtVectorType::DependentSizedExtVectorType(QualType ElementType,
: TypeDependence::None)),
SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {}
-void
-DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
- const ASTContext &Context,
- QualType ElementType, Expr *SizeExpr) {
+void DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
+ const ASTContext &Context,
+ QualType ElementType,
+ Expr *SizeExpr) {
ID.AddPointer(ElementType.getAsOpaquePtr());
SizeExpr->Profile(ID, Context, true);
}
@@ -479,7 +479,8 @@ const Type *Type::getArrayElementTypeNoTypeQual() const {
// If this is a typedef for an array type, strip the typedef off without
// losing all typedef information.
return cast<ArrayType>(getUnqualifiedDesugaredType())
- ->getElementType().getTypePtr();
+ ->getElementType()
+ .getTypePtr();
}
/// getDesugaredType - Return the specified type with any "sugar" removed from
@@ -503,8 +504,8 @@ QualType QualType::getSingleStepDesugaredTypeImpl(QualType type,
// Check that no type class is polymorphic. LLVM style RTTI should be used
// instead. If absolutely needed an exception can still be added here by
// defining the appropriate macro (but please don't do this).
-#define TYPE(CLASS, BASE) \
- static_assert(!std::is_polymorphic<CLASS##Type>::value, \
+#define TYPE(CLASS, BASE) \
+ static_assert(!std::is_polymorphic<CLASS##Type>::value, \
#CLASS "Type should not be polymorphic!");
#include "clang/AST/TypeNodes.inc"
@@ -519,11 +520,12 @@ QualType QualType::getSingleStepDesugaredTypeImpl(QualType type,
QualType Type::getLocallyUnqualifiedSingleStepDesugaredType() const {
switch (getTypeClass()) {
#define ABSTRACT_TYPE(Class, Parent)
-#define TYPE(Class, Parent) \
- case Type::Class: { \
- const auto *ty = cast<Class##Type>(this); \
- if (!ty->isSugared()) return QualType(ty, 0); \
- return ty->desugar(); \
+#define TYPE(Class, Parent) \
+ case Type::Class: { \
+ const auto *ty = cast<Class##Type>(this); \
+ if (!ty->isSugared()) \
+ return QualType(ty, 0); \
+ return ty->desugar(); \
}
#include "clang/AST/TypeNodes.inc"
}
@@ -538,14 +540,14 @@ SplitQualType QualType::getSplitDesugaredType(QualType T) {
const Type *CurTy = Qs.strip(Cur);
switch (CurTy->getTypeClass()) {
#define ABSTRACT_TYPE(Class, Parent)
-#define TYPE(Class, Parent) \
- case Type::Class: { \
- const auto *Ty = cast<Class##Type>(CurTy); \
- if (!Ty->isSugared()) \
- return SplitQualType(Ty, Qs); \
- Cur = Ty->desugar(); \
- break; \
- }
+#define TYPE(Class, Parent) \
+ case Type::Class: { \
+ const auto *Ty = cast<Class##Type>(CurTy); \
+ if (!Ty->isSugared()) \
+ return SplitQualType(Ty, Qs); \
+ Cur = Ty->desugar(); \
+ break; \
+ }
#include "clang/AST/TypeNodes.inc"
}
}
@@ -567,13 +569,14 @@ SplitQualType QualType::getSplitUnqualifiedTypeImpl(QualType type) {
// sugared.
switch (split.Ty->getTypeClass()) {
#define ABSTRACT_TYPE(Class, Parent)
-#define TYPE(Class, Parent) \
- case Type::Class: { \
- const auto *ty = cast<Class##Type>(split.Ty); \
- if (!ty->isSugared()) goto done; \
- next = ty->desugar(); \
- break; \
- }
+#define TYPE(Class, Parent) \
+ case Type::Class: { \
+ const auto *ty = cast<Class##Type>(split.Ty); \
+ if (!ty->isSugared()) \
+ goto done; \
+ next = ty->desugar(); \
+ break; \
+ }
#include "clang/AST/TypeNodes.inc"
}
@@ -586,7 +589,7 @@ SplitQualType QualType::getSplitUnqualifiedTypeImpl(QualType type) {
}
}
- done:
+done:
return SplitQualType(lastTypeWithQuals, quals);
}
@@ -600,19 +603,20 @@ QualType QualType::IgnoreParens(QualType T) {
/// This will check for a T (which should be a Type which can act as
/// sugar, such as a TypedefType) by removing any existing sugar until it
/// reaches a T or a non-sugared type.
-template<typename T> static const T *getAsSugar(const Type *Cur) {
+template <typename T> static const T *getAsSugar(const Type *Cur) {
while (true) {
if (const auto *Sugar = dyn_cast<T>(Cur))
return Sugar;
switch (Cur->getTypeClass()) {
#define ABSTRACT_TYPE(Class, Parent)
-#define TYPE(Class, Parent) \
- case Type::Class: { \
- const auto *Ty = cast<Class##Type>(Cur); \
- if (!Ty->isSugared()) return 0; \
- Cur = Ty->desugar().getTypePtr(); \
- break; \
- }
+#define TYPE(Class, Parent) \
+ case Type::Class: { \
+ const auto *Ty = cast<Class##Type>(Cur); \
+ if (!Ty->isSugared()) \
+ return 0; \
+ Cur = Ty->desugar().getTypePtr(); \
+ break; \
+ }
#include "clang/AST/TypeNodes.inc"
}
}
@@ -651,13 +655,14 @@ const Type *Type::getUnqualifiedDesugaredType() const {
while (true) {
switch (Cur->getTypeClass()) {
#define ABSTRACT_TYPE(Class, Parent)
-#define TYPE(Class, Parent) \
- case Class: { \
- const auto *Ty = cast<Class##Type>(Cur); \
- if (!Ty->isSugared()) return Cur; \
- Cur = Ty->desugar().getTypePtr(); \
- break; \
- }
+#define TYPE(Class, Parent) \
+ case Class: { \
+ const auto *Ty = cast<Class##Type>(Cur); \
+ if (!Ty->isSugared()) \
+ return Cur; \
+ Cur = Ty->desugar().getTypePtr(); \
+ break; \
+ }
#include "clang/AST/TypeNodes.inc"
}
}
@@ -821,8 +826,9 @@ bool Type::isObjCIdOrObjectKindOfType(const ASTContext &ctx,
return false;
// Figure out the type bound for the __kindof type.
- bound = OPT->getObjectType()->stripObjCKindOfTypeAndQuals(ctx)
- ->getAs<ObjCObjectType>();
+ bound = OPT->getObjectType()
+ ->stripObjCKindOfTypeAndQuals(ctx)
+ ->getAs<ObjCObjectType>();
return true;
}
@@ -925,8 +931,8 @@ bool ObjCObjectType::isKindOfType() const {
return false;
}
-QualType ObjCObjectType::stripObjCKindOfTypeAndQuals(
- const ASTContext &ctx) const {
+QualType
+ObjCObjectType::stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const {
if (!isKindOfType() && qual_empty())
return QualType(this, 0);
@@ -936,11 +942,11 @@ QualType ObjCObjectType::stripObjCKindOfTypeAndQuals(
if (const auto *baseObj = splitBaseType.Ty->getAs<ObjCObjectType>())
baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
- return ctx.getObjCObjectType(ctx.getQualifiedType(baseType,
- splitBaseType.Quals),
- getTypeArgsAsWritten(),
- /*protocols=*/{},
- /*isKindOf=*/false);
+ return ctx.getObjCObjectType(
+ ctx.getQualifiedType(baseType, splitBaseType.Quals),
+ getTypeArgsAsWritten(),
+ /*protocols=*/{},
+ /*isKindOf=*/false);
}
ObjCInterfaceDecl *ObjCInterfaceType::getDecl() const {
@@ -951,7 +957,7 @@ ObjCInterfaceDecl *ObjCInterfaceType::getDecl() const {
}
const ObjCObjectPointerType *ObjCObjectPointerType::stripObjCKindOfTypeAndQuals(
- const ASTContext &ctx) const {
+ const ASTContext &ctx) const {
if (!isKindOfType() && qual_empty())
return this;
@@ -987,22 +993,22 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
// None of the clients of this transformation can occur where
// there are dependent types, so skip dependent types.
#define TYPE(Class, Base)
-#define DEPENDENT_TYPE(Class, Base) \
+#define DEPENDENT_TYPE(Class, Base) \
QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
#include "clang/AST/TypeNodes.inc"
-#define TRIVIAL_TYPE_CLASS(Class) \
+#define TRIVIAL_TYPE_CLASS(Class) \
QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
-#define SUGARED_TYPE_CLASS(Class) \
- QualType Visit##Class##Type(const Class##Type *T) { \
- if (!T->isSugared()) \
- return QualType(T, 0); \
- QualType desugaredType = recurse(T->desugar()); \
- if (desugaredType.isNull()) \
- return {}; \
- if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
- return QualType(T, 0); \
- return desugaredType; \
+#define SUGARED_TYPE_CLASS(Class) \
+ QualType Visit##Class##Type(const Class##Type *T) { \
+ if (!T->isSugared()) \
+ return QualType(T, 0); \
+ QualType desugaredType = recurse(T->desugar()); \
+ if (desugaredType.isNull()) \
+ return {}; \
+ if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
+ return QualType(T, 0); \
+ return desugaredType; \
}
TRIVIAL_TYPE_CLASS(Builtin)
@@ -1045,8 +1051,8 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (pointeeType.isNull())
return {};
- if (pointeeType.getAsOpaquePtr()
- == T->getPointeeTypeAsWritten().getAsOpaquePtr())
+ if (pointeeType.getAsOpaquePtr() ==
+ T->getPointeeTypeAsWritten().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getLValueReferenceType(pointeeType, T->isSpelledAsLValue());
@@ -1057,8 +1063,8 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (pointeeType.isNull())
return {};
- if (pointeeType.getAsOpaquePtr()
- == T->getPointeeTypeAsWritten().getAsOpaquePtr())
+ if (pointeeType.getAsOpaquePtr() ==
+ T->getPointeeTypeAsWritten().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getRValueReferenceType(pointeeType);
@@ -1231,8 +1237,8 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (adjustedType.isNull())
return {};
- if (originalType.getAsOpaquePtr()
- == T->getOriginalType().getAsOpaquePtr() &&
+ if (originalType.getAsOpaquePtr() ==
+ T->getOriginalType().getAsOpaquePtr() &&
adjustedType.getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())
return QualType(T, 0);
@@ -1244,8 +1250,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (originalType.isNull())
return {};
- if (originalType.getAsOpaquePtr()
- == T->getOriginalType().getAsOpaquePtr())
+ if (originalType.getAsOpaquePtr() == T->getOriginalType().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getDecayedType(originalType);
@@ -1278,10 +1283,10 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (equivalentType.isNull())
return {};
- if (modifiedType.getAsOpaquePtr()
- == T->getModifiedType().getAsOpaquePtr() &&
- equivalentType.getAsOpaquePtr()
- == T->getEquivalentType().getAsOpaquePtr())
+ if (modifiedType.getAsOpaquePtr() ==
+ T->getModifiedType().getAsOpaquePtr() &&
+ equivalentType.getAsOpaquePtr() ==
+ T->getEquivalentType().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getAttributedType(T->getAttrKind(), modifiedType, equivalentType,
@@ -1293,8 +1298,8 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (replacementType.isNull())
return {};
- if (replacementType.getAsOpaquePtr()
- == T->getReplacementType().getAsOpaquePtr())
+ if (replacementType.getAsOpaquePtr() ==
+ T->getReplacementType().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getSubstTemplateTypeParmType(
@@ -1313,13 +1318,11 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (deducedType.isNull())
return {};
- if (deducedType.getAsOpaquePtr()
- == T->getDeducedType().getAsOpaquePtr())
+ if (deducedType.getAsOpaquePtr() == T->getDeducedType().getAsOpaquePtr())
return QualType(T, 0);
- return Ctx.getAutoType(deducedType, T->getKeyword(),
- T->isDependentType(), /*IsPack=*/false,
- T->getTypeConstraintConcept(),
+ return Ctx.getAutoType(deducedType, T->getKeyword(), T->isDependentType(),
+ /*IsPack=*/false, T->getTypeConstraintConcept(),
T->getTypeConstraintArguments());
}
@@ -1359,8 +1362,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (pointeeType.isNull())
return {};
- if (pointeeType.getAsOpaquePtr()
- == T->getPointeeType().getAsOpaquePtr())
+ if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getObjCObjectPointerType(pointeeType);
@@ -1371,8 +1373,7 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> {
if (valueType.isNull())
return {};
- if (valueType.getAsOpaquePtr()
- ...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't clang-format entire files; it makes it hard to follow git history, and we usually like to review the result of the formatter to make sure everything is formatted appropriately.
@@ -3518,9 +3520,11 @@ static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF, | |||
// Look for: | |||
// %generator = call i8* @objc_retain(i8* %originalResult) | |||
// or | |||
// %generator = call i8* @objc_retainAutoreleasedReturnValue(i8* %originalResult) | |||
// %generator = call i8* @objc_retainAutoreleasedReturnValue(i8* | |||
// %originalResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line wrapping looks wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix thanks
@@ -3990,7 +3997,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, | |||
RV = SI->getValueOperand(); | |||
SI->eraseFromParent(); | |||
|
|||
// Otherwise, we have to do a simple load. | |||
// Otherwise, we have to do a simple load. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For comments before an "else", the indentation is significant because it indicates it's supposed to describe the "else", as opposed to the remaining bits of the "if". We've moved away from this kind of formatting because it's hard for tooling to understand the difference, but for existing code, we usually want to move the comment to make the context clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix thanks
Sorry, I should have only formatted the parts I needed, will do that in the future. |
Fixes for #138000 Signed-off-by: Sarnie, Nick <[email protected]>
I'm planning on modifying this code so format it so we can pass the formatting check. Signed-off-by: Sarnie, Nick <[email protected]>
Fixes for llvm#138000 Signed-off-by: Sarnie, Nick <[email protected]>
I'm planning on modifying this code so format it so we can pass the formatting check. Signed-off-by: Sarnie, Nick <[email protected]>
Fixes for llvm#138000 Signed-off-by: Sarnie, Nick <[email protected]>
I'm planning on modifying this code so format it so we can pass the formatting check. Signed-off-by: Sarnie, Nick <[email protected]>
Fixes for llvm#138000 Signed-off-by: Sarnie, Nick <[email protected]>
Fixes for llvm/llvm-project#138000 Signed-off-by: Sarnie, Nick <[email protected]>
I'm planning on modifying this code so format it so we can pass the formatting check. Signed-off-by: Sarnie, Nick <[email protected]>
Fixes for llvm#138000 Signed-off-by: Sarnie, Nick <[email protected]>
I'm planning on modifying this code so format it so we can pass the formatting check.