[PATCH] D116203: [clang] adds unary type transformations as compiler built-ins
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 06:45:18 PDT 2022
aaron.ballman added a comment.
Pre-commit CI found build errors that should be addressed.
================
Comment at: clang/include/clang/AST/TransformTypeTraits.def:1-2
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
----------------
Have to fix the formatting manually though.
================
Comment at: clang/include/clang/Sema/DeclSpec.h:424-431
+ static bool isTransformTypeTrait(TST T) {
+ constexpr TST Traits[] = {
+#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) TST_##Trait,
+#include "clang/AST/TransformTypeTraits.def"
+ };
+
+ return (T >= Traits[0] && T <= std::end(Traits)[-1]);
----------------
Errr, this isn't Python, so that `[-1]` terrifies me. It took me a good solid ten minutes to convince myself this was actually valid. Any interest in something along the lines of this form?
================
Comment at: clang/lib/AST/TypePrinter.cpp:1158
raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
}
----------------
cjdb wrote:
> rsmith wrote:
> > Remove this line too. No point building an RAII scope with nothing in it.
> Can we get rid of this function entirely in that case?
I believe you can.
================
Comment at: clang/lib/Parse/ParseDecl.cpp:3475
+ case tok::identifier:
+ ParseIdentifier : {
// This identifier can only be a typedef name if we haven't already seen
----------------
================
Comment at: clang/lib/Sema/SemaType.cpp:9267
+ constexpr auto UKind = UTTKind::RemovePointer;
+ // We don't want block pointers or ObjectiveC's id type
+ if (!BaseType->isAnyPointerType() || BaseType->isObjCIdType())
----------------
================
Comment at: clang/lib/Sema/SemaType.cpp:9305-9308
+ else if (const auto *AT = Context.getAsArrayType(BaseType))
+ return AT->getElementType();
+ else
+ return BaseType;
----------------
================
Comment at: clang/lib/Sema/SemaType.cpp:9350-9352
+ if (auto BitInt = dyn_cast<BitIntType>(Underlying)) {
+ return S.Context.getBitIntType(!IsMakeSigned, BitInt->getNumBits());
}
----------------
An interesting test case for you to consider (both for enumeration underlying types as well as types in general): `signed _BitInt` requires at least two bits, so trying to do a make_signed on `_BitInt(1)` should be diagnosed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116203/new/
https://reviews.llvm.org/D116203
More information about the cfe-commits
mailing list