Skip to content

Commit 4d6a0e1

Browse files
committed
Symbolic links are my nemesis
Found 2 more places where we should be using the absolute path. refs #240
1 parent 9a7aea6 commit 4d6a0e1

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

bin/pm/parse_s_define.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,9 @@ sub parse_s_define ($) {
261261
} else {
262262
my $found = 0 ;
263263
foreach my $inc_path ( @valid_inc_paths ) {
264-
if ( -f "$inc_path/$object_file" ) {
265-
push @{$$sim_ref{mis_entry_files}}, "$inc_path/$object_file" ;
264+
my $f = abs_path(dirname("$inc_path/$object_file")) . "/" . basename("$inc_path/$object_file") ;
265+
if ( -f "$f" ) {
266+
push @{$$sim_ref{mis_entry_files}}, "$f" ;
266267
$found = 1 ;
267268
last ;
268269
}

trick_source/codegen/Interface_Code_Gen/CommentSaver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ void CommentSaver::getICGField( std::string file_name ) {
134134

135135
}
136136

137+
bool CommentSaver::hasTrickHeader( std::string file_name ) {
138+
std::string th_str = getTrickHeaderComment(file_name) ;
139+
return (! th_str.empty()) ;
140+
}
141+
137142
bool CommentSaver::hasICGNo( std::string file_name ) {
138143

139144
if ( icg_no_found.find(file_name) == icg_no_found.end() ) {

trick_source/codegen/Interface_Code_Gen/CommentSaver.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ class CommentSaver : public clang::CommentHandler {
5858
*/
5959
void getICGField( std::string file_name ) ;
6060

61+
/** Returns if the header has a Trick header comment
62+
@param file_name = File name to search
63+
@return true = if header comment found
64+
*/
65+
bool hasTrickHeader(std::string file_name ) ;
66+
6167
/** Searches the Trick header comment for the ICG:(No) entry.
6268
@param file_name = File name to search
6369
@return true = ICG:(No) was found.

trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,29 @@ bool FieldVisitor::VisitDeclaratorDecl( clang::DeclaratorDecl *dd ) {
144144
fdes->setName(dd->getNameAsString()) ;
145145
fdes->setAccess(dd->getAccess()) ;
146146

147-
/* Get the source location of this field. */
147+
/* Get the source location of this field.*/
148148
clang::SourceRange dd_range = dd->getSourceRange() ;
149-
std::string file_name = ci.getSourceManager().getBufferName(dd_range.getEnd()) ;
150-
char * resolved_path = almostRealPath( file_name.c_str() ) ;
151-
if ( resolved_path ) {
152-
if ( ! ci.getSourceManager().isInSystemHeader(dd_range.getEnd()) ) {
149+
clang::PresumedLoc PLoc = ci.getSourceManager().getPresumedLoc(dd_range.getEnd());
150+
std::string file_name ;
151+
if (!PLoc.isInvalid()) {
152+
char * resolved_path = almostRealPath(PLoc.getFilename()) ;
153+
if ( resolved_path != NULL ) {
154+
file_name = std::string(resolved_path) ;
155+
free(resolved_path) ;
156+
}
157+
}
158+
159+
if ( ! file_name.empty() ) {
160+
if ( isInUserOrTrickCode( ci , dd_range.getEnd() , hsd ) ) {
153161
fdes->setLineNo(ci.getSourceManager().getSpellingLineNumber(dd_range.getEnd())) ;
154162
/* process comment if neither ICG:(No) or ICG:(NoComment) is present */
155-
if ( ! cs.hasICGNoComment(file_name) and ! hsd.isPathInICGNoComment(file_name) ) {
163+
if ( cs.hasTrickHeader(file_name) and
164+
!cs.hasICGNoComment(file_name) and
165+
!hsd.isPathInICGNoComment(file_name) ) {
156166
/* Get the possible comment on this line and parse it */
157167
fdes->parseComment(cs.getComment(file_name , fdes->getLineNo())) ;
158168
}
159169
}
160-
free(resolved_path) ;
161170
}
162171

163172
if ( debug_level >= 3 ) {

0 commit comments

Comments
 (0)