alexfh marked an inline comment as done.
alexfh added inline comments.

================
Comment at: clang/include/clang/Lex/PPCallbacks.h:346
+
+  virtual void setPreprocessor(Preprocessor *preprocessor) {
+    preprocessor_ = preprocessor;
----------------
sammccall wrote:
> This seems pretty tangly from a layering point of view, giving each object a 
> reference to the other. I always find it hard to reason about ownership in 
> such cases.
> 
> What about lifecycle methods `beginPreprocessing(Preprocessor*)` and 
> `endPreprocessing(Preprocessor*)`? It will look similar in practice: 
> subclasses that need it can still track the PP instance, but the circular 
> references will only be there when needed, and will be explicit.
We can do that as well. However, adding another couple of overrides to each 
PPCallbacks implementation will result in quite some boilerplate. How would you 
look at creating an intermediate class in the `PPCallbacks` -> <users' 
PPCallbacks handlers> hierarchy that will handle 
`beginPreprocessing`/`endPreprocessing` and expose the preprocessor pointer via 
a protected `getPreprocessor()` method?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58278



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to