Commit Graph

205 Commits

Author SHA1 Message Date
Derek Bankieris
294e8c9e40 Correct forward-declaration-detection logic in ICG
Fixes #724
2019-02-14 10:55:55 -06:00
Scott Fennell
21c01a5454 scan-build changes
This reverts commit e86027f825.
2018-11-06 11:23:12 -06:00
Scott Fennell
e86027f825 revert scan-build changes, need further testing before merge 2018-10-22 15:11:29 -05:00
Scott Fennell
bc35e64406
Merge pull request #673 from nasa/#scan-build
#671 fix all non memory manager scan-build bugs.
2018-10-20 13:16:35 -05:00
Pappy Van Winkle
af2575da5b Remove all unused variables (style warning). 2018-10-11 22:05:50 -05:00
Scott Fennell
6619ecb92f move commented prints in FieldDescription to debug_level 4 2018-09-27 08:10:05 -05:00
Scott Fennell
a9f84d1d9f various static analyser bug fixes 2018-09-26 14:27:03 -05:00
Scott Fennell
77e0e73b3f various static analyser bug fixes 2018-09-25 10:41:14 -05:00
Alex Lin
6ce60cb2ec Is Trick ICG missing some uses of TRICK_ICG #608
Some functions changed signatures in 3.5, others in 3.7.
2018-05-18 08:38:28 -05:00
Alex Lin
be6f9dc855 Trick will not compile with llvm 6.0 and Xcode 9.2 on the mac. #579
Found a new language option we need to set in ICG when llvm >= 6.0 to parse
header files correctly.  The option is DoubleSquareBracketAttributes.
2018-05-07 16:26:20 -05:00
Alex Lin
f412125715 Is Trick ICG missing some uses of TRICK_ICG #608
Yes, it is, it's missing all of them.  Any clang/llvm version 3.5 and
above.  So it's been broken for a while.  We inherit from a
clang class that processes preprocessing statements.  If we override
virtual functions of a certain signature, we can inject our code into
the preprocessing process.  In this case we're looking for the use
of TRICK_ICG.  Clang changed the function signature in version 3.5.
From 3.5 on our functions were never called, so we never would find
TRICK_ICG.  I created new signatures for the functions post 3.5 so
they will work again.
2018-04-23 16:40:32 -05:00
Thadeus Fleming
db07582616 Only left-shift FieldDescription::io when io_found == true
The `io` field of `FieldDescription` takes a default value of 15. In
`FieldDescription::parseComment`, it may be updated as specified in the comment
text. There are 4 possible cases:

1) Neither IO attributes nor checkpoint IO attributes are found in the comment
2) IO attributes are found in the comment, but checkpoint IO attributes are not
3) Checkpoint IO attributes are found in the comment, but IO attributes are not
4) Both IO attributes and checkpoint IO attributes are found in the comment

In case 2, the IO attributes are copied into the checkpoint IO attributes by the
statement `io |= (io << 2)`. However, this also erroneously runs in case 1,
causing the default value of 15 to change to 63.

By testing `io_found == true`, this logic occurs only in case 2.

Fixes #568
2018-03-27 09:37:26 -05:00
Derek Bankieris
050e552d7c Update ICG for clang 6
Fixes #578
2018-03-13 09:30:01 -05:00
Alex Lin
54b57bc351 Pointers to STLs cannot be checkpointed. #552
Added code to disable printing of STLs if it is arrayed or has pointer
dimensions.
2018-01-25 09:40:23 -06:00
Alex Lin
c694700148 Add environment variable to ignore types from ICG processing #535
Added a new environment variable TRICK_ICG_IGNORE_TYPES.  Class/struct/enum
types found in this semicolon delimited list will not have attributes written
out.
2017-12-19 10:02:41 -06:00
Alex Lin
9509924b64 Don't create attributes for class members that are of private embedded class types #534
Test the class field type.  If the type is a private embedded class mark the field
as io=0 so we don't create attributes for the field.
2017-12-19 08:26:52 -06:00
Alex Lin
5285f1a72e Symbolic links rise again #530
Found more places where symbolic links cause havoc.  Also added back a #define
that was removed in parameter_types.h and added back the messaging routines to
the list swig processes.
2017-12-12 10:17:24 -06:00
Thadeus Fleming
143d0f2c41 Make object .d files order-only prerequisites
This will ensure objects are rebuilt only due to a missing dependency
file, not a newer one.

