[PATCH] D29003: [OptDiag] Split code region out of DiagnosticInfoOptimizationBase

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 10:36:19 PST 2017


MatzeB added a comment.

Still good to go.



================
Comment at: lib/Analysis/OptimizationDiagnosticInfo.cpp:157
   if (Out) {
-    auto *P = &const_cast<DiagnosticInfoOptimizationBase &>(OptDiag);
+    auto *P =
+        const_cast<DiagnosticInfoOptimizationCommonBase *>(&OptDiagCommon);
----------------
anemet wrote:
> MatzeB wrote:
> > dito.
> Actually, this one needs to be a pointer because << requires an lvalue so we can't pass a temporary (&P).
I am pretty sure this is equivalent and taking the address of a reference variable does produce a pointer that can still be used when the reference variable is out of scope (as long as the referenced object is still around which is the case here):
```
auto &P = const_cast<DiagnosticInfoOptimizationBase&>(OptDiagBase);
*out << &P;
```


https://reviews.llvm.org/D29003





More information about the llvm-commits mailing list