blob: 3599df82c79fc197260197e3d4409f3f5fda8cb4 [file] [log] [blame]
Ted Kremenek2898d4f2011-12-17 05:26:04 +00001//===--- DiagnosticRenderer.cpp - Diagnostic Pretty-Printing --------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/Frontend/DiagnosticRenderer.h"
Douglas Gregor02c23eb2012-10-23 22:26:28 +000011#include "clang/Basic/DiagnosticOptions.h"
Ted Kremenek2898d4f2011-12-17 05:26:04 +000012#include "clang/Basic/FileManager.h"
13#include "clang/Basic/SourceManager.h"
Ted Kremenek2898d4f2011-12-17 05:26:04 +000014#include "clang/Lex/Lexer.h"
Ted Kremenek30660a82012-03-06 20:06:33 +000015#include "clang/Edit/EditedSource.h"
16#include "clang/Edit/Commit.h"
17#include "clang/Edit/EditsReceiver.h"
Ted Kremenek2898d4f2011-12-17 05:26:04 +000018#include "llvm/Support/MemoryBuffer.h"
19#include "llvm/Support/raw_ostream.h"
20#include "llvm/Support/ErrorHandling.h"
Eli Friedman9cb1c3d2012-11-03 03:36:51 +000021#include "llvm/ADT/SmallSet.h"
Ted Kremenek2898d4f2011-12-17 05:26:04 +000022#include "llvm/ADT/SmallString.h"
23#include <algorithm>
24using namespace clang;
25
Argyrios Kyrtzidis7f6cf972012-01-23 16:58:33 +000026/// \brief Retrieve the name of the immediate macro expansion.
27///
28/// This routine starts from a source location, and finds the name of the macro
29/// responsible for its immediate expansion. It looks through any intervening
30/// macro argument expansions to compute this. It returns a StringRef which
31/// refers to the SourceManager-owned buffer of the source where that macro
32/// name is spelled. Thus, the result shouldn't out-live that SourceManager.
33///
34/// This differs from Lexer::getImmediateMacroName in that any macro argument
35/// location will result in the topmost function macro that accepted it.
36/// e.g.
37/// \code
38/// MAC1( MAC2(foo) )
39/// \endcode
40/// for location of 'foo' token, this function will return "MAC1" while
41/// Lexer::getImmediateMacroName will return "MAC2".
42static StringRef getImmediateMacroName(SourceLocation Loc,
43 const SourceManager &SM,
44 const LangOptions &LangOpts) {
45 assert(Loc.isMacroID() && "Only reasonble to call this on macros");
46 // Walk past macro argument expanions.
47 while (SM.isMacroArgExpansion(Loc))
48 Loc = SM.getImmediateExpansionRange(Loc).first;
49
50 // Find the spelling location of the start of the non-argument expansion
51 // range. This is where the macro name was spelled in order to begin
52 // expanding this macro.
53 Loc = SM.getSpellingLoc(SM.getImmediateExpansionRange(Loc).first);
54
55 // Dig out the buffer where the macro name was spelled and the extents of the
56 // name so that we can render it into the expansion note.
57 std::pair<FileID, unsigned> ExpansionInfo = SM.getDecomposedLoc(Loc);
58 unsigned MacroTokenLength = Lexer::MeasureTokenLength(Loc, SM, LangOpts);
59 StringRef ExpansionBuffer = SM.getBufferData(ExpansionInfo.first);
60 return ExpansionBuffer.substr(ExpansionInfo.second, MacroTokenLength);
61}
62
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +000063DiagnosticRenderer::DiagnosticRenderer(const LangOptions &LangOpts,
Douglas Gregor02c23eb2012-10-23 22:26:28 +000064 DiagnosticOptions *DiagOpts)
65 : LangOpts(LangOpts), DiagOpts(DiagOpts), LastLevel() {}
Ted Kremenek2898d4f2011-12-17 05:26:04 +000066
67DiagnosticRenderer::~DiagnosticRenderer() {}
68
Ted Kremenek30660a82012-03-06 20:06:33 +000069namespace {
70
71class FixitReceiver : public edit::EditsReceiver {
72 SmallVectorImpl<FixItHint> &MergedFixits;
73
74public:
75 FixitReceiver(SmallVectorImpl<FixItHint> &MergedFixits)
76 : MergedFixits(MergedFixits) { }
77 virtual void insert(SourceLocation loc, StringRef text) {
78 MergedFixits.push_back(FixItHint::CreateInsertion(loc, text));
79 }
80 virtual void replace(CharSourceRange range, StringRef text) {
81 MergedFixits.push_back(FixItHint::CreateReplacement(range, text));
82 }
83};
84
85}
86
87static void mergeFixits(ArrayRef<FixItHint> FixItHints,
88 const SourceManager &SM, const LangOptions &LangOpts,
89 SmallVectorImpl<FixItHint> &MergedFixits) {
90 edit::Commit commit(SM, LangOpts);
91 for (ArrayRef<FixItHint>::const_iterator
92 I = FixItHints.begin(), E = FixItHints.end(); I != E; ++I) {
93 const FixItHint &Hint = *I;
94 if (Hint.CodeToInsert.empty()) {
95 if (Hint.InsertFromRange.isValid())
96 commit.insertFromRange(Hint.RemoveRange.getBegin(),
97 Hint.InsertFromRange, /*afterToken=*/false,
98 Hint.BeforePreviousInsertions);
99 else
100 commit.remove(Hint.RemoveRange);
101 } else {
102 if (Hint.RemoveRange.isTokenRange() ||
103 Hint.RemoveRange.getBegin() != Hint.RemoveRange.getEnd())
104 commit.replace(Hint.RemoveRange, Hint.CodeToInsert);
105 else
106 commit.insert(Hint.RemoveRange.getBegin(), Hint.CodeToInsert,
107 /*afterToken=*/false, Hint.BeforePreviousInsertions);
108 }
109 }
110
111 edit::EditedSource Editor(SM, LangOpts);
112 if (Editor.commit(commit)) {
113 FixitReceiver Rec(MergedFixits);
114 Editor.applyRewrites(Rec);
115 }
116}
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000117
118void DiagnosticRenderer::emitDiagnostic(SourceLocation Loc,
119 DiagnosticsEngine::Level Level,
120 StringRef Message,
121 ArrayRef<CharSourceRange> Ranges,
122 ArrayRef<FixItHint> FixItHints,
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000123 const SourceManager *SM,
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000124 DiagOrStoredDiag D) {
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000125 assert(SM || Loc.isInvalid());
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000126
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000127 beginDiagnostic(D, Level);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000128
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000129 PresumedLoc PLoc;
130 if (Loc.isValid()) {
Richard Smith62221b12012-11-14 23:55:25 +0000131 PLoc = SM->getPresumedLocForDisplay(Loc, DiagOpts->ShowPresumedLoc);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000132
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000133 // First, if this diagnostic is not in the main file, print out the
134 // "included from" lines.
135 emitIncludeStack(PLoc.getIncludeLoc(), Level, *SM);
136 }
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000137
138 // Next, emit the actual diagnostic message.
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000139 emitDiagnosticMessage(Loc, PLoc, Level, Message, Ranges, SM, D);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000140
141 // Only recurse if we have a valid location.
142 if (Loc.isValid()) {
143 // Get the ranges into a local array we can hack on.
144 SmallVector<CharSourceRange, 20> MutableRanges(Ranges.begin(),
145 Ranges.end());
146
Ted Kremenek30660a82012-03-06 20:06:33 +0000147 llvm::SmallVector<FixItHint, 8> MergedFixits;
148 if (!FixItHints.empty()) {
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000149 mergeFixits(FixItHints, *SM, LangOpts, MergedFixits);
Ted Kremenek30660a82012-03-06 20:06:33 +0000150 FixItHints = MergedFixits;
151 }
152
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000153 for (ArrayRef<FixItHint>::const_iterator I = FixItHints.begin(),
154 E = FixItHints.end();
155 I != E; ++I)
156 if (I->RemoveRange.isValid())
157 MutableRanges.push_back(I->RemoveRange);
158
159 unsigned MacroDepth = 0;
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000160 emitMacroExpansionsAndCarets(Loc, Level, MutableRanges, FixItHints, *SM,
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000161 MacroDepth);
162 }
163
164 LastLoc = Loc;
165 LastLevel = Level;
166
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000167 endDiagnostic(D, Level);
168}
169
170
171void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {
172 emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),
173 Diag.getRanges(), Diag.getFixIts(),
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000174 Diag.getLocation().isValid() ? &Diag.getLocation().getManager()
175 : 0,
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000176 &Diag);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000177}
178
179/// \brief Prints an include stack when appropriate for a particular
180/// diagnostic level and location.
181///
182/// This routine handles all the logic of suppressing particular include
183/// stacks (such as those for notes) and duplicate include stacks when
184/// repeated warnings occur within the same file. It also handles the logic
185/// of customizing the formatting and display of the include stack.
186///
187/// \param Level The diagnostic level of the message this stack pertains to.
188/// \param Loc The include location of the current file (not the diagnostic
189/// location).
190void DiagnosticRenderer::emitIncludeStack(SourceLocation Loc,
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000191 DiagnosticsEngine::Level Level,
192 const SourceManager &SM) {
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000193 // Skip redundant include stacks altogether.
194 if (LastIncludeLoc == Loc)
195 return;
196 LastIncludeLoc = Loc;
197
Douglas Gregor02c23eb2012-10-23 22:26:28 +0000198 if (!DiagOpts->ShowNoteIncludeStack && Level == DiagnosticsEngine::Note)
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000199 return;
200
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000201 emitIncludeStackRecursively(Loc, SM);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000202}
203
204/// \brief Helper to recursivly walk up the include stack and print each layer
205/// on the way back down.
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000206void DiagnosticRenderer::emitIncludeStackRecursively(SourceLocation Loc,
207 const SourceManager &SM) {
Douglas Gregor830ea5b2012-11-30 18:38:50 +0000208 if (Loc.isInvalid()) {
209 emitModuleBuildPath(SM);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000210 return;
Douglas Gregor830ea5b2012-11-30 18:38:50 +0000211 }
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000212
Richard Smith62221b12012-11-14 23:55:25 +0000213 PresumedLoc PLoc = SM.getPresumedLoc(Loc, DiagOpts->ShowPresumedLoc);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000214 if (PLoc.isInvalid())
215 return;
216
217 // Emit the other include frames first.
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000218 emitIncludeStackRecursively(PLoc.getIncludeLoc(), SM);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000219
220 // Emit the inclusion text/note.
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000221 emitIncludeLocation(Loc, PLoc, SM);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000222}
223
Douglas Gregor830ea5b2012-11-30 18:38:50 +0000224/// \brief Emit the module build path, for cases where a module is (re-)built
225/// on demand.
226void DiagnosticRenderer::emitModuleBuildPath(const SourceManager &SM) {
227 ModuleBuildPath Path = SM.getModuleBuildPath();
228 for (unsigned I = 0, N = Path.size(); I != N; ++I) {
229 const SourceManager &CurSM = Path[I].second.getManager();
230 SourceLocation CurLoc = Path[I].second;
231 emitBuildingModuleLocation(CurLoc,
232 CurSM.getPresumedLoc(CurLoc,
233 DiagOpts->ShowPresumedLoc),
234 Path[I].first,
235 CurSM);
236 }
237}
238
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000239// Helper function to fix up source ranges. It takes in an array of ranges,
240// and outputs an array of ranges where we want to draw the range highlighting
241// around the location specified by CaretLoc.
242//
243// To find locations which correspond to the caret, we crawl the macro caller
244// chain for the beginning and end of each range. If the caret location
245// is in a macro expansion, we search each chain for a location
246// in the same expansion as the caret; otherwise, we crawl to the top of
247// each chain. Two locations are part of the same macro expansion
248// iff the FileID is the same.
249static void mapDiagnosticRanges(
250 SourceLocation CaretLoc,
251 const SmallVectorImpl<CharSourceRange>& Ranges,
252 SmallVectorImpl<CharSourceRange>& SpellingRanges,
253 const SourceManager *SM) {
254 FileID CaretLocFileID = SM->getFileID(CaretLoc);
255
256 for (SmallVectorImpl<CharSourceRange>::const_iterator I = Ranges.begin(),
257 E = Ranges.end();
258 I != E; ++I) {
259 SourceLocation Begin = I->getBegin(), End = I->getEnd();
260 bool IsTokenRange = I->isTokenRange();
261
Eli Friedmanecdc8d32012-11-30 06:19:40 +0000262 FileID BeginFileID = SM->getFileID(Begin);
263 FileID EndFileID = SM->getFileID(End);
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000264
Eli Friedmanecdc8d32012-11-30 06:19:40 +0000265 // Find the common parent for the beginning and end of the range.
266
267 // First, crawl the expansion chain for the beginning of the range.
268 llvm::SmallDenseMap<FileID, SourceLocation> BeginLocsMap;
269 while (Begin.isMacroID() && BeginFileID != EndFileID) {
270 BeginLocsMap[BeginFileID] = Begin;
271 Begin = SM->getImmediateExpansionRange(Begin).first;
272 BeginFileID = SM->getFileID(Begin);
273 }
274
275 // Then, crawl the expansion chain for the end of the range.
276 if (BeginFileID != EndFileID) {
277 while (End.isMacroID() && !BeginLocsMap.count(EndFileID)) {
278 End = SM->getImmediateExpansionRange(End).second;
279 EndFileID = SM->getFileID(End);
280 }
281 if (End.isMacroID()) {
282 Begin = BeginLocsMap[EndFileID];
283 BeginFileID = EndFileID;
284 }
285 }
286
287 while (Begin.isMacroID() && BeginFileID != CaretLocFileID) {
288 if (SM->isMacroArgExpansion(Begin)) {
289 Begin = SM->getImmediateSpellingLoc(Begin);
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000290 End = SM->getImmediateSpellingLoc(End);
291 } else {
Eli Friedmanecdc8d32012-11-30 06:19:40 +0000292 Begin = SM->getImmediateExpansionRange(Begin).first;
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000293 End = SM->getImmediateExpansionRange(End).second;
294 }
Eli Friedmanecdc8d32012-11-30 06:19:40 +0000295 BeginFileID = SM->getFileID(Begin);
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000296 }
297
298 // Return the spelling location of the beginning and end of the range.
299 Begin = SM->getSpellingLoc(Begin);
300 End = SM->getSpellingLoc(End);
301 SpellingRanges.push_back(CharSourceRange(SourceRange(Begin, End),
302 IsTokenRange));
303 }
304}
305
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000306/// \brief Recursively emit notes for each macro expansion and caret
307/// diagnostics where appropriate.
308///
309/// Walks up the macro expansion stack printing expansion notes, the code
310/// snippet, caret, underlines and FixItHint display as appropriate at each
311/// level.
312///
313/// \param Loc The location for this caret.
314/// \param Level The diagnostic level currently being emitted.
315/// \param Ranges The underlined ranges for this code snippet.
316/// \param Hints The FixIt hints active for this diagnostic.
317/// \param MacroSkipEnd The depth to stop skipping macro expansions.
318/// \param OnMacroInst The current depth of the macro expansion stack.
319void DiagnosticRenderer::emitMacroExpansionsAndCarets(
320 SourceLocation Loc,
321 DiagnosticsEngine::Level Level,
322 SmallVectorImpl<CharSourceRange>& Ranges,
323 ArrayRef<FixItHint> Hints,
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000324 const SourceManager &SM,
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000325 unsigned &MacroDepth,
326 unsigned OnMacroInst)
327{
328 assert(!Loc.isInvalid() && "must have a valid source location here");
329
330 // If this is a file source location, directly emit the source snippet and
331 // caret line. Also record the macro depth reached.
332 if (Loc.isFileID()) {
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000333 // Map the ranges.
334 SmallVector<CharSourceRange, 4> SpellingRanges;
335 mapDiagnosticRanges(Loc, Ranges, SpellingRanges, &SM);
336
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000337 assert(MacroDepth == 0 && "We shouldn't hit a leaf node twice!");
338 MacroDepth = OnMacroInst;
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000339 emitCodeContext(Loc, Level, SpellingRanges, Hints, SM);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000340 return;
341 }
342 // Otherwise recurse through each macro expansion layer.
343
344 // When processing macros, skip over the expansions leading up to
345 // a macro argument, and trace the argument's expansion stack instead.
Matt Beaumont-Gay29271fb2012-06-18 20:12:05 +0000346 Loc = SM.skipToMacroArgExpansion(Loc);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000347
Matt Beaumont-Gay29271fb2012-06-18 20:12:05 +0000348 SourceLocation OneLevelUp = SM.getImmediateMacroCallerLoc(Loc);
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000349
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000350 emitMacroExpansionsAndCarets(OneLevelUp, Level, Ranges, Hints, SM, MacroDepth,
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000351 OnMacroInst + 1);
352
353 // Save the original location so we can find the spelling of the macro call.
354 SourceLocation MacroLoc = Loc;
355
356 // Map the location.
Matt Beaumont-Gay29271fb2012-06-18 20:12:05 +0000357 Loc = SM.getImmediateMacroCalleeLoc(Loc);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000358
359 unsigned MacroSkipStart = 0, MacroSkipEnd = 0;
Douglas Gregor02c23eb2012-10-23 22:26:28 +0000360 if (MacroDepth > DiagOpts->MacroBacktraceLimit &&
361 DiagOpts->MacroBacktraceLimit != 0) {
362 MacroSkipStart = DiagOpts->MacroBacktraceLimit / 2 +
363 DiagOpts->MacroBacktraceLimit % 2;
364 MacroSkipEnd = MacroDepth - DiagOpts->MacroBacktraceLimit / 2;
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000365 }
366
367 // Whether to suppress printing this macro expansion.
368 bool Suppressed = (OnMacroInst >= MacroSkipStart &&
369 OnMacroInst < MacroSkipEnd);
370
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000371 if (Suppressed) {
372 // Tell the user that we've skipped contexts.
373 if (OnMacroInst == MacroSkipStart) {
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000374 SmallString<200> MessageStorage;
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000375 llvm::raw_svector_ostream Message(MessageStorage);
376 Message << "(skipping " << (MacroSkipEnd - MacroSkipStart)
377 << " expansions in backtrace; use -fmacro-backtrace-limit=0 to "
378 "see all)";
379 emitBasicNote(Message.str());
380 }
381 return;
382 }
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000383
384 // Map the ranges.
385 SmallVector<CharSourceRange, 4> SpellingRanges;
386 mapDiagnosticRanges(MacroLoc, Ranges, SpellingRanges, &SM);
387
Dylan Noblesmithf7ccbad2012-02-05 02:13:05 +0000388 SmallString<100> MessageStorage;
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000389 llvm::raw_svector_ostream Message(MessageStorage);
390 Message << "expanded from macro '"
Argyrios Kyrtzidis7f6cf972012-01-23 16:58:33 +0000391 << getImmediateMacroName(MacroLoc, SM, LangOpts) << "'";
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000392 emitDiagnostic(SM.getSpellingLoc(Loc), DiagnosticsEngine::Note,
393 Message.str(),
Eli Friedman9cb1c3d2012-11-03 03:36:51 +0000394 SpellingRanges, ArrayRef<FixItHint>(), &SM);
Ted Kremenek2898d4f2011-12-17 05:26:04 +0000395}
396
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000397DiagnosticNoteRenderer::~DiagnosticNoteRenderer() {}
398
399void DiagnosticNoteRenderer::emitIncludeLocation(SourceLocation Loc,
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000400 PresumedLoc PLoc,
401 const SourceManager &SM) {
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000402 // Generate a note indicating the include location.
403 SmallString<200> MessageStorage;
404 llvm::raw_svector_ostream Message(MessageStorage);
405 Message << "in file included from " << PLoc.getFilename() << ':'
406 << PLoc.getLine() << ":";
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000407 emitNote(Loc, Message.str(), &SM);
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000408}
409
Douglas Gregor830ea5b2012-11-30 18:38:50 +0000410void
411DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc,
412 PresumedLoc PLoc,
413 StringRef ModuleName,
414 const SourceManager &SM) {
415 // Generate a note indicating the include location.
416 SmallString<200> MessageStorage;
417 llvm::raw_svector_ostream Message(MessageStorage);
418 Message << "while building module '" << ModuleName << "' imported from "
419 << PLoc.getFilename() << ':' << PLoc.getLine() << ":";
420 emitNote(Loc, Message.str(), &SM);
421}
422
423
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000424void DiagnosticNoteRenderer::emitBasicNote(StringRef Message) {
Argyrios Kyrtzidis16afdf72012-05-10 05:03:45 +0000425 emitNote(SourceLocation(), Message, 0);
Ted Kremenek8be51ea2012-02-14 02:46:00 +0000426}