This is an archive of the discontinued LLVM Phabricator instance.

Sema: adjust assertion to account for deduced types
ClosedPublic

Authored by compnerd on May 20 2022, 2:39 PM.

Details

Summary

Previous changes for the BTF attributes introduced a new sub-tree
visitation. That uncovered that when accessing the typespec location we
would assert that the type specification is either a type declaration or
typename. However, typename was explicitly permitted. This change
predates the introduction of newer deduced type representations such as
__underlying_type from C++ and the addition of the GNU __typeof__
expression.

Thanks to aaron.ballman for the valuable discussion and pointer to
isTypeRep.

Diff Detail

Event Timeline

compnerd created this revision.May 20 2022, 2:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2022, 2:39 PM
compnerd requested review of this revision.May 20 2022, 2:39 PM
compnerd updated this revision to Diff 431084.May 20 2022, 3:56 PM

git-clang-format

yonghong-song accepted this revision.May 24 2022, 12:10 AM
yonghong-song added a subscriber: yonghong-song.

Sorry. I missed this patch somehow and did another patch https://reviews.llvm.org/D126223. My patch skipped TL.setNameLoc(DS.getTypeSpecTypeNameLoc()); which probably not correct. Accept this patch and abandon my patch D126223.

This revision is now accepted and ready to land.May 24 2022, 12:10 AM
aaron.ballman accepted this revision.May 24 2022, 4:20 AM

LGTM aside from a testing request and a nit. Thanks for the fix!

clang/include/clang/Sema/DeclSpec.h
520

I think you've got a test case covering isExprRep() because your __typeof__ names an expression, but can you also add coverage for isTypeRep() where __typeof__ names a type instead, as in: https://godbolt.org/z/hfK8ds9EM

clang/test/Sema/typerep-typespec.c
2
This revision was automatically updated to reflect the committed changes.
compnerd marked an inline comment as done.