[PATCH] D50883: [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzer
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 10 13:26:39 PDT 2018
JonasToth added a comment.
Ofc the current limitation with assuming always modification stays with my proposed tests. But these are the tests we need once implemented full analysis of pointers.
================
Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:658
+ "void f() { UniquePtr<const S> x; x->mf(); }");
+ Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext());
+ EXPECT_FALSE(isMutated(Results, AST.get()));
----------------
Template testcases i miss:
```
// modifying
template <typename T>
void f() { UnqiuePtr<T> x; x->mf(); }
// constant
template <typename T>
void f2() { UnqiuePtr<T> x; x->cmf(); }
// indecidable for the template itself, but only the instantiations
template <typename T>
void f3() { T x; x->cmf(); }
struct const_class { void cmf() const; }
struct modifying_class { void cmf(); };
void call_template() {
// don't trigger
f3<UniquePtr<const_class>>();
// trigger modification
f3<random_class*>();
}
// again not decidable by the template itself
template <typename T>
void f4() { T t; *t; }
struct very_weird {
int& operator*() { return *new int(42); }
};
void call_template_deref() {
// no modification
f4<int*>();
// modification, because deref is not const
f4<UniquePtr<very_weird>>():
}
```
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D50883
More information about the cfe-commits
mailing list