JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
The code search language allows users to search in analyzed source files. In particular, users can search for occurrence tuples by specifying token names and other syntactic and semantic properties.
This language has a more restricted grammar than the other CodeSonar search languages, along with slightly different semantics.
Note that code-domain searches are only available within the scope of a focal analysis, and the results will depend on cross-referencing information availability.
The code search language has a more restricted grammar than the other CodeSonar search languages. Note in particular that:
Every search is a T. Literal strings are displayed in pink text.
T : quoted-string | field-condition | T T | word word : (not whitespace)* quoted-string 1 : " ( word | whitespace | escape-code)* " field-condition : field-name operator condition field-name : usage | kind | directory | file | path | def_directory | def_file | def_path | def_line | occ_sf | occ_line
operator 2 : = | : condition : word | quoted-string | int | kind-val | usage-val whitespace : space | tab | line-feed | carriage-return | form-feed | vertical-tab escape_code 3 : \\ | \' | \" | \f | \n | \r | \t | \v int : an integer usage-val : call | cast | "catch parameter" | constant | "constructor initialization" | declaration | definition | extension | "file static" | formal | friend | global | goto | include | invocation | "local static" | local | member | "method invocation" | new | occurrence | other | qualifier | read | redefinition | "return type" | sizeof | subclass | tag | "take address" | "template argument" | "template parameter" | "throw exception specifier" | typedef | undefinition | using | "write through" | write kind-val : builtin | enum | field | "file static variable" | file | function | "global variable" | label | "local static variable" | "local variable" | macro | method | namespace | parameter | "static function" | "static method" | "string literal" | tag | "template type" | "template value" | type
The following table shows the relationship between the code-specific field-name values and the properties of an occurrence tuple, along with the expected type of the condition part of a field-condition.
| field-name | Contents | Condition Type |
|---|---|---|
| def_directory | Definition File . Directory | word | quoted-string |
| def_file | Definition File . File | word | quoted-string |
| def_line | Definition Line | int |
| def_path | Definition File . File Path | word | quoted-string |
| directory | File . Directory | word | quoted-string |
| file | File . File | word | quoted-string |
| kind | Kind | kind-val |
| occ_line | Line | int |
| path | File . File Path | word | quoted-string |
| usage | Usage | usage-val |
word and quoted-string search terms are matched against the Token Name. The matching is case-sensitive.
The semantics of the code search language differs from that of the other CodeSonar search languages in the interpretation of complex queries. When a query contains multiple terms (T T):
For example, query
is equivalent to
Where (x or y or z) matches tokens whose names are in the set {x,y,z}.
Note: For Java and C#, code search will only find occurrences of tokens that are defined in user code. Tokens defined in the respective language runtimes are not searchable.
| example | explanation |
|---|---|
| myvar | Find all occurrence tuples where the token name is myvar. |
| myvar othervar | Find all occurrence tuples where the token name is myvar or othervar. |
| def_directory:src | Find all occurrence tuples where the token's definition is in a file located in a directory whose name includes this string. |
| def_path=/src/main.c | Find all occurrence tuples where the token's definition is in a file with the (case-insensitive) absolute name /src/main.c. |
| def_path="c:\\Program Files \\src\\main.c" | Find all occurrence tuples where the token's definition is in a file with the (case-insensitive) absolute name c:\Program Files\src\main.c. Note that backslashes must be escaped. |
| def_path:/src/other.c | Find all occurrence tuples where the token's definition is in a file whose (case-insensitive) absolute name contains the substring /src/other.c. |
| def_file:src/mod1/bar.c | Find all occurrence tuples where the token's definition is in a file whose (case-insensitive) absolute name contains the substring src/mod1/bar.c. |
| directory:iodir | Find all occurrence tuples where the token's occurrence is in a file located in a directory whose name includes this string. |
| file=main.c | Find all occurrence tuples in any file with basename main.c (case insensitively). |
| kind=function | Find all occurrence tuples describing occurrences of a (non-static) function name. |
| kind=function kind=macro print | Find all occurrence tuples describing an occurrence of print as a (non-static) function or macro name. |
| occ_line=45 | Find all occurrence tuples describing an occurrence on line 45 of any file. |
| path=/src/main.c | Find all occurrence tuples describing an occurrence in the file with the (case-insensitive) absolute name /src/main.c. |
| usage=sizeof | Find all occurrence tuples describing an argument to sizeof(). |
| 1 |
quoted-strings must be delimited
with double quotes (""): single quotes
('') cannot
be substituted.
|
||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 |
Operators are interpreted as follows.
|
||||||||||||||||
| 3 |
Escape codes are interpreted as follows.
|
To report problems with this documentation, please visit https://support.codesecure.com/.