diff options
author | Andrey Tuganov <andreyt@google.com> | 2017-10-11 18:13:21 -0400 |
---|---|---|
committer | David Neto <dneto@google.com> | 2017-10-12 15:32:32 -0400 |
commit | b54997e6ebd9e361ed438fd5cdb1de5dfa5f4f56 (patch) | |
tree | 99b7cc36e165bd78df82187e656025cce118c5c2 /source/val | |
parent | 720beb161a7c3802cbc086c05466b52e8f187e07 (diff) | |
download | spirv-tools-b54997e6ebd9e361ed438fd5cdb1de5dfa5f4f56.tar.gz |
Validator checks OpReturn called from void func
Added check into validate_cfg which checks that OpReturn is not called
from functions which are supposed to return a value.
Diffstat (limited to 'source/val')
-rw-r--r-- | source/val/function.h | 5 | ||||
-rw-r--r-- | source/val/validation_state.cpp | 5 | ||||
-rw-r--r-- | source/val/validation_state.h | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/source/val/function.h b/source/val/function.h index 7eb8dcdf..8baeb33f 100644 --- a/source/val/function.h +++ b/source/val/function.h @@ -133,9 +133,12 @@ class Function { /// Returns the number of blocks in the current function being parsed size_t block_count() const; - /// Returns the id of the funciton + /// Returns the id of the function uint32_t id() const { return id_; } + /// Returns return type id of the function + uint32_t GetResultTypeId() const { return result_type_id_; } + /// Returns the number of blocks in the current function being parsed size_t undefined_block_count() const; const std::unordered_set<uint32_t>& undefined_blocks() const { diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp index ee11e1dc..8594e8ad 100644 --- a/source/val/validation_state.cpp +++ b/source/val/validation_state.cpp @@ -261,6 +261,11 @@ Function& ValidationState_t::current_function() { return module_functions_.back(); } +const Function& ValidationState_t::current_function() const { + assert(in_function_body()); + return module_functions_.back(); +} + bool ValidationState_t::in_function_body() const { return in_function_; } bool ValidationState_t::in_block() const { diff --git a/source/val/validation_state.h b/source/val/validation_state.h index ad56703f..736f4c25 100644 --- a/source/val/validation_state.h +++ b/source/val/validation_state.h @@ -138,6 +138,7 @@ class ValidationState_t { /// Returns the function states Function& current_function(); + const Function& current_function() const; /// Returns true if the called after a function instruction but before the /// function end instruction |