fix vardecl const

Summary:
the predicate to check that a decl is const was not working for VarDecl.
This diff fixes this

Reviewed By: jvillard

Differential Revision: D14106798

fbshipit-source-id: 1f6c24113
master
Dino Distefano 6 years ago committed by Facebook Github Bot
parent 4d5f8e6fea
commit aae5192b79

@ -531,6 +531,8 @@ let is_qual_type_const an =
ei.Clang_ast_t.ei_qual_type.qt_is_const
| _ ->
false )
| Ctl_parser_types.Decl (Clang_ast_t.VarDecl (_, _, qt, _)) ->
qt.qt_is_const
| _ ->
false

@ -809,3 +809,11 @@ DEFINE-CHECKER TEST_IS_RECEIVER_SUPER = {
SET message = "This node is a method call to 'super'.";
};
DEFINE-CHECKER CONST_NAMING = {
SET report_when = WHEN
is_qual_type_const()
HOLDS-IN-NODE VarDecl;
SET message = "That's a const";
};

@ -0,0 +1,11 @@
/*
* Copyright (c) 2019-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
static int* const kSome1 = 0;
const float kSome2 = 12.f;
static int* kSome3 = 0;
void main() {}

@ -204,6 +204,14 @@ codetoanalyze/objc/linters-for-test-only/InContextOfMethodsTest.m, objc_block_1,
codetoanalyze/objc/linters-for-test-only/InContextOfMethodsTest.m, objc_block_2, 19, TEST_IN_BLOCK_CONTEXT, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/InSubclassExample.m, HappySadView2_makeBadAction, 33, IN_SUBCLASS_TEST, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/PrivateAPIChecker.m, TestView_methoddd, 19, TEST_SELECTOR, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, Linters_dummy_method, 1, CONST_NAMING, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, Linters_dummy_method, 1, TEST_VAR_TYPE_CHECK, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, Linters_dummy_method, 2, CONST_NAMING, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, Linters_dummy_method, 3, TEST_VAR_TYPE_CHECK, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, main, 5, ALL_PATH_NO_FILTER_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, main, 5, BLACKLIST_PATH_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, main, 5, FILTER_BY_ALL_PATH_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/const.m, main, 5, WHITE_BLACKLIST_PATH_EXAMPLE, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/enums.m, test, 15, ENUM_CONSTANTS, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/enums.m, test, 15, ENUM_CONSTANTS_OF_ENUM, no_bucket, WARNING, []
codetoanalyze/objc/linters-for-test-only/enums.m, test_c_style_enum, 21, ENUM_CONSTANTS, no_bucket, WARNING, []

Loading…
Cancel
Save