void Rule_18_7_1::registerPPCallbacksImpl() { using BannedIncludePPCallback = common::BannedInclude<Rule_18_7_1>; getPreprocessor().addPPCallbacks(::llvm::make_unique<BannedIncludePPCallback>( *this, BannedIncludePPCallback::StringSet{"csignal"})); using BannedMacroPPCallback = common::BannedMacro<Rule_18_7_1>; getPreprocessor().addPPCallbacks(::llvm::make_unique<BannedMacroPPCallback>( *this, BannedMacroPPCallback::StringSet{ "SIGABRT", "SIGFPE", "SIGILL", "SIGINT", "SIGSEGV", "SIGTERM", "SIG_DFL", "SIG_IGN", "SIG_ERR"})); }
void SlangRS::initASTContext() { mRSContext = new RSContext(getPreprocessor(), getASTContext(), getTargetInfo(), &mPragmas, mTargetAPI, &mGeneratedFileNames); }
void SlangRS::initPreprocessor() { clang::Preprocessor &PP = getPreprocessor(); std::stringstream RSH; RSH << "#define RS_VERSION " << mTargetAPI << std::endl; RSH << "#include \"rs_core." RS_HEADER_SUFFIX "\"" << std::endl; PP.setPredefines(RSH.str()); }
void SlangRS::initASTContext() { mRSContext = new RSContext(getPreprocessor(), getASTContext(), getTargetInfo(), &mPragmas, mTargetAPI, mVerbose); }
ClangCompiler::ClangCompiler(const std::string& file_name) : pimpl(new ClangCompilerImpl) { setDiagnosticClient(pimpl->clang); pimpl->clang.createFileManager(); pimpl->clang.createSourceManager( pimpl->clang.getFileManager() ); // A compiler invocation object has to be created in order for the diagnostic object to work CompilerInvocation* CI = new CompilerInvocation; // CompilerInvocation will be deleted by CompilerInstance CompilerInvocation::CreateFromArgs(*CI, 0, 0, pimpl->clang.getDiagnostics()); pimpl->clang.setInvocation(CI); //setup headers pimpl->clang.getHeaderSearchOpts().UseBuiltinIncludes = 0; pimpl->clang.getHeaderSearchOpts().UseStandardSystemIncludes = 1; // Includes system includes, usually /usr/include pimpl->clang.getHeaderSearchOpts().UseStandardCXXIncludes = 0; // Add default header pimpl->clang.getHeaderSearchOpts().AddPath (CLANG_SYSTEM_INCLUDE_FOLDER, clang::frontend::System, true, false, false); // fix the target architecture to be a 64 bit machine pimpl->TO->Triple = llvm::Triple("x86_64", "PC", "Linux").getTriple(); // TO.Triple = llvm::sys::getHostTriple(); pimpl->clang.setTarget( TargetInfo::CreateTargetInfo (pimpl->clang.getDiagnostics(), *(pimpl->TO)) ); std::string extension(file_name.substr(file_name.rfind('.')+1, std::string::npos)); bool enableCpp = extension == "C" || extension == "cpp" || extension == "cxx" || extension == "hpp" || extension == "hxx"; LangOptions& LO = pimpl->clang.getLangOpts(); LO.GNUMode = 1; LO.Bool = 1; LO.POSIXThreads = 1; // if(CommandLineOptions::STD == "c99") LO.C99 = 1; // set c99 if(enableCpp) { LO.CPlusPlus = 1; // set C++ 98 support LO.CXXOperatorNames = 1; //if(CommandLineOptions::STD == "c++0x") { // LO.CPlusPlus0x = 1; // set C++0x support //} LO.RTTI = 1; LO.Exceptions = 1; LO.CXXExceptions = 1; } // Do this AFTER setting preprocessor options pimpl->clang.createPreprocessor(); pimpl->clang.createASTContext(); getPreprocessor().getBuiltinInfo().InitializeBuiltins( getPreprocessor().getIdentifierTable(), getPreprocessor().getLangOpts() ); std::cout << file_name << std::endl; const FileEntry *FileIn = pimpl->clang.getFileManager().getFile(file_name, true); assert(FileIn && "file not found"); pimpl->clang.getSourceManager().createMainFileID(FileIn); pimpl->clang.getDiagnosticClient().BeginSourceFile( pimpl->clang.getLangOpts(), &pimpl->clang.getPreprocessor()); }
void GetRexxBlock( ss_block *ss_new, char *start, line *line, linenum line_no ) { line = line; line_no = line_no; if( start[0] == '\0' ) { if( firstNonWS == start ) { // line is empty - // do not flag following line as having anything to do // with an unterminated " or # or // from previous line flags.inString = flags.inPreprocessor = flags.inCPPComment = false; } getBeyondText( ss_new ); return; } if( flags.inCComment ) { getCComment( ss_new, start, 0 ); return; } if( flags.inCPPComment ) { getCPPComment( ss_new, start ); return; } if( flags.inPreprocessor ) { getPreprocessor( ss_new, start ); return; } if( flags.inString ) { getString( ss_new, start, 0 ); return; } if( isspace( start[0] ) ) { getWhiteSpace( ss_new, start ); return; } if( *firstNonWS == '#' && (!EditFlags.PPKeywordOnly || firstNonWS == start) ) { getPreprocessor( ss_new, start ); return; } switch( start[0] ) { case '"': getString( ss_new, start, 1 ); return; case '/': if( start[1] == '*' ) { getCComment( ss_new, start, 2 ); return; } else if( start[1] == '/' ) { getCPPComment( ss_new, start ); return; } break; case '\'': getChar( ss_new, start, 1 ); return; case 'L': if( start[1] == '\'' ) { // wide char constant getChar( ss_new, start, 2 ); return; } break; case '.': if( isdigit( start[1] ) ) { getFloat( ss_new, start, 1, AFTER_DOT ); return; } break; case '0': if( start[1] == 'x' || start[1] == 'X' ) { getHex( ss_new, start ); return; } else { getNumber( ss_new, start, '7' ); return; } break; } if( issymbol( start[0] ) ) { getSymbol( ss_new ); return; } if( isdigit( start[0] ) ) { getNumber( ss_new, start, '9' ); return; } if( isalpha( *start ) || ( *start == '_' ) ) { getText( ss_new, start ); return; } getInvalidChar( ss_new ); }
void Rule_18_2_1::registerPPCallbacksImpl() { using BannedMacroPPCallback = common::BannedMacro<Rule_18_2_1>; getPreprocessor().addPPCallbacks(::llvm::make_unique<BannedMacroPPCallback>( *this, BannedMacroPPCallback::StringSet{"offsetof"})); }