Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Sepanski
loopy
Commits
37f317c5
Commit
37f317c5
authored
8 years ago
by
Matt Wala
Browse files
Options
Downloads
Patches
Plain Diff
C expression to code mapper: Parenthesize '&&' within '||' to avoid
warnings from clang-based compilers.
parent
61adce98
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loopy/target/c/codegen/expression.py
+14
-3
14 additions, 3 deletions
loopy/target/c/codegen/expression.py
with
14 additions
and
3 deletions
loopy/target/c/codegen/expression.py
+
14
−
3
View file @
37f317c5
...
@@ -685,6 +685,10 @@ class CExpressionToCodeMapper(RecursiveMapper):
...
@@ -685,6 +685,10 @@ class CExpressionToCodeMapper(RecursiveMapper):
return
f
%
tuple
(
return
f
%
tuple
(
self
.
rec
(
i
,
prec
)
for
i
in
iterable
)
self
.
rec
(
i
,
prec
)
for
i
in
iterable
)
def
join
(
self
,
joiner
,
iterable
):
f
=
joiner
.
join
(
"
%s
"
for
i
in
iterable
)
return
f
%
tuple
(
iterable
)
# }}}
# }}}
def
map_constant
(
self
,
expr
,
prec
):
def
map_constant
(
self
,
expr
,
prec
):
...
@@ -779,9 +783,16 @@ class CExpressionToCodeMapper(RecursiveMapper):
...
@@ -779,9 +783,16 @@ class CExpressionToCodeMapper(RecursiveMapper):
enclosing_prec
,
PREC_LOGICAL_AND
)
enclosing_prec
,
PREC_LOGICAL_AND
)
def
map_logical_or
(
self
,
expr
,
enclosing_prec
):
def
map_logical_or
(
self
,
expr
,
enclosing_prec
):
return
self
.
parenthesize_if_needed
(
mapped_children
=
[]
self
.
join_rec
(
"
||
"
,
expr
.
children
,
PREC_LOGICAL_OR
),
from
pymbolic.primitives
import
LogicalAnd
enclosing_prec
,
PREC_LOGICAL_OR
)
for
child
in
expr
.
children
:
mapped_child
=
self
.
rec
(
child
,
PREC_LOGICAL_OR
)
# clang warns on unparenthesized && within ||
if
isinstance
(
child
,
LogicalAnd
):
mapped_child
=
"
(%s)
"
%
mapped_child
mapped_children
.
append
(
mapped_child
)
return
self
.
join
(
"
||
"
,
mapped_children
)
def
map_sum
(
self
,
expr
,
enclosing_prec
):
def
map_sum
(
self
,
expr
,
enclosing_prec
):
from
pymbolic.mapper.stringifier
import
PREC_SUM
from
pymbolic.mapper.stringifier
import
PREC_SUM
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment