mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
parent
a2cee328d2
commit
294e8c9e40
@ -40,17 +40,33 @@ bool TranslationUnitVisitor::TraverseDecl(clang::Decl *d) {
|
||||
break ;
|
||||
case clang::Decl::CXXRecord : {
|
||||
clang::CXXRecordDecl * crd = static_cast<clang::CXXRecordDecl *>(d) ;
|
||||
clang::RecordDecl * rd = crd->getDefinition() ;
|
||||
bool is_forward_declaration = false;
|
||||
|
||||
/* The definition of the record must exist before we can process it. The definition is
|
||||
NULL when this is only a forward declaration of a class */
|
||||
if ( rd == NULL ) {
|
||||
is_forward_declaration = true;
|
||||
}
|
||||
/* Sometimes rd is not NULL when we still only have a forward declaration because
|
||||
the file that defines the class is included before processing this fwd declare.
|
||||
In this case the CXXRecordDecl file name will not match the current file name, and is
|
||||
in fact empty */
|
||||
clang::RecordDecl * rd = crd->getDefinition() ;
|
||||
if ( rd != NULL ) {
|
||||
else {
|
||||
std::string rd_file = getFileName(ci , rd->RBRACELOC(), hsd) ;
|
||||
std::string crd_file = getFileName(ci , crd->RBRACELOC(), hsd) ;
|
||||
if (!crd_file.empty() and !crd_file.compare(rd_file)) {
|
||||
if (crd_file.empty() || crd_file.compare(rd_file)) {
|
||||
is_forward_declaration = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_forward_declaration) {
|
||||
// These are forward declarations. Insert this into the set of fwd declares keyed by the current file.
|
||||
if ( ! crd->getNameAsString().empty() ) {
|
||||
fwd_declared_classes[getFileName(ci , d->getLocEnd(), hsd)].insert(crd->getNameAsString()) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//crd->dump() ; std::cout << std::endl ;
|
||||
if ( isInUserCode(ci , crd->RBRACELOC(), hsd) ) {
|
||||
CXXRecordVisitor cvis(ci , cs, hsd , pa, true) ;
|
||||
@ -76,12 +92,6 @@ bool TranslationUnitVisitor::TraverseDecl(clang::Decl *d) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// These are forward declarations. Insert this into the set of fwd declares keyed by the current file.
|
||||
if ( ! crd->getNameAsString().empty() ) {
|
||||
fwd_declared_classes[getFileName(ci , d->getLocEnd(), hsd)].insert(crd->getNameAsString()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case clang::Decl::Enum : {
|
||||
|
Loading…
Reference in New Issue
Block a user