mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-13 03:32:14 +00:00
Validate RecordDecl
This commit is contained in:
parent
b5c2a48bb0
commit
820e99a804
@ -27,7 +27,7 @@ OUTPUT:
|
||||
"bases": [],
|
||||
"derived": [],
|
||||
"vars": [],
|
||||
"uses": ["5:3-5:9|10177235824697315808|3|16420", "5:3-5:9|2459767597003442547|3|16420"],
|
||||
"uses": ["5:3-5:9|10177235824697315808|3|16420"],
|
||||
"callees": []
|
||||
}, {
|
||||
"usr": 2459767597003442547,
|
||||
|
@ -301,6 +301,19 @@ const Decl* GetSpecialized(const Decl* D) {
|
||||
return Template;
|
||||
}
|
||||
|
||||
bool ValidateRecord(const RecordDecl *RD) {
|
||||
for (const auto *I : RD->fields()){
|
||||
QualType FQT = I->getType();
|
||||
if (FQT->isIncompleteType() || FQT->isDependentType())
|
||||
return false;
|
||||
if (const RecordType *ChildType = I->getType()->getAs<RecordType>())
|
||||
if (const RecordDecl *Child = ChildType->getDecl())
|
||||
if (!ValidateRecord(Child))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class IndexDataConsumer : public index::IndexDataConsumer {
|
||||
public:
|
||||
ASTContext *Ctx;
|
||||
@ -835,7 +848,8 @@ public:
|
||||
int offset;
|
||||
std::tie(RD, offset) = Stack.back();
|
||||
Stack.pop_back();
|
||||
if (!RD->isCompleteDefinition() || RD->isDependentType())
|
||||
if (!RD->isCompleteDefinition() || RD->isDependentType() ||
|
||||
!ValidateRecord(RD))
|
||||
offset = -1;
|
||||
for (FieldDecl *FD : RD->fields()) {
|
||||
int offset1 = offset >= 0 ? offset + Ctx->getFieldOffset(FD) : -1;
|
||||
|
Loading…
Reference in New Issue
Block a user