================
@@ -309,6 +309,10 @@ Changes in existing checks
 
   - ``for`` loops are supported.
 
+- Improved :doc:`misc-const-correctness
+  <clang-tidy/checks/misc/const-correctness>` check to avoid false
+  positives when pointers is tranferred to non-const references.
----------------
flovent wrote:

For the second function in link:
```
void const_ref() {
  int* p1 {nullptr};
  int* const& r1 = p1;
}
```
It's not fixed by this patch actually, because it's a reference points to const 
(`int* const`), and it's not legal to write a const reference version:
```
   int*  p1 {nullptr};
   const int* & r1 = p1;
```

And `canResolveToExprPointee` don't handle `NoOp` right now, for the AST:
```
VarDecl <col:4, col:22> col:17 r1 'int *const &' cinit
  `-ImplicitCastExpr <col:22> 'int *const' lvalue <NoOp>
    `-DeclRefExpr <col:22> 'int *' lvalue Var 0x38dc2e98 'p1' 'int *'
```
So it might need more work to erase this FP.

https://github.com/llvm/llvm-project/pull/160971
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to