Summary: This diff adds a model for NSFileManager.contentsOfDirectoryAtURL as returning a constant-length collection. The analyzer cannot know files in a directory. We have some options to handle such unknown data. 1. Use `Unknown` value, ie `top` 2. Use a symbolic value 3. Use a constant value We had been used the first option. An upside of this is that the analyzer can remain as sound. However, a downside of this is the top value can be propagated to other procedures, making their costs top, thus we may miss some cost changes of them. The second option is to introduce a symbolic value, ie. that for the number of files. A problem is that the symbolic value will never be concretized. As a result, the symbol can be propagated to other procedures, increasing the coefficient of the complexity or making top costs. Note that handling multiple symbols is somewhat limited in Inferbo's interval domain. The last option is to introduce a constant value. I think this is the best approach we can take among above. Even though we may have FNs when there are a lot of files in a directory, we cannot reason or expect about that at the analysis time anyway. Reviewed By: ezgicicek Differential Revision: D24418099 fbshipit-source-id: bf8cf3538master
parent
dbc33aa427
commit
cd27695524
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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 <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
/* We model the file lookup as returning a constant-length collection
|
||||||
|
* (T77961166). */
|
||||||
|
void contents_of_directory_at_url_constant(NSFileManager* file_manager,
|
||||||
|
NSURL* url,
|
||||||
|
NSArray* keys) {
|
||||||
|
NSArray* array = [file_manager contentsOfDirectoryAtURL:url
|
||||||
|
includingPropertiesForKeys:keys
|
||||||
|
options:0
|
||||||
|
error:nil];
|
||||||
|
for (int i = 0; i < array.count; i++) {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue