[clang] [clang-repl] Refactor locking of runtime PTU stack (NFC) (PR #84176)

Stefan Gränitz via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 12:31:47 PST 2024


================
@@ -137,9 +136,10 @@ class Interpreter {
 
   Expr *SynthesizeExpr(Expr *E);
 
-private:
----------------
weliveindetail wrote:

> We can befriend the test to the interpreter.

I don't think we can do this:
```
// Defines FRIEND_TEST.
#include <gtest/gtest_prod.h>
```

> make this `protected:` and have a derived class on the test side to access this

The derived class must mimic `clang::Interpreter::create()`, but we can't because the ctor is private. There are a few more options:
(1) Allow to derive properly from Interpreter. (Pragmatic choice. Effort seems reasonable.)
(2) Build another factory interface around it, like "InterpreterBuilder". (Too much effort.)
(3) Integrate it into `IncrementalCompilerBuilder`. (Not sure, but maybe interesting.)
(4) Add a special purpose `create` function. (Quick and hacky)

This will not remain the only case, where we want to access the extended class surface from tests. What do you think?

https://github.com/llvm/llvm-project/pull/84176


More information about the cfe-commits mailing list