Sanitize debug source location tracking for implicit branch and return

This patch tries to attach debug location of a branch/return instruction to its predecessor or the closing brace. If none could be found, no debug info should be emitted.
This commit is contained in:
Qingyuan Zheng 2024-08-26 03:53:07 +00:00 committed by arcady-lunarg
parent b1fac200c4
commit a496a34b43
30 changed files with 4713 additions and 4253 deletions

View file

@ -1694,8 +1694,12 @@ typedef TVector<TStorageQualifier> TQualifierList;
//
class TIntermAggregate : public TIntermOperator {
public:
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(nullptr) { }
TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(nullptr) { }
TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(nullptr) {
endLoc.init();
}
TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(nullptr) {
endLoc.init();
}
~TIntermAggregate() { delete pragmaTable; }
virtual TIntermAggregate* getAsAggregate() { return this; }
virtual const TIntermAggregate* getAsAggregate() const { return this; }
@ -1719,6 +1723,9 @@ public:
void setSpirvInstruction(const TSpirvInstruction& inst) { spirvInst = inst; }
const TSpirvInstruction& getSpirvInstruction() const { return spirvInst; }
void setEndLoc(TSourceLoc loc) { endLoc = loc; }
TSourceLoc getEndLoc() const { return endLoc; }
void setLinkType(TLinkType l) { linkType = l; }
TLinkType getLinkType() const { return linkType; }
protected:
@ -1733,6 +1740,10 @@ protected:
TPragmaTable* pragmaTable;
TSpirvInstruction spirvInst;
TLinkType linkType = ELinkNone;
// Marking the end source location of the aggregate.
// This is currently only set for a compound statement or a function body, pointing to '}'.
TSourceLoc endLoc;
};
//

View file

@ -3773,8 +3773,10 @@ compound_statement
--parseContext.statementNestingLevel;
}
RIGHT_BRACE {
if ($3 && $3->getAsAggregate())
if ($3 && $3->getAsAggregate()) {
$3->getAsAggregate()->setOperator(parseContext.intermediate.getDebugInfo() ? EOpScope : EOpSequence);
$3->getAsAggregate()->setEndLoc($5.loc);
}
$$ = $3;
}
;
@ -3810,8 +3812,10 @@ compound_statement_no_new_scope
$$ = 0;
}
| LEFT_BRACE statement_list RIGHT_BRACE {
if ($2 && $2->getAsAggregate())
if ($2 && $2->getAsAggregate()) {
$2->getAsAggregate()->setOperator(EOpSequence);
$2->getAsAggregate()->setEndLoc($3.loc);
}
$$ = $2;
}
;

File diff suppressed because it is too large Load diff