diff options
author | Jonas Toth <development@jonas-toth.eu> | 2022-07-24 19:35:52 +0200 |
---|---|---|
committer | Jonas Toth <development@jonas-toth.eu> | 2022-07-24 19:37:54 +0200 |
commit | 46ae26e7eb7095faeda6d6c15470c256f9294c48 (patch) | |
tree | 7d0a86edccacb599990472a28537839ad66b520b /clang/unittests | |
parent | 8f24a56a3a9363f353c8da318d97491a6818781d (diff) | |
download | llvm-46ae26e7eb7095faeda6d6c15470c256f9294c48.zip llvm-46ae26e7eb7095faeda6d6c15470c256f9294c48.tar.gz llvm-46ae26e7eb7095faeda6d6c15470c256f9294c48.tar.bz2 |
[clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables
This patch connects the check for const-correctness with the new general
utility to add `const` to variables.
The code-transformation is only done, if the detected variable for const-ness
is not part of a group-declaration.
The check allows to control multiple facets of adding `const`, e.g. if pointers themself should be
marked as `const` if they are not changed.
Reviewed By: njames93
Differential Revision: https://reviews.llvm.org/D54943
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp index e6360d8..b886259 100644 --- a/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp +++ b/clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp @@ -1251,13 +1251,13 @@ TEST(ExprMutationAnalyzerTest, RangeForArrayByValue) { AST = buildASTFromCode("void f() { int* x[2]; for (int* e : x) e = nullptr; }"); Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); - EXPECT_FALSE(isMutated(Results, AST.get())); + EXPECT_TRUE(isMutated(Results, AST.get())); AST = buildASTFromCode( "typedef int* IntPtr;" "void f() { int* x[2]; for (IntPtr e : x) e = nullptr; }"); Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); - EXPECT_FALSE(isMutated(Results, AST.get())); + EXPECT_TRUE(isMutated(Results, AST.get())); } TEST(ExprMutationAnalyzerTest, RangeForArrayByConstRef) { |