mirror of
https://github.com/nasa/trick.git
synced 2025-06-22 00:41:52 +00:00
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.
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "TranslationUnitVisitor.hh"
|
||||
#include "PrintAttributes.hh"
|
||||
#include "Utilities.hh"
|
||||
#include "FindTrickICG.hh"
|
||||
|
||||
/* Command line arguments. These work better as globals, as suggested in llvm/CommandLine documentation */
|
||||
llvm::cl::list<std::string> include_dirs("I", llvm::cl::Prefix, llvm::cl::desc("Include directory"), llvm::cl::value_desc("directory"));
|
||||
@ -41,6 +42,7 @@ llvm::cl::list<std::string> sink(llvm::cl::Sink, llvm::cl::ZeroOrMore);
|
||||
llvm::cl::list<std::string> pre_compiled_headers("include", llvm::cl::Prefix, llvm::cl::desc("pre-compiled headers"), llvm::cl::value_desc("pre_compiled_headers"));
|
||||
|
||||
llvm::cl::opt<bool> global_compat15("c", llvm::cl::desc("Print the offsetof calculations in attributes")) ;
|
||||
llvm::cl::opt<llvm::cl::boolOrDefault> print_trick_icg("print-TRICK-ICG", llvm::cl::desc("Print warnings where TRICK_ICG may cause io_src inconsistencies")) ;
|
||||
llvm::cl::alias compat15_alias ("compat15" , llvm::cl::desc("Alias for -c") , llvm::cl::aliasopt(global_compat15)) ;
|
||||
|
||||
/**
|
||||
@ -125,6 +127,10 @@ int main(int argc, char * argv[]) {
|
||||
HeaderSearchDirs hsd(ci.getPreprocessor().getHeaderSearchInfo(), ci.getHeaderSearchOpts(), pp, sim_services_flag);
|
||||
hsd.addSearchDirs(include_dirs);
|
||||
|
||||
// Add a preprocessor callback to search for TRICK_ICG
|
||||
FindTrickICG * ftg = new FindTrickICG(ci, hsd, print_trick_icg != llvm::cl::BOU_FALSE ) ;
|
||||
pp.addPPCallbacks(ftg) ;
|
||||
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 8))
|
||||
pp.getBuiltinInfo().initializeBuiltins(pp.getIdentifierTable(), pp.getLangOpts());
|
||||
#else
|
||||
|
Reference in New Issue
Block a user