void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const { SourceLocation TheLoc = Loc; if (TheLoc.isInvalid() && TheDecl) TheLoc = TheDecl->getLocation(); if (TheLoc.isValid()) { TheLoc.print(OS, SM); OS << ": "; } OS << Message; if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(TheDecl)) OS << " '" << DN->getQualifiedNameAsString() << '\''; OS << '\n'; }
void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const { SourceLocation Loc = this->Loc; if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation(); if (Loc.isValid()) { Loc.print(OS, S.getSourceManager()); OS << ": "; } OS << Message; if (TheDecl && isa<NamedDecl>(TheDecl)) { std::string Name = cast<NamedDecl>(TheDecl)->getNameAsString(); if (!Name.empty()) OS << " '" << Name << '\''; } OS << '\n'; }
virtual void run(const MatchFinder::MatchResult &Result) { if (const DeclRefExpr *drExpr = Result.Nodes.getNodeAs<DeclRefExpr>("declRefExpr")) { const FunctionDecl *fd = Result.Nodes.getNodeAs<FunctionDecl>("functionDecl"); if (fd == mFunctionDecl) { const NamedDecl *foundDecl = drExpr->getFoundDecl(); SourceLocation location = foundDecl->getLocation(); if (!Result.Context->getSourceManager().isInMainFile(location)) { llvm::outs() << "DeclRefExpr: " << drExpr->getDecl()->getName() << " in " << fd->getName() << "\n"; location.print(llvm::outs(), Result.Context->getSourceManager()); llvm::outs() << "\n"; } } } }
void UnnecessaryIncludeFinder::InclusionDirective ( SourceLocation hashLoc, const Token& includeToken, StringRef fileName, bool isAngled, const FileEntry* pFile, SourceLocation endLoc, const SmallVectorImpl<char>& rawPath) #endif { std::string directiveLocation; raw_string_ostream rso(directiveLocation); hashLoc.print(rso, sourceManager_); rso.flush(); // Remember #include directive that included the file. IncludeDirective::Ptr pIncludeDirective( new IncludeDirective(directiveLocation, fileName, isAngled)); fileToIncludeDirectiveMap_.erase(pFile); fileToIncludeDirectiveMap_.insert(std::make_pair(pFile, pIncludeDirective)); }
std::string SynthesizeRemovalConsumer::loc(SourceLocation L) { std::string src; llvm::raw_string_ostream sst(src); L.print(sst, astContext->getSourceManager()); return sst.str(); }
void Preprocessor::DumpLocation(SourceLocation Loc) const { Loc.print(llvm::errs(), SourceMgr); }