Fixes #501.
2017-11-02 12:34:48 -05:00
Alex Lin
de012dde71 Feature request: Support checkpointing and logging of std::array #480
Added std::array as an STL type Trick recognizes.  We can now create io code
that can save and restore std::arrays like std::vectors and other similar
types. Like other STL types, an std::array cannot be logged or viewed in
trick-tv.
2017-09-27 16:01:52 -05:00
Alex Lin
c6ecd76be5 ICG does not compile with llvm 5.0 #476
Added a preprocessor check for llvm version >= 5.  If true use
clang::InputKind::CXX instead of clang::IK_CXX
2017-09-13 14:07:23 -05:00
Alex Lin
70a81acc6c ICG handling of \brief in comments differs on Linux and Mac #453
Adjusted regular expression so it will work on the mac.  Changed "\w" to
"[a-zA-Z0-9]".
2017-08-21 14:03:49 -05:00
Alex Lin
9207bd0ab1 io_src makefile applying TRICK_SYSTEM_CXXFLAGS to all compilation units. #470
Changed TRICK_SYSTEM_CXXFLAGS in Makefile_io_src to TRICK_IO_CXXFLAGS.
2017-08-21 13:28:28 -05:00
Alex Lin
e2693de992 Many Trick sims SEGFAULT when built in 32-bit mode #440
Added a switch to trick-ICG to handle the -m32 flag.  When the
flag is present we tell clang to use a 32bit layout when calculating
member offsets.
2017-06-19 14:18:37 -05:00
Derek Bankieris
1dbeb3e2d4 Fix io code for classes with excluded parents
Check the return value of CXXRecordVisitor::TraverseCXXRecordDecl and
don't add information from excluded parents.
Add a parameter to PrintAttributes::isHeaderExcluded to toggle exlusion
of TRICK_EXT_LIB_DIRS paths. When traversing a CXX record, we don't
actually want to skip these paths since their io code should exist in
the Trickified library.
Fix memory leak.

Refs #435
2017-05-24 10:51:27 -05:00
Derek Bankieris
05b4d09b2b Sanitize field names when generating STL functions
A sanitizing function was already present in FieldVisitor.cpp. I
refactored and moved it to Utilities.
Refs #429
2017-05-22 10:37:20 -05:00
Derek Bankieris
fe79aa81a5 Improve printable field detection
Renamed determinePrintAttr to isPrintable.
Different callers need to filter on different IO specs, so I added an
ioMask parameter.
Additional refactoring.
Refs #427
2017-05-17 09:37:22 -05:00
Derek Bankieris
353905c1ed Generate STL functions only when requested
Remove STL prototypes. They don't appear to be necessary anymore.
Refs #427
2017-05-16 15:31:08 -05:00
Alex Lin
a11e51cce7 Sim build doesn't stop on error #421
When I added the "tee" commands to split off command outputs to
a file and the screen, I forgot that the exit status of the make commands
takes the exit status of "tee" which does not ususally have an error and
masks any error in the actual compilation.  I added an exit ${PIPESTATUS[0]}
which returns the exit status of the compilation.
2017-05-15 13:36:06 -05:00
Alex Lin
b2ebe157ed Lost the MAKE_out file when we updated simulation makefiles #412
Added echos to all compile commands to append to MAKE_out.  tee'd
the output of the compile command so that it will go to both the MAKE_out
file and the screen.
2017-04-18 10:26:58 -05:00
Derek Bankieris
b53c52ac33 Separate ICG & SWIG exclusion constructs
Refs #392
2017-03-27 15:19:43 -05:00
Derek Bankieris
73cbbd96cd Refactor ICG to report skipped files consistently
Refs #394
2017-03-15 15:53:56 -05:00
Alex Lin
b88c75631a Missing includes when using clang/llvm 4.0 #393
Added some missing header file includes.
2017-03-15 10:05:06 -05:00
Derek Bankieris
2e4c3286a3 Automatically generate dependencies with SWIG
Like gcc, swig supports all those -M options. Use them to automatically
manage *_py.cpp dependencies.
Add dependency generation to trickify.mk as well.
2017-03-14 13:38:09 -05:00
Alex Lin
a1bc45548b tool for detecting mismatch between friend init_attr and containing class #371
Added a check and warning message in ICG that warns you if a friend function
starts with "init_attr" but does not match the current class name.
2017-03-10 09:38:33 -06:00
Derek Bankieris
e6ad95f493 Grand Make Dependency Graph, part 1
Refs #360
2017-02-23 13:26:28 -06:00
Derek Bankieris
d965f4b0a8 Infer TRICK_HOME automatically
Refs #358
2017-02-10 10:29:56 -06:00
Alex Lin
337139cacb S_overrides.mk is included twice when building #360
A different approach.  Instead of trying to limit the number of times
S_overrides.mk is included, combine the makefiles so only one
call to make is made.
2017-02-09 09:46:58 -06:00
Alex Lin
38d2b10b9e 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().
2017-01-23 17:48:16 -06:00
Alex Lin
8a0653fa09 Detect when TRICK_ICG is used in header files and compensate for it. #375
clang call to addPPCallbacks changed between clang versions 3.5 and 3.6.
2017-01-12 08:42:16 -06:00
Alex Lin
9f01209316 ICG generates non-compilable io_* code for std::vector::iterator members #331
Added a test if our field is an iterator type.  If it is we cannot create io_src
code for it.  We skip it once identified.
2017-01-11 16:07:02 -06:00
Alex Lin
b60320464a Detect when TRICK_ICG is used in header files and compensate for it. #375
Always differences between clang versions.
2017-01-11 15:59:10 -06:00
Alex Lin
ba47c2048c Detect when TRICK_ICG is used in header files and compensate for it. #375
Created a hook for the clang preprocessor.  The hook does 2 things.  It
keeps track to which header files we have entered and exited.  Second it
searches for the use of TRICK_ICG.  If we find an instance of TRICK_ICG we
mark all of the included files from this point up the chain as requiring
compensation.  To compensate for using TRICK_ICG we write out the older
offset statements to get the location of variables in classes/structures.
2017-01-11 15:02:21 -06:00
Thadeus Fleming
fb1925e0d8 Use std::cerr instead of std::cout for error messages 2016-12-10 11:49:44 -06:00
Michael Vetter
18f0d7e871 Remove trailing whitespaces
Makes it easier to edit the files. So if we press 'end of line' we are
really at the end of line.
2016-11-08 10:25:07 +01:00
Alex Lin
d875f837f2 ICG produces non-compilable io_* code for this weird example #334
When saving the list of namespaces and classes a particular type is contained in
we have to save the class name and any template args it includes separately.  This
allows us to mangle the names easier.  And we now search for type names to see
if they follow this pattern template_name<template_args>::embedded_class.  If
we are using a template embedded class we need to create attributes for the embedded class.
2016-11-02 13:56:40 -05:00
Derek Bankieris
664797e391 Move one-time-use variables into their call site #341 2016-10-31 10:00:48 -05:00
Derek Bankieris
29b0d2d223 Alex doesn't like auto #341
Granted, there are times you shouldn't hide the type.
2016-10-31 09:51:44 -05:00
Derek Bankieris
5898f3fdec Improve loop efficiency #341
Calling getTemplateArgs() every iteration is wasteful. This should
be done once outside of the loop. Even better, use a foreach loop and
get rid of the index varible!
2016-10-31 09:34:24 -05:00
Derek Bankieris
bdcfbb4e3a Restore debug functions #341 2016-10-31 09:10:33 -05:00
Derek Bankieris
ef1405c3be Refactor ICG
Hey buddy. I wanted to tell you this before you heard it from someone
else...

I refactored ICG.

Now, it's gonna look a little scary at first. But I promise you'll like
it when you get used to it. It'll be fine. You can trust me. #341
2016-10-28 14:37:12 -05:00
Alex Lin
ba75f6ff37 ICG does not compile using llvm 3.9 #339
The call getRBraceLoc to find the ending source location of things is gone.  Replaced
it with getting the source range and get the end of that range.  Also the way to
get clang/llvm 3.9 to process c++11 code required some reordering of calls in main as
well as adding some more features to be turned on.
2016-10-28 13:21:21 -05:00
Derek Bankieris
0ba68e40aa Merge branch 'master' of https://github.com/nasa/trick
Conflicts:
	trick_source/codegen/Interface_Code_Gen/main.cpp
2016-10-21 15:15:41 -05:00
Derek Bankieris
015965abab Renamed most variabes so that they are self-descriptive. Stop using abbreviations! No one can tell what anything is.
Applied a consistent formatting.
Inlined several one-off variables.
2016-10-21 15:06:44 -05:00
Derek Bankieris
108d3d40c5 Added a version of almostRealPath that takes a const std::string& parameter so we don't have to use c_str() everywhere 2016-10-21 15:06:35 -05:00
Derek Bankieris
75c35752d6 Spacing 2016-10-21 15:05:26 -05:00
Alex Lin
a2452aacd0 ICG creates offsetof statements that will not compile when using clang #327
When copying inherited variables to a child class in ICG, the inherited flags
were not being set on the mac.
2016-10-21 13:13:43 -05:00
Alex Lin
f1cbacd646 ICG exclude of class member variables now defines incorrect memory offsets in io_src #311
This changes back the default behavior to not use offsetof in io_src code.
Added a flag to ICG, -c or --compat15, to globally generate offsetof statements.
Added an ENV variable that can be used to generate offsetof statements by file or directory.
Added in a warning if classes parsed at ICG time are different in size than at runtime.
2016-10-21 13:13:43 -05:00
Derek Bankieris
bcb421678a Fix spacing. Move declaration of loop variable into loop initializer. Rename stupid 1337 variable. 2016-10-21 10:49:11 -05:00
Derek Bankieris
2279ba8648 Restore print out when compiling io_* files #326 2016-10-21 09:20:50 -05:00
Derek Bankieris
4f49460a6f Clean up io_* code #330 2016-10-20 14:55:00 -05:00
Derek Bankieris
beb93f7e88 Removed useless local alias, eliminating the need to silence set but unused variable warnings #326 2016-10-20 14:55:00 -05:00
Derek Bankieris
2fb06cf133 Got rid of the individual io, py, and model conglomerate objects #326
Link all of the objects as part of the S_MAIN target using the link lists.
Renamed some variables and files to make them more self-descriptive.
2016-10-18 13:06:42 -05:00
Alex Lin
23af89681e ICG creates offsetof statements that will not compile when using clang #327
Added a check that was in 15 that tested the platform we are running on.  If we
are on an mac, we want to skip fully qualifying variable names because it creates
code that doesn't compile under clang.
2016-10-12 13:34:04 -05:00
Derek Bankieris
054245f968 Forgot to remove this debugging print out before the last commit 2016-10-06 14:28:06 -05:00
Derek Bankieris
f161ddb18c Made everything about Trick's build process better 2016-10-06 13:54:06 -05:00
Alex Lin
bbba26e057 Merge branch '17.0' 2016-09-16 09:50:12 -05:00
Alex Lin
00a0e8be44 ICG exclude of class member variables now defines incorrect memory offsets in io_src #311
Missed some bitfield offset calculations.
2016-09-16 09:46:03 -05:00
Alex Lin
c134ffea8f Merge branch '17.0' 2016-09-16 08:43:47 -05:00
Alex Lin
ae07b26243 ICG exclude of class member variables now defines incorrect memory offsets in io_src #311
Added back the code that set the offset of variables with the offsetof function. This
code is running by default.  Any code that includes #ifndef TRICK_ICG in
classes/structures will want this on.

Added a flag to ICG that allows us to turn off writing of these lines.  If the flag
is present, ICG may write out io_src code for private/protected variables that it could
not reach if an offsetof function was required.  Code cannot have any #ifndef TRICK_ICG
present in classes/structures for this to work.
2016-09-16 08:39:37 -05:00
Alex Lin
b2432fd269 Trickified Project Libraries #309
We were ignoring classes completely if it was found in to be in an external library
directory.  We need to partially process it so it is included in the ICG generated
class_map file which registers attributes of classes and eventually works it's way
to populating the S_sie file.
2016-09-15 14:48:23 -05:00
Alex Lin
9801e3d210 ICG not setting default checkpointing io correctly. #308
If a checkpoint_io field is found we were or'ing this in to bits already
set by default.  Clear the bits first.
2016-09-14 09:38:28 -05:00
Alex Lin
256c83a876 ICG not setting default checkpointing io correctly. #308
Changed the default io value from 3 which left out checkpointing to 15 which does
include checkpointing.
2016-09-13 16:37:59 -05:00
Alex Lin
919a8e2068 Variable using an enumeration as array index causes infinite loop #299
Once we determine the type of a variable we should stop processing the
AST tree at that point. We do this for record types but not for the
built in types.  Changed the return value of the process builtin
function to false so we stop processing.
2016-09-01 16:06:33 -05:00
Alex Lin
858602fe01 New STL framework doesn't support const #293
So using consts as arguments to STLs causes errors in our io code and SWIG.
Added a check for const template arguments and going to ignore them for
both ICG and what we input to SWIG.
2016-08-25 08:42:43 -05:00
Alex Lin
82049ead95 Add a printout when ICG parses header file with no Trick header comment #281
Added the printout.
2016-08-19 10:04:42 -05:00
Alex Lin
b26fcf2f3b Swap order of libraries during ICG linking. #277
Order swapped.
2016-08-03 09:03:41 -05:00
Alex Lin
89fda63293 Remove doxygen documentation now housed on wiki #189
moved all of the design documentation to the wiki
2016-08-02 17:50:49 -05:00
Alex Lin
ca02209d8f man pages completely out of date #253
Created man pages for each executable we have in bin.  Updated the
couple of man pages we did have in there.  Modified trick-CP
to accept arguments.  Updated the version number reported by ICG
as well.
2016-08-02 09:56:43 -05:00
Alex Lin
f7d1ff6376 ICG fails to compile on Mac when using clang/llvm 3.8.1. #271
Modified the makefile to define LIBCLANG_MAJOR, LIBCLANG_MINOR, and
LIBCLANG_PATCHLEVEL based on the llvm-config executable in the llvm
directory pointed to by the configuration.  These new variable names
are independent of the __clang_major__, etc. variables we were defining
only in Linux.  Using these names, we can reduce the clang version
checks to a single consistent set of version numbers.  We don't have
to deal with the different version numbers assigned by Apple.
2016-07-25 14:57:07 -05:00
Alex Lin
6e5beec9e1 Support clang releases that do not define a patchlevel.
Modified the makefile that creates the __clang_patchlevel__ define to
only create the variable if it is present in the clang version.

refs #266
2016-07-06 15:04:15 -05:00
Alex Lin
1731390c98 Switch compilation of ICG from clang++ to g++
Removed the lines that set the compiler to clang++, defaulting
it to g++.  Added lines in the makefile to set __clang_major__,
__clang_minor__, and __clang_patchlevel__.  These are required
to compile several of the files in the ICG directory.

refs #259
2016-06-29 17:33:04 -05:00
Alex Lin
1224c43e7f Set and use LD in our makefiles correctly.
Set LD in our makefiles to the ld executable found by configure.
Changed the final sim link to use TRICK_CPPC as the link command since
it was using the compiler anyways.  Changed the places where we use "ld" to
use LD.

refs #131
2016-06-27 12:48:35 -05:00
Alex Lin
fcb63e0e06 Output "--" if that was specified in the header file.
Used the mods field in the attributes to indicate of "--" was specified in the header file.  We
still save the units as "1" to keep it compatible with udunits.  When outputting the variable
in data recording or variable server we check to see if the mods field for "--" is set.  We
output "--" if the mods field is set.  Also allowed "--" to persist in data products.

refs #254
2016-06-21 16:12:28 -05:00
Alex Lin
c9e3bc77da er7_util header files not being installed
Added a makefile install rule to copy the header files out of
er7_utils to the install directory.  Adjusted ICG to ignore
Trick header files if they are installed.

refs #246
2016-06-20 13:40:45 -05:00
John M. Penn
af8548ce6a Exclude /sw (Fink directories from being processed by ICG. Refs#248 2016-06-10 14:52:19 -05:00
Alex Lin
1615e0f13b ICG should ignore FILE * variables
In ICG if we encounter a FILE * variable, we ignore it setting the IO specification to 0.

refs #244
2016-06-02 08:50:18 -05:00
Alex Lin
3e82f79f28 Use udunits package for units conversions.
FieldDescription.cpp is missing and include for stack.  Strange it compiles
on most platforms.

refs #231
2016-05-18 08:26:14 -05:00
Alex Lin
929372e863 Use udunits package for units conversions
Created a UDUNITS_LDFLAGS to store an link library path and -luduints2.

refs #231
2016-05-11 14:43:53 -05:00
Alex Lin
01fd86a513 Use udunits package for units conversions
Needed to add UDUNITS_INCLUDES to the ICG makefile and remove
the hardcoded udunits include path

refs #231
2016-05-11 11:27:39 -05:00
Alex Lin
26cb44e946 Use udunits package for units conversions
So our unit tests did their job, they pointed to quite a few errors.
Fixed them all on my platform (CentOS 7).

refs #231
2016-05-11 09:01:54 -05:00
Alex Lin
d72aa59fdd Use udunits package for units conversions
Converted data products to use udunits.

refs #231
2016-05-10 14:45:31 -05:00
Alex Lin
6defa99b34 Use udunits package for units conversions
Changed the include for udunits to #include <udunits2.h> to work
on all platforms.  Added the include directory /usr/include/udunits2
for Linux.

refs #231
2016-05-09 10:23:19 -05:00
Alex Lin
684f0e6bdc Use udunits package for units conversions
Initial checkin of using udunits for measurement units conversions.  Replaced
our conversion code in ICG and swig code to use udunits.

Also added code to convert unit symbols that we used in Trick that are different
names in udunits.

Added a sim_object that will eventually allow users to specify a custom
set of files to read units information.

refs #231
2016-05-05 14:49:49 -05:00
Alex Lin
9e743ffa92 Invoking trick-ICG without any arguments results in a Segmentation fault
ICG dies on a strdup if the the input file is empty.  Added a check for
an empty input file name.  We exit with an error message if there is
no input file given.

refs #229
2016-04-27 11:24:03 -05:00
Alex Lin
2381c487d1 Build fails on Ubuntu 16.04
clang changed a call in 3.8.0 from uppercase to lowercase.  I changed
pp.getBuiltinInfo().InitializeBuiltins to pp.getBuiltinInfo().initializeBuiltins

refs #174
2016-04-18 15:22:52 -05:00
Alex Lin
d6e01ee1c4 Ignore privacy
We need to exclude STL or other template io_src code being created with they use
a protected/private enumerations, just like classes.  Also remove a check for
a static bitfield, because you can't have a static bitfield.

refs #218
2016-04-15 15:01:14 -05:00
Alex Lin
3ae6fc50e1 Ignore privacy
I moved the item size into the attribute structure itself.  When moving this, I did not follow
what was written before.  The difference caused problems.  Fixed it so the size
written now matches what was written before.

refs #218
2016-04-14 09:22:23 -05:00
Alex Lin
54591ec005 Ignore privacy
Found some of those uncommon cases like inheriting from templates which contain
private embedded classes.

refs #218
2016-04-13 16:07:16 -05:00
Alex Lin
6ea18b425d Ignore privacy
Removed an #if 0 section of code.

refs #218
2016-04-13 16:07:15 -05:00
Alex Lin
f63f44d876 Ignore privacy
Changed the storage of offsets from bytes to bits to better handle bitfields.
Added code to track classes that are defined within other classes and are
private/protected.  These classes cannot be used in templates because our
io_src code declares variables outside of the class that would try and use
these private/protected variables.  When a template is found to use a
private/protected class it is skipped.

refs #218
2016-04-13 16:07:15 -05:00