[clang] Rough first stab at addressing #85120 (PR #85147)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 16:08:46 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff ad23127222fe23e28ac3deaa16f3ae64d13b7b6f 613f04e311f083c129acaa4598cbfd9894fe3805 -- clang/include/clang/AST/ASTContext.h clang/lib/AST/ASTContext.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/TreeTransform.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index ca90417c9b..adffdc00f6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1303,8 +1303,9 @@ public:
/// Transform a function type to have the provided result type, preserving
/// AttributedType and MacroQualifiedType sugar.
- QualType getFunctionTypeWithResultType(QualType OrigFuncType, QualType ResultType,
- const FunctionProtoType::ExtProtoInfo &EPI) const;
+ QualType getFunctionTypeWithResultType(
+ QualType OrigFuncType, QualType ResultType,
+ const FunctionProtoType::ExtProtoInfo &EPI) const;
/// Get a function type and produce the equivalent function type with the
/// specified exception specification. Type sugar that can be present on a
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 035dc19ba7..04ea684b13 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3140,17 +3140,18 @@ const FunctionType *ASTContext::adjustFunctionType(const FunctionType *T,
return cast<FunctionType>(Result.getTypePtr());
}
-// EPI is provided by the caller because in the case of adjustDeducedFunctionResultType, it
-// is copied entirely from the previous FunctionType, but with a block (ActOnBlockStmtExpr),
-// it is more complicated...
-QualType ASTContext::getFunctionTypeWithResultType(QualType OrigFuncType, QualType ResultType,
- const FunctionProtoType::ExtProtoInfo &EPI) const
-{
+// EPI is provided by the caller because in the case of
+// adjustDeducedFunctionResultType, it is copied entirely from the previous
+// FunctionType, but with a block (ActOnBlockStmtExpr), it is more
+// complicated...
+QualType ASTContext::getFunctionTypeWithResultType(
+ QualType OrigFuncType, QualType ResultType,
+ const FunctionProtoType::ExtProtoInfo &EPI) const {
// Might be wrapped in a macro qualified type.
if (const auto *MQT = dyn_cast<MacroQualifiedType>(OrigFuncType)) {
- return getMacroQualifiedType(
- getFunctionTypeWithResultType(MQT->getUnderlyingType(), ResultType, EPI),
- MQT->getMacroIdentifier());
+ return getMacroQualifiedType(getFunctionTypeWithResultType(
+ MQT->getUnderlyingType(), ResultType, EPI),
+ MQT->getMacroIdentifier());
}
// Might have a calling-convention attribute.
@@ -3158,10 +3159,12 @@ QualType ASTContext::getFunctionTypeWithResultType(QualType OrigFuncType, QualTy
return getAttributedType(
AT->getAttrKind(),
getFunctionTypeWithResultType(AT->getModifiedType(), ResultType, EPI),
- getFunctionTypeWithResultType(AT->getEquivalentType(), ResultType, EPI));
+ getFunctionTypeWithResultType(AT->getEquivalentType(), ResultType,
+ EPI));
}
-
- // Anything else must be a function type. Rebuild it with the new return value.
+
+ // Anything else must be a function type. Rebuild it with the new return
+ // value.
const auto *FPT = OrigFuncType->castAs<FunctionProtoType>();
return getFunctionType(ResultType, FPT->getParamTypes(), EPI);
}
@@ -3191,15 +3194,20 @@ void ASTContext::adjustDeducedFunctionResultType(FunctionDecl *FD,
const auto *FPT = OrigFuncType->castAs<FunctionProtoType>();
FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
#if 1 // my new way
- QualType NewFuncType = getFunctionTypeWithResultType(OrigFuncType, ResultType, EPI);
+ QualType NewFuncType =
+ getFunctionTypeWithResultType(OrigFuncType, ResultType, EPI);
#else // original way
- QualType NewFuncType = getFunctionType(ResultType, FPT->getParamTypes(), EPI);
+ QualType NewFuncType =
+ getFunctionType(ResultType, FPT->getParamTypes(), EPI);
#endif
- /*llvm::outs() << "transform " << OrigFuncType << " -> " << NewFuncType << "\n";
- llvm::outs() << " isConstQualified " << OrigFuncType.isConstQualified() << NewFuncType.isConstQualified() << "\n";
- llvm::outs() << " isLocalConstQualified " << OrigFuncType.isLocalConstQualified() << NewFuncType.isLocalConstQualified() << "\n";
- llvm::outs() << " const method " << FPT->isConst() << NewFuncType->castAs<FunctionProtoType>()->isConst() << "\n";
- llvm::outs() << " canonical " << NewFuncType.getCanonicalType() << "\n";*/
+ /*llvm::outs() << "transform " << OrigFuncType << " -> " << NewFuncType <<
+ "\n"; llvm::outs() << " isConstQualified " <<
+ OrigFuncType.isConstQualified() << NewFuncType.isConstQualified() << "\n";
+ llvm::outs() << " isLocalConstQualified " <<
+ OrigFuncType.isLocalConstQualified() << NewFuncType.isLocalConstQualified()
+ << "\n"; llvm::outs() << " const method " << FPT->isConst() <<
+ NewFuncType->castAs<FunctionProtoType>()->isConst() << "\n"; llvm::outs() <<
+ " canonical " << NewFuncType.getCanonicalType() << "\n";*/
/*examineType("original ", OrigFuncType, "\n");
examineType("deduced ", NewFuncType, "\n");*/
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 651136d7c1..123a2bee69 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -17161,7 +17161,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
EPI.TypeQuals = Qualifiers();
EPI.ExtInfo = Ext;
- BlockTy = Context.getFunctionTypeWithResultType(BSI->FunctionType, RetTy, EPI);
+ BlockTy =
+ Context.getFunctionTypeWithResultType(BSI->FunctionType, RetTy, EPI);
}
// If we don't have a function type, just build one from nothing.
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 9a8dac2258..de12f042a7 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13856,7 +13856,6 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
+ }
#endif
-
// Transform the type of the original lambda's call operator.
// The transformation MUST be done in the CurrentInstantiationScope since
// it introduces a mapping of the original to the newly created
@@ -13896,7 +13895,8 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
return ExprError();
// NewCallOpTSI =
- // NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
+ // NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
+ // NewCallOpType);
if (IsAttributed) {
const AttributedType *oldType = OldCallOpATTL.getTypePtr();
``````````
</details>
https://github.com/llvm/llvm-project/pull/85147
More information about the cfe-commits
mailing list