[PATCH] D131423: [clang] fix frontend crash when evaluating type trait
YingChi Long via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 11 21:54:46 PDT 2022
inclyc added inline comments.
================
Comment at: clang/lib/Basic/TypeTraits.cpp:64
+#define TYPE_TRAIT_N(Spelling, Name, Key) 0,
+#include "clang/Basic/TokenKinds.def"
+};
----------------
inclyc wrote:
> shafik wrote:
> > @aaron.ballman do we really have to include this three times? We are defining different macros so shouldn't we be able to include is just once?
> >
> > I see we do this in several other places but a few we don't.
> I've tried
>
> ```
> #define TYPE_TRAIT(N, I, K) N,
> #include "clang/Basic/TokenKinds.def"
> ```
>
> But using enum `TypeTrait` as array index seems to have incorrect mapping.
> @aaron.ballman do we really have to include this three times? We are defining different macros so shouldn't we be able to include is just once?
>
> I see we do this in several other places but a few we don't.
Type trait definitions in `#include "clang/Basic/TokenKinds.def"` may not be sorted by the number of arguments.
Example:
```
#define TYPE_TRAIT_1(some_stuff)
#define TYPE_TRAIT_N(some_stuff)
#define TYPE_TRAIT_2(some_stuff)
```
Might be necessary to include this 3 times to get sorted layouts, like
`[1, 1, 1, 2, 2, 2, 0, 0]`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131423/new/
https://reviews.llvm.org/D131423
More information about the cfe-commits
mailing list