void DeprecatedIosBaseAliasesCheck::check( const MatchFinder::MatchResult &Result) { SourceManager &SM = *Result.SourceManager; const auto *Typedef = Result.Nodes.getNodeAs<TypedefDecl>("TypeDecl"); StringRef TypeName = Typedef->getName(); bool HasReplacement = ReplacementTypes.count(TypeName); const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("TypeLoc"); SourceLocation IoStateLoc = TL->getBeginLoc(); // Do not generate fixits for matches depending on template arguments and // macro expansions. bool Fix = HasReplacement && !TL->getType()->isDependentType(); if (IoStateLoc.isMacroID()) { IoStateLoc = SM.getSpellingLoc(IoStateLoc); Fix = false; } SourceLocation EndLoc = IoStateLoc.getLocWithOffset(TypeName.size() - 1); if (HasReplacement) { auto FixName = ReplacementTypes.lookup(TypeName); auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use " "'std::ios_base::%1' instead") << TypeName << FixName; if (Fix) Builder << FixItHint::CreateReplacement(SourceRange(IoStateLoc, EndLoc), FixName); } else diag(IoStateLoc, "'std::ios_base::%0' is deprecated") << TypeName; }
static void hide(llvm::StringMap<cl::Option *> &map, const char *name) { // Check if option exists first for resilience against LLVM changes // between versions. if (map.count(name)) { map[name]->setHiddenFlag(cl::Hidden); } }
llvm::Constant* embedRelocatablePtr(const void* addr, llvm::Type* type, llvm::StringRef shared_name) { assert(addr); if (!ENABLE_JIT_OBJECT_CACHE) return embedConstantPtr(addr, type); std::string name; if (!shared_name.empty()) { llvm::GlobalVariable* gv = g.cur_module->getGlobalVariable(shared_name, true); if (gv) return gv; assert(!relocatable_syms.count(name)); name = shared_name; } else { name = (llvm::Twine("c") + llvm::Twine(relocatable_syms.size())).str(); } relocatable_syms[name] = addr; llvm::Type* var_type = type->getPointerElementType(); return new llvm::GlobalVariable(*g.cur_module, var_type, true, llvm::GlobalVariable::ExternalLinkage, 0, name); }