Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
5be8a4d1
Commit
5be8a4d1
authored
13 years ago
by
Anna Zaks
Browse files
Options
Downloads
Patches
Plain Diff
[analyzer] MacOSKeychainAPIChecker: Cleanup AllocationState structure.
llvm-svn: 138535
parent
3ca20e64
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+10
-11
10 additions, 11 deletions
...g/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
with
10 additions
and
11 deletions
clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+
10
−
11
View file @
5be8a4d1
...
@@ -35,29 +35,28 @@ public:
...
@@ -35,29 +35,28 @@ public:
/// AllocationState is a part of the checker specific state together with the
/// AllocationState is a part of the checker specific state together with the
/// MemRegion corresponding to the allocated data.
/// MemRegion corresponding to the allocated data.
struct
AllocationState
{
struct
AllocationState
{
const
Expr
*
Address
;
/// The index of the allocator function.
/// The index of the allocator function.
unsigned
int
AllocatorIdx
;
unsigned
int
AllocatorIdx
;
SymbolRef
Re
tValue
;
SymbolRef
Re
gion
;
AllocationState
(
const
Expr
*
E
,
unsigned
int
Idx
,
SymbolRef
R
)
:
AllocationState
(
const
Expr
*
E
,
unsigned
int
Idx
,
SymbolRef
R
)
:
Address
(
E
),
AllocatorIdx
(
Idx
),
AllocatorIdx
(
Idx
),
Re
tValue
(
R
)
{}
Re
gion
(
R
)
{}
bool
operator
==
(
const
AllocationState
&
X
)
const
{
bool
operator
==
(
const
AllocationState
&
X
)
const
{
return
Address
==
X
.
Address
;
return
(
AllocatorIdx
==
X
.
AllocatorIdx
&&
Region
==
X
.
Region
);
}
}
void
Profile
(
llvm
::
FoldingSetNodeID
&
ID
)
const
{
void
Profile
(
llvm
::
FoldingSetNodeID
&
ID
)
const
{
ID
.
AddPointer
(
Address
);
ID
.
AddInteger
(
AllocatorIdx
);
ID
.
AddInteger
(
AllocatorIdx
);
ID
.
AddPointer
(
Region
);
}
}
};
};
void
checkPreStmt
(
const
CallExpr
*
S
,
CheckerContext
&
C
)
const
;
void
checkPreStmt
(
const
CallExpr
*
S
,
CheckerContext
&
C
)
const
;
void
checkPreStmt
(
const
ReturnStmt
*
S
,
CheckerContext
&
C
)
const
;
void
checkPreStmt
(
const
ReturnStmt
*
S
,
CheckerContext
&
C
)
const
;
void
checkPostStmt
(
const
CallExpr
*
S
,
CheckerContext
&
C
)
const
;
void
checkPostStmt
(
const
CallExpr
*
S
,
CheckerContext
&
C
)
const
;
void
checkDeadSymbols
(
SymbolReaper
&
SR
,
CheckerContext
&
C
)
const
;
void
checkDeadSymbols
(
SymbolReaper
&
SR
,
CheckerContext
&
C
)
const
;
void
checkEndPath
(
EndOfFunctionNodeBuilder
&
B
,
ExprEngine
&
Eng
)
const
;
void
checkEndPath
(
EndOfFunctionNodeBuilder
&
B
,
ExprEngine
&
Eng
)
const
;
...
@@ -303,7 +302,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE,
...
@@ -303,7 +302,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE,
const
Expr
*
ArgExpr
=
CE
->
getArg
(
FunctionsToTrack
[
idx
].
Param
);
const
Expr
*
ArgExpr
=
CE
->
getArg
(
FunctionsToTrack
[
idx
].
Param
);
if
(
SymbolRef
V
=
getAsPointeeSymbol
(
ArgExpr
,
C
))
if
(
SymbolRef
V
=
getAsPointeeSymbol
(
ArgExpr
,
C
))
if
(
const
AllocationState
*
AS
=
State
->
get
<
AllocatedData
>
(
V
))
{
if
(
const
AllocationState
*
AS
=
State
->
get
<
AllocatedData
>
(
V
))
{
if
(
!
definitelyReturnedError
(
AS
->
Re
tValue
,
State
,
C
.
getSValBuilder
()))
{
if
(
!
definitelyReturnedError
(
AS
->
Re
gion
,
State
,
C
.
getSValBuilder
()))
{
// Remove the value from the state. The new symbol will be added for
// Remove the value from the state. The new symbol will be added for
// tracking when the second allocator is processed in checkPostStmt().
// tracking when the second allocator is processed in checkPostStmt().
State
=
State
->
remove
<
AllocatedData
>
(
V
);
State
=
State
->
remove
<
AllocatedData
>
(
V
);
...
@@ -424,7 +423,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE,
...
@@ -424,7 +423,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE,
}
}
// If the return status is undefined or is error, report a bad call to free.
// If the return status is undefined or is error, report a bad call to free.
if
(
!
definitelyDidnotReturnError
(
AS
->
Re
tValue
,
State
,
C
.
getSValBuilder
()))
{
if
(
!
definitelyDidnotReturnError
(
AS
->
Re
gion
,
State
,
C
.
getSValBuilder
()))
{
ExplodedNode
*
N
=
C
.
generateNode
(
State
);
ExplodedNode
*
N
=
C
.
generateNode
(
State
);
if
(
!
N
)
if
(
!
N
)
return
;
return
;
...
@@ -540,7 +539,7 @@ void MacOSKeychainAPIChecker::checkDeadSymbols(SymbolReaper &SR,
...
@@ -540,7 +539,7 @@ void MacOSKeychainAPIChecker::checkDeadSymbols(SymbolReaper &SR,
// If the allocated symbol is null or if the allocation call might have
// If the allocated symbol is null or if the allocation call might have
// returned an error, do not report.
// returned an error, do not report.
if
(
State
->
getSymVal
(
I
->
first
)
||
if
(
State
->
getSymVal
(
I
->
first
)
||
definitelyReturnedError
(
I
->
second
.
Re
tValue
,
State
,
C
.
getSValBuilder
()))
definitelyReturnedError
(
I
->
second
.
Re
gion
,
State
,
C
.
getSValBuilder
()))
continue
;
continue
;
Errors
.
push_back
(
std
::
make_pair
(
I
->
first
,
&
I
->
second
));
Errors
.
push_back
(
std
::
make_pair
(
I
->
first
,
&
I
->
second
));
}
}
...
@@ -577,7 +576,7 @@ void MacOSKeychainAPIChecker::checkEndPath(EndOfFunctionNodeBuilder &B,
...
@@ -577,7 +576,7 @@ void MacOSKeychainAPIChecker::checkEndPath(EndOfFunctionNodeBuilder &B,
// If the allocated symbol is null or if error code was returned at
// If the allocated symbol is null or if error code was returned at
// allocation, do not report.
// allocation, do not report.
if
(
state
->
getSymVal
(
I
.
getKey
())
||
if
(
state
->
getSymVal
(
I
.
getKey
())
||
definitelyReturnedError
(
I
->
second
.
Re
tValue
,
state
,
definitelyReturnedError
(
I
->
second
.
Re
gion
,
state
,
Eng
.
getSValBuilder
()))
{
Eng
.
getSValBuilder
()))
{
continue
;
continue
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment