Path: blob/main/contrib/llvm-project/clang/lib/Frontend/DiagnosticRenderer.cpp
35233 views
//===- DiagnosticRenderer.cpp - Diagnostic Pretty-Printing ----------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "clang/Frontend/DiagnosticRenderer.h"9#include "clang/Basic/Diagnostic.h"10#include "clang/Basic/DiagnosticOptions.h"11#include "clang/Basic/LLVM.h"12#include "clang/Basic/SourceLocation.h"13#include "clang/Basic/SourceManager.h"14#include "clang/Edit/Commit.h"15#include "clang/Edit/EditedSource.h"16#include "clang/Edit/EditsReceiver.h"17#include "clang/Lex/Lexer.h"18#include "llvm/ADT/ArrayRef.h"19#include "llvm/ADT/DenseMap.h"20#include "llvm/ADT/SmallString.h"21#include "llvm/ADT/SmallVector.h"22#include "llvm/ADT/StringRef.h"23#include "llvm/Support/raw_ostream.h"24#include <algorithm>25#include <cassert>26#include <iterator>27#include <utility>2829using namespace clang;3031DiagnosticRenderer::DiagnosticRenderer(const LangOptions &LangOpts,32DiagnosticOptions *DiagOpts)33: LangOpts(LangOpts), DiagOpts(DiagOpts), LastLevel() {}3435DiagnosticRenderer::~DiagnosticRenderer() = default;3637namespace {3839class FixitReceiver : public edit::EditsReceiver {40SmallVectorImpl<FixItHint> &MergedFixits;4142public:43FixitReceiver(SmallVectorImpl<FixItHint> &MergedFixits)44: MergedFixits(MergedFixits) {}4546void insert(SourceLocation loc, StringRef text) override {47MergedFixits.push_back(FixItHint::CreateInsertion(loc, text));48}4950void replace(CharSourceRange range, StringRef text) override {51MergedFixits.push_back(FixItHint::CreateReplacement(range, text));52}53};5455} // namespace5657static void mergeFixits(ArrayRef<FixItHint> FixItHints,58const SourceManager &SM, const LangOptions &LangOpts,59SmallVectorImpl<FixItHint> &MergedFixits) {60edit::Commit commit(SM, LangOpts);61for (const auto &Hint : FixItHints)62if (Hint.CodeToInsert.empty()) {63if (Hint.InsertFromRange.isValid())64commit.insertFromRange(Hint.RemoveRange.getBegin(),65Hint.InsertFromRange, /*afterToken=*/false,66Hint.BeforePreviousInsertions);67else68commit.remove(Hint.RemoveRange);69} else {70if (Hint.RemoveRange.isTokenRange() ||71Hint.RemoveRange.getBegin() != Hint.RemoveRange.getEnd())72commit.replace(Hint.RemoveRange, Hint.CodeToInsert);73else74commit.insert(Hint.RemoveRange.getBegin(), Hint.CodeToInsert,75/*afterToken=*/false, Hint.BeforePreviousInsertions);76}7778edit::EditedSource Editor(SM, LangOpts);79if (Editor.commit(commit)) {80FixitReceiver Rec(MergedFixits);81Editor.applyRewrites(Rec);82}83}8485void DiagnosticRenderer::emitDiagnostic(FullSourceLoc Loc,86DiagnosticsEngine::Level Level,87StringRef Message,88ArrayRef<CharSourceRange> Ranges,89ArrayRef<FixItHint> FixItHints,90DiagOrStoredDiag D) {91assert(Loc.hasManager() || Loc.isInvalid());9293beginDiagnostic(D, Level);9495if (!Loc.isValid())96// If we have no source location, just emit the diagnostic message.97emitDiagnosticMessage(Loc, PresumedLoc(), Level, Message, Ranges, D);98else {99// Get the ranges into a local array we can hack on.100SmallVector<CharSourceRange, 20> MutableRanges(Ranges.begin(),101Ranges.end());102103SmallVector<FixItHint, 8> MergedFixits;104if (!FixItHints.empty()) {105mergeFixits(FixItHints, Loc.getManager(), LangOpts, MergedFixits);106FixItHints = MergedFixits;107}108109for (const auto &Hint : FixItHints)110if (Hint.RemoveRange.isValid())111MutableRanges.push_back(Hint.RemoveRange);112113FullSourceLoc UnexpandedLoc = Loc;114115// Find the ultimate expansion location for the diagnostic.116Loc = Loc.getFileLoc();117118PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);119120// First, if this diagnostic is not in the main file, print out the121// "included from" lines.122emitIncludeStack(Loc, PLoc, Level);123124// Next, emit the actual diagnostic message and caret.125emitDiagnosticMessage(Loc, PLoc, Level, Message, Ranges, D);126emitCaret(Loc, Level, MutableRanges, FixItHints);127128// If this location is within a macro, walk from UnexpandedLoc up to Loc129// and produce a macro backtrace.130if (UnexpandedLoc.isValid() && UnexpandedLoc.isMacroID()) {131emitMacroExpansions(UnexpandedLoc, Level, MutableRanges, FixItHints);132}133}134135LastLoc = Loc;136LastLevel = Level;137138endDiagnostic(D, Level);139}140141void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {142emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),143Diag.getRanges(), Diag.getFixIts(),144&Diag);145}146147void DiagnosticRenderer::emitBasicNote(StringRef Message) {148emitDiagnosticMessage(FullSourceLoc(), PresumedLoc(), DiagnosticsEngine::Note,149Message, std::nullopt, DiagOrStoredDiag());150}151152/// Prints an include stack when appropriate for a particular153/// diagnostic level and location.154///155/// This routine handles all the logic of suppressing particular include156/// stacks (such as those for notes) and duplicate include stacks when157/// repeated warnings occur within the same file. It also handles the logic158/// of customizing the formatting and display of the include stack.159///160/// \param Loc The diagnostic location.161/// \param PLoc The presumed location of the diagnostic location.162/// \param Level The diagnostic level of the message this stack pertains to.163void DiagnosticRenderer::emitIncludeStack(FullSourceLoc Loc, PresumedLoc PLoc,164DiagnosticsEngine::Level Level) {165FullSourceLoc IncludeLoc =166PLoc.isInvalid() ? FullSourceLoc()167: FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager());168169// Skip redundant include stacks altogether.170if (LastIncludeLoc == IncludeLoc)171return;172173LastIncludeLoc = IncludeLoc;174175if (!DiagOpts->ShowNoteIncludeStack && Level == DiagnosticsEngine::Note)176return;177178if (IncludeLoc.isValid())179emitIncludeStackRecursively(IncludeLoc);180else {181emitModuleBuildStack(Loc.getManager());182emitImportStack(Loc);183}184}185186/// Helper to recursively walk up the include stack and print each layer187/// on the way back down.188void DiagnosticRenderer::emitIncludeStackRecursively(FullSourceLoc Loc) {189if (Loc.isInvalid()) {190emitModuleBuildStack(Loc.getManager());191return;192}193194PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);195if (PLoc.isInvalid())196return;197198// If this source location was imported from a module, print the module199// import stack rather than the200// FIXME: We want submodule granularity here.201std::pair<FullSourceLoc, StringRef> Imported = Loc.getModuleImportLoc();202if (!Imported.second.empty()) {203// This location was imported by a module. Emit the module import stack.204emitImportStackRecursively(Imported.first, Imported.second);205return;206}207208// Emit the other include frames first.209emitIncludeStackRecursively(210FullSourceLoc(PLoc.getIncludeLoc(), Loc.getManager()));211212// Emit the inclusion text/note.213emitIncludeLocation(Loc, PLoc);214}215216/// Emit the module import stack associated with the current location.217void DiagnosticRenderer::emitImportStack(FullSourceLoc Loc) {218if (Loc.isInvalid()) {219emitModuleBuildStack(Loc.getManager());220return;221}222223std::pair<FullSourceLoc, StringRef> NextImportLoc = Loc.getModuleImportLoc();224emitImportStackRecursively(NextImportLoc.first, NextImportLoc.second);225}226227/// Helper to recursively walk up the import stack and print each layer228/// on the way back down.229void DiagnosticRenderer::emitImportStackRecursively(FullSourceLoc Loc,230StringRef ModuleName) {231if (ModuleName.empty()) {232return;233}234235PresumedLoc PLoc = Loc.getPresumedLoc(DiagOpts->ShowPresumedLoc);236237// Emit the other import frames first.238std::pair<FullSourceLoc, StringRef> NextImportLoc = Loc.getModuleImportLoc();239emitImportStackRecursively(NextImportLoc.first, NextImportLoc.second);240241// Emit the inclusion text/note.242emitImportLocation(Loc, PLoc, ModuleName);243}244245/// Emit the module build stack, for cases where a module is (re-)built246/// on demand.247void DiagnosticRenderer::emitModuleBuildStack(const SourceManager &SM) {248ModuleBuildStack Stack = SM.getModuleBuildStack();249for (const auto &I : Stack) {250emitBuildingModuleLocation(I.second, I.second.getPresumedLoc(251DiagOpts->ShowPresumedLoc),252I.first);253}254}255256/// A recursive function to trace all possible backtrace locations257/// to match the \p CaretLocFileID.258static SourceLocation259retrieveMacroLocation(SourceLocation Loc, FileID MacroFileID,260FileID CaretFileID,261const SmallVectorImpl<FileID> &CommonArgExpansions,262bool IsBegin, const SourceManager *SM,263bool &IsTokenRange) {264assert(SM->getFileID(Loc) == MacroFileID);265if (MacroFileID == CaretFileID)266return Loc;267if (!Loc.isMacroID())268return {};269270CharSourceRange MacroRange, MacroArgRange;271272if (SM->isMacroArgExpansion(Loc)) {273// Only look at the immediate spelling location of this macro argument if274// the other location in the source range is also present in that expansion.275if (std::binary_search(CommonArgExpansions.begin(),276CommonArgExpansions.end(), MacroFileID))277MacroRange =278CharSourceRange(SM->getImmediateSpellingLoc(Loc), IsTokenRange);279MacroArgRange = SM->getImmediateExpansionRange(Loc);280} else {281MacroRange = SM->getImmediateExpansionRange(Loc);282MacroArgRange =283CharSourceRange(SM->getImmediateSpellingLoc(Loc), IsTokenRange);284}285286SourceLocation MacroLocation =287IsBegin ? MacroRange.getBegin() : MacroRange.getEnd();288if (MacroLocation.isValid()) {289MacroFileID = SM->getFileID(MacroLocation);290bool TokenRange = IsBegin ? IsTokenRange : MacroRange.isTokenRange();291MacroLocation =292retrieveMacroLocation(MacroLocation, MacroFileID, CaretFileID,293CommonArgExpansions, IsBegin, SM, TokenRange);294if (MacroLocation.isValid()) {295IsTokenRange = TokenRange;296return MacroLocation;297}298}299300// If we moved the end of the range to an expansion location, we now have301// a range of the same kind as the expansion range.302if (!IsBegin)303IsTokenRange = MacroArgRange.isTokenRange();304305SourceLocation MacroArgLocation =306IsBegin ? MacroArgRange.getBegin() : MacroArgRange.getEnd();307MacroFileID = SM->getFileID(MacroArgLocation);308return retrieveMacroLocation(MacroArgLocation, MacroFileID, CaretFileID,309CommonArgExpansions, IsBegin, SM, IsTokenRange);310}311312/// Walk up the chain of macro expansions and collect the FileIDs identifying the313/// expansions.314static void getMacroArgExpansionFileIDs(SourceLocation Loc,315SmallVectorImpl<FileID> &IDs,316bool IsBegin, const SourceManager *SM) {317while (Loc.isMacroID()) {318if (SM->isMacroArgExpansion(Loc)) {319IDs.push_back(SM->getFileID(Loc));320Loc = SM->getImmediateSpellingLoc(Loc);321} else {322auto ExpRange = SM->getImmediateExpansionRange(Loc);323Loc = IsBegin ? ExpRange.getBegin() : ExpRange.getEnd();324}325}326}327328/// Collect the expansions of the begin and end locations and compute the set329/// intersection. Produces a sorted vector of FileIDs in CommonArgExpansions.330static void computeCommonMacroArgExpansionFileIDs(331SourceLocation Begin, SourceLocation End, const SourceManager *SM,332SmallVectorImpl<FileID> &CommonArgExpansions) {333SmallVector<FileID, 4> BeginArgExpansions;334SmallVector<FileID, 4> EndArgExpansions;335getMacroArgExpansionFileIDs(Begin, BeginArgExpansions, /*IsBegin=*/true, SM);336getMacroArgExpansionFileIDs(End, EndArgExpansions, /*IsBegin=*/false, SM);337llvm::sort(BeginArgExpansions);338llvm::sort(EndArgExpansions);339std::set_intersection(BeginArgExpansions.begin(), BeginArgExpansions.end(),340EndArgExpansions.begin(), EndArgExpansions.end(),341std::back_inserter(CommonArgExpansions));342}343344// Helper function to fix up source ranges. It takes in an array of ranges,345// and outputs an array of ranges where we want to draw the range highlighting346// around the location specified by CaretLoc.347//348// To find locations which correspond to the caret, we crawl the macro caller349// chain for the beginning and end of each range. If the caret location350// is in a macro expansion, we search each chain for a location351// in the same expansion as the caret; otherwise, we crawl to the top of352// each chain. Two locations are part of the same macro expansion353// iff the FileID is the same.354static void355mapDiagnosticRanges(FullSourceLoc CaretLoc, ArrayRef<CharSourceRange> Ranges,356SmallVectorImpl<CharSourceRange> &SpellingRanges) {357FileID CaretLocFileID = CaretLoc.getFileID();358359const SourceManager *SM = &CaretLoc.getManager();360361for (const auto &Range : Ranges) {362if (Range.isInvalid())363continue;364365SourceLocation Begin = Range.getBegin(), End = Range.getEnd();366bool IsTokenRange = Range.isTokenRange();367368FileID BeginFileID = SM->getFileID(Begin);369FileID EndFileID = SM->getFileID(End);370371// Find the common parent for the beginning and end of the range.372373// First, crawl the expansion chain for the beginning of the range.374llvm::SmallDenseMap<FileID, SourceLocation> BeginLocsMap;375while (Begin.isMacroID() && BeginFileID != EndFileID) {376BeginLocsMap[BeginFileID] = Begin;377Begin = SM->getImmediateExpansionRange(Begin).getBegin();378BeginFileID = SM->getFileID(Begin);379}380381// Then, crawl the expansion chain for the end of the range.382if (BeginFileID != EndFileID) {383while (End.isMacroID() && !BeginLocsMap.count(EndFileID)) {384auto Exp = SM->getImmediateExpansionRange(End);385IsTokenRange = Exp.isTokenRange();386End = Exp.getEnd();387EndFileID = SM->getFileID(End);388}389if (End.isMacroID()) {390Begin = BeginLocsMap[EndFileID];391BeginFileID = EndFileID;392}393}394395// There is a chance that begin or end is invalid here, for example if396// specific compile error is reported.397// It is possible that the FileID's do not match, if one comes from an398// included file. In this case we can not produce a meaningful source range.399if (Begin.isInvalid() || End.isInvalid() || BeginFileID != EndFileID)400continue;401402// Do the backtracking.403SmallVector<FileID, 4> CommonArgExpansions;404computeCommonMacroArgExpansionFileIDs(Begin, End, SM, CommonArgExpansions);405Begin = retrieveMacroLocation(Begin, BeginFileID, CaretLocFileID,406CommonArgExpansions, /*IsBegin=*/true, SM,407IsTokenRange);408End = retrieveMacroLocation(End, BeginFileID, CaretLocFileID,409CommonArgExpansions, /*IsBegin=*/false, SM,410IsTokenRange);411if (Begin.isInvalid() || End.isInvalid()) continue;412413// Return the spelling location of the beginning and end of the range.414Begin = SM->getSpellingLoc(Begin);415End = SM->getSpellingLoc(End);416417SpellingRanges.push_back(CharSourceRange(SourceRange(Begin, End),418IsTokenRange));419}420}421422void DiagnosticRenderer::emitCaret(FullSourceLoc Loc,423DiagnosticsEngine::Level Level,424ArrayRef<CharSourceRange> Ranges,425ArrayRef<FixItHint> Hints) {426SmallVector<CharSourceRange, 4> SpellingRanges;427mapDiagnosticRanges(Loc, Ranges, SpellingRanges);428emitCodeContext(Loc, Level, SpellingRanges, Hints);429}430431/// A helper function for emitMacroExpansion to print the432/// macro expansion message433void DiagnosticRenderer::emitSingleMacroExpansion(434FullSourceLoc Loc, DiagnosticsEngine::Level Level,435ArrayRef<CharSourceRange> Ranges) {436// Find the spelling location for the macro definition. We must use the437// spelling location here to avoid emitting a macro backtrace for the note.438FullSourceLoc SpellingLoc = Loc.getSpellingLoc();439440// Map the ranges into the FileID of the diagnostic location.441SmallVector<CharSourceRange, 4> SpellingRanges;442mapDiagnosticRanges(Loc, Ranges, SpellingRanges);443444SmallString<100> MessageStorage;445llvm::raw_svector_ostream Message(MessageStorage);446StringRef MacroName = Lexer::getImmediateMacroNameForDiagnostics(447Loc, Loc.getManager(), LangOpts);448if (MacroName.empty())449Message << "expanded from here";450else451Message << "expanded from macro '" << MacroName << "'";452453emitDiagnostic(SpellingLoc, DiagnosticsEngine::Note, Message.str(),454SpellingRanges, std::nullopt);455}456457/// Check that the macro argument location of Loc starts with ArgumentLoc.458/// The starting location of the macro expansions is used to differeniate459/// different macro expansions.460static bool checkLocForMacroArgExpansion(SourceLocation Loc,461const SourceManager &SM,462SourceLocation ArgumentLoc) {463SourceLocation MacroLoc;464if (SM.isMacroArgExpansion(Loc, &MacroLoc)) {465if (ArgumentLoc == MacroLoc) return true;466}467468return false;469}470471/// Check if all the locations in the range have the same macro argument472/// expansion, and that the expansion starts with ArgumentLoc.473static bool checkRangeForMacroArgExpansion(CharSourceRange Range,474const SourceManager &SM,475SourceLocation ArgumentLoc) {476SourceLocation BegLoc = Range.getBegin(), EndLoc = Range.getEnd();477while (BegLoc != EndLoc) {478if (!checkLocForMacroArgExpansion(BegLoc, SM, ArgumentLoc))479return false;480BegLoc.getLocWithOffset(1);481}482483return checkLocForMacroArgExpansion(BegLoc, SM, ArgumentLoc);484}485486/// A helper function to check if the current ranges are all inside the same487/// macro argument expansion as Loc.488static bool checkRangesForMacroArgExpansion(FullSourceLoc Loc,489ArrayRef<CharSourceRange> Ranges) {490assert(Loc.isMacroID() && "Must be a macro expansion!");491492SmallVector<CharSourceRange, 4> SpellingRanges;493mapDiagnosticRanges(Loc, Ranges, SpellingRanges);494495// Count all valid ranges.496unsigned ValidCount =497llvm::count_if(Ranges, [](const auto &R) { return R.isValid(); });498499if (ValidCount > SpellingRanges.size())500return false;501502// To store the source location of the argument location.503FullSourceLoc ArgumentLoc;504505// Set the ArgumentLoc to the beginning location of the expansion of Loc506// so to check if the ranges expands to the same beginning location.507if (!Loc.isMacroArgExpansion(&ArgumentLoc))508return false;509510for (const auto &Range : SpellingRanges)511if (!checkRangeForMacroArgExpansion(Range, Loc.getManager(), ArgumentLoc))512return false;513514return true;515}516517/// Recursively emit notes for each macro expansion and caret518/// diagnostics where appropriate.519///520/// Walks up the macro expansion stack printing expansion notes, the code521/// snippet, caret, underlines and FixItHint display as appropriate at each522/// level.523///524/// \param Loc The location for this caret.525/// \param Level The diagnostic level currently being emitted.526/// \param Ranges The underlined ranges for this code snippet.527/// \param Hints The FixIt hints active for this diagnostic.528void DiagnosticRenderer::emitMacroExpansions(FullSourceLoc Loc,529DiagnosticsEngine::Level Level,530ArrayRef<CharSourceRange> Ranges,531ArrayRef<FixItHint> Hints) {532assert(Loc.isValid() && "must have a valid source location here");533const SourceManager &SM = Loc.getManager();534SourceLocation L = Loc;535536// Produce a stack of macro backtraces.537SmallVector<SourceLocation, 8> LocationStack;538unsigned IgnoredEnd = 0;539while (L.isMacroID()) {540// If this is the expansion of a macro argument, point the caret at the541// use of the argument in the definition of the macro, not the expansion.542if (SM.isMacroArgExpansion(L))543LocationStack.push_back(SM.getImmediateExpansionRange(L).getBegin());544else545LocationStack.push_back(L);546547if (checkRangesForMacroArgExpansion(FullSourceLoc(L, SM), Ranges))548IgnoredEnd = LocationStack.size();549550L = SM.getImmediateMacroCallerLoc(L);551552// Once the location no longer points into a macro, try stepping through553// the last found location. This sometimes produces additional useful554// backtraces.555if (L.isFileID())556L = SM.getImmediateMacroCallerLoc(LocationStack.back());557assert(L.isValid() && "must have a valid source location here");558}559560LocationStack.erase(LocationStack.begin(),561LocationStack.begin() + IgnoredEnd);562563unsigned MacroDepth = LocationStack.size();564unsigned MacroLimit = DiagOpts->MacroBacktraceLimit;565if (MacroDepth <= MacroLimit || MacroLimit == 0) {566for (auto I = LocationStack.rbegin(), E = LocationStack.rend();567I != E; ++I)568emitSingleMacroExpansion(FullSourceLoc(*I, SM), Level, Ranges);569return;570}571572unsigned MacroStartMessages = MacroLimit / 2;573unsigned MacroEndMessages = MacroLimit / 2 + MacroLimit % 2;574575for (auto I = LocationStack.rbegin(),576E = LocationStack.rbegin() + MacroStartMessages;577I != E; ++I)578emitSingleMacroExpansion(FullSourceLoc(*I, SM), Level, Ranges);579580SmallString<200> MessageStorage;581llvm::raw_svector_ostream Message(MessageStorage);582Message << "(skipping " << (MacroDepth - MacroLimit)583<< " expansions in backtrace; use -fmacro-backtrace-limit=0 to "584"see all)";585emitBasicNote(Message.str());586587for (auto I = LocationStack.rend() - MacroEndMessages,588E = LocationStack.rend();589I != E; ++I)590emitSingleMacroExpansion(FullSourceLoc(*I, SM), Level, Ranges);591}592593DiagnosticNoteRenderer::~DiagnosticNoteRenderer() = default;594595void DiagnosticNoteRenderer::emitIncludeLocation(FullSourceLoc Loc,596PresumedLoc PLoc) {597// Generate a note indicating the include location.598SmallString<200> MessageStorage;599llvm::raw_svector_ostream Message(MessageStorage);600Message << "in file included from " << PLoc.getFilename() << ':'601<< PLoc.getLine() << ":";602emitNote(Loc, Message.str());603}604605void DiagnosticNoteRenderer::emitImportLocation(FullSourceLoc Loc,606PresumedLoc PLoc,607StringRef ModuleName) {608// Generate a note indicating the include location.609SmallString<200> MessageStorage;610llvm::raw_svector_ostream Message(MessageStorage);611Message << "in module '" << ModuleName;612if (PLoc.isValid())613Message << "' imported from " << PLoc.getFilename() << ':'614<< PLoc.getLine();615Message << ":";616emitNote(Loc, Message.str());617}618619void DiagnosticNoteRenderer::emitBuildingModuleLocation(FullSourceLoc Loc,620PresumedLoc PLoc,621StringRef ModuleName) {622// Generate a note indicating the include location.623SmallString<200> MessageStorage;624llvm::raw_svector_ostream Message(MessageStorage);625if (PLoc.isValid())626Message << "while building module '" << ModuleName << "' imported from "627<< PLoc.getFilename() << ':' << PLoc.getLine() << ":";628else629Message << "while building module '" << ModuleName << "':";630emitNote(Loc, Message.str());631}632633634