[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 16 00:10:42 PDT 2018
JonasToth added a comment.
You are totally right.
Am 16.08.2018 um 02:41 schrieb Shuai Wang via Phabricator:
> shuaiwang added inline comments.
>
> ================
> Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:309
>
> +TEST(ExprMutationAnalyzerTest, CallUnresolved) {
> + auto AST =
>
> ----------------
>
> JonasToth wrote:
>
>> I think we are missing tests for non-type template paramters (`template <size_t N>`). They should behave the same. But the following case would not be a mutation:
>>
>> void non_mutating(const char* Array, int size) { /* Foo */ }
>> template <int N>
>> struct ArrayLike {
>> char* data[N]; // Initialized to something
>> void SomeFunction() {
>> non_mutating(data, N);
>> }
>> };
>>
>>
>> The difference between the 'normal' and non-type templates would be, that `N` is not mutatable at all and the semantics is clear (builtin integer-like type).
>>
>> If the current implementation would not figure that out, you can just add a test for it and assume a mutation. Handling non-type templates later is absolutly ok.
>
> We have to assume `data` is mutated here as well. I'll add a test case for this.
>
> void g(const char*, int); // <-- doesn't mutate
> void g(char(&)[8], int); // <-- do mutate
>
> template <int N>
> void f() {
> char data[N];
> g(data, N); // <-- we don't know which `g` will be called yet
> }
>
> void h() {
> f<8>(); // <-- f calls g(char(&)[8], int) internally
> f<9>(); // <-- f calls g(const char*, int) internally
> }
>
>
> Repository:
>
> rCTE Clang Tools Extra
>
> https://reviews.llvm.org/D50619
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D50619
More information about the cfe-commits
mailing list