[AL] fix ast_node_cxx_fully_qualified_name w/non-global vars

Reviewed By: ddino

Differential Revision: D14371054

fbshipit-source-id: eb675166b
master
David Lively 6 years ago committed by Facebook Github Bot
parent f3dd99ef00
commit 96beec5e53

@ -1 +1 @@
Subproject commit 1f77ff5f316a72aacdf9816ce36190a5d869a952 Subproject commit 36266f6c86041896bed32ffec0637fefbc4463e0

@ -85,20 +85,23 @@ let rec ast_node_cxx_fully_qualified_name an =
let open Clang_ast_t in let open Clang_ast_t in
match an with match an with
| Decl dec -> ( | Decl dec -> (
match Clang_ast_proj.get_var_decl_tuple dec with
| Some (_, ndi, _, {vdi_is_global= false}) ->
ndi.ni_name
| Some (_, ndi, _, _) ->
fully_qualified_name ndi.ni_qual_name
| None -> (
match Clang_ast_proj.get_named_decl_tuple dec with match Clang_ast_proj.get_named_decl_tuple dec with
| Some (_, n) -> | Some (_, ndi) ->
fully_qualified_name n.Clang_ast_t.ni_qual_name fully_qualified_name ndi.ni_qual_name
| None ->
"" ) )
| Stmt (DeclRefExpr (_, _, _, {drti_decl_ref= Some dr})) -> (
match CAst_utils.get_decl dr.dr_decl_pointer with
| Some decl ->
ast_node_cxx_fully_qualified_name (Decl decl)
| None -> | None ->
"" ) "" )
| Stmt (DeclRefExpr (_, _, _, {drti_decl_ref= Some dr})) ->
let ndi, _, _ = CAst_utils.get_info_from_decl_ref dr in
fully_qualified_name ndi.ni_qual_name
| Stmt (OpaqueValueExpr (_, _, _, {ovei_source_expr= Some stmt}))
| Stmt (ImplicitCastExpr (_, [stmt], _, _))
| Stmt (PseudoObjectExpr (_, stmt :: _, _))
| Stmt (ParenExpr (_, [stmt], _))
| Stmt (CallExpr (_, stmt :: _, _)) ->
ast_node_cxx_fully_qualified_name (Stmt stmt)
| _ -> | _ ->
"" ""

@ -1,5 +1,12 @@
codetoanalyze/cpp/linters-for-test-only/test_constructor.cpp, f, 12, FIND_STATIC_LOCAL_VAR, no_bucket, WARNING, [] codetoanalyze/cpp/linters-for-test-only/test_constructor.cpp, f, 12, FIND_STATIC_LOCAL_VAR, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_constructor.cpp, g, 17, FIND_CXX_COPY_CONSTRUCTOR, no_bucket, WARNING, [] codetoanalyze/cpp/linters-for-test-only/test_constructor.cpp, g, 17, FIND_CXX_COPY_CONSTRUCTOR, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_f, 26, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_f, 28, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_f, 29, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Linters_dummy_method, 22, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Linters_dummy_method, 24, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Linters_dummy_method, 25, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Linters_dummy_method, 33, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_included.h, Bazoo_fibble, 11, FIND_CXX_METHODS_FROM_HEADER_FILE, no_bucket, WARNING, [] codetoanalyze/cpp/linters-for-test-only/test_included.h, Bazoo_fibble, 11, FIND_CXX_METHODS_FROM_HEADER_FILE, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_overrides.cpp, B_bar, 16, FIND_CXX_METHOD_OVERRIDES, no_bucket, WARNING, [] codetoanalyze/cpp/linters-for-test-only/test_overrides.cpp, B_bar, 16, FIND_CXX_METHOD_OVERRIDES, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_overrides.cpp, B_foo, 14, FIND_CXX_METHOD_OVERRIDES, no_bucket, WARNING, [] codetoanalyze/cpp/linters-for-test-only/test_overrides.cpp, B_foo, 14, FIND_CXX_METHOD_OVERRIDES, no_bucket, WARNING, []

@ -0,0 +1,36 @@
/*
* 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.
*/
int globalVarInTopNs;
namespace {
int globalVarInAnonNs;
struct Baz {
int fld_;
};
} // namespace
namespace Foo {
int globalVarInFoo;
class Bar : public Baz {
static int classVar;
int f(const Baz& baz) {
label:
return baz.fld_ + fld_ + barFld_ + classVar + globalVarInTopNs +
globalVarInAnonNs + globalVarInFoo;
}
private:
int barFld_;
};
} // namespace Foo
Loading…
Cancel
Save