You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CODING_STANDARD.md
+94Lines changed: 94 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,3 +240,97 @@ or use a symbolic link. Then, when running git commit, you should get the
240
240
linter output (if any) before being prompted to enter a commit message. To
241
241
bypass the check (e.g. if there was a false positive), add the option
242
242
`--no-verify`.
243
+
244
+
# CODE COVERAGE
245
+
246
+
Code coverage metrics are provided using gcov and lcov. Ensure that you have
247
+
installed lcov from http://ltp.sourceforge.net/coverage/lcov.php note for
248
+
ubuntu lcov is available in the standard apt-get repos.
249
+
250
+
To get coverage metrics run the following script from the regression directory:
251
+
```
252
+
get_coverage.sh
253
+
```
254
+
This will:
255
+
1) Rebuild CBMC with gcov enabled
256
+
2) Run all the regression tests
257
+
3) Collate the coverage metrics
258
+
4) Provide an HTML report of the current coverage
259
+
260
+
# USING CLANG-FORMAT
261
+
262
+
CBMC uses clang-format to ensure that the formatting of new patches is readable
263
+
and consistent. There are two main ways of running clang-format: remotely, and
264
+
locally.
265
+
266
+
## RUNNING CLANG-FORMAT REMOTELY
267
+
268
+
When patches are submitted to CBMC, they are automatically run through
269
+
continuous integration (CI). One of the CI checks will run clang-format over
270
+
the diff that your pull request introduces. If clang-format finds formatting
271
+
issues at this point, the build will be failed, and a patch will be produced
272
+
in the CI output that you can apply to your code so that it conforms to the
273
+
style guidelines.
274
+
275
+
To apply the patch, copy and paste it into a local file (`patch.txt`) and then
276
+
run:
277
+
```
278
+
patch -p1 -i patch.txt
279
+
```
280
+
Now, you can commit and push the formatting fixes.
281
+
282
+
## RUNNING CLANG-FORMAT LOCALLY
283
+
284
+
### INSTALLATION
285
+
286
+
To avoid waiting until you've made a PR to find formatting issues, you can
287
+
install clang-format locally and run it against your code as you are working.
288
+
289
+
Different versions of clang-format have slightly different behaviors. CBMC uses
290
+
clang-format-3.8 as it is available the repositories for Ubuntu 16.04 and
291
+
Homebrew.
292
+
To install on a Unix-like system, try installing using the system package
293
+
manager:
294
+
```
295
+
apt-get install clang-format-3.8 # Run this on Ubuntu, Debian etc.
296
+
brew install [email protected] # Run this on a Mac with Homebrew installed
297
+
```
298
+
299
+
If your platform doesn't have a package for clang-format, you can download a
300
+
pre-built binary, or compile clang-format yourself using the appropriate files
301
+
from the [LLVM Downloads page](http://releases.llvm.org/download.html).
302
+
303
+
An installer for Windows (along with a Visual Studio plugin) can be found at
304
+
the [LLVM Snapshot Builds page](http://llvm.org/builds/).
305
+
306
+
### FORMATTING A RANGE OF COMMITS
307
+
308
+
Clang-format is distributed with a driver script called git-clang-format-3.8.
309
+
This script can be used to format git diffs (rather than entire files).
310
+
311
+
After committing some code, it is recommended to run:
312
+
```
313
+
git-clang-format-3.8 upstream/develop
314
+
```
315
+
*Important:* If your branch is based on a branch other than `upstream/develop`,
316
+
use the name or checksum of that branch instead. It is strongly recommended to
317
+
rebase your work onto the tip of the branch it's based on before running
318
+
`git-clang-format` in this way.
319
+
320
+
### RETROACTIVELY FORMATTING INDIVIDUAL COMMITS
321
+
322
+
If your works spans several commits and you'd like to keep the formatting
323
+
correct in each individual commit, you can automatically rewrite the commits
324
+
with correct formatting.
325
+
326
+
The following command will stop at each commit in the range and run
327
+
clang-format on the diff at that point. This rewrites git history, so it's
328
+
*unsafe*, and you should back up your branch before running this command:
1. To compile with Visual Studio, change the second line of `src/config.inc`
@@ -169,20 +171,19 @@ Follow these instructions:
169
171
BUILD_ENV = MSVC
170
172
```
171
173
Open the Developer Command Prompt for Visual Studio, then start the
172
-
Cygwin shell with
173
-
```
174
-
bash.exe -login
175
-
```
174
+
Cygwin shell with
175
+
```
176
+
bash.exe -login
177
+
```
176
178
2. To compile with MinGW, use Cygwin setup to install a mingw g++ compiler
177
179
package, i.e. one of `mingw{32,64}-{x86_64,i686}-gcc-g++`. You may also
178
180
have to adjust the section in `src/common` that defines `CC` and `CXX`
179
181
for BUILD_ENV = Cygwin.
180
182
Then start the Cygwin shell.
181
183
4. In the Cygwin shell, type
182
184
```
183
-
cd cbmc-git/src
184
-
make DOWNLOADER=wget minisat2-download
185
-
make
185
+
make -C src DOWNLOADER=wget minisat2-download
186
+
make -C src
186
187
```
187
188
188
189
(Optional) A Visual Studio project file can be generated with the script
@@ -277,96 +278,3 @@ To work with Eclipse, do the following:
277
278
5. Click "Finish"
278
279
6. Select Project -> Build All
279
280
280
-
# CODE COVERAGE
281
-
282
-
Code coverage metrics are provided using gcov and lcov. Ensure that you have
283
-
installed lcov from http://ltp.sourceforge.net/coverage/lcov.php note for
284
-
ubuntu lcov is available in the standard apt-get repos.
285
-
286
-
To get coverage metrics run the following script from the regression directory:
287
-
```
288
-
get_coverage.sh
289
-
```
290
-
This will:
291
-
1) Rebuild CBMC with gcov enabled
292
-
2) Run all the regression tests
293
-
3) Collate the coverage metrics
294
-
4) Provide an HTML report of the current coverage
295
-
296
-
# USING CLANG-FORMAT
297
-
298
-
CBMC uses clang-format to ensure that the formatting of new patches is readable
299
-
and consistent. There are two main ways of running clang-format: remotely, and
300
-
locally.
301
-
302
-
## RUNNING CLANG-FORMAT REMOTELY
303
-
304
-
When patches are submitted to CBMC, they are automatically run through
305
-
continuous integration (CI). One of the CI checks will run clang-format over
306
-
the diff that your pull request introduces. If clang-format finds formatting
307
-
issues at this point, the build will be failed, and a patch will be produced
308
-
in the CI output that you can apply to your code so that it conforms to the
309
-
style guidelines.
310
-
311
-
To apply the patch, copy and paste it into a local file (`patch.txt`) and then
312
-
run:
313
-
```
314
-
patch -p1 -i patch.txt
315
-
```
316
-
Now, you can commit and push the formatting fixes.
317
-
318
-
## RUNNING CLANG-FORMAT LOCALLY
319
-
320
-
### INSTALLATION
321
-
322
-
To avoid waiting until you've made a PR to find formatting issues, you can
323
-
install clang-format locally and run it against your code as you are working.
324
-
325
-
Different versions of clang-format have slightly different behaviors. CBMC uses
326
-
clang-format-3.8 as it is available the repositories for Ubuntu 16.04 and
327
-
Homebrew.
328
-
To install on a Unix-like system, try installing using the system package
329
-
manager:
330
-
```
331
-
apt-get install clang-format-3.8 # Run this on Ubuntu, Debian etc.
332
-
brew install [email protected] # Run this on a Mac with Homebrew installed
333
-
```
334
-
335
-
If your platform doesn't have a package for clang-format, you can download a
336
-
pre-built binary, or compile clang-format yourself using the appropriate files
337
-
from the [LLVM Downloads page](http://releases.llvm.org/download.html).
338
-
339
-
An installer for Windows (along with a Visual Studio plugin) can be found at
340
-
the [LLVM Snapshot Builds page](http://llvm.org/builds/).
341
-
342
-
### FORMATTING A RANGE OF COMMITS
343
-
344
-
Clang-format is distributed with a driver script called git-clang-format-3.8.
345
-
This script can be used to format git diffs (rather than entire files).
346
-
347
-
After committing some code, it is recommended to run:
348
-
```
349
-
git-clang-format-3.8 upstream/develop
350
-
```
351
-
*Important:* If your branch is based on a branch other than `upstream/develop`,
352
-
use the name or checksum of that branch instead. It is strongly recommended to
353
-
rebase your work onto the tip of the branch it's based on before running
354
-
`git-clang-format` in this way.
355
-
356
-
### RETROACTIVELY FORMATTING INDIVIDUAL COMMITS
357
-
358
-
If your works spans several commits and you'd like to keep the formatting
359
-
correct in each individual commit, you can automatically rewrite the commits
360
-
with correct formatting.
361
-
362
-
The following command will stop at each commit in the range and run
363
-
clang-format on the diff at that point. This rewrites git history, so it's
364
-
*unsafe*, and you should back up your branch before running this command:
0 commit comments