[llvm] r198799 - Use getError and remove the error_code operator.

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Jan 8 14:16:04 PST 2014


Hi Rafael,

I’m getting compile errors after this commit:

[44/1484] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/ELFObjectFile.cpp.o
FAILED: /usr/bin/c++   -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -fcolor-diagnostics -fno-rtti -g -Ilib/Object -I/Users/dexonsmith/data/trunk/llvm/lib/Object -Iinclude -I/Users/dexonsmith/data/trunk/llvm/include    -fno-exceptions -MMD -MT lib/Object/CMakeFiles/LLVMObject.dir/ELFObjectFile.cpp.o -MF "lib/Object/CMakeFiles/LLVMObject.dir/ELFObjectFile.cpp.o.d" -o lib/Object/CMakeFiles/LLVMObject.dir/ELFObjectFile.cpp.o -c /Users/dexonsmith/data/trunk/llvm/lib/Object/ELFObjectFile.cpp
In file included from /Users/dexonsmith/data/trunk/llvm/lib/Object/ELFObjectFile.cpp:14:
In file included from /Users/dexonsmith/data/trunk/llvm/include/llvm/Object/ELFObjectFile.h:22:
In file included from /Users/dexonsmith/data/trunk/llvm/include/llvm/Object/ELF.h:29:
/Users/dexonsmith/data/trunk/llvm/include/llvm/Support/ErrorOr.h:206:31: error: no matching constructor for initialization of 'llvm::error_code'
      new (getErrorStorage()) error_code(Other);
                              ^          ~~~~~
/Users/dexonsmith/data/trunk/llvm/include/llvm/Support/ErrorOr.h:127:5: note: in instantiation of function template specialization 'llvm::ErrorOr<llvm::StringRef>::copyConstruct<llvm::StringRef>' requested here
    copyConstruct(Other);
    ^
/Users/dexonsmith/data/trunk/llvm/include/llvm/Object/ELFObjectFile.h:234:7: note: in instantiation of member function 'llvm::ErrorOr<llvm::StringRef>::ErrorOr' requested here
      EF.getSymbolVersion(EF.getSection(Symb.d.b), symb, IsDefault);
      ^
/Users/dexonsmith/data/trunk/llvm/include/llvm/Object/ELFObjectFile.h:1008:20: note: in instantiation of member function 'llvm::object::ELFObjectFile<llvm::object::ELFType<1, 2, false> >::getSymbolVersion' requested here
    return ELFObj->getSymbolVersion(Sym, Version, IsDefault);
                   ^
/Users/dexonsmith/data/trunk/llvm/include/llvm/Support/system_error.h:726:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const ErrorOr<llvm::StringRef>' to 'const llvm::error_code' for 1st argument
class error_code {
      ^
/Users/dexonsmith/data/trunk/llvm/include/llvm/Support/system_error.h:740:3: note: candidate template ignored: substitution failure [with E = llvm::ErrorOr<llvm::StringRef>]: no type named 'type' in 'llvm::enable_if_c<false, void>'
  error_code(E _e, typename enable_if_c<
  ^
/Users/dexonsmith/data/trunk/llvm/include/llvm/Support/system_error.h:730:3: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
  error_code() : _val_(0), _cat_(&system_category()) {}
  ^
/Users/dexonsmith/data/trunk/llvm/include/llvm/Support/system_error.h:736:3: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
  error_code(int _val, const error_category& _cat)
  ^
1 error generated.


On Jan 8, 2014, at 2:03 PM, Rafael Espindola <rafael.espindola at gmail.com> wrote:

> Author: rafael
> Date: Wed Jan  8 16:03:39 2014
> New Revision: 198799
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=198799&view=rev
> Log:
> Use getError and remove the error_code operator.
> 
> Modified:
>    llvm/trunk/include/llvm/Object/ELFObjectFile.h
>    llvm/trunk/include/llvm/Support/ErrorOr.h
>    llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
>    llvm/trunk/unittests/Support/ErrorOrTest.cpp
> 
> Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=198799&r1=198798&r2=198799&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Wed Jan  8 16:03:39 2014
> @@ -219,7 +219,7 @@ error_code ELFObjectFile<ELFT>::getSymbo
>                                               StringRef &Result) const {
>   ErrorOr<StringRef> Name = EF.getSymbolName(toELFSymIter(Symb));
>   if (!Name)
> -    return Name;
> +    return Name.getError();
>   Result = *Name;
>   return object_error::success;
> }
> @@ -233,7 +233,7 @@ error_code ELFObjectFile<ELFT>::getSymbo
>   ErrorOr<StringRef> Ver =
>       EF.getSymbolVersion(EF.getSection(Symb.d.b), symb, IsDefault);
>   if (!Ver)
> -    return Ver;
> +    return Ver.getError();
>   Version = *Ver;
>   return object_error::success;
> }
> @@ -435,7 +435,7 @@ error_code ELFObjectFile<ELFT>::getSecti
>                                                StringRef &Result) const {
>   ErrorOr<StringRef> Name = EF.getSectionName(&*toELFShdrIter(Sec));
>   if (!Name)
> -    return Name;
> +    return Name.getError();
>   Result = *Name;
>   return object_error::success;
> }
> @@ -743,7 +743,7 @@ error_code ELFObjectFile<ELFT>::getReloc
>   ErrorOr<StringRef> SymName =
>       EF.getSymbolName(EF.getSection(sec->sh_link), symb);
>   if (!SymName)
> -    return SymName;
> +    return SymName.getError();
>   switch (EF.getHeader()->e_machine) {
>   case ELF::EM_X86_64:
>     switch (type) {
> 
> Modified: llvm/trunk/include/llvm/Support/ErrorOr.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorOr.h?rev=198799&r1=198798&r2=198799&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/ErrorOr.h (original)
> +++ llvm/trunk/include/llvm/Support/ErrorOr.h Wed Jan  8 16:03:39 2014
> @@ -181,10 +181,6 @@ public:
>   T &get() { return *getStorage(); }
>   const T &get() const { return const_cast<ErrorOr<T> >(this)->get(); }
> 
> -  operator llvm::error_code() const {
> -    return HasError ? *getErrorStorage() : llvm::error_code::success();
> -  }
> -
>   error_code getError() const {
>     return HasError ? *getErrorStorage() : error_code::success();
>   }
> @@ -240,7 +236,7 @@ private:
>     } else {
>       // Get other's error.
>       HasError = true;
> -      new (getErrorStorage()) error_code(Other);
> +      new (getErrorStorage()) error_code(Other.getError());
>     }
>   }
> 
> 
> Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=198799&r1=198798&r2=198799&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
> +++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Jan  8 16:03:39 2014
> @@ -66,7 +66,7 @@ private:
> 
> template <class T> T errorOrDefault(ErrorOr<T> Val, T Default = T()) {
>   if (!Val) {
> -    error(Val);
> +    error(Val.getError());
>     return Default;
>   }
> 
> @@ -632,7 +632,7 @@ void ELFDumper<ELFT>::printSymbol(typena
>       FullSymbolName += (IsDefault ? "@@" : "@");
>       FullSymbolName += *Version;
>     } else
> -      error(Version);
> +      error(Version.getError());
>   }
> 
>   DictScope D(W, "Symbol");
> 
> Modified: llvm/trunk/unittests/Support/ErrorOrTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ErrorOrTest.cpp?rev=198799&r1=198798&r2=198799&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/Support/ErrorOrTest.cpp (original)
> +++ llvm/trunk/unittests/Support/ErrorOrTest.cpp Wed Jan  8 16:03:39 2014
> @@ -25,7 +25,7 @@ TEST(ErrorOr, SimpleValue) {
> 
>   a = t2();
>   EXPECT_FALSE(a);
> -  EXPECT_EQ(errc::invalid_argument, a);
> +  EXPECT_EQ(errc::invalid_argument, a.getError());
> #ifdef EXPECT_DEBUG_DEATH
>   EXPECT_DEBUG_DEATH(*a, "Cannot get value when an error exists");
> #endif
> 
> 
> _______________________________________________
> 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