diff options
author | Tim King <taking@google.com> | 2015-10-23 15:11:57 -0700 |
---|---|---|
committer | Tim King <taking@google.com> | 2015-10-23 19:12:23 -0700 |
commit | c9b7de773cdc53044e5cf4a55d4893d2be476b60 (patch) | |
tree | 24b93deaf10909a476cb2d3c0b16e26956a57641 /src/options | |
parent | dd59444639796fb56b11d3852ca436fc049f39c7 (diff) |
Switching Options::current() to return a pointer. This helps avoid undefined behavior due to dereferencing a null pointer in the future.
Diffstat (limited to 'src/options')
-rwxr-xr-x | src/options/mkoptions | 14 | ||||
-rw-r--r-- | src/options/options.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/options/mkoptions b/src/options/mkoptions index 03d7837ac..b4cea04d1 100755 --- a/src/options/mkoptions +++ b/src/options/mkoptions @@ -493,9 +493,9 @@ function handle_option { extern struct CVC4_PUBLIC ${internal}__option_t { typedef $type type; type operator()() const; bool wasSetByUser() const; } $internal CVC4_PUBLIC;" module_inlines="${module_inlines} #line $lineno \"$kf\" -inline ${internal}__option_t::type ${internal}__option_t::operator()() const { return Options::current()[*this]; } +inline ${internal}__option_t::type ${internal}__option_t::operator()() const { return (*Options::current())[*this]; } #line $lineno \"$kf\" -inline bool ${internal}__option_t::wasSetByUser() const { return Options::current().wasSetByUser(*this); } +inline bool ${internal}__option_t::wasSetByUser() const { return Options::current()->wasSetByUser(*this); } " else module_decls="${module_decls} @@ -503,11 +503,11 @@ inline bool ${internal}__option_t::wasSetByUser() const { return Options::curren extern struct CVC4_PUBLIC ${internal}__option_t { typedef $type type; type operator()() const; bool wasSetByUser() const; void set(const type& v); } $internal CVC4_PUBLIC;" module_inlines="${module_inlines} #line $lineno \"$kf\" -inline ${internal}__option_t::type ${internal}__option_t::operator()() const { return Options::current()[*this]; } +inline ${internal}__option_t::type ${internal}__option_t::operator()() const { return (*Options::current())[*this]; } #line $lineno \"$kf\" -inline bool ${internal}__option_t::wasSetByUser() const { return Options::current().wasSetByUser(*this); } +inline bool ${internal}__option_t::wasSetByUser() const { return Options::current()->wasSetByUser(*this); } #line $lineno \"$kf\" -inline void ${internal}__option_t::set(const ${internal}__option_t::type& v) { Options::current().set(*this, v); } +inline void ${internal}__option_t::set(const ${internal}__option_t::type& v) { Options::current()->set(*this, v); } " module_specializations="${module_specializations} #line $lineno \"$kf\" @@ -783,7 +783,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - Options::current().assignBool(options::$internal, \"$smtname\", optionarg == \"true\", smt);$run_smt_links + Options::current()->assignBool(options::$internal, \"$smtname\", optionarg == \"true\", smt);$run_smt_links return; }" elif [ -n "$expect_arg" -a "$internal" != - ]; then @@ -800,7 +800,7 @@ template <> options::${internal}__option_t::type runHandlerAndPredicates(options #line $lineno \"$kf\" if(key == \"$smtname\") { #line $lineno \"$kf\" - Options::current().assign(options::$internal, \"$smtname\", optionarg, smt);$run_smt_links + Options::current()->assign(options::$internal, \"$smtname\", optionarg, smt);$run_smt_links return; }" elif [ -n "$expect_arg" ]; then diff --git a/src/options/options.h b/src/options/options.h index 9656007f4..95c0fc331 100644 --- a/src/options/options.h +++ b/src/options/options.h @@ -66,8 +66,8 @@ public: } /** Get the current Options in effect */ - static inline Options& current() { - return *s_current; + static inline Options* current() { + return s_current; } Options(); |