From 360d4f7a17a066cc878cdb2c558464bfdeaa3418 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 17 Feb 2021 19:04:48 -0500 Subject: More #line improvements (#1713) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP: First pass in supporting output of line error information. * Add support for lexing to better be able to indicate SourceLocation information. * Fix lexer usage in DiagnosticSink in C++ extractor. * Update diagnostics tests to have line location info. * Fixed test expected output that now have source location information in them. * Better handling of tab. * Fix test expected results for tabbing change. * DiagnosticLexer -> DiagnosticSink::SourceLocationLexer Added line continuation tests. * Fix typo. * Added String::appendRepeatedChar * Change to rerun tests. * Added source locations to IR dumping. * Output column for IR dump source loc. * Add support for closing brace location to AST. Use closing brace location in lowering when adding return void. * Set the source location through SourceLoc - simplifies identifying if current loc is valid. * Copy terminator sloc. * Test for improved #line handling. * Made writer the last parameter for dumpIR. Small improvements to comments. * Disable sloc output on dump IR by default. * Fix issue with #line and inlining. * Fix for output with improved #line output. * Small comment change - mainly to kick off TC build. Co-authored-by: Tim Foley --- source/slang/slang-source-loc.cpp | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'source/slang/slang-source-loc.cpp') diff --git a/source/slang/slang-source-loc.cpp b/source/slang/slang-source-loc.cpp index f6b0afcc1..4b9e16b8e 100644 --- a/source/slang/slang-source-loc.cpp +++ b/source/slang/slang-source-loc.cpp @@ -21,6 +21,61 @@ const String PathInfo::getMostUniqueIdentity() const } } +bool PathInfo::operator==(const ThisType& rhs) const +{ + // They must be the same type + if (type != rhs.type) + { + return false; + } + + switch (type) + { + case Type::TokenPaste: + case Type::TypeParse: + case Type::Unknown: + case Type::CommandLine: + { + return true; + } + case Type::Normal: + { + return foundPath == rhs.foundPath && uniqueIdentity == rhs.uniqueIdentity; + } + case Type::FromString: + case Type::FoundPath: + { + // Only have a found path + return foundPath == rhs.foundPath; + } + default: break; + } + + return false; +} + +void PathInfo::appendDisplayName(StringBuilder& out) const +{ + switch (type) + { + case Type::TokenPaste: out << "[Token Paste]"; break; + case Type::TypeParse: out << "[Type Parse]"; break; + case Type::Unknown: out << "[Unknown]"; break; + case Type::CommandLine: out << "[Command Line]"; break; + case Type::Normal: + case Type::FromString: + case Type::FoundPath: + { + // TODO(JS): We might want to escape the path here if necessary + out.appendChar('"'); + out << foundPath; + out.appendChar('"'); + break; + } + default: break; + } +} + /* !!!!!!!!!!!!!!!!!!!!!!!!! SourceView !!!!!!!!!!!!!!!!!!!!!!!!!!!! */ int SourceView::findEntryIndex(SourceLoc sourceLoc) const -- cgit v1.2.3