diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-02-17 19:04:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-17 16:04:48 -0800 |
| commit | 360d4f7a17a066cc878cdb2c558464bfdeaa3418 (patch) | |
| tree | 99133158bb0cae370c70ce060344ca1acbe958a2 /source/slang/slang-emit-c-like.cpp | |
| parent | e59aee131b6d51236613bc374cfa2d5f3b54efe1 (diff) | |
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 <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 570d48156..0bd6efad3 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -323,9 +323,9 @@ void CLikeSourceEmitter::emitTypeImpl(IRType* type, const StringSliceLoc* nameAn { if (nameAndLoc) { - // TODO(JS): No call to the previous version of this method was passing in a typeLoc, so disabled for - // now for simplicity - //m_writer->advanceToSourceLocation(typeLoc); + // We advance here, such that if there is a #line directive to output it will + // be done so before the type name appears. + m_writer->advanceToSourceLocationIfValid(nameAndLoc->loc); EDeclarator nameDeclarator; nameDeclarator.flavor = EDeclarator::Flavor::Name; @@ -1986,7 +1986,16 @@ void CLikeSourceEmitter::_emitInst(IRInst* inst) return; } - m_writer->advanceToSourceLocation(inst->sourceLoc); + // Specially handle params. The issue here is around PHI nodes, and that they do not + // have source loc information, by default, but we don't want to force outputting a #line. + if (inst->getOp() == kIROp_Param) + { + m_writer->advanceToSourceLocationIfValid(inst->sourceLoc); + } + else + { + m_writer->advanceToSourceLocation(inst->sourceLoc); + } switch(inst->getOp()) { @@ -2694,6 +2703,7 @@ void CLikeSourceEmitter::emitSimpleFuncImpl(IRFunc* func) auto name = getName(func); emitFuncDecorations(func); + emitType(resultType, name); emitSimpleFuncParamsImpl(func); emitSemantics(func); |
