[PATCH] D111198: [Support] Make consumeError, toString callable from code compiled with RTTI.

Vassil Vassilev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 7 12:36:44 PDT 2021


v.g.vassilev added a comment.

In D111198#3048647 <https://reviews.llvm.org/D111198#3048647>, @v.g.vassilev wrote:

> In D111198#3044293 <https://reviews.llvm.org/D111198#3044293>, @lhames wrote:
>
>> Vassil -- This is a generalization of the error fix that we discussed. Could you double check that it fixes the linker error that you saw?
>>
>> After thinking about it for a while I'm on the fence about this approach -- on the one hand it's a reasonable cleanup, on the other hand I don't think we generally support linking -no-rtti LLVM libraries from -rtti code, and support for doing that (even partial support) might be an explicit non-goal for the project.
>>
>> Another approach to fixing the example might just be to split it into two files. Pros of that approach: it deals with no-rtti/rtti crossover code The Right Way, Con: it complicates the example for everyone else.
>
> @lhames, thanks a lot for the patch -- this makes D107049 <https://reviews.llvm.org/D107049> compile. I do not have a strong opinion on how/should we bridge rtti/no-rtti. I feel this will come up more often due to clang-repl...

Going via C also works for me:

  diff
  diff --git a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  index 744a98bcdc87..fbdeddf0300b 100644
  --- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  +++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  @@ -25,6 +25,7 @@
   #include "llvm/ExecutionEngine/Orc/LLJIT.h"
   #include "llvm/Support/ManagedStatic.h"
   #include "llvm/Support/TargetSelect.h"
  +#include "llvm-c/Error.h"
   
   #include "gmock/gmock.h"
   #include "gtest/gtest.h"
  @@ -52,9 +53,7 @@ TEST(InterpreterTest, CatchException) {
       auto J = llvm::orc::LLJITBuilder().create();
       if (!J) {
         // The platform does not support JITs.
  -      // We can't use llvm::consumeError as it needs typeinfo for ErrorInfoBase.
  -      auto E = J.takeError();
  -      (void)E;
  +      LLVMConsumeError(llvm::wrap(J.takeError()));
         return;
       }
     }

I think that would be the least intrusive way to go...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111198/new/

https://reviews.llvm.org/D111198



More information about the llvm-commits mailing list