2018-03-22 08:53:26 +08:00
|
|
|
//===- DiagnosticRenderer.cpp - Diagnostic Pretty-Printing ----------------===//
|
2011-12-17 13:26:04 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-12-17 13:26:04 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Frontend/DiagnosticRenderer.h"
|
2018-03-22 08:53:26 +08:00
|
|
|
#include "clang/Basic/Diagnostic.h"
|
2012-10-24 06:26:28 +08:00
|
|
|
#include "clang/Basic/DiagnosticOptions.h"
|
2018-03-22 08:53:26 +08:00
|
|
|
#include "clang/Basic/LLVM.h"
|
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2011-12-17 13:26:04 +08:00
|
|
|
#include "clang/Basic/SourceManager.h"
|
2012-03-07 04:06:33 +08:00
|
|
|
#include "clang/Edit/Commit.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "clang/Edit/EditedSource.h"
|
2012-03-07 04:06:33 +08:00
|
|
|
#include "clang/Edit/EditsReceiver.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "clang/Lex/Lexer.h"
|
2018-03-22 08:53:26 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/None.h"
|
2011-12-17 13:26:04 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2018-03-22 08:53:26 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2012-12-04 17:13:33 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2011-12-17 13:26:04 +08:00
|
|
|
#include <algorithm>
|
2018-03-22 08:53:26 +08:00
|
|
|
#include <cassert>
|
|
|
|
#include <iterator>
|
|
|
|
#include <utility>
|
|
|
|
|
2011-12-17 13:26:04 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
2012-05-10 13:03:45 +08:00
|
|
|
DiagnosticRenderer::DiagnosticRenderer(const LangOptions &LangOpts,
|
2012-10-24 06:26:28 +08:00
|
|
|
DiagnosticOptions *DiagOpts)
|
2018-03-22 08:53:26 +08:00
|
|
|
: LangOpts(LangOpts), DiagOpts(DiagOpts), LastLevel() {}
|
2011-12-17 13:26:04 +08:00
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
DiagnosticRenderer::~DiagnosticRenderer() = default;
|
2011-12-17 13:26:04 +08:00
|
|
|
|
2012-03-07 04:06:33 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
class FixitReceiver : public edit::EditsReceiver {
|
|
|
|
SmallVectorImpl<FixItHint> &MergedFixits;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FixitReceiver(SmallVectorImpl<FixItHint> &MergedFixits)
|
2018-03-22 08:53:26 +08:00
|
|
|
: MergedFixits(MergedFixits) {}
|
|
|
|
|
2014-03-13 14:07:04 +08:00
|
|
|
void insert(SourceLocation loc, StringRef text) override {
|
2012-03-07 04:06:33 +08:00
|
|
|
MergedFixits.push_back(FixItHint::CreateInsertion(loc, text));
|
|
|
|
}
|
2018-03-22 08:53:26 +08:00
|
|
|
|
2014-03-13 14:07:04 +08:00
|
|
|
void replace(CharSourceRange range, StringRef text) override {
|
2012-03-07 04:06:33 +08:00
|
|
|
MergedFixits.push_back(FixItHint::CreateReplacement(range, text));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
} // namespace
|
2012-03-07 04:06:33 +08:00
|
|
|
|
|
|
|
static void mergeFixits(ArrayRef<FixItHint> FixItHints,
|
|
|
|
const SourceManager &SM, const LangOptions &LangOpts,
|
|
|
|
SmallVectorImpl<FixItHint> &MergedFixits) {
|
|
|
|
edit::Commit commit(SM, LangOpts);
|
2018-03-22 08:53:26 +08:00
|
|
|
for (const auto &Hint : FixItHints)
|
2012-03-07 04:06:33 +08:00
|
|
|
if (Hint.CodeToInsert.empty()) {
|
|
|
|
if (Hint.InsertFromRange.isValid())
|
|
|
|
commit.insertFromRange(Hint.RemoveRange.getBegin(),
|
|
|
|
Hint.InsertFromRange, /*afterToken=*/false,
|
|
|
|
Hint.BeforePreviousInsertions);
|
|
|
|
else
|
|
|
|
commit.remove(Hint.RemoveRange);
|
|
|
|
} else {
|
|
|
|
if (Hint.RemoveRange.isTokenRange() ||
|
|
|
|
Hint.RemoveRange.getBegin() != Hint.RemoveRange.getEnd())
|
|
|
|
commit.replace(Hint.RemoveRange, Hint.CodeToInsert);
|
|
|
|
else
|
|
|
|
commit.insert(Hint.RemoveRange.getBegin(), Hint.CodeToInsert,
|
|
|
|
/*afterToken=*/false, Hint.BeforePreviousInsertions);
|
|
|
|
}
|
|
|
|
|
|
|
|
edit::EditedSource Editor(SM, LangOpts);
|
|
|
|
if (Editor.commit(commit)) {
|
|
|
|
FixitReceiver Rec(MergedFixits);
|
|
|
|
Editor.applyRewrites(Rec);
|
|
|
|
}
|
|
|
|
}
|
2011-12-17 13:26:04 +08:00
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitDiagnostic(FullSourceLoc Loc,
|
2011-12-17 13:26:04 +08:00
|
|
|
DiagnosticsEngine::Level Level,
|
|
|
|
StringRef Message,
|
|
|
|
ArrayRef<CharSourceRange> Ranges,
|
|
|
|
ArrayRef<FixItHint> FixItHints,
|
2012-02-14 10:46:00 +08:00
|
|
|
DiagOrStoredDiag D) {
|
2017-06-27 17:50:38 +08:00
|
|
|
assert(Loc.hasManager() || Loc.isInvalid());
|
2012-12-05 17:47:49 +08:00
|
|
|
|
2012-02-14 10:46:00 +08:00
|
|
|
beginDiagnostic(D, Level);
|
2012-12-05 17:47:49 +08:00
|
|
|
|
|
|
|
if (!Loc.isValid())
|
|
|
|
// If we have no source location, just emit the diagnostic message.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitDiagnosticMessage(Loc, PresumedLoc(), Level, Message, Ranges, D);
|
2012-12-05 17:47:49 +08:00
|
|
|
else {
|
2011-12-17 13:26:04 +08:00
|
|
|
// Get the ranges into a local array we can hack on.
|
|
|
|
SmallVector<CharSourceRange, 20> MutableRanges(Ranges.begin(),
|
|
|
|
Ranges.end());
|
2012-12-05 17:47:49 +08:00
|
|
|
|
2013-01-13 03:30:44 +08:00
|
|
|
SmallVector<FixItHint, 8> MergedFixits;
|
2012-03-07 04:06:33 +08:00
|
|
|
if (!FixItHints.empty()) {
|
2017-06-27 17:50:38 +08:00
|
|
|
mergeFixits(FixItHints, Loc.getManager(), LangOpts, MergedFixits);
|
2012-03-07 04:06:33 +08:00
|
|
|
FixItHints = MergedFixits;
|
|
|
|
}
|
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
for (const auto &Hint : FixItHints)
|
|
|
|
if (Hint.RemoveRange.isValid())
|
|
|
|
MutableRanges.push_back(Hint.RemoveRange);
|
2012-12-05 14:20:58 +08:00
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
FullSourceLoc UnexpandedLoc = Loc;
|
2012-12-05 17:47:49 +08:00
|
|
|
|
2012-12-19 09:16:49 +08:00
|
|
|
// Find the ultimate expansion location for the diagnostic.
|
2017-06-27 17:50:38 +08:00
|
|
|
Loc = Loc.getFileLoc();
|
2012-12-05 14:20:58 +08:00
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);
|
2012-12-05 17:47:49 +08:00
|
|
|
|
|
|
|
// First, if this diagnostic is not in the main file, print out the
|
|
|
|
// "included from" lines.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitIncludeStack(Loc, PLoc, Level);
|
2012-12-05 17:47:49 +08:00
|
|
|
|
|
|
|
// Next, emit the actual diagnostic message and caret.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitDiagnosticMessage(Loc, PLoc, Level, Message, Ranges, D);
|
|
|
|
emitCaret(Loc, Level, MutableRanges, FixItHints);
|
2012-12-05 17:47:49 +08:00
|
|
|
|
|
|
|
// If this location is within a macro, walk from UnexpandedLoc up to Loc
|
|
|
|
// and produce a macro backtrace.
|
|
|
|
if (UnexpandedLoc.isValid() && UnexpandedLoc.isMacroID()) {
|
2017-06-27 17:50:38 +08:00
|
|
|
emitMacroExpansions(UnexpandedLoc, Level, MutableRanges, FixItHints);
|
2012-12-05 14:20:58 +08:00
|
|
|
}
|
2011-12-17 13:26:04 +08:00
|
|
|
}
|
2012-12-05 17:47:49 +08:00
|
|
|
|
2011-12-17 13:26:04 +08:00
|
|
|
LastLoc = Loc;
|
|
|
|
LastLevel = Level;
|
2012-12-05 17:47:49 +08:00
|
|
|
|
2012-02-14 10:46:00 +08:00
|
|
|
endDiagnostic(D, Level);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {
|
|
|
|
emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),
|
|
|
|
Diag.getRanges(), Diag.getFixIts(),
|
|
|
|
&Diag);
|
2011-12-17 13:26:04 +08:00
|
|
|
}
|
|
|
|
|
2014-06-22 07:31:59 +08:00
|
|
|
void DiagnosticRenderer::emitBasicNote(StringRef Message) {
|
2017-06-27 17:50:38 +08:00
|
|
|
emitDiagnosticMessage(FullSourceLoc(), PresumedLoc(), DiagnosticsEngine::Note,
|
|
|
|
Message, None, DiagOrStoredDiag());
|
2014-06-22 07:31:59 +08:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Prints an include stack when appropriate for a particular
|
2011-12-17 13:26:04 +08:00
|
|
|
/// diagnostic level and location.
|
|
|
|
///
|
|
|
|
/// This routine handles all the logic of suppressing particular include
|
|
|
|
/// stacks (such as those for notes) and duplicate include stacks when
|
|
|
|
/// repeated warnings occur within the same file. It also handles the logic
|
|
|
|
/// of customizing the formatting and display of the include stack.
|
|
|
|
///
|
2012-12-01 05:58:49 +08:00
|
|
|
/// \param Loc The diagnostic location.
|
|
|
|
/// \param PLoc The presumed location of the diagnostic location.
|
2011-12-17 13:26:04 +08:00
|
|
|
/// \param Level The diagnostic level of the message this stack pertains to.
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitIncludeStack(FullSourceLoc Loc, PresumedLoc PLoc,
|
|
|
|
DiagnosticsEngine::Level Level) {
|
|
|
|
FullSourceLoc IncludeLoc =
|
|
|
|
PLoc.isInvalid() ? FullSourceLoc()
|
|
|
|
: FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager());
|
2012-12-01 05:58:49 +08:00
|
|
|
|
2011-12-17 13:26:04 +08:00
|
|
|
// Skip redundant include stacks altogether.
|
2012-12-01 05:58:49 +08:00
|
|
|
if (LastIncludeLoc == IncludeLoc)
|
2011-12-17 13:26:04 +08:00
|
|
|
return;
|
2018-07-31 03:24:48 +08:00
|
|
|
|
2012-12-01 05:58:49 +08:00
|
|
|
LastIncludeLoc = IncludeLoc;
|
2018-07-31 03:24:48 +08:00
|
|
|
|
2012-10-24 06:26:28 +08:00
|
|
|
if (!DiagOpts->ShowNoteIncludeStack && Level == DiagnosticsEngine::Note)
|
2011-12-17 13:26:04 +08:00
|
|
|
return;
|
2012-12-01 05:58:49 +08:00
|
|
|
|
|
|
|
if (IncludeLoc.isValid())
|
2017-06-27 17:50:38 +08:00
|
|
|
emitIncludeStackRecursively(IncludeLoc);
|
2012-12-01 05:58:49 +08:00
|
|
|
else {
|
2017-06-27 17:50:38 +08:00
|
|
|
emitModuleBuildStack(Loc.getManager());
|
|
|
|
emitImportStack(Loc);
|
2012-12-01 05:58:49 +08:00
|
|
|
}
|
2011-12-17 13:26:04 +08:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Helper to recursively walk up the include stack and print each layer
|
2011-12-17 13:26:04 +08:00
|
|
|
/// on the way back down.
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitIncludeStackRecursively(FullSourceLoc Loc) {
|
2012-12-01 02:38:50 +08:00
|
|
|
if (Loc.isInvalid()) {
|
2017-06-27 17:50:38 +08:00
|
|
|
emitModuleBuildStack(Loc.getManager());
|
2011-12-17 13:26:04 +08:00
|
|
|
return;
|
2012-12-01 02:38:50 +08:00
|
|
|
}
|
2017-06-27 17:50:38 +08:00
|
|
|
|
|
|
|
PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);
|
2011-12-17 13:26:04 +08:00
|
|
|
if (PLoc.isInvalid())
|
|
|
|
return;
|
2012-12-01 05:58:49 +08:00
|
|
|
|
|
|
|
// If this source location was imported from a module, print the module
|
2018-07-31 03:24:48 +08:00
|
|
|
// import stack rather than the
|
2012-12-01 05:58:49 +08:00
|
|
|
// FIXME: We want submodule granularity here.
|
2017-06-27 17:50:38 +08:00
|
|
|
std::pair<FullSourceLoc, StringRef> Imported = Loc.getModuleImportLoc();
|
2015-08-11 08:05:21 +08:00
|
|
|
if (!Imported.second.empty()) {
|
2012-12-01 05:58:49 +08:00
|
|
|
// This location was imported by a module. Emit the module import stack.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitImportStackRecursively(Imported.first, Imported.second);
|
2012-12-01 05:58:49 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-17 13:26:04 +08:00
|
|
|
// Emit the other include frames first.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitIncludeStackRecursively(
|
|
|
|
FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager()));
|
|
|
|
|
2011-12-17 13:26:04 +08:00
|
|
|
// Emit the inclusion text/note.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitIncludeLocation(Loc, PLoc);
|
2011-12-17 13:26:04 +08:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Emit the module import stack associated with the current location.
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitImportStack(FullSourceLoc Loc) {
|
2012-12-01 05:58:49 +08:00
|
|
|
if (Loc.isInvalid()) {
|
2017-06-27 17:50:38 +08:00
|
|
|
emitModuleBuildStack(Loc.getManager());
|
2012-12-01 05:58:49 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
std::pair<FullSourceLoc, StringRef> NextImportLoc = Loc.getModuleImportLoc();
|
|
|
|
emitImportStackRecursively(NextImportLoc.first, NextImportLoc.second);
|
2012-12-01 05:58:49 +08:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Helper to recursively walk up the import stack and print each layer
|
2012-12-01 05:58:49 +08:00
|
|
|
/// on the way back down.
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitImportStackRecursively(FullSourceLoc Loc,
|
|
|
|
StringRef ModuleName) {
|
2015-08-11 08:05:21 +08:00
|
|
|
if (ModuleName.empty()) {
|
2012-12-01 05:58:49 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);
|
2012-12-01 05:58:49 +08:00
|
|
|
|
|
|
|
// Emit the other import frames first.
|
2017-06-27 17:50:38 +08:00
|
|
|
std::pair<FullSourceLoc, StringRef> NextImportLoc = Loc.getModuleImportLoc();
|
|
|
|
emitImportStackRecursively(NextImportLoc.first, NextImportLoc.second);
|
2012-12-01 05:58:49 +08:00
|
|
|
|
|
|
|
// Emit the inclusion text/note.
|
2017-06-27 17:50:38 +08:00
|
|
|
emitImportLocation(Loc, PLoc, ModuleName);
|
2012-12-01 05:58:49 +08:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Emit the module build stack, for cases where a module is (re-)built
|
2012-12-01 02:38:50 +08:00
|
|
|
/// on demand.
|
2012-12-01 06:11:57 +08:00
|
|
|
void DiagnosticRenderer::emitModuleBuildStack(const SourceManager &SM) {
|
|
|
|
ModuleBuildStack Stack = SM.getModuleBuildStack();
|
2018-03-22 08:53:26 +08:00
|
|
|
for (const auto &I : Stack) {
|
|
|
|
emitBuildingModuleLocation(I.second, I.second.getPresumedLoc(
|
|
|
|
DiagOpts->ShowPresumedLoc),
|
|
|
|
I.first);
|
2012-12-01 02:38:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
/// A recursive function to trace all possible backtrace locations
|
|
|
|
/// to match the \p CaretLocFileID.
|
2015-12-08 09:08:09 +08:00
|
|
|
static SourceLocation
|
|
|
|
retrieveMacroLocation(SourceLocation Loc, FileID MacroFileID,
|
|
|
|
FileID CaretFileID,
|
|
|
|
const SmallVectorImpl<FileID> &CommonArgExpansions,
|
2018-04-30 13:25:48 +08:00
|
|
|
bool IsBegin, const SourceManager *SM,
|
|
|
|
bool &IsTokenRange) {
|
2015-12-08 09:08:09 +08:00
|
|
|
assert(SM->getFileID(Loc) == MacroFileID);
|
|
|
|
if (MacroFileID == CaretFileID)
|
|
|
|
return Loc;
|
|
|
|
if (!Loc.isMacroID())
|
2018-03-22 08:53:26 +08:00
|
|
|
return {};
|
2015-09-24 09:21:01 +08:00
|
|
|
|
2018-04-30 13:25:48 +08:00
|
|
|
CharSourceRange MacroRange, MacroArgRange;
|
2015-09-24 09:21:01 +08:00
|
|
|
|
|
|
|
if (SM->isMacroArgExpansion(Loc)) {
|
2015-12-08 09:08:09 +08:00
|
|
|
// Only look at the immediate spelling location of this macro argument if
|
|
|
|
// the other location in the source range is also present in that expansion.
|
|
|
|
if (std::binary_search(CommonArgExpansions.begin(),
|
|
|
|
CommonArgExpansions.end(), MacroFileID))
|
2018-04-30 13:25:48 +08:00
|
|
|
MacroRange =
|
|
|
|
CharSourceRange(SM->getImmediateSpellingLoc(Loc), IsTokenRange);
|
|
|
|
MacroArgRange = SM->getImmediateExpansionRange(Loc);
|
2015-09-24 09:21:01 +08:00
|
|
|
} else {
|
2018-04-30 13:25:48 +08:00
|
|
|
MacroRange = SM->getImmediateExpansionRange(Loc);
|
|
|
|
MacroArgRange =
|
|
|
|
CharSourceRange(SM->getImmediateSpellingLoc(Loc), IsTokenRange);
|
2015-09-24 09:21:01 +08:00
|
|
|
}
|
|
|
|
|
2018-04-30 13:25:48 +08:00
|
|
|
SourceLocation MacroLocation =
|
|
|
|
IsBegin ? MacroRange.getBegin() : MacroRange.getEnd();
|
2015-12-08 09:08:09 +08:00
|
|
|
if (MacroLocation.isValid()) {
|
|
|
|
MacroFileID = SM->getFileID(MacroLocation);
|
2018-04-30 13:25:48 +08:00
|
|
|
bool TokenRange = IsBegin ? IsTokenRange : MacroRange.isTokenRange();
|
2015-12-08 09:08:09 +08:00
|
|
|
MacroLocation =
|
|
|
|
retrieveMacroLocation(MacroLocation, MacroFileID, CaretFileID,
|
2018-04-30 13:25:48 +08:00
|
|
|
CommonArgExpansions, IsBegin, SM, TokenRange);
|
|
|
|
if (MacroLocation.isValid()) {
|
|
|
|
IsTokenRange = TokenRange;
|
2015-12-08 09:08:09 +08:00
|
|
|
return MacroLocation;
|
2018-04-30 13:25:48 +08:00
|
|
|
}
|
2015-12-08 09:08:09 +08:00
|
|
|
}
|
2015-09-24 09:21:01 +08:00
|
|
|
|
2018-04-30 13:25:48 +08:00
|
|
|
// If we moved the end of the range to an expansion location, we now have
|
|
|
|
// a range of the same kind as the expansion range.
|
|
|
|
if (!IsBegin)
|
|
|
|
IsTokenRange = MacroArgRange.isTokenRange();
|
|
|
|
|
|
|
|
SourceLocation MacroArgLocation =
|
|
|
|
IsBegin ? MacroArgRange.getBegin() : MacroArgRange.getEnd();
|
2015-09-24 09:21:01 +08:00
|
|
|
MacroFileID = SM->getFileID(MacroArgLocation);
|
|
|
|
return retrieveMacroLocation(MacroArgLocation, MacroFileID, CaretFileID,
|
2018-04-30 13:25:48 +08:00
|
|
|
CommonArgExpansions, IsBegin, SM, IsTokenRange);
|
2015-12-08 09:08:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Walk up the chain of macro expansions and collect the FileIDs identifying the
|
|
|
|
/// expansions.
|
|
|
|
static void getMacroArgExpansionFileIDs(SourceLocation Loc,
|
|
|
|
SmallVectorImpl<FileID> &IDs,
|
|
|
|
bool IsBegin, const SourceManager *SM) {
|
|
|
|
while (Loc.isMacroID()) {
|
|
|
|
if (SM->isMacroArgExpansion(Loc)) {
|
|
|
|
IDs.push_back(SM->getFileID(Loc));
|
|
|
|
Loc = SM->getImmediateSpellingLoc(Loc);
|
|
|
|
} else {
|
|
|
|
auto ExpRange = SM->getImmediateExpansionRange(Loc);
|
2018-04-30 13:25:48 +08:00
|
|
|
Loc = IsBegin ? ExpRange.getBegin() : ExpRange.getEnd();
|
2015-12-08 09:08:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Collect the expansions of the begin and end locations and compute the set
|
|
|
|
/// intersection. Produces a sorted vector of FileIDs in CommonArgExpansions.
|
|
|
|
static void computeCommonMacroArgExpansionFileIDs(
|
|
|
|
SourceLocation Begin, SourceLocation End, const SourceManager *SM,
|
|
|
|
SmallVectorImpl<FileID> &CommonArgExpansions) {
|
|
|
|
SmallVector<FileID, 4> BeginArgExpansions;
|
|
|
|
SmallVector<FileID, 4> EndArgExpansions;
|
|
|
|
getMacroArgExpansionFileIDs(Begin, BeginArgExpansions, /*IsBegin=*/true, SM);
|
|
|
|
getMacroArgExpansionFileIDs(End, EndArgExpansions, /*IsBegin=*/false, SM);
|
2018-09-27 06:16:28 +08:00
|
|
|
llvm::sort(BeginArgExpansions);
|
|
|
|
llvm::sort(EndArgExpansions);
|
2015-12-08 09:08:09 +08:00
|
|
|
std::set_intersection(BeginArgExpansions.begin(), BeginArgExpansions.end(),
|
|
|
|
EndArgExpansions.begin(), EndArgExpansions.end(),
|
|
|
|
std::back_inserter(CommonArgExpansions));
|
2015-09-24 09:21:01 +08:00
|
|
|
}
|
|
|
|
|
2012-11-03 11:36:51 +08:00
|
|
|
// Helper function to fix up source ranges. It takes in an array of ranges,
|
|
|
|
// and outputs an array of ranges where we want to draw the range highlighting
|
|
|
|
// around the location specified by CaretLoc.
|
|
|
|
//
|
|
|
|
// To find locations which correspond to the caret, we crawl the macro caller
|
|
|
|
// chain for the beginning and end of each range. If the caret location
|
|
|
|
// is in a macro expansion, we search each chain for a location
|
|
|
|
// in the same expansion as the caret; otherwise, we crawl to the top of
|
|
|
|
// each chain. Two locations are part of the same macro expansion
|
|
|
|
// iff the FileID is the same.
|
2017-06-27 17:50:38 +08:00
|
|
|
static void
|
|
|
|
mapDiagnosticRanges(FullSourceLoc CaretLoc, ArrayRef<CharSourceRange> Ranges,
|
|
|
|
SmallVectorImpl<CharSourceRange> &SpellingRanges) {
|
|
|
|
FileID CaretLocFileID = CaretLoc.getFileID();
|
|
|
|
|
|
|
|
const SourceManager *SM = &CaretLoc.getManager();
|
2012-11-03 11:36:51 +08:00
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
for (const auto &Range : Ranges) {
|
|
|
|
if (Range.isInvalid())
|
|
|
|
continue;
|
2015-09-24 09:21:01 +08:00
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
SourceLocation Begin = Range.getBegin(), End = Range.getEnd();
|
|
|
|
bool IsTokenRange = Range.isTokenRange();
|
2012-11-03 11:36:51 +08:00
|
|
|
|
2012-12-13 08:14:59 +08:00
|
|
|
FileID BeginFileID = SM->getFileID(Begin);
|
2012-12-14 03:58:10 +08:00
|
|
|
FileID EndFileID = SM->getFileID(End);
|
|
|
|
|
|
|
|
// Find the common parent for the beginning and end of the range.
|
|
|
|
|
|
|
|
// First, crawl the expansion chain for the beginning of the range.
|
|
|
|
llvm::SmallDenseMap<FileID, SourceLocation> BeginLocsMap;
|
|
|
|
while (Begin.isMacroID() && BeginFileID != EndFileID) {
|
|
|
|
BeginLocsMap[BeginFileID] = Begin;
|
2018-04-30 13:25:48 +08:00
|
|
|
Begin = SM->getImmediateExpansionRange(Begin).getBegin();
|
2012-12-14 03:58:10 +08:00
|
|
|
BeginFileID = SM->getFileID(Begin);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then, crawl the expansion chain for the end of the range.
|
|
|
|
if (BeginFileID != EndFileID) {
|
|
|
|
while (End.isMacroID() && !BeginLocsMap.count(EndFileID)) {
|
2018-04-30 13:25:48 +08:00
|
|
|
auto Exp = SM->getImmediateExpansionRange(End);
|
|
|
|
IsTokenRange = Exp.isTokenRange();
|
|
|
|
End = Exp.getEnd();
|
2012-12-14 03:58:10 +08:00
|
|
|
EndFileID = SM->getFileID(End);
|
|
|
|
}
|
|
|
|
if (End.isMacroID()) {
|
|
|
|
Begin = BeginLocsMap[EndFileID];
|
|
|
|
BeginFileID = EndFileID;
|
|
|
|
}
|
|
|
|
}
|
2012-11-30 14:19:40 +08:00
|
|
|
|
2021-02-16 22:52:44 +08:00
|
|
|
// There is a chance that begin or end is invalid here, for example if
|
|
|
|
// specific compile error is reported.
|
|
|
|
// It is possible that the FileID's do not match, if one comes from an
|
|
|
|
// included file. In this case we can not produce a meaningful source range.
|
|
|
|
if (Begin.isInvalid() || End.isInvalid() || BeginFileID != EndFileID)
|
|
|
|
continue;
|
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
// Do the backtracking.
|
2015-12-08 09:08:09 +08:00
|
|
|
SmallVector<FileID, 4> CommonArgExpansions;
|
|
|
|
computeCommonMacroArgExpansionFileIDs(Begin, End, SM, CommonArgExpansions);
|
2015-09-24 09:21:01 +08:00
|
|
|
Begin = retrieveMacroLocation(Begin, BeginFileID, CaretLocFileID,
|
2018-04-30 13:25:48 +08:00
|
|
|
CommonArgExpansions, /*IsBegin=*/true, SM,
|
|
|
|
IsTokenRange);
|
2015-09-24 09:21:01 +08:00
|
|
|
End = retrieveMacroLocation(End, BeginFileID, CaretLocFileID,
|
2018-04-30 13:25:48 +08:00
|
|
|
CommonArgExpansions, /*IsBegin=*/false, SM,
|
|
|
|
IsTokenRange);
|
2015-09-24 09:21:01 +08:00
|
|
|
if (Begin.isInvalid() || End.isInvalid()) continue;
|
2012-11-03 11:36:51 +08:00
|
|
|
|
|
|
|
// Return the spelling location of the beginning and end of the range.
|
|
|
|
Begin = SM->getSpellingLoc(Begin);
|
|
|
|
End = SM->getSpellingLoc(End);
|
2015-09-24 09:21:01 +08:00
|
|
|
|
2012-11-03 11:36:51 +08:00
|
|
|
SpellingRanges.push_back(CharSourceRange(SourceRange(Begin, End),
|
|
|
|
IsTokenRange));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitCaret(FullSourceLoc Loc,
|
2012-12-05 14:20:58 +08:00
|
|
|
DiagnosticsEngine::Level Level,
|
|
|
|
ArrayRef<CharSourceRange> Ranges,
|
2017-06-27 17:50:38 +08:00
|
|
|
ArrayRef<FixItHint> Hints) {
|
2012-12-05 14:20:58 +08:00
|
|
|
SmallVector<CharSourceRange, 4> SpellingRanges;
|
2017-06-27 17:50:38 +08:00
|
|
|
mapDiagnosticRanges(Loc, Ranges, SpellingRanges);
|
|
|
|
emitCodeContext(Loc, Level, SpellingRanges, Hints);
|
2012-12-05 14:20:58 +08:00
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// A helper function for emitMacroExpansion to print the
|
2015-07-29 04:53:46 +08:00
|
|
|
/// macro expansion message
|
|
|
|
void DiagnosticRenderer::emitSingleMacroExpansion(
|
2017-06-27 17:50:38 +08:00
|
|
|
FullSourceLoc Loc, DiagnosticsEngine::Level Level,
|
|
|
|
ArrayRef<CharSourceRange> Ranges) {
|
2015-07-29 04:53:46 +08:00
|
|
|
// Find the spelling location for the macro definition. We must use the
|
|
|
|
// spelling location here to avoid emitting a macro backtrace for the note.
|
2017-06-27 17:50:38 +08:00
|
|
|
FullSourceLoc SpellingLoc = Loc.getSpellingLoc();
|
2015-07-29 04:53:46 +08:00
|
|
|
|
|
|
|
// Map the ranges into the FileID of the diagnostic location.
|
|
|
|
SmallVector<CharSourceRange, 4> SpellingRanges;
|
2017-06-27 17:50:38 +08:00
|
|
|
mapDiagnosticRanges(Loc, Ranges, SpellingRanges);
|
2015-07-29 04:53:46 +08:00
|
|
|
|
|
|
|
SmallString<100> MessageStorage;
|
|
|
|
llvm::raw_svector_ostream Message(MessageStorage);
|
2017-06-27 17:50:38 +08:00
|
|
|
StringRef MacroName = Lexer::getImmediateMacroNameForDiagnostics(
|
|
|
|
Loc, Loc.getManager(), LangOpts);
|
2015-07-29 04:53:46 +08:00
|
|
|
if (MacroName.empty())
|
|
|
|
Message << "expanded from here";
|
|
|
|
else
|
|
|
|
Message << "expanded from macro '" << MacroName << "'";
|
|
|
|
|
|
|
|
emitDiagnostic(SpellingLoc, DiagnosticsEngine::Note, Message.str(),
|
2017-06-27 17:50:38 +08:00
|
|
|
SpellingRanges, None);
|
2015-07-29 04:53:46 +08:00
|
|
|
}
|
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
/// Check that the macro argument location of Loc starts with ArgumentLoc.
|
|
|
|
/// The starting location of the macro expansions is used to differeniate
|
|
|
|
/// different macro expansions.
|
|
|
|
static bool checkLocForMacroArgExpansion(SourceLocation Loc,
|
|
|
|
const SourceManager &SM,
|
|
|
|
SourceLocation ArgumentLoc) {
|
|
|
|
SourceLocation MacroLoc;
|
|
|
|
if (SM.isMacroArgExpansion(Loc, &MacroLoc)) {
|
|
|
|
if (ArgumentLoc == MacroLoc) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Check if all the locations in the range have the same macro argument
|
2018-04-06 23:14:32 +08:00
|
|
|
/// expansion, and that the expansion starts with ArgumentLoc.
|
2015-08-13 02:24:59 +08:00
|
|
|
static bool checkRangeForMacroArgExpansion(CharSourceRange Range,
|
2015-09-24 09:21:01 +08:00
|
|
|
const SourceManager &SM,
|
|
|
|
SourceLocation ArgumentLoc) {
|
2015-08-13 02:24:59 +08:00
|
|
|
SourceLocation BegLoc = Range.getBegin(), EndLoc = Range.getEnd();
|
|
|
|
while (BegLoc != EndLoc) {
|
2015-09-24 09:21:01 +08:00
|
|
|
if (!checkLocForMacroArgExpansion(BegLoc, SM, ArgumentLoc))
|
2015-08-13 02:24:59 +08:00
|
|
|
return false;
|
|
|
|
BegLoc.getLocWithOffset(1);
|
|
|
|
}
|
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
return checkLocForMacroArgExpansion(BegLoc, SM, ArgumentLoc);
|
2015-08-13 02:24:59 +08:00
|
|
|
}
|
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
/// A helper function to check if the current ranges are all inside the same
|
|
|
|
/// macro argument expansion as Loc.
|
2017-06-27 17:50:38 +08:00
|
|
|
static bool checkRangesForMacroArgExpansion(FullSourceLoc Loc,
|
|
|
|
ArrayRef<CharSourceRange> Ranges) {
|
2015-08-13 02:24:59 +08:00
|
|
|
assert(Loc.isMacroID() && "Must be a macro expansion!");
|
|
|
|
|
|
|
|
SmallVector<CharSourceRange, 4> SpellingRanges;
|
2017-06-27 17:50:38 +08:00
|
|
|
mapDiagnosticRanges(Loc, Ranges, SpellingRanges);
|
2015-08-13 02:24:59 +08:00
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
/// Count all valid ranges.
|
|
|
|
unsigned ValidCount = 0;
|
2018-03-22 08:53:26 +08:00
|
|
|
for (const auto &Range : Ranges)
|
|
|
|
if (Range.isValid())
|
|
|
|
ValidCount++;
|
2015-09-24 09:21:01 +08:00
|
|
|
|
|
|
|
if (ValidCount > SpellingRanges.size())
|
2015-08-13 02:24:59 +08:00
|
|
|
return false;
|
|
|
|
|
2015-09-24 09:21:01 +08:00
|
|
|
/// To store the source location of the argument location.
|
2017-06-27 17:50:38 +08:00
|
|
|
FullSourceLoc ArgumentLoc;
|
2015-09-24 09:21:01 +08:00
|
|
|
|
|
|
|
/// Set the ArgumentLoc to the beginning location of the expansion of Loc
|
|
|
|
/// so to check if the ranges expands to the same beginning location.
|
2017-06-27 17:50:38 +08:00
|
|
|
if (!Loc.isMacroArgExpansion(&ArgumentLoc))
|
2015-09-24 09:21:01 +08:00
|
|
|
return false;
|
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
for (const auto &Range : SpellingRanges)
|
|
|
|
if (!checkRangeForMacroArgExpansion(Range, Loc.getManager(), ArgumentLoc))
|
2015-08-13 02:24:59 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-05-09 09:00:01 +08:00
|
|
|
/// Recursively emit notes for each macro expansion and caret
|
2011-12-17 13:26:04 +08:00
|
|
|
/// diagnostics where appropriate.
|
|
|
|
///
|
|
|
|
/// Walks up the macro expansion stack printing expansion notes, the code
|
|
|
|
/// snippet, caret, underlines and FixItHint display as appropriate at each
|
|
|
|
/// level.
|
|
|
|
///
|
|
|
|
/// \param Loc The location for this caret.
|
|
|
|
/// \param Level The diagnostic level currently being emitted.
|
|
|
|
/// \param Ranges The underlined ranges for this code snippet.
|
|
|
|
/// \param Hints The FixIt hints active for this diagnostic.
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticRenderer::emitMacroExpansions(FullSourceLoc Loc,
|
2012-12-05 14:20:58 +08:00
|
|
|
DiagnosticsEngine::Level Level,
|
|
|
|
ArrayRef<CharSourceRange> Ranges,
|
2017-06-27 17:50:38 +08:00
|
|
|
ArrayRef<FixItHint> Hints) {
|
2015-10-03 13:15:57 +08:00
|
|
|
assert(Loc.isValid() && "must have a valid source location here");
|
2018-04-30 13:25:48 +08:00
|
|
|
const SourceManager &SM = Loc.getManager();
|
|
|
|
SourceLocation L = Loc;
|
2012-12-05 11:18:16 +08:00
|
|
|
|
2015-07-29 04:53:46 +08:00
|
|
|
// Produce a stack of macro backtraces.
|
2018-04-30 13:25:48 +08:00
|
|
|
SmallVector<SourceLocation, 8> LocationStack;
|
2015-08-13 02:24:59 +08:00
|
|
|
unsigned IgnoredEnd = 0;
|
2018-04-30 13:25:48 +08:00
|
|
|
while (L.isMacroID()) {
|
2015-08-28 07:38:45 +08:00
|
|
|
// If this is the expansion of a macro argument, point the caret at the
|
|
|
|
// use of the argument in the definition of the macro, not the expansion.
|
2018-04-30 13:25:48 +08:00
|
|
|
if (SM.isMacroArgExpansion(L))
|
|
|
|
LocationStack.push_back(SM.getImmediateExpansionRange(L).getBegin());
|
2015-08-28 07:38:45 +08:00
|
|
|
else
|
2018-04-30 13:25:48 +08:00
|
|
|
LocationStack.push_back(L);
|
2015-08-28 07:38:45 +08:00
|
|
|
|
2018-04-30 13:25:48 +08:00
|
|
|
if (checkRangesForMacroArgExpansion(FullSourceLoc(L, SM), Ranges))
|
2015-08-13 02:24:59 +08:00
|
|
|
IgnoredEnd = LocationStack.size();
|
|
|
|
|
2018-04-30 13:25:48 +08:00
|
|
|
L = SM.getImmediateMacroCallerLoc(L);
|
2015-08-28 07:38:45 +08:00
|
|
|
|
|
|
|
// Once the location no longer points into a macro, try stepping through
|
|
|
|
// the last found location. This sometimes produces additional useful
|
|
|
|
// backtraces.
|
2018-04-30 13:25:48 +08:00
|
|
|
if (L.isFileID())
|
|
|
|
L = SM.getImmediateMacroCallerLoc(LocationStack.back());
|
|
|
|
assert(L.isValid() && "must have a valid source location here");
|
2011-12-17 13:26:04 +08:00
|
|
|
}
|
2012-12-05 11:18:16 +08:00
|
|
|
|
2015-08-13 02:24:59 +08:00
|
|
|
LocationStack.erase(LocationStack.begin(),
|
|
|
|
LocationStack.begin() + IgnoredEnd);
|
|
|
|
|
2015-07-29 04:53:46 +08:00
|
|
|
unsigned MacroDepth = LocationStack.size();
|
|
|
|
unsigned MacroLimit = DiagOpts->MacroBacktraceLimit;
|
|
|
|
if (MacroDepth <= MacroLimit || MacroLimit == 0) {
|
|
|
|
for (auto I = LocationStack.rbegin(), E = LocationStack.rend();
|
|
|
|
I != E; ++I)
|
2018-04-30 13:25:48 +08:00
|
|
|
emitSingleMacroExpansion(FullSourceLoc(*I, SM), Level, Ranges);
|
2011-12-17 13:26:04 +08:00
|
|
|
return;
|
|
|
|
}
|
2012-11-03 11:36:51 +08:00
|
|
|
|
2015-07-29 04:53:46 +08:00
|
|
|
unsigned MacroStartMessages = MacroLimit / 2;
|
|
|
|
unsigned MacroEndMessages = MacroLimit / 2 + MacroLimit % 2;
|
2012-12-05 11:18:16 +08:00
|
|
|
|
2015-07-29 04:53:46 +08:00
|
|
|
for (auto I = LocationStack.rbegin(),
|
|
|
|
E = LocationStack.rbegin() + MacroStartMessages;
|
|
|
|
I != E; ++I)
|
2018-04-30 13:25:48 +08:00
|
|
|
emitSingleMacroExpansion(FullSourceLoc(*I, SM), Level, Ranges);
|
2012-11-03 11:36:51 +08:00
|
|
|
|
2015-07-29 04:53:46 +08:00
|
|
|
SmallString<200> MessageStorage;
|
2011-12-17 13:26:04 +08:00
|
|
|
llvm::raw_svector_ostream Message(MessageStorage);
|
2015-07-29 04:53:46 +08:00
|
|
|
Message << "(skipping " << (MacroDepth - MacroLimit)
|
|
|
|
<< " expansions in backtrace; use -fmacro-backtrace-limit=0 to "
|
|
|
|
"see all)";
|
|
|
|
emitBasicNote(Message.str());
|
|
|
|
|
|
|
|
for (auto I = LocationStack.rend() - MacroEndMessages,
|
|
|
|
E = LocationStack.rend();
|
|
|
|
I != E; ++I)
|
2018-04-30 13:25:48 +08:00
|
|
|
emitSingleMacroExpansion(FullSourceLoc(*I, SM), Level, Ranges);
|
2011-12-17 13:26:04 +08:00
|
|
|
}
|
|
|
|
|
2018-03-22 08:53:26 +08:00
|
|
|
DiagnosticNoteRenderer::~DiagnosticNoteRenderer() = default;
|
2012-02-14 10:46:00 +08:00
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticNoteRenderer::emitIncludeLocation(FullSourceLoc Loc,
|
|
|
|
PresumedLoc PLoc) {
|
2012-02-14 10:46:00 +08:00
|
|
|
// Generate a note indicating the include location.
|
|
|
|
SmallString<200> MessageStorage;
|
|
|
|
llvm::raw_svector_ostream Message(MessageStorage);
|
|
|
|
Message << "in file included from " << PLoc.getFilename() << ':'
|
|
|
|
<< PLoc.getLine() << ":";
|
2017-06-27 17:50:38 +08:00
|
|
|
emitNote(Loc, Message.str());
|
2012-02-14 10:46:00 +08:00
|
|
|
}
|
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticNoteRenderer::emitImportLocation(FullSourceLoc Loc,
|
2012-12-01 05:58:49 +08:00
|
|
|
PresumedLoc PLoc,
|
2017-06-27 17:50:38 +08:00
|
|
|
StringRef ModuleName) {
|
2012-12-01 05:58:49 +08:00
|
|
|
// Generate a note indicating the include location.
|
|
|
|
SmallString<200> MessageStorage;
|
|
|
|
llvm::raw_svector_ostream Message(MessageStorage);
|
2015-08-11 08:05:21 +08:00
|
|
|
Message << "in module '" << ModuleName;
|
2015-10-03 13:15:57 +08:00
|
|
|
if (PLoc.isValid())
|
2015-08-11 08:05:21 +08:00
|
|
|
Message << "' imported from " << PLoc.getFilename() << ':'
|
|
|
|
<< PLoc.getLine();
|
|
|
|
Message << ":";
|
2017-06-27 17:50:38 +08:00
|
|
|
emitNote(Loc, Message.str());
|
2012-12-01 05:58:49 +08:00
|
|
|
}
|
|
|
|
|
2017-06-27 17:50:38 +08:00
|
|
|
void DiagnosticNoteRenderer::emitBuildingModuleLocation(FullSourceLoc Loc,
|
|
|
|
PresumedLoc PLoc,
|
|
|
|
StringRef ModuleName) {
|
2012-12-01 02:38:50 +08:00
|
|
|
// Generate a note indicating the include location.
|
|
|
|
SmallString<200> MessageStorage;
|
|
|
|
llvm::raw_svector_ostream Message(MessageStorage);
|
2016-06-28 09:02:31 +08:00
|
|
|
if (PLoc.isValid())
|
2014-03-06 04:55:36 +08:00
|
|
|
Message << "while building module '" << ModuleName << "' imported from "
|
|
|
|
<< PLoc.getFilename() << ':' << PLoc.getLine() << ":";
|
|
|
|
else
|
2014-07-26 09:22:02 +08:00
|
|
|
Message << "while building module '" << ModuleName << "':";
|
2017-06-27 17:50:38 +08:00
|
|
|
emitNote(Loc, Message.str());
|
2012-12-01 02:38:50 +08:00
|
|
|
}
|