diff options
| author | Yong He <yonghe@outlook.com> | 2019-01-28 09:45:42 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-28 09:45:42 -0800 |
| commit | 962f265df9e1b8549202a9b9543e1bead190638d (patch) | |
| tree | d11ff742f08a25469fa1a86c8b4d0061853fb63d /source/slang/emit.cpp | |
| parent | 864c38ee72991f414f2478ccacb462bfb11b4bca (diff) | |
| parent | df9dc5710725d00630831b77ca7005e390383aa6 (diff) | |
Merge branch 'master' into yong-fix
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 536c72e11..dd6feb50d 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3002,9 +3002,19 @@ struct EmitVisitor } else { + // If it returns void -> then we don't need parenthesis + + const auto returnType = inst->getDataType(); + const bool isVoid = as<IRVoidType>(returnType) != nullptr; + + // We could determine here is the return type is void... if so no braces? + // General case: we are going to emit some more complex text. - Emit("("); + if (!isVoid) + { + Emit("("); + } char const* cursor = name.begin(); char const* end = name.end(); @@ -3364,7 +3374,10 @@ struct EmitVisitor } } - Emit(")"); + if (!isVoid) + { + Emit(")"); + } } } |
