diff --git a/infer/man/man1/infer-capture.txt b/infer/man/man1/infer-capture.txt index b13a55acb..63ab44d8d 100644 --- a/infer/man/man1/infer-capture.txt +++ b/infer/man/man1/infer-capture.txt @@ -310,6 +310,10 @@ JAVA OPTIONS The version of Java being used. Set it to your Java version if mvn is failing. + --kotlin-capture + Activates: Enable Kotlin capture (experimental, do not use). + (Conversely: --no-kotlin-capture) + --no-mask-sawja-exceptions Deactivates: Mask exceptions thrown by Sawja/Javalib during Java capture (Conversely: --mask-sawja-exceptions) diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index 30a68c77a..5775801a5 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -792,6 +792,10 @@ OPTIONS Activates: Keep going when the analysis encounters a failure (Conversely: --no-keep-going) See also infer-analyze(1). + --kotlin-capture + Activates: Enable Kotlin capture (experimental, do not use). + (Conversely: --no-kotlin-capture) See also infer-capture(1). + --linter string From the linters available, only run this one linter. (Useful together with --linters-developer-mode) See also infer-capture(1). diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 558851f83..3aa10dc91 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -792,6 +792,10 @@ OPTIONS Activates: Keep going when the analysis encounters a failure (Conversely: --no-keep-going) See also infer-analyze(1). + --kotlin-capture + Activates: Enable Kotlin capture (experimental, do not use). + (Conversely: --no-kotlin-capture) See also infer-capture(1). + --linter string From the linters available, only run this one linter. (Useful together with --linters-developer-mode) See also infer-capture(1). diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 92d347d14..0acccee48 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1635,6 +1635,12 @@ and jobs = ~meta:"int" "Run the specified number of analysis jobs simultaneously" +and kotlin_capture = + CLOpt.mk_bool ~long:"kotlin-capture" ~default:false + ~in_help:InferCommand.[(Capture, manual_java)] + "Enable Kotlin capture (experimental, do not use)." + + and liveness_dangerous_classes = CLOpt.mk_json ~long:"liveness-dangerous-classes" ~in_help:InferCommand.[(Analyze, manual_clang)] @@ -3171,6 +3177,8 @@ and job_id = !job_id and jobs = Option.fold !max_jobs ~init:!jobs ~f:min +and kotlin_capture = !kotlin_capture + and linter = !linter and linters_def_file = RevList.to_list !linters_def_file diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index e788f6fac..4da7889af 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -385,6 +385,8 @@ val jobs : int val keep_going : bool +val kotlin_capture : bool + val linter : string option val linters_def_file : string list diff --git a/infer/src/base/SourceFile.ml b/infer/src/base/SourceFile.ml index 0ad978714..2cab224ed 100644 --- a/infer/src/base/SourceFile.ml +++ b/infer/src/base/SourceFile.ml @@ -170,7 +170,15 @@ let to_string ?(force_relative = false) fname = else path -let has_extension t ~ext = String.is_suffix (to_string t) ~suffix:ext +let has_extension ~ext = function + | Invalid _ -> + false + | RelativeProjectRootAndWorkspace {rel_path= path} + | HashedBuckOut path + | RelativeProjectRoot path + | Absolute path -> + String.is_suffix path ~suffix:ext + let pp fmt fname = Format.pp_print_string fmt (to_string fname) diff --git a/infer/src/base/SourceFile.mli b/infer/src/base/SourceFile.mli index f1837255e..88c2f47d7 100644 --- a/infer/src/base/SourceFile.mli +++ b/infer/src/base/SourceFile.mli @@ -60,7 +60,7 @@ val to_string : ?force_relative:bool -> t -> string (** convert a source file to a string WARNING: result may not be valid file path, do not use this function to perform operations on filenames *) -val has_extension : t -> ext:string -> bool +val has_extension : ext:string -> t -> bool (** returns whether the source file has provided extension *) module SQLite : SqliteUtils.Data with type t = t diff --git a/infer/src/java/jClasspath.ml b/infer/src/java/jClasspath.ml index fd679347b..972e4c578 100644 --- a/infer/src/java/jClasspath.ml +++ b/infer/src/java/jClasspath.ml @@ -178,7 +178,12 @@ let search_sources () = initial_map | Some sourcepath -> Utils.directory_fold - (fun map p -> if Filename.check_suffix p "java" then add_source_file p map else map) + (fun map p -> + if + Filename.check_suffix p "java" + || (Config.kotlin_capture && Filename.check_suffix p Config.kotlin_source_extension) + then add_source_file p map + else map ) initial_map sourcepath diff --git a/infer/src/java/jFrontend.ml b/infer/src/java/jFrontend.ml index ee1db3a8e..ddff8db0e 100644 --- a/infer/src/java/jFrontend.ml +++ b/infer/src/java/jFrontend.ml @@ -88,8 +88,10 @@ let add_edges (context : JContext.t) start_node exn_node exit_nodes method_body_ (** Add a concrete method. *) let add_cmethod source_file program icfg cm proc_name = let cn, _ = JBasics.cms_split cm.Javalib.cm_class_method_signature in - if SourceFile.has_extension source_file ~ext:Config.kotlin_source_extension then - ignore (JTrans.create_empty_procdesc source_file program icfg cm proc_name) + if + (not Config.kotlin_capture) + && SourceFile.has_extension source_file ~ext:Config.kotlin_source_extension + then ignore (JTrans.create_empty_procdesc source_file program icfg cm proc_name) else match JTrans.create_cm_procdesc source_file program icfg cm proc_name with | None ->