diff options
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/HTMLDiagnostics.cpp | 35 | ||||
-rw-r--r-- | lib/Frontend/PlistDiagnostics.cpp | 35 |
2 files changed, 40 insertions, 30 deletions
diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp index 0b266cda0f..fbca057849 100644 --- a/lib/Frontend/HTMLDiagnostics.cpp +++ b/lib/Frontend/HTMLDiagnostics.cpp @@ -130,12 +130,12 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { if (noDir) return; - SourceManager &SMgr = D.begin()->getLocation().getManager(); + const SourceManager &SMgr = D.begin()->getLocation().getManager(); FileID FID; // Verify that the entire path is from the same FileID. for (PathDiagnostic::const_iterator I = D.begin(), E = D.end(); I != E; ++I) { - FullSourceLoc L = I->getLocation().getInstantiationLoc(); + FullSourceLoc L = I->getLocation().asLocation().getInstantiationLoc(); if (FID.isInvalid()) { FID = SMgr.getFileID(L); @@ -162,7 +162,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { return; // FIXME: Emit a warning? // Create a new rewriter to generate HTML. - Rewriter R(SMgr); + Rewriter R(const_cast<SourceManager&>(SMgr)); // Process the path. unsigned n = D.size(); @@ -215,18 +215,18 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { llvm::raw_string_ostream os(s); os << "<!-- REPORTHEADER -->\n" - << "<h3>Bug Summary</h3>\n<table class=\"simpletable\">\n" + << "<h3>Bug Summary</h3>\n<table class=\"simpletable\">\n" "<tr><td class=\"rowname\">File:</td><td>" - << html::EscapeText(DirName) - << html::EscapeText(Entry->getName()) - << "</td></tr>\n<tr><td class=\"rowname\">Location:</td><td>" - "<a href=\"#EndPath\">line " - << (*D.rbegin()).getLocation().getInstantiationLineNumber() - << ", column " - << (*D.rbegin()).getLocation().getInstantiationColumnNumber() - << "</a></td></tr>\n" - "<tr><td class=\"rowname\">Description:</td><td>" - << D.getDescription() << "</td></tr>\n"; + << html::EscapeText(DirName) + << html::EscapeText(Entry->getName()) + << "</td></tr>\n<tr><td class=\"rowname\">Location:</td><td>" + "<a href=\"#EndPath\">line " + << (*D.rbegin()).getLocation().asLocation().getInstantiationLineNumber() + << ", column " + << (*D.rbegin()).getLocation().asLocation().getInstantiationColumnNumber() + << "</a></td></tr>\n" + "<tr><td class=\"rowname\">Description:</td><td>" + << D.getDescription() << "</td></tr>\n"; // Output any other meta data. @@ -280,7 +280,8 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { std::string s; llvm::raw_string_ostream os(s); os << "\n<!-- BUGLINE " - << D.back()->getLocation().getInstantiationLineNumber() << " -->\n"; + << D.back()->getLocation().asLocation().getInstantiationLineNumber() + << " -->\n"; R.InsertStrBefore(SMgr.getLocForStartOfFile(FID), os.str()); } @@ -336,7 +337,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, // For now, just draw a box above the line in question, and emit the // warning. - FullSourceLoc Pos = P.getLocation(); + FullSourceLoc Pos = P.getLocation().asLocation(); if (!Pos.isValid()) return; @@ -460,7 +461,7 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, // Get the name of the macro by relexing it. { - FullSourceLoc L = MP->getLocation().getInstantiationLoc(); + FullSourceLoc L = MP->getLocation().asLocation().getInstantiationLoc(); assert(L.isFileID()); std::pair<const char*, const char*> BufferInfo = L.getBufferData(); const char* MacroName = L.getDecomposedLoc().second + BufferInfo.first; diff --git a/lib/Frontend/PlistDiagnostics.cpp b/lib/Frontend/PlistDiagnostics.cpp index 0c146e54c2..75fad19806 100644 --- a/lib/Frontend/PlistDiagnostics.cpp +++ b/lib/Frontend/PlistDiagnostics.cpp @@ -40,7 +40,7 @@ namespace { ~PlistDiagnostics(); void HandlePathDiagnostic(const PathDiagnostic* D); - PathGenerationScheme getGenerationScheme() const { return Extensive; } + PathGenerationScheme getGenerationScheme() const { return Minimal; } bool supportsLogicalOpControlFlow() const { return true; } bool supportsAllBlockEdges() const { return true; } }; @@ -56,7 +56,7 @@ clang::CreatePlistDiagnosticClient(const std::string& s, } static void AddFID(FIDMap &FIDs, llvm::SmallVectorImpl<FileID> &V, - SourceManager* SM, SourceLocation L) { + const SourceManager* SM, SourceLocation L) { FileID FID = SM->getFileID(SM->getInstantiationLoc(L)); FIDMap::iterator I = FIDs.find(FID); @@ -65,7 +65,8 @@ static void AddFID(FIDMap &FIDs, llvm::SmallVectorImpl<FileID> &V, V.push_back(FID); } -static unsigned GetFID(const FIDMap& FIDs, SourceManager* SM, SourceLocation L){ +static unsigned GetFID(const FIDMap& FIDs, const SourceManager* SM, + SourceLocation L) { FileID FID = SM->getFileID(SM->getInstantiationLoc(L)); FIDMap::const_iterator I = FIDs.find(FID); assert(I != FIDs.end()); @@ -77,7 +78,7 @@ static llvm::raw_ostream& Indent(llvm::raw_ostream& o, const unsigned indent) { return o; } -static void EmitLocation(llvm::raw_ostream& o, SourceManager* SM, +static void EmitLocation(llvm::raw_ostream& o, const SourceManager* SM, SourceLocation L, const FIDMap& FM, const unsigned indent) { @@ -91,8 +92,15 @@ static void EmitLocation(llvm::raw_ostream& o, SourceManager* SM, Indent(o, indent) << "</dict>\n"; } -static void EmitRange(llvm::raw_ostream& o, SourceManager* SM, SourceRange R, - const FIDMap& FM, const unsigned indent) { +static void EmitLocation(llvm::raw_ostream& o, const SourceManager* SM, + const PathDiagnosticLocation &L, const FIDMap& FM, + const unsigned indent) { + EmitLocation(o, SM, L.asLocation(), FM, indent); +} + +static void EmitRange(llvm::raw_ostream& o, const SourceManager* SM, + SourceRange R, const FIDMap& FM, + const unsigned indent) { Indent(o, indent) << "<array>\n"; EmitLocation(o, SM, R.getBegin(), FM, indent+1); @@ -120,7 +128,7 @@ static llvm::raw_ostream& EmitString(llvm::raw_ostream& o, static void ReportControlFlow(llvm::raw_ostream& o, const PathDiagnosticControlFlowPiece& P, - const FIDMap& FM, SourceManager *SM, + const FIDMap& FM, const SourceManager *SM, unsigned indent) { Indent(o, indent) << "<dict>\n"; @@ -167,7 +175,8 @@ static void ReportControlFlow(llvm::raw_ostream& o, } static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P, - const FIDMap& FM, SourceManager* SM, unsigned indent) { + const FIDMap& FM, const SourceManager* SM, + unsigned indent) { Indent(o, indent) << "<dict>\n"; ++indent; @@ -175,7 +184,7 @@ static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P, Indent(o, indent) << "<key>kind</key><string>event</string>\n"; // Output the location. - FullSourceLoc L = P.getLocation(); + FullSourceLoc L = P.getLocation().asLocation(); Indent(o, indent) << "<key>location</key>\n"; EmitLocation(o, SM, L, FM, indent); @@ -211,7 +220,7 @@ static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P, static void ReportMacro(llvm::raw_ostream& o, const PathDiagnosticMacroPiece& P, - const FIDMap& FM, SourceManager *SM, + const FIDMap& FM, const SourceManager *SM, unsigned indent) { for (PathDiagnosticMacroPiece::const_iterator I=P.begin(), E=P.end(); @@ -231,7 +240,7 @@ static void ReportMacro(llvm::raw_ostream& o, } static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P, - const FIDMap& FM, SourceManager* SM) { + const FIDMap& FM, const SourceManager* SM) { unsigned indent = 4; @@ -267,7 +276,7 @@ PlistDiagnostics::~PlistDiagnostics() { // ranges of the diagnostics. FIDMap FM; llvm::SmallVector<FileID, 10> Fids; - SourceManager* SM = 0; + const SourceManager* SM = 0; if (!BatchedDiags.empty()) SM = &(*BatchedDiags.begin())->begin()->getLocation().getManager(); @@ -278,7 +287,7 @@ PlistDiagnostics::~PlistDiagnostics() { const PathDiagnostic *D = *DI; for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I!=E; ++I) { - AddFID(FM, Fids, SM, I->getLocation()); + AddFID(FM, Fids, SM, I->getLocation().asLocation()); for (PathDiagnosticPiece::range_iterator RI=I->ranges_begin(), RE=I->ranges_end(); RI!=RE; ++RI) { |