-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c5bb64
commit 503830a
Showing
56 changed files
with
1,964 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
c/cert/test/rules/EXP35-C/DoNotModifyObjectsWithTemporaryLifetime.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
| test.c:65:18:65:18 | a | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:65:9:65:14 | call to get_s1 | function call | | ||
| test.c:67:18:67:19 | s1 | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:67:9:67:14 | call to get_s3 | function call | | ||
| test.c:68:18:68:19 | i1 | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:68:9:68:14 | call to get_s3 | function call | | ||
| test.c:69:18:69:21 | af12 | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:69:9:69:14 | call to get_s4 | function call | | ||
| test.c:65:18:65:18 | a | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:65:9:65:14 | call to get_s1 | temporary object | | ||
| test.c:67:18:67:19 | s1 | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:67:9:67:14 | call to get_s3 | temporary object | | ||
| test.c:68:18:68:19 | i1 | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:68:9:68:14 | call to get_s3 | temporary object | | ||
| test.c:69:18:69:21 | af12 | Field access on $@ qualifier occurs after its temporary object lifetime. | test.c:69:9:69:14 | call to get_s4 | temporary object | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import cpp | ||
|
||
newtype TIdentifierLinkage = | ||
TIdentifierLinkageExternal() or | ||
TIdentifierLinkageInternal() or | ||
TIdentifierLinkageNone() | ||
|
||
/** | ||
* In C, identifiers have internal linkage, or external linkage, or no linkage (6.2.2.1). | ||
* | ||
* The linkage of an identifier is used to, among other things, determine the storage duration | ||
* and/or lifetime of that identifier. Storage durations and lifetimes are often used to define | ||
* rules in the various coding standards. | ||
*/ | ||
class IdentifierLinkage extends TIdentifierLinkage { | ||
predicate isExternal() { this = TIdentifierLinkageExternal() } | ||
|
||
predicate isInternal() { this = TIdentifierLinkageInternal() } | ||
|
||
predicate isNone() { this = TIdentifierLinkageNone() } | ||
|
||
string toString() { | ||
this.isExternal() and result = "external linkage" | ||
or | ||
this.isInternal() and result = "internal linkage" | ||
or | ||
this.isNone() and result = "no linkage" | ||
} | ||
} | ||
|
||
/** | ||
* Determine the linkage of a variable: external, or static, or none. | ||
* | ||
* The linkage of a variable is determined by its scope and storage class. Note that other types of | ||
* identifiers (e.g. functions) may also have linkage, but that behavior is not covered in this | ||
* predicate. | ||
*/ | ||
IdentifierLinkage linkageOfVariable(Variable v) { | ||
// 6.2.2.3, file scope identifiers marked static have internal linkage. | ||
v.isTopLevel() and v.isStatic() and result.isInternal() | ||
or | ||
// 6.2.2.4 describes generally non-static file scope identifiers, which have external linkage. | ||
v.isTopLevel() and not v.isStatic() and result.isExternal() | ||
or | ||
// Note: Not all identifiers have linkage, see 6.2.2.6 | ||
not v.isTopLevel() and result.isNone() | ||
} |
Oops, something went wrong.