Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
f6deacd5
Commit
f6deacd5
authored
Jun 06, 2017
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSL: Track control-flow nesting and warn on aliasing under it.
parent
9b2531ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
hlslGrammar.cpp
hlsl/hlslGrammar.cpp
+20
-3
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+1
-1
No files found.
hlsl/hlslGrammar.cpp
View file @
f6deacd5
...
@@ -2594,6 +2594,8 @@ bool HlslGrammar::acceptConditionalExpression(TIntermTyped*& node)
...
@@ -2594,6 +2594,8 @@ bool HlslGrammar::acceptConditionalExpression(TIntermTyped*& node)
if
(
node
==
nullptr
)
if
(
node
==
nullptr
)
return
false
;
return
false
;
++
parseContext
.
controlFlowNestingLevel
;
// this only needs to work right if no errors
TIntermTyped
*
trueNode
=
nullptr
;
TIntermTyped
*
trueNode
=
nullptr
;
if
(
!
acceptExpression
(
trueNode
))
{
if
(
!
acceptExpression
(
trueNode
))
{
expected
(
"expression after ?"
);
expected
(
"expression after ?"
);
...
@@ -2612,6 +2614,8 @@ bool HlslGrammar::acceptConditionalExpression(TIntermTyped*& node)
...
@@ -2612,6 +2614,8 @@ bool HlslGrammar::acceptConditionalExpression(TIntermTyped*& node)
return
false
;
return
false
;
}
}
--
parseContext
.
controlFlowNestingLevel
;
node
=
intermediate
.
addSelection
(
node
,
trueNode
,
falseNode
,
loc
);
node
=
intermediate
.
addSelection
(
node
,
trueNode
,
falseNode
,
loc
);
return
true
;
return
true
;
...
@@ -3288,6 +3292,8 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement)
...
@@ -3288,6 +3292,8 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement)
// create the child statements
// create the child statements
TIntermNodePair
thenElse
=
{
nullptr
,
nullptr
};
TIntermNodePair
thenElse
=
{
nullptr
,
nullptr
};
++
parseContext
.
controlFlowNestingLevel
;
// this only needs to work right if no errors
// then statement
// then statement
if
(
!
acceptScopedStatement
(
thenElse
.
node1
))
{
if
(
!
acceptScopedStatement
(
thenElse
.
node1
))
{
expected
(
"then statement"
);
expected
(
"then statement"
);
...
@@ -3306,6 +3312,7 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement)
...
@@ -3306,6 +3312,7 @@ bool HlslGrammar::acceptSelectionStatement(TIntermNode*& statement)
// Put the pieces together
// Put the pieces together
statement
=
intermediate
.
addSelection
(
condition
,
thenElse
,
loc
);
statement
=
intermediate
.
addSelection
(
condition
,
thenElse
,
loc
);
parseContext
.
popScope
();
parseContext
.
popScope
();
--
parseContext
.
controlFlowNestingLevel
;
return
true
;
return
true
;
}
}
...
@@ -3330,7 +3337,11 @@ bool HlslGrammar::acceptSwitchStatement(TIntermNode*& statement)
...
@@ -3330,7 +3337,11 @@ bool HlslGrammar::acceptSwitchStatement(TIntermNode*& statement)
// compound_statement
// compound_statement
parseContext
.
pushSwitchSequence
(
new
TIntermSequence
);
parseContext
.
pushSwitchSequence
(
new
TIntermSequence
);
++
parseContext
.
controlFlowNestingLevel
;
bool
statementOkay
=
acceptCompoundStatement
(
statement
);
bool
statementOkay
=
acceptCompoundStatement
(
statement
);
--
parseContext
.
controlFlowNestingLevel
;
if
(
statementOkay
)
if
(
statementOkay
)
statement
=
parseContext
.
addSwitch
(
loc
,
switchExpression
,
statement
?
statement
->
getAsAggregate
()
:
nullptr
);
statement
=
parseContext
.
addSwitch
(
loc
,
switchExpression
,
statement
?
statement
->
getAsAggregate
()
:
nullptr
);
...
@@ -3363,8 +3374,9 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
...
@@ -3363,8 +3374,9 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
case
EHTokWhile
:
case
EHTokWhile
:
// so that something declared in the condition is scoped to the lifetime
// so that something declared in the condition is scoped to the lifetime
// of the while sub-statement
// of the while sub-statement
parseContext
.
pushScope
();
parseContext
.
pushScope
();
// this only needs to work right if no errors
parseContext
.
nestLooping
();
parseContext
.
nestLooping
();
++
parseContext
.
controlFlowNestingLevel
;
// LEFT_PAREN condition RIGHT_PAREN
// LEFT_PAREN condition RIGHT_PAREN
if
(
!
acceptParenExpression
(
condition
))
if
(
!
acceptParenExpression
(
condition
))
...
@@ -3381,13 +3393,15 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
...
@@ -3381,13 +3393,15 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
parseContext
.
unnestLooping
();
parseContext
.
unnestLooping
();
parseContext
.
popScope
();
parseContext
.
popScope
();
--
parseContext
.
controlFlowNestingLevel
;
statement
=
intermediate
.
addLoop
(
statement
,
condition
,
nullptr
,
true
,
loc
,
control
);
statement
=
intermediate
.
addLoop
(
statement
,
condition
,
nullptr
,
true
,
loc
,
control
);
return
true
;
return
true
;
case
EHTokDo
:
case
EHTokDo
:
parseContext
.
nestLooping
();
parseContext
.
nestLooping
();
// this only needs to work right if no errors
++
parseContext
.
controlFlowNestingLevel
;
// statement
// statement
if
(
!
acceptScopedStatement
(
statement
))
{
if
(
!
acceptScopedStatement
(
statement
))
{
...
@@ -3413,6 +3427,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
...
@@ -3413,6 +3427,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
expected
(
";"
);
expected
(
";"
);
parseContext
.
unnestLooping
();
parseContext
.
unnestLooping
();
--
parseContext
.
controlFlowNestingLevel
;
statement
=
intermediate
.
addLoop
(
statement
,
condition
,
0
,
false
,
loc
,
control
);
statement
=
intermediate
.
addLoop
(
statement
,
condition
,
0
,
false
,
loc
,
control
);
...
@@ -3433,7 +3448,8 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
...
@@ -3433,7 +3448,8 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
if
(
!
acceptSimpleStatement
(
initNode
))
if
(
!
acceptSimpleStatement
(
initNode
))
expected
(
"for-loop initializer statement"
);
expected
(
"for-loop initializer statement"
);
parseContext
.
nestLooping
();
parseContext
.
nestLooping
();
// this only needs to work right if no errors
++
parseContext
.
controlFlowNestingLevel
;
// condition SEMI_COLON
// condition SEMI_COLON
acceptExpression
(
condition
);
acceptExpression
(
condition
);
...
@@ -3461,6 +3477,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
...
@@ -3461,6 +3477,7 @@ bool HlslGrammar::acceptIterationStatement(TIntermNode*& statement, const TAttri
parseContext
.
popScope
();
parseContext
.
popScope
();
parseContext
.
unnestLooping
();
parseContext
.
unnestLooping
();
--
parseContext
.
controlFlowNestingLevel
;
return
true
;
return
true
;
}
}
...
...
hlsl/hlslParseHelper.cpp
View file @
f6deacd5
...
@@ -518,7 +518,7 @@ TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const
...
@@ -518,7 +518,7 @@ TIntermTyped* HlslParseContext::handleSamplerLvalue(const TSourceLoc& loc, const
}
}
if
(
controlFlowNestingLevel
>
0
)
if
(
controlFlowNestingLevel
>
0
)
error
(
loc
,
"can't alias sampler in control flow
"
,
op
,
""
);
warn
(
loc
,
"sampler or image aliased under control flow; consumption must be in same path
"
,
op
,
""
);
// Best is if we are aliasing a flattened struct member "S.s1 = s2",
// Best is if we are aliasing a flattened struct member "S.s1 = s2",
// in which case we want to update the flattening information with the alias,
// in which case we want to update the flattening information with the alias,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment