[PATCH] D50953: [clang-tidy] Handle sugared reference types in ExprMutationAnalyzer
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 10 11:57:15 PDT 2018
JonasToth added a comment.
What happens to pointers in a typedef (in the sense of `*` instead of `&`)?
================
Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:51
const auto nonConstReferenceType = [] {
- return referenceType(pointee(unless(isConstQualified())));
+ return hasUnqualifiedDesugaredType(
+ referenceType(pointee(unless(isConstQualified()))));
----------------
Not directly related, but this matcher matches universal references, even though they might result in a value. (one of the bugs lebedevri reported).
================
Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:171
+ AST = tooling::buildASTFromCode("typedef int& IntRef;"
+ "void g(IntRef); void f() { int x; g(x); }");
----------------
i think the following tests should be added as well
- `typedef const int& IntRef;`
- `template <typename T> using TemplateRef = T&`
It would be better to have at least one positive and negative test (with `const` and without `const` in the typedef) for each of theses cases.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D50953
More information about the cfe-commits
mailing list