[analyzer][StdLibraryFunctionsChecker] Use Optionals throughout the summary API

By using optionals, we no longer have to check the validity of types that we
get from a lookup. This way, the definition of the summaries have a declarative
form, there are no superflous conditions in the source code.

Differential Revision: https://reviews.llvm.org/D86531
This commit is contained in:
Gabor Marton 2020-08-25 13:33:41 +02:00
parent 9fbb113247
commit a787a4ed16
2 changed files with 637 additions and 599 deletions

View File

@ -0,0 +1,22 @@
// RUN: %clang_analyze_cc1 %s \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \
// RUN: -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
// RUN: -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -triple i686-unknown-linux 2>&1 | FileCheck %s --allow-empty
// We test here the implementation of our summary API with Optional types. In
// this TU we do not provide declaration for any of the functions that have
// summaries. The implementation should be able to handle the nonexistent
// declarations in a way that the summary is not added to the map. We expect no
// crashes (i.e. no optionals should be 'dereferenced') and no output.
// Must have at least one call expression to initialize the summary map.
int bar(void);
void foo() {
bar();
}
// CHECK-NOT: Loaded summary for: