From 5004f95fdd5d26e0f9efdd938a1d471819c26cb6 Mon Sep 17 00:00:00 2001 From: sfennell Date: Fri, 27 Sep 2019 14:58:54 -0500 Subject: [PATCH] changes to support llvm 9.0 closes #869 --- bin/trick-CP | 2 +- trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp | 8 ++------ trick_source/codegen/Interface_Code_Gen/main.cpp | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/bin/trick-CP b/bin/trick-CP index 2a0b0080..efdd81d7 100755 --- a/bin/trick-CP +++ b/bin/trick-CP @@ -197,7 +197,7 @@ ICG: force_ICG: $(PRINT_ICG) - $(call ECHO_AND_LOG,${TRICK_HOME}/bin/trick-ICG -f -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh) + $(call ECHO_AND_LOG,${TRICK_HOME}/bin/trick-ICG -force -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh) # Create makefile for IO code build/Makefile_io_src: S_source.hh | build diff --git a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp index 7dfc3ce4..d081518c 100644 --- a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp @@ -43,13 +43,9 @@ void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRan { if ( ConditionRange.isValid() ) { // Get the full text of the if statement into a string - clang::FullSourceLoc fsl_begin(ConditionRange.getBegin() , ci.getSourceManager()) ; - clang::FullSourceLoc fsl_end(ConditionRange.getEnd() , ci.getSourceManager()) ; - std::string if_text( fsl_begin.getCharacterData() , - (size_t)(fsl_end.getCharacterData() - fsl_begin.getCharacterData())) ; - + llvm::StringRef ref = clang::Lexer::getSourceText(clang::CharSourceRange::getCharRange(ConditionRange), ci.getSourceManager(), clang::LangOptions()); // if the if statement contains TRICK_ICG we need to mark it. - if ( if_text.find("TRICK_ICG") != std::string::npos ) { + if ( ref.str().find("TRICK_ICG") != std::string::npos ) { // for each header in the stack, mark them as being exposed to TRICK_ICG std::vector::iterator it ; for ( it = included_files.begin() ; it != included_files.end() ; it++ ) { diff --git a/trick_source/codegen/Interface_Code_Gen/main.cpp b/trick_source/codegen/Interface_Code_Gen/main.cpp index 743476c7..f8ea7e92 100644 --- a/trick_source/codegen/Interface_Code_Gen/main.cpp +++ b/trick_source/codegen/Interface_Code_Gen/main.cpp @@ -29,18 +29,18 @@ /* Command line arguments. These work better as globals, as suggested in llvm/CommandLine documentation */ llvm::cl::list include_dirs("I", llvm::cl::Prefix, llvm::cl::desc("Include directory"), llvm::cl::value_desc("directory")); +llvm::cl::list f_options("f", llvm::cl::Prefix, llvm::cl::desc("Compiler options that have f prefix"), llvm::cl::value_desc("option")); llvm::cl::list isystem_dirs("isystem", llvm::cl::Prefix, llvm::cl::desc("Include directory, suppress all warnings"), llvm::cl::value_desc("directory")); llvm::cl::list defines("D", llvm::cl::Prefix, llvm::cl::desc("Defines"), llvm::cl::value_desc("define")); // TODO: remove units_truth_is_scary in 2021. llvm::cl::opt units_truth_is_scary("units-truth-is-scary", llvm::cl::desc("DEPRECATED: Don't print units conversion messages")); llvm::cl::opt sim_services_flag("s", llvm::cl::desc("Gernerate io_src for Trick core headers")); -llvm::cl::opt force("f", llvm::cl::desc("Force all io_src files to be generated")); +llvm::cl::opt force("force", llvm::cl::desc("Force all io_src files to be generated")); llvm::cl::opt attr_version("v", llvm::cl::desc("Select version of attributes to produce. 10 and 13 are valid"), llvm::cl::init(10)); llvm::cl::opt debug_level("d", llvm::cl::desc("Set debug level"), llvm::cl::init(0), llvm::cl::ZeroOrMore); llvm::cl::opt create_map("m", llvm::cl::desc("Create map files"), llvm::cl::init(false)); llvm::cl::opt output_dir("o", llvm::cl::desc("Output directory")); llvm::cl::alias ssf_alias("sim_services" , llvm::cl::desc("Alias for -s") , llvm::cl::aliasopt(sim_services_flag)); -llvm::cl::alias force_alias("force" , llvm::cl::desc("Alias for -f") , llvm::cl::aliasopt(force)); llvm::cl::list input_file_names(llvm::cl::Positional, llvm::cl::desc(""), llvm::cl::ZeroOrMore); llvm::cl::list sink(llvm::cl::Sink, llvm::cl::ZeroOrMore); llvm::cl::list pre_compiled_headers("include", llvm::cl::Prefix, llvm::cl::desc("pre-compiled headers"), llvm::cl::value_desc("pre_compiled_headers"));