[PATCH] D82882: [ASTImporter] Fix AST import crash for a friend decl
Vince Bridgers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 08:39:49 PDT 2020
vabridgers created this revision.
vabridgers added a reviewer: martong.
Herald added subscribers: cfe-commits, teemperor, rnkovacs, kristof.beyls.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.
Running CTU testing, we found that VisitFriendDecl in
ASTImporterLookup.cpp was not handling a particular non-dependent case,
so we reached the llvm_unreachable case.
The FriendDecl and QualType not handled were:
(gdb) p D->dump()
FriendDecl 0x7ffff5cf1958
< <<srcfile>>, 'nlohmann::basic_json<std::map, std::vector,
std::basic_string<char>, bool, long long, unsigned long long, double,
std::allocator, adl_serializer, std::vector<unsigned char,
std::allocator<unsigned char>>>':'nlohmann::basic_json<std::map,
std::vector, std::basic_string<char>, bool, long long, unsigned long
long, double, std::allocator, adl_serializer, std::vector<unsigned char,
std::allocator<unsigned char>>>'
(gdb) p Ty->dump()
SubstTemplateTypeParmType 0x7ffff5cf0df0 'class
nlohmann::basic_json<std::map, std::vector, class
std::basic_string<char>, _Bool, long long, unsigned long long, double,
std::allocator, adl_serializer, class std::vector<unsigned char, class
std::allocator<unsigned char> > >' sugar
| -TemplateTypeParmType 0x7ffff643ea40 'BasicJsonType' dependent depth 0 |
|
index 0
| `-TemplateTypeParm 0x7ffff643e9e8 'BasicJsonType' |
|
`-RecordType 0x1012ad20 'class nlohmann::basic_json<std::map,
std::vector, class std::basic_string<char>, _Bool, long long, unsigned
long long, double, std::allocator, adl_serializer, class
std::vector<unsigned char, class std::allocator<unsigned char> > >'
`-ClassTemplateSpecialization 0x1012ab68 'basic_json'
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82882
Files:
clang/lib/AST/ASTImporterLookupTable.cpp
Index: clang/lib/AST/ASTImporterLookupTable.cpp
===================================================================
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -45,7 +45,10 @@
LT.add(RTy->getAsCXXRecordDecl());
else if (const auto *SpecTy = dyn_cast<TemplateSpecializationType>(Ty))
LT.add(SpecTy->getAsCXXRecordDecl());
- else if (isa<TypedefType>(Ty)) {
+ else if (const auto *SubstTy = dyn_cast<SubstTemplateTypeParmType>(Ty)) {
+ if (SubstTy->getAsCXXRecordDecl())
+ LT.add(SubstTy->getAsCXXRecordDecl());
+ } else if (isa<TypedefType>(Ty)) {
// We do not put friend typedefs to the lookup table because
// ASTImporter does not organize typedefs into redecl chains.
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82882.274494.patch
Type: text/x-patch
Size: 833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200630/1a201268/attachment-0001.bin>
More information about the cfe-commits
mailing list