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 |
There are two Clang compiler models: clang and clangpp.
The clang compiler model is based on the gcc model. The clangpp compiler model is based on the clang model, and thus transitively on the gcc model.
The only difference between the clang and clangpp models is is that compilations modeled with the clangpp model are always modeled in C++ mode unless the language is explicitly specified using the -x flag.
The following file extensions are supported.
| Compiler model |
Modeled native compiler | Source file extensions | |
|---|---|---|---|
| clang | Clang C compiler | Source file extensions indicate the source language unless the language is otherwise specified using the -x flag or --driver_mode=g++. | |
|
C mode | ||
|
C++ mode | ||
| clangpp | Clang C++ compiler |
|
C++ mode unless the language is explicitly specified using the -x flag or --driver_mode=g++. |
| Platform Availability | The clang and clangpp compiler models are available for all platforms. | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Default Recognition/Handling | By default, compilations
are recognized and handled as follows.
|
|||||||||
| Specifying Additional Mappings | If your compiler executable has a different name, specify a corresponding COMPILER_MODELS rule to map your executable name to the clang or clangpp model. |
For full details of all native compilers recognized by CodeSonar by default, see section Compilers Recognized by CodeSonar.
The clang and clangpp compiler models are based on the gcc model, so you can associate an ABI key in the gcc-model-specific format with any compilation handled by the clang or clangpp model. The key structure and interpretation are described in GNU Compiler Models: Model-Specific ABI Key Format.
The clang and clangpp compiler models can be used for both LLVM Clang and Apple Clang compilations. However, there are some differences between the two, so the models attempt to invoke the native compiler to determine which of the two it corresponds to.
If this determination cannot be performed, the model defaults to assuming that you are using LLVM Clang.
If the model determines that you are using Apple Clang, it performs two additional actions.
| Native Compiler Version ver | Equivalent LLVM Version Computed by Model |
|---|---|
| 1.0 ≤ ver < 4.1 | 3.1 |
| 4.1 ≤ ver < 5.0 | 3.2 |
| ver = 5.0 | 3.3 |
| 5.0 < ver < 6.0 | 3.4 |
| ver = 6.0 | 3.5 |
| 6.0 < ver < 7.0 | 3.6 |
| 7.0 ≤ ver < 7.3 | 3.7 |
| 7.3 < ver < 8.0 | 3.8 |
| 8.0 ≤ ver < 9.0 | 3.9 |
| 9.0 ≤ ver < 10.0 | 4.0 |
| 10.0 ≤ ver < 11.0 | 6.0 |
| 11.0 ≤ ver < 12.0 | 8.0 |
| otherwise | 8.0 |
The default C++ standard also depends on whether or not the modeled native compiler is determined to be Apple Clang.
Command argument handling for the clang and clangpp compiler models is the same as that for the gcc model (described in GNU Compiler Models: Command Arguments), with the following additions.
| Argument | Additional Treatment in Model | |||||
|---|---|---|---|---|---|---|
| -ansi --ansi |
In addition to the handling specified for -ansi in the gcc model, specifies front end option --cs_c11_atomic_keyword. | addition | ||||
| -c-isystem=dir -c-isystem dir |
[C mode only] Specifies front end option --sys_include dir. | addition | ||||
| -cxx-isystem=dir -cxx-isystem dir |
[C++ mode only] Specifies front end option --sys_include dir. | addition | ||||
| --driver_mode=mode --driver_mode mode |
Handling depends on value of mode:
|
addition | ||||
| -emit-obj | Accepted, but incurs no additional handling and is not passed to the native compiler invocation. | addition | ||||
| -fdeclspec |
Specifes front end option --cs_declspec. | addition | ||||
| -fnodeclspec |
Specifes front end option --cs_no_declspec. | addition | ||||
| -ObjC -ObjC++ |
The compilation is ignored. | addition | ||||
| -std=arg -std arg --std=arg --std arg |
Handling is the same as that for -std in the gcc compiler model, but note that the clang and clangpp models have behaviors that depend on both the applicable C standard and the applicable C++ standard. | - | ||||
| -target
arg -targetarg |
If arg contains substring windows and the applicable C++ standard is before C++11, specifies front end options --cs_declspec and --cs_static_assert. | - | ||||
| -x
lang -xlang |
Handling is the same as that for -x in the gcc compiler model; this table entry is provided for navigation purposes only. | - | ||||
| -Xclang=arg -Xclang arg |
Handling depends on the value of arg as follows.
|
addition | ||||
The modeled compilation mode is determined as follows.
| --driver_mode=g++ specified (and not subsequently superseded)? |
|||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| YES | NO | ||||||||||||
| -x lang specified? | YES |
The modeled compilation mode for each source file F depends on
whether F appears before or after the first
occurence of -x in the
build command line.
|
Modeled
compilation mode will depend on lang as follows.
|
||||||||||
| NO | Modeled compilation mode for all source files is C++. |
Modeled compilation mode determination depends on the model:
|
|||||||||||
The applicable C or C++ standard for the modeled compilation is determined as follows.
| arg | Standard Set | |
|---|---|---|
| C | C++ | |
| c89 |
C89 | - |
| c90 iso9899:1990 iso9899:199409 gnu89 gnu90 |
C90 | - |
| c99 c9x gnu99 gnu9x iso9899:1999 iso9899:199x |
C99 | - |
| c11 c1x gnu11 gnu1x c17 c18 gnu17 gnu18 iso9899:2017 iso9899:2018 c2x |
C11 | - |
| c++98 gnu++98 |
- | C++98 |
| c++03 gnu++03 |
- | C++03 |
| c++0x gnu++0x |
- | C++0x |
| c++11 gnu++11 |
- | C++11 |
| c++14 c++1y gnu++14 gnu++1y |
- | C++14 |
| c++17 c++1z gnu++17 gnu++1z |
- | C++17 |
| c++2a gnu++2a |
- | C++20 |
| other arg | - | - |
| C standard | C11 if Clang version is 3.6 or later, | C99 otherwise. | If you are using Apple Clang (as opposed to LLVM Clang), note that this is the computed Clang version resulting from the translation described above. |
|---|---|---|---|
| C++ standard | C++14 if Clang version is 6.0 or later, or if the native compiler is Apple Clang; |
C++98 otherwise. |
If any of the following are specified, CodeSonar will ignore the compilation and will not generate any corresponding internal representation. If a CodeSonar project is based only on ignored compilations, it will have no contents and so will not be finalized.
Predefined macros for the clang and clangpp compiler models are the same as those for the gcc model (described in GNU Compiler Models: Predefined Macros and Include Paths), with the following exceptions.
If you are using Apple Clang (as opposed to LLVM Clang), note that the "Clang version" upon which some conditional definitions depend is the version resulting from the translation described above.
| Macros always defined |
As for the gcc model, with the following
additions.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Macros Conditionally Defined |
As for the
gcc model, with the
following additions.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Include Paths | Defined by compiler configuration files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Front End Options Always Specified |
As for the
gcc model, with the
following additions and modifications.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Front End Options Conditionally Specified |
As for the
gcc model, with the
following additions and modifications.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To report problems with this documentation, please visit https://support.codesecure.com/.