From a005007c2e9132788c92aa5a9c5fed2cb90f7841 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 22 Jan 2019 16:15:15 -0500 Subject: * Fix comment on VerbosePath flag (#790) * Only output a 'verbose path' if it's different from the already output nominal path --- source/slang/diagnostics.cpp | 16 +++++++++++----- source/slang/diagnostics.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/slang/diagnostics.cpp b/source/slang/diagnostics.cpp index 00205fed3..4edea57a2 100644 --- a/source/slang/diagnostics.cpp +++ b/source/slang/diagnostics.cpp @@ -240,12 +240,18 @@ static void formatDiagnostic( if (sourceView && (sink->flags & DiagnosticSink::Flag::VerbosePath)) { - auto actualLoc = sourceView->getHumaneLoc(diagnostic.loc, SourceLocType::Actual); - // Look up the full path - SourceFile* sourceFile = sourceView->getSourceFile(); - actualLoc.pathInfo.foundPath = sourceFile->calcVerbosePath(); + auto actualHumaneLoc = sourceView->getHumaneLoc(diagnostic.loc, SourceLocType::Actual); - formatDiagnostic(actualLoc, diagnostic, sb); + // Look up the path verbosely (will get the canonical path if necessary) + actualHumaneLoc.pathInfo.foundPath = sourceView->getSourceFile()->calcVerbosePath(); + + // Only output if it's actually different + if (actualHumaneLoc.pathInfo.foundPath != humaneLoc.pathInfo.foundPath || + actualHumaneLoc.line != humaneLoc.line || + actualHumaneLoc.column != humaneLoc.column) + { + formatDiagnostic(actualHumaneLoc, diagnostic, sb); + } } } diff --git a/source/slang/diagnostics.h b/source/slang/diagnostics.h index fed492bc7..e3aba32e6 100644 --- a/source/slang/diagnostics.h +++ b/source/slang/diagnostics.h @@ -145,7 +145,7 @@ namespace Slang { enum Enum: uint32_t { - VerbosePath = 0x1, ///< Will try and display a + VerbosePath = 0x1, ///< Will display a more verbose path (if available) - such as a canonical or absolute path }; }; typedef uint32_t Flags; -- cgit v1.2.3