[llvm] r210591 - Mark a few functions noexcept.

Nick Kledzik kledzik at apple.com
Tue Jun 10 14:55:10 PDT 2014


Rafael,

Out of curiosity, how did you choose these functions to mark noexcept?   Is there some usage pattern that can be better optimized with noexcept? 

-Nick

On Jun 10, 2014, at 2:26 PM, Rafael Espindola <rafael.espindola at gmail.com> wrote:
> Author: rafael
> Date: Tue Jun 10 16:26:47 2014
> New Revision: 210591
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=210591&view=rev
> Log:
> Mark a few functions noexcept.
> 
> This reduces the difference between std::error_code and llvm::error_code.
> 
> Modified:
>    llvm/trunk/include/llvm/Support/system_error.h
>    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
>    llvm/trunk/lib/Object/Error.cpp
>    llvm/trunk/lib/ProfileData/InstrProf.cpp
>    llvm/trunk/lib/Support/system_error.cpp
>    llvm/trunk/tools/llvm-readobj/Error.cpp
>    llvm/trunk/tools/obj2yaml/Error.cpp
> 
> Modified: llvm/trunk/include/llvm/Support/system_error.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/system_error.h?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/system_error.h (original)
> +++ llvm/trunk/include/llvm/Support/system_error.h Tue Jun 10 16:26:47 2014
> @@ -624,10 +624,12 @@ private:
>   error_category& operator=(const error_category&) LLVM_DELETED_FUNCTION;
> 
> public:
> -  virtual const char* name() const = 0;
> -  virtual error_condition default_error_condition(int _ev) const;
> -  virtual bool equivalent(int _code, const error_condition& _condition) const;
> -  virtual bool equivalent(const error_code& _code, int _condition) const;
> +  virtual const char* name() const LLVM_NOEXCEPT = 0;
> +  virtual error_condition default_error_condition(int _ev) const LLVM_NOEXCEPT;
> +  virtual bool
> +  equivalent(int _code, const error_condition &_condition) const LLVM_NOEXCEPT;
> +  virtual bool equivalent(const error_code &_code,
> +                          int _condition) const LLVM_NOEXCEPT;
>   virtual std::string message(int _ev) const = 0;
> 
>   bool operator==(const error_category& _rhs) const {return this == &_rhs;}
> 
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jun 10 16:26:47 2014
> @@ -3301,7 +3301,7 @@ error_code BitcodeReader::InitLazyStream
> 
> namespace {
> class BitcodeErrorCategoryType : public error_category {
> -  const char *name() const override {
> +  const char *name() const LLVM_NOEXCEPT override {
>     return "llvm.bitcode";
>   }
>   std::string message(int IE) const override {
> 
> Modified: llvm/trunk/lib/Object/Error.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/Error.cpp (original)
> +++ llvm/trunk/lib/Object/Error.cpp Tue Jun 10 16:26:47 2014
> @@ -20,9 +20,9 @@ using namespace object;
> namespace {
> class _object_error_category : public error_category {
> public:
> -  const char* name() const override;
> +  const char* name() const LLVM_NOEXCEPT override;
>   std::string message(int ev) const override;
> -  error_condition default_error_condition(int ev) const override;
> +  error_condition default_error_condition(int ev) const LLVM_NOEXCEPT override;
> };
> }
> 
> 
> Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
> +++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Jun 10 16:26:47 2014
> @@ -19,7 +19,7 @@ using namespace llvm;
> 
> namespace {
> class InstrProfErrorCategoryType : public error_category {
> -  const char *name() const override { return "llvm.instrprof"; }
> +  const char *name() const LLVM_NOEXCEPT override { return "llvm.instrprof"; }
>   std::string message(int IE) const override {
>     instrprof_error E = static_cast<instrprof_error>(IE);
>     switch (E) {
> @@ -52,7 +52,7 @@ class InstrProfErrorCategoryType : publi
>     }
>     llvm_unreachable("A value of instrprof_error has no message.");
>   }
> -  error_condition default_error_condition(int EV) const override {
> +  error_condition default_error_condition(int EV) const LLVM_NOEXCEPT override {
>     if (static_cast<instrprof_error>(EV) == instrprof_error::success)
>       return error_condition();
>     return errc::invalid_argument;
> 
> Modified: llvm/trunk/lib/Support/system_error.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/system_error.cpp?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/system_error.cpp (original)
> +++ llvm/trunk/lib/Support/system_error.cpp Tue Jun 10 16:26:47 2014
> @@ -48,7 +48,7 @@ _do_message::message(int ev) const {
> 
> class _generic_error_category : public _do_message {
> public:
> -  const char* name() const override;
> +  const char* name() const LLVM_NOEXCEPT override;
>   std::string message(int ev) const override;
> };
> 
> @@ -74,7 +74,7 @@ generic_category() {
> 
> class _system_error_category : public _do_message {
> public:
> -  const char* name() const override;
> +  const char* name() const LLVM_NOEXCEPT override;
>   std::string message(int ev) const override;
>   error_condition default_error_condition(int ev) const override;
> };
> 
> Modified: llvm/trunk/tools/llvm-readobj/Error.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/Error.cpp?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/Error.cpp (original)
> +++ llvm/trunk/tools/llvm-readobj/Error.cpp Tue Jun 10 16:26:47 2014
> @@ -19,9 +19,9 @@ using namespace llvm;
> namespace {
> class _readobj_error_category : public error_category {
> public:
> -  const char* name() const override;
> +  const char* name() const LLVM_NOEXCEPT override;
>   std::string message(int ev) const override;
> -  error_condition default_error_condition(int ev) const override;
> +  error_condition default_error_condition(int ev) const LLVM_NOEXCEPT override;
> };
> } // namespace
> 
> 
> Modified: llvm/trunk/tools/obj2yaml/Error.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/Error.cpp?rev=210591&r1=210590&r2=210591&view=diff
> ==============================================================================
> --- llvm/trunk/tools/obj2yaml/Error.cpp (original)
> +++ llvm/trunk/tools/obj2yaml/Error.cpp Tue Jun 10 16:26:47 2014
> @@ -15,9 +15,9 @@ using namespace llvm;
> namespace {
> class _obj2yaml_error_category : public error_category {
> public:
> -  const char *name() const override;
> +  const char *name() const LLVM_NOEXCEPT override;
>   std::string message(int ev) const override;
> -  error_condition default_error_condition(int ev) const override;
> +  error_condition default_error_condition(int ev) const LLVM_NOEXCEPT override;
> };
> } // namespace
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list