Skip to content

Commit 2ca73de

Browse files
author
Azharuddin Mohammed
committed
Merge remote-tracking branch 'llvmorg/master' into upstream-with-swift
Conflicts: include/clang/Basic/DiagnosticCommonKinds.td apple-llvm-split-commit: 0c56b1e94a10cbc566acfeae765c0daea54c559f apple-llvm-split-dir: clang/
2 parents 7430f17 + cf41271 commit 2ca73de

26 files changed

+299
-106
lines changed

clang/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
129129
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
130130

131131
if(LLVM_INCLUDE_TESTS)
132-
set(Python_ADDITIONAL_VERSIONS 2.7)
133132
include(FindPythonInterp)
134133
if(NOT PYTHONINTERP_FOUND)
135134
message(FATAL_ERROR

clang/docs/ReleaseNotes.rst

+16-51
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
=======================================
2-
Clang 9.0.0 (In-Progress) Release Notes
3-
=======================================
1+
========================================
2+
Clang 10.0.0 (In-Progress) Release Notes
3+
========================================
44

55
.. contents::
66
:local:
@@ -10,15 +10,15 @@ Written by the `LLVM Team <https://llvm.org/>`_
1010

1111
.. warning::
1212

13-
These are in-progress notes for the upcoming Clang 9 release.
13+
These are in-progress notes for the upcoming Clang 10 release.
1414
Release notes for previous releases can be found on
1515
`the Download Page <https://releases.llvm.org/download.html>`_.
1616

1717
Introduction
1818
============
1919

2020
This document contains the release notes for the Clang C/C++/Objective-C
21-
frontend, part of the LLVM Compiler Infrastructure, release 9.0.0. Here we
21+
frontend, part of the LLVM Compiler Infrastructure, release 10.0.0. Here we
2222
describe the status of Clang in some detail, including major
2323
improvements from the previous release and new feature work. For the
2424
general LLVM release notes, see `the LLVM
@@ -35,8 +35,8 @@ main Clang web page, this document applies to the *next* release, not
3535
the current one. To see the release notes for a specific release, please
3636
see the `releases page <https://llvm.org/releases/>`_.
3737

38-
What's New in Clang 9.0.0?
39-
==========================
38+
What's New in Clang 10.0.0?
39+
===========================
4040

4141
Some of the major new features and improvements to Clang are listed
4242
here. Generic improvements to Clang as a whole or to its underlying
@@ -56,12 +56,6 @@ Improvements to Clang's diagnostics
5656
Non-comprehensive list of changes in this release
5757
-------------------------------------------------
5858

59-
- The ``__VERSION__`` macro has been updated.
60-
Previously this macro contained the string '4.2.1 Compatible' to achieve
61-
compatibility with GCC 4.2.1, but that should no longer be necessary.
62-
However, to retrieve Clang's version, please favor the one of the macro
63-
defined in :ref:`clang namespaced version macros <languageextensions-builtin-macros>`.
64-
6559
- ...
6660

6761

@@ -81,8 +75,6 @@ future versions of Clang.
8175
Modified Compiler Flags
8276
-----------------------
8377

84-
- ``clang -dumpversion`` now returns the version of Clang itself.
85-
8678
- ...
8779

8880
New Pragmas in Clang
@@ -98,19 +90,11 @@ Attribute Changes in Clang
9890
Windows Support
9991
---------------
10092

101-
- clang-cl now treats non-existent files as possible typos for flags,
102-
``clang-cl /diagnostic:caret /c test.cc`` for example now produces
103-
``clang: error: no such file or directory: '/diagnostic:caret'; did you mean '/diagnostics:caret'?``
104-
105-
93+
- ...
10694

10795
C Language Changes in Clang
10896
---------------------------
10997

110-
- ``__FILE_NAME__`` macro has been added as a Clang specific extension supported
111-
in all C-family languages. This macro is similar to ``__FILE__`` except it
112-
will always provide the last path component when possible.
113-
11498
- ...
11599

116100
C11 Feature Support
@@ -131,14 +115,7 @@ C++1z Feature Support
131115
Objective-C Language Changes in Clang
132116
-------------------------------------
133117

134-
- Fixed encoding of ObjC pointer types that are pointers to typedefs.
135-
136-
.. code-block:: objc
137-
138-
typedef NSArray<NSObject *> MyArray;
139-
140-
// clang used to encode this as "^{NSArray=#}" instead of "@".
141-
const char *s0 = @encode(MyArray *);
118+
- ...
142119

143120
OpenCL C Language Changes in Clang
144121
----------------------------------
@@ -153,24 +130,24 @@ ABI Changes in Clang
153130
OpenMP Support in Clang
154131
-----------------------
155132

156-
- Added emission of the debug information for NVPTX target devices.
133+
- ...
157134

158135
CUDA Support in Clang
159136
---------------------
160137

161-
- Added emission of the debug information for the device code.
138+
- ...
162139

163140
Internal API Changes
164141
--------------------
165142

166-
These are major API changes that have happened since the 8.0.0 release of
143+
These are major API changes that have happened since the 9.0.0 release of
167144
Clang. If upgrading an external codebase that uses Clang as a library,
168145
this section should help get you past the largest hurdles of upgrading.
169146

170147
Build System Changes
171148
--------------------
172149

173-
These are major changes to the build system that have happened since the 8.0.0
150+
These are major changes to the build system that have happened since the 9.0.0
174151
release of Clang. Users of the build system should adjust accordingly.
175152

176153
- In 8.0.0 and below, the install-clang-headers target would install clang's
@@ -190,30 +167,18 @@ AST Matchers
190167
clang-format
191168
------------
192169

193-
- Add language support for clang-formatting C# files.
194-
- Add Microsoft coding style to encapsulate default C# formatting style.
195-
- Added new option `PPDIS_BeforeHash` (in configuration: `BeforeHash`) to
196-
`IndentPPDirectives` which indents preprocessor directives before the hash.
197-
- Added new option `AlignConsecutiveMacros` to align the C/C++ preprocessor
198-
macros of consecutive lines.
170+
- ...
199171

200172
libclang
201173
--------
202174

203-
- When `CINDEXTEST_INCLUDE_ATTRIBUTED_TYPES` is not provided when making a
204-
CXType, the equivalent type of the AttributedType is returned instead of the
205-
modified type if the user does not want attribute sugar. The equivalent type
206-
represents the minimally-desugared type which the AttributedType is
207-
canonically equivalent to.
175+
- ...
208176

209177

210178
Static Analyzer
211179
---------------
212180

213-
- The UninitializedObject checker is now considered as stable.
214-
(moved from the 'alpha.cplusplus' to the 'optin.cplusplus' package)
215-
216-
...
181+
- ...
217182

218183
.. _release-notes-ubsan:
219184

clang/docs/analyzer/user-docs.rst

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ User Docs
22
=========
33

44
Contents:
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
9+
user-docs/CrossTranslationUnit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
=====================================
2+
Cross Translation Unit (CTU) Analysis
3+
=====================================
4+
5+
Normally, static analysis works in the boundary of one translation unit (TU).
6+
However, with additional steps and configuration we can enable the analysis to inline the definition of a function from another TU.
7+
8+
.. contents::
9+
:local:
10+
11+
Manual CTU Analysis
12+
-------------------
13+
14+
Let's consider these source files in our minimal example:
15+
16+
.. code-block:: cpp
17+
18+
// main.cpp
19+
int foo();
20+
21+
int main() {
22+
return 3 / foo();
23+
}
24+
25+
.. code-block:: cpp
26+
27+
// foo.cpp
28+
int foo() {
29+
return 0;
30+
}
31+
32+
And a compilation database:
33+
34+
.. code-block:: bash
35+
36+
[
37+
{
38+
"directory": "/path/to/your/project",
39+
"command": "clang++ -c foo.cpp -o foo.o",
40+
"file": "foo.cpp"
41+
},
42+
{
43+
"directory": "/path/to/your/project",
44+
"command": "clang++ -c main.cpp -o main.o",
45+
"file": "main.cpp"
46+
}
47+
]
48+
49+
We'd like to analyze `main.cpp` and discover the division by zero bug.
50+
In order to be able to inline the definition of `foo` from `foo.cpp` first we have to generate the `AST` (or `PCH`) file of `foo.cpp`:
51+
52+
.. code-block:: bash
53+
54+
$ pwd $ /path/to/your/project
55+
$ clang++ -emit-ast -o foo.cpp.ast foo.cpp
56+
$ # Check that the .ast file is generated:
57+
$ ls
58+
compile_commands.json foo.cpp.ast foo.cpp main.cpp
59+
$
60+
61+
The next step is to create a CTU index file which holds the `USR` name and location of external definitions in the source files:
62+
63+
.. code-block:: bash
64+
65+
$ clang-extdef-mapping -p . foo.cpp
66+
c:@F@foo# /path/to/your/project/foo.cpp
67+
$ clang-extdef-mapping -p . foo.cpp > externalDefMap.txt
68+
69+
We have to modify `externalDefMap.txt` to contain the name of the `.ast` files instead of the source files:
70+
71+
.. code-block:: bash
72+
73+
$ sed -i -e "s/.cpp/.cpp.ast/g" externalDefMap.txt
74+
75+
We still have to further modify the `externalDefMap.txt` file to contain relative paths:
76+
77+
.. code-block:: bash
78+
79+
$ sed -i -e "s|$(pwd)/||g" externalDefMap.txt
80+
81+
Now everything is available for the CTU analysis.
82+
We have to feed Clang with CTU specific extra arguments:
83+
84+
.. code-block:: bash
85+
86+
$ pwd
87+
/path/to/your/project
88+
$ clang++ --analyze -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true -Xclang -analyzer-config -Xclang ctu-dir=. -Xclang -analyzer-output=plist-multi-file main.cpp
89+
main.cpp:5:12: warning: Division by zero
90+
return 3 / foo();
91+
~~^~~~~~~
92+
1 warning generated.
93+
$ # The plist file with the result is generated.
94+
$ ls
95+
compile_commands.json externalDefMap.txt foo.ast foo.cpp foo.cpp.ast main.cpp main.plist
96+
$
97+
98+
This manual procedure is error-prone and not scalable, therefore to analyze real projects it is recommended to use `CodeChecker` or `scan-build-py`.
99+
100+
Automated CTU Analysis with CodeChecker
101+
---------------------------------------
102+
The `CodeChecker <https://github.com/Ericsson/codechecker>`_ project fully supports automated CTU analysis with Clang.
103+
Once we have set up the `PATH` environment variable and we activated the python `venv` then it is all it takes:
104+
105+
.. code-block:: bash
106+
107+
$ CodeChecker analyze --ctu compile_commands.json -o reports
108+
[INFO 2019-07-16 17:21] - Pre-analysis started.
109+
[INFO 2019-07-16 17:21] - Collecting data for ctu analysis.
110+
[INFO 2019-07-16 17:21] - [1/2] foo.cpp
111+
[INFO 2019-07-16 17:21] - [2/2] main.cpp
112+
[INFO 2019-07-16 17:21] - Pre-analysis finished.
113+
[INFO 2019-07-16 17:21] - Starting static analysis ...
114+
[INFO 2019-07-16 17:21] - [1/2] clangsa analyzed foo.cpp successfully.
115+
[INFO 2019-07-16 17:21] - [2/2] clangsa analyzed main.cpp successfully.
116+
[INFO 2019-07-16 17:21] - ----==== Summary ====----
117+
[INFO 2019-07-16 17:21] - Successfully analyzed
118+
[INFO 2019-07-16 17:21] - clangsa: 2
119+
[INFO 2019-07-16 17:21] - Total analyzed compilation commands: 2
120+
[INFO 2019-07-16 17:21] - ----=================----
121+
[INFO 2019-07-16 17:21] - Analysis finished.
122+
[INFO 2019-07-16 17:21] - To view results in the terminal use the "CodeChecker parse" command.
123+
[INFO 2019-07-16 17:21] - To store results use the "CodeChecker store" command.
124+
[INFO 2019-07-16 17:21] - See --help and the user guide for further options about parsing and storing the reports.
125+
[INFO 2019-07-16 17:21] - ----=================----
126+
[INFO 2019-07-16 17:21] - Analysis length: 0.659618854523 sec.
127+
$ ls
128+
compile_commands.json foo.cpp foo.cpp.ast main.cpp reports
129+
$ tree reports
130+
reports
131+
├── compile_cmd.json
132+
├── compiler_info.json
133+
├── foo.cpp_53f6fbf7ab7ec9931301524b551959e2.plist
134+
├── main.cpp_23db3d8df52ff0812e6e5a03071c8337.plist
135+
├── metadata.json
136+
└── unique_compile_commands.json
137+
138+
0 directories, 6 files
139+
$
140+
141+
The `plist` files contain the results of the analysis, which may be viewed with the regular analysis tools.
142+
E.g. one may use `CodeChecker parse` to view the results in command line:
143+
144+
.. code-block:: bash
145+
146+
$ CodeChecker parse reports
147+
[HIGH] /home/egbomrt/ctu_mini_raw_project/main.cpp:5:12: Division by zero [core.DivideZero]
148+
return 3 / foo();
149+
^
150+
151+
Found 1 defect(s) in main.cpp
152+
153+
154+
----==== Summary ====----
155+
-----------------------
156+
Filename | Report count
157+
-----------------------
158+
main.cpp | 1
159+
-----------------------
160+
-----------------------
161+
Severity | Report count
162+
-----------------------
163+
HIGH | 1
164+
-----------------------
165+
----=================----
166+
Total number of reports: 1
167+
----=================----
168+
169+
Or we can use `CodeChecker parse -e html` to export the results into HTML format:
170+
171+
.. code-block:: bash
172+
173+
$ CodeChecker parse -e html -o html_out reports
174+
$ firefox html_out/index.html
175+
176+
If you experience that Clang crashes during the visitation of the BugPath then please disable macro expansion when CTU is used:
177+
178+
.. code-block:: bash
179+
180+
$ echo "-Xclang -analyzer-stats -Xclang -analyzer-config -Xclang expand-macros=false" >./saargs_file
181+
$ CodeChecker analyze --ctu --saargs ./saargs_file compile_commands.json -o reports
182+
183+
We have a patch which will solve this issue soon.
184+
185+
Automated CTU Analysis with scan-build-py (don't do it)
186+
-------------------------------------------------------
187+
We actively develop CTU with CodeChecker as a "runner" script, `scan-build-py` is not actively developed for CTU.
188+
`scan-build-py` has various errors and issues, expect it to work with the very basic projects only.
189+
190+
Example usage of scan-build-py:
191+
192+
.. code-block:: bash
193+
194+
$ /your/path/to/llvm-project/clang/tools/scan-build-py/bin/analyze-build --ctu
195+
analyze-build: Run 'scan-view /tmp/scan-build-2019-07-17-17-53-33-810365-7fqgWk' to examine bug reports.
196+
$ /your/path/to/llvm-project/clang/tools/scan-view/bin/scan-view /tmp/scan-build-2019-07-17-17-53-33-810365-7fqgWk
197+
Starting scan-view at: http://127.0.0.1:8181
198+
Use Ctrl-C to exit.
199+
[6336:6431:0717/175357.633914:ERROR:browser_process_sub_thread.cc(209)] Waited 5 ms for network service
200+
Opening in existing browser session.
201+
^C
202+
$

clang/docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
# built documents.
5151
#
5252
# The short version.
53-
version = '9'
53+
version = '10'
5454
# The full version, including alpha/beta/rc tags.
55-
release = '9'
55+
release = '10'
5656

5757
# The language for content autogenerated by Sphinx. Refer to documentation
5858
# for a list of supported languages.

0 commit comments

Comments
 (0)