mirror of
https://github.com/nasa/trick.git
synced 2025-01-22 20:38:19 +00:00
Forward-declared classes aren't fully populated in S_sie.resource #378
I chose the wrong call when trying to support clang 3.9 and it's removal of getRBraceLoc. The best equivalent call in 3.9 is getBraceRange().getEnd().
This commit is contained in:
parent
b6854521f0
commit
70b5bcd1ab
10
trick_source/codegen/Interface_Code_Gen/BraceMacro.hh
Normal file
10
trick_source/codegen/Interface_Code_Gen/BraceMacro.hh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef BRACEMACRO_HH
|
||||||
|
#define BRACEMACRO_HH
|
||||||
|
|
||||||
|
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 9))
|
||||||
|
#define RBRACELOC getBraceRange().getEnd
|
||||||
|
#else
|
||||||
|
#define RBRACELOC getRBraceLoc
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -14,6 +14,7 @@
|
|||||||
#include "FieldVisitor.hh"
|
#include "FieldVisitor.hh"
|
||||||
#include "Utilities.hh"
|
#include "Utilities.hh"
|
||||||
#include "PrintAttributes.hh"
|
#include "PrintAttributes.hh"
|
||||||
|
#include "BraceMacro.hh"
|
||||||
|
|
||||||
extern llvm::cl::opt< int > debug_level ;
|
extern llvm::cl::opt< int > debug_level ;
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ bool CXXRecordVisitor::TraverseDecl(clang::Decl *d) {
|
|||||||
process embedded classes that have public access. */
|
process embedded classes that have public access. */
|
||||||
clang::RecordDecl * rd = crd->getDefinition() ;
|
clang::RecordDecl * rd = crd->getDefinition() ;
|
||||||
if ( rd != NULL and rd->getAccess() == clang::AS_public ) {
|
if ( rd != NULL and rd->getAccess() == clang::AS_public ) {
|
||||||
if ( isInUserCode(ci , crd->getSourceRange().getEnd(), hsd) ) {
|
if ( isInUserCode(ci , crd->RBRACELOC(), hsd) ) {
|
||||||
CXXRecordVisitor embedded_cvis(ci , cs, hsd , pa, false, false, true) ;
|
CXXRecordVisitor embedded_cvis(ci , cs, hsd , pa, false, false, true) ;
|
||||||
embedded_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(d)) ;
|
embedded_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(d)) ;
|
||||||
pa.printClass(embedded_cvis.get_class_data()) ;
|
pa.printClass(embedded_cvis.get_class_data()) ;
|
||||||
@ -149,7 +150,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
|
|||||||
cval.setHasPublicDestructor(true) ;
|
cval.setHasPublicDestructor(true) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string file_name = getFileName(ci , rec->getSourceRange().getEnd(), hsd) ;
|
std::string file_name = getFileName(ci , rec->RBRACELOC(), hsd) ;
|
||||||
char * rp = almostRealPath(file_name.c_str()) ;
|
char * rp = almostRealPath(file_name.c_str()) ;
|
||||||
if ( rp == NULL ) {
|
if ( rp == NULL ) {
|
||||||
return false ;
|
return false ;
|
||||||
@ -178,13 +179,13 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
|
|||||||
clang::RecordDecl * rd = rt->getDecl() ;
|
clang::RecordDecl * rd = rt->getDecl() ;
|
||||||
//std::cout << " [34m" << cval.getName() << " inherits from " << rd->getNameAsString() << "[00m" << std::endl ;
|
//std::cout << " [34m" << cval.getName() << " inherits from " << rd->getNameAsString() << "[00m" << std::endl ;
|
||||||
//rd->dump() ; std::cout << std::endl ;
|
//rd->dump() ; std::cout << std::endl ;
|
||||||
if ( isInUserOrTrickCode(ci , rd->getSourceRange().getEnd(), hsd) ) {
|
if ( isInUserOrTrickCode(ci , rd->RBRACELOC(), hsd) ) {
|
||||||
const clang::ASTRecordLayout &record_layout = rec->getASTContext().getASTRecordLayout(rec);
|
const clang::ASTRecordLayout &record_layout = rec->getASTContext().getASTRecordLayout(rec);
|
||||||
unsigned int inherit_class_offset ;
|
unsigned int inherit_class_offset ;
|
||||||
|
|
||||||
inherit_class_offset = record_layout.getBaseClassOffset(llvm::cast<clang::CXXRecordDecl>(rd)).getQuantity() ;
|
inherit_class_offset = record_layout.getBaseClassOffset(llvm::cast<clang::CXXRecordDecl>(rd)).getQuantity() ;
|
||||||
//std::cout << " [34minherit_class_offset = " << inherit_class_offset << "[00m" << std::endl ;
|
//std::cout << " [34minherit_class_offset = " << inherit_class_offset << "[00m" << std::endl ;
|
||||||
//std::cout << " [34m" << getFileName(ci , rd->getSourceRange().getEnd(), hsd) << "[00m" << std::endl ;
|
//std::cout << " [34m" << getFileName(ci , rd->RBRACELOC(), hsd) << "[00m" << std::endl ;
|
||||||
CXXRecordVisitor inherit_cvis(ci , cs, hsd , pa, true, bcii->isVirtual(), false, inherit_class_offset) ;
|
CXXRecordVisitor inherit_cvis(ci , cs, hsd , pa, true, bcii->isVirtual(), false, inherit_class_offset) ;
|
||||||
inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd)) ;
|
inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd)) ;
|
||||||
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription()) ;
|
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription()) ;
|
||||||
@ -220,7 +221,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
|
|||||||
clang::RecordDecl * rd = rt->getDecl() ;
|
clang::RecordDecl * rd = rt->getDecl() ;
|
||||||
//std::cout << " [34m" << cval.getName() << " virtually inherits from " << rd->getNameAsString() << "[00m" << std::endl ;
|
//std::cout << " [34m" << cval.getName() << " virtually inherits from " << rd->getNameAsString() << "[00m" << std::endl ;
|
||||||
//rd->dump() ; std::cout << std::endl ;
|
//rd->dump() ; std::cout << std::endl ;
|
||||||
if ( isInUserOrTrickCode(ci , rd->getSourceRange().getEnd(), hsd) ) {
|
if ( isInUserOrTrickCode(ci , rd->RBRACELOC(), hsd) ) {
|
||||||
const clang::ASTRecordLayout &record_layout = rec->getASTContext().getASTRecordLayout(rec);
|
const clang::ASTRecordLayout &record_layout = rec->getASTContext().getASTRecordLayout(rec);
|
||||||
unsigned int inherit_class_offset ;
|
unsigned int inherit_class_offset ;
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ bool CXXRecordVisitor::VisitCXXRecordDecl( clang::CXXRecordDecl *rec ) {
|
|||||||
inherit_class_offset = record_layout.getVBaseClassOffset(llvm::cast<clang::CXXRecordDecl>(rd)).getQuantity() ;
|
inherit_class_offset = record_layout.getVBaseClassOffset(llvm::cast<clang::CXXRecordDecl>(rd)).getQuantity() ;
|
||||||
|
|
||||||
//std::cout << " [34minherit_class_offset = " << inherit_class_offset << "[00m" << std::endl ;
|
//std::cout << " [34minherit_class_offset = " << inherit_class_offset << "[00m" << std::endl ;
|
||||||
//std::cout << " [34m" << getFileName(ci , rd->getSourceRange().getEnd(), hsd) << "[00m" << std::endl ;
|
//std::cout << " [34m" << getFileName(ci , rd->RBRACELOC(), hsd) << "[00m" << std::endl ;
|
||||||
CXXRecordVisitor inherit_cvis(ci , cs, hsd , pa, true, bcii->isVirtual(), false, inherit_class_offset) ;
|
CXXRecordVisitor inherit_cvis(ci , cs, hsd , pa, true, bcii->isVirtual(), false, inherit_class_offset) ;
|
||||||
inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd)) ;
|
inherit_cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(rd)) ;
|
||||||
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription()) ;
|
cval.addInheritedFieldDescriptions(inherit_cvis.get_class_data()->getFieldDescription()) ;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "EnumVisitor.hh"
|
#include "EnumVisitor.hh"
|
||||||
#include "EnumValues.hh"
|
#include "EnumValues.hh"
|
||||||
#include "Utilities.hh"
|
#include "Utilities.hh"
|
||||||
|
#include "BraceMacro.hh"
|
||||||
|
|
||||||
extern llvm::cl::opt< int > debug_level ;
|
extern llvm::cl::opt< int > debug_level ;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ bool EnumVisitor::VisitType(clang::Type *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EnumVisitor::VisitEnumDecl(clang::EnumDecl *ed) {
|
bool EnumVisitor::VisitEnumDecl(clang::EnumDecl *ed) {
|
||||||
eval.setFileName(getFileName(ci , ed->getSourceRange().getEnd(), hsd)) ;
|
eval.setFileName(getFileName(ci , ed->RBRACELOC(), hsd)) ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "VariableVisitor.hh"
|
#include "VariableVisitor.hh"
|
||||||
#include "Utilities.hh"
|
#include "Utilities.hh"
|
||||||
#include "PrintAttributes.hh"
|
#include "PrintAttributes.hh"
|
||||||
|
#include "BraceMacro.hh"
|
||||||
|
|
||||||
TranslationUnitVisitor::TranslationUnitVisitor(clang::CompilerInstance & in_ci , HeaderSearchDirs & in_hsd ,
|
TranslationUnitVisitor::TranslationUnitVisitor(clang::CompilerInstance & in_ci , HeaderSearchDirs & in_hsd ,
|
||||||
CommentSaver & in_cs , PrintAttributes & in_pa ) :
|
CommentSaver & in_cs , PrintAttributes & in_pa ) :
|
||||||
@ -47,11 +48,11 @@ bool TranslationUnitVisitor::TraverseDecl(clang::Decl *d) {
|
|||||||
in fact empty */
|
in fact empty */
|
||||||
clang::RecordDecl * rd = crd->getDefinition() ;
|
clang::RecordDecl * rd = crd->getDefinition() ;
|
||||||
if ( rd != NULL ) {
|
if ( rd != NULL ) {
|
||||||
std::string rd_file = getFileName(ci , rd->getSourceRange().getEnd(), hsd) ;
|
std::string rd_file = getFileName(ci , rd->RBRACELOC(), hsd) ;
|
||||||
std::string crd_file = getFileName(ci , crd->getSourceRange().getEnd(), hsd) ;
|
std::string crd_file = getFileName(ci , crd->RBRACELOC(), hsd) ;
|
||||||
if (!crd_file.empty() and !crd_file.compare(rd_file)) {
|
if (!crd_file.empty() and !crd_file.compare(rd_file)) {
|
||||||
//crd->dump() ; std::cout << std::endl ;
|
//crd->dump() ; std::cout << std::endl ;
|
||||||
if ( isInUserCode(ci , crd->getSourceRange().getEnd(), hsd) ) {
|
if ( isInUserCode(ci , crd->RBRACELOC(), hsd) ) {
|
||||||
CXXRecordVisitor cvis(ci , cs, hsd , pa, false, false, true) ;
|
CXXRecordVisitor cvis(ci , cs, hsd , pa, false, false, true) ;
|
||||||
|
|
||||||
cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(d)) ;
|
cvis.TraverseCXXRecordDecl(static_cast<clang::CXXRecordDecl *>(d)) ;
|
||||||
@ -85,7 +86,7 @@ bool TranslationUnitVisitor::TraverseDecl(clang::Decl *d) {
|
|||||||
break ;
|
break ;
|
||||||
case clang::Decl::Enum : {
|
case clang::Decl::Enum : {
|
||||||
clang::EnumDecl * ed = static_cast<clang::EnumDecl *>(d) ;
|
clang::EnumDecl * ed = static_cast<clang::EnumDecl *>(d) ;
|
||||||
if ( isInUserCode(ci , ed->getSourceRange().getEnd(), hsd) ) {
|
if ( isInUserCode(ci , ed->RBRACELOC(), hsd) ) {
|
||||||
EnumVisitor evis(ci, hsd) ;
|
EnumVisitor evis(ci, hsd) ;
|
||||||
evis.TraverseDecl(ed) ;
|
evis.TraverseDecl(ed) ;
|
||||||
//if ( evis.get_enum_data() != NULL ) {
|
//if ( evis.get_enum_data() != NULL ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user