[PATCH] D48460: [analyzer] Fix invalidation on C++ const methods.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 23 15:58:32 PDT 2018
NoQ added a comment.
Well, i guess that's just one of those mildly infuriating aspects of the AST and/or the standard :)
> If references are resolved, why are pointers not?
It's kinda understandable. References are simple aliases to glvalues. When you use a reference, you simply get *the* original glvalue, which is exactly what the AST gives you: a glvalue expression of object type. Here's what `Expr::setType()` says:
130 void setType(QualType t) {
131 // In C++, the type of an expression is always adjusted so that it
132 // will not have reference type (C++ [expr]p6). Use
133 // QualType::getNonReferenceType() to retrieve the non-reference
134 // type. Additionally, inspect Expr::isLvalue to determine whether
135 // an expression that is adjusted in this manner should be
136 // considered an lvalue.
137 assert((t.isNull() || !t->isReferenceType()) &&
138 "Expressions can't have reference type");
139
140 TR = t;
141 }
----
This code is still imperfect because it doesn't take dynamic type of the region into account, which may be more specific than the expression's type. I guess i'll add a FIXME.
Repository:
rC Clang
https://reviews.llvm.org/D48460
More information about the cfe-commits
mailing list