diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index 8904f6b99..2a61eab1d 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -682,8 +682,7 @@ and get_struct_methods struct_decl tenv = | CXXConstructorDecl _ | CXXConversionDecl _ | CXXDestructorDecl _ - | ObjCMethodDecl _ - | BlockDecl _ -> + | ObjCMethodDecl _ -> Some (procname_from_decl ~tenv decl) | _ -> None ) diff --git a/infer/tests/codetoanalyze/objcpp/frontend/Makefile b/infer/tests/codetoanalyze/objcpp/frontend/Makefile index 4682ca735..181e0146b 100644 --- a/infer/tests/codetoanalyze/objcpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/objcpp/frontend/Makefile @@ -10,7 +10,7 @@ CLANG_OPTIONS = -c $(OBJCPP_CLANG_OPTIONS) INFER_OPTIONS = SOURCES = \ - $(wildcard */*.mm) \ + $(wildcard *.mm) $(wildcard */*.mm) \ include $(TESTS_DIR)/clang-frontend.make include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objcpp/frontend/block_in_struct.mm b/infer/tests/codetoanalyze/objcpp/frontend/block_in_struct.mm new file mode 100644 index 000000000..2f080c814 --- /dev/null +++ b/infer/tests/codetoanalyze/objcpp/frontend/block_in_struct.mm @@ -0,0 +1,18 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +#import + +typedef BOOL (^ExperimentBlock)(void); + +struct Configuration { + + ExperimentBlock block = ^{ + return NO; + }; +}; + +int main() { return 0; } diff --git a/infer/tests/codetoanalyze/objcpp/frontend/block_in_struct.mm.dot b/infer/tests/codetoanalyze/objcpp/frontend/block_in_struct.mm.dot new file mode 100644 index 000000000..c0d47ee4e --- /dev/null +++ b/infer/tests/codetoanalyze/objcpp/frontend/block_in_struct.mm.dot @@ -0,0 +1,14 @@ +/* @generated */ +digraph cfg { +"main.fad58de7366495db4650cfefac2fcd61_1" [label="1: Start main\nFormals: \nLocals: \n " color=yellow style=filled] + + + "main.fad58de7366495db4650cfefac2fcd61_1" -> "main.fad58de7366495db4650cfefac2fcd61_3" ; +"main.fad58de7366495db4650cfefac2fcd61_2" [label="2: Exit main \n " color=yellow style=filled] + + +"main.fad58de7366495db4650cfefac2fcd61_3" [label="3: Return Stmt \n *&return:int=0 [line 18, column 14]\n APPLY_ABSTRACTION; [line 18, column 14]\n " shape="box"] + + + "main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ; +}