[AL] fix ast_node_cxx_fully_qualified_name for constructor exprs

Reviewed By: ddino

Differential Revision: D14402382

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

@ -80,30 +80,39 @@ let rec ast_node_name an =
""
let rec ast_node_cxx_fully_qualified_name an =
let fully_qualified_name qual_name = "::" ^ String.concat ~sep:"::" (List.rev qual_name) in
let open Clang_ast_t in
match an with
| Decl dec -> (
match Clang_ast_proj.get_var_decl_tuple dec with
let decl_cxx_fully_qualified_name (decl : Clang_ast_t.decl) =
match Clang_ast_proj.get_var_decl_tuple decl 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 decl with
| Some (_, ndi) ->
fully_qualified_name ndi.ni_qual_name
"::" ^ String.concat ~sep:"::" (List.rev ndi.ni_qual_name)
| None ->
"" ) )
"" )
let ast_node_cxx_fully_qualified_name an =
let open Clang_ast_t in
match an with
| Decl decl ->
decl_cxx_fully_qualified_name decl
| 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)
decl_cxx_fully_qualified_name decl
| None ->
"" )
| Stmt stmt -> (
match Clang_ast_proj.get_cxx_construct_expr_tuple stmt with
| Some (_, _, _, xcei) -> (
match CAst_utils.get_decl xcei.xcei_decl_ref.dr_decl_pointer with
| Some decl ->
decl_cxx_fully_qualified_name decl
| None ->
"" )
| None ->
"" )
| _ ->
""
let ast_node_kind node =

@ -1,12 +1,15 @@
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_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, Foo::Bar_Bar, 26, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_f, 30, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_f, 32, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_f, 33, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_fooey, 36, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Foo::Bar_fooey, 36, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Linters_dummy_method, 23, 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_fully_qualified_names.cpp, Linters_dummy_method, 28, FIND_NODES_WITH_CXX_FULL_NAME, no_bucket, WARNING, []
codetoanalyze/cpp/linters-for-test-only/test_fully_qualified_names.cpp, Linters_dummy_method, 39, 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_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, []

@ -12,6 +12,7 @@ namespace {
int globalVarInAnonNs;
struct Baz {
Baz(int x) : fld_(x) {}
int fld_;
};
@ -21,14 +22,19 @@ namespace Foo {
int globalVarInFoo;
class Bar : public Baz {
struct Bar : public Baz {
Bar(int x, int y) : Baz(x), barFld_(y) {}
static int classVar;
int f(const Baz& baz) {
label:
return baz.fld_ + fld_ + barFld_ + classVar + globalVarInTopNs +
globalVarInAnonNs + globalVarInFoo;
}
static int fooey(int x) { return Bar(x, x + 1).f(Baz(x)); }
private:
int barFld_;
};

Loading…
Cancel
Save