[libcxx-commits] [clang] [libcxx] [Clang] Add __builtin_common_reference (PR #121199)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 27 02:31:07 PST 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 f334db92be168876b618db72dc93078ce23ffa89 e0db7316b2705398a2ac7e69cd1e3e83ece52613 --extensions h,cpp -- clang/test/SemaCXX/type-trait-common-reference.cpp clang/include/clang/AST/ASTContext.h clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/DeclID.h clang/include/clang/AST/DeclTemplate.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/Builtins.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/CodeGen/CGDecl.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaLookup.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Sema/SemaType.cpp clang/lib/Serialization/ASTCommon.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/tools/libclang/CIndex.cpp libcxx/include/__type_traits/common_reference.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index b765e0d17c..e94dcdb612 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1807,9 +1807,7 @@ public:
return new (C, DC) CVRefQualifyingTemplateDecl(C, DC, Ref);
}
- SourceRange getSourceRange() const override LLVM_READONLY {
- return {};
- }
+ SourceRange getSourceRange() const override LLVM_READONLY { return {}; }
CVRefQuals getQuals() { return Quals; }
};
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 635e2eb348..c43ebb2086 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1697,11 +1697,9 @@ static TemplateParameterList *createBuiltinCommonTypeList(const ASTContext &C,
nullptr);
}
-static TemplateTypeParmDecl *BICreateTemplateParm(const ASTContext &C,
- DeclContext *DC,
- unsigned Depth,
- unsigned Position,
- bool ParameterPack = false) {
+static TemplateTypeParmDecl *
+BICreateTemplateParm(const ASTContext &C, DeclContext *DC, unsigned Depth,
+ unsigned Position, bool ParameterPack = false) {
return TemplateTypeParmDecl::Create(
C, DC, SourceLocation(), SourceLocation(), Depth, Position,
/*Id=*/nullptr, /*Typename=*/false, ParameterPack);
@@ -1733,8 +1731,8 @@ createBuiltinCommonReferenceBasicCommonReferenceT(const ASTContext &C,
/*Position=*/0);
}
-static TemplateParameterList *createBuiltinCommonReferenceList(const ASTContext &C,
- DeclContext *DC) {
+static TemplateParameterList *
+createBuiltinCommonReferenceList(const ASTContext &C, DeclContext *DC) {
// template <class, class, template <class> class, template <class> class>
// class
auto *BasicCommonReference =
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 4706013ff7..6672fdedd0 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3232,26 +3232,24 @@ static QualType CondRes(Sema &S, QualType X, QualType Y, SourceLocation Loc) {
Sema::ContextRAII TUContext(S, S.Context.getTranslationUnitDecl());
// false
- OpaqueValueExpr CondExpr(SourceLocation(), S.Context.BoolTy,
- VK_PRValue);
+ OpaqueValueExpr CondExpr(SourceLocation(), S.Context.BoolTy, VK_PRValue);
ExprResult Cond = &CondExpr;
// declval<X(&)()>()()
OpaqueValueExpr LHSExpr(Loc, X.getNonLValueExprType(S.Context),
- Expr::getValueKindForType(X));
+ Expr::getValueKindForType(X));
ExprResult LHS = &LHSExpr;
// declval<Y(&)()>()()
OpaqueValueExpr RHSExpr(Loc, Y.getNonLValueExprType(S.Context),
- Expr::getValueKindForType(Y));
+ Expr::getValueKindForType(Y));
ExprResult RHS = &RHSExpr;
ExprValueKind VK = VK_PRValue;
ExprObjectKind OK = OK_Ordinary;
// decltype(false ? declval<X(&)()>()() : declval<Y(&)()>()())
- QualType Result =
- S.CheckConditionalOperands(Cond, LHS, RHS, VK, OK, Loc);
+ QualType Result = S.CheckConditionalOperands(Cond, LHS, RHS, VK, OK, Loc);
if (SFINAE.hasErrorOccurred())
return QualType();
@@ -3260,8 +3258,7 @@ static QualType CondRes(Sema &S, QualType X, QualType Y, SourceLocation Loc) {
return Result;
}
-static QualType CommonRef(Sema &S, QualType A, QualType B,
- SourceLocation Loc) {
+static QualType CommonRef(Sema &S, QualType A, QualType B, SourceLocation Loc) {
// Given types A and B, let X be remove_reference_t<A>, let Y be
// remove_reference_t<B>, and let COMMON-REF(A, B) be:
assert(A->isReferenceType() && B->isReferenceType() &&
@@ -3394,13 +3391,15 @@ static QualType builtinCommonReferenceImpl(Sema &S,
auto T1 = Ts[0];
auto T2 = Ts[1];
auto Rest = Ts.drop_front(2);
- auto C = builtinCommonReferenceImpl(S, CommonReference, CommonType, TemplateLoc, {T1, T2});
+ auto C = builtinCommonReferenceImpl(S, CommonReference, CommonType,
+ TemplateLoc, {T1, T2});
if (C.isNull())
return QualType();
llvm::SmallVector<TemplateArgument, 4> Args;
Args.emplace_back(C);
Args.append(Rest.begin(), Rest.end());
- return builtinCommonReferenceImpl(S, CommonReference, CommonType, TemplateLoc, Args);
+ return builtinCommonReferenceImpl(S, CommonReference, CommonType,
+ TemplateLoc, Args);
}
}
}
diff --git a/libcxx/include/__type_traits/common_reference.h b/libcxx/include/__type_traits/common_reference.h
index a41143670b..31889b2c61 100644
--- a/libcxx/include/__type_traits/common_reference.h
+++ b/libcxx/include/__type_traits/common_reference.h
@@ -38,15 +38,16 @@ using common_reference_t = typename common_reference<_Types...>::type;
template <class, class, template <class> class, template <class> class>
struct basic_common_reference {};
-#if __has_builtin(__builtin_common_reference)
+# if __has_builtin(__builtin_common_reference)
template <class _Tp, class _Up, template <class> class _Tx, template <class> class _Ux>
using __basic_common_reference_t = basic_common_reference<_Tp, _Up, _Tx, _Ux>::type;
template <class... _Args>
-struct common_reference : __builtin_common_reference<__basic_common_reference_t, common_type_t, type_identity, __empty, _Args...> {};
+struct common_reference
+ : __builtin_common_reference<__basic_common_reference_t, common_type_t, type_identity, __empty, _Args...> {};
-#else
+# else
// Let COND_RES(X, Y) be:
template <class _Xp, class _Yp>
@@ -198,7 +199,7 @@ struct common_reference<_Tp, _Up, _Vp, _Rest...> : common_reference<common_refer
template <class...>
struct common_reference {};
-#endif // __has_builtin(__builtin_common_reference)
+# endif // __has_builtin(__builtin_common_reference)
_LIBCPP_END_NAMESPACE_STD
``````````
</details>
https://github.com/llvm/llvm-project/pull/121199
More information about the libcxx-commits
mailing list