Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,102 @@
if (DOXYGEN_FOUND)
if (LLVM_ENABLE_DOXYGEN)
set(abs_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
set(abs_builddir ${CMAKE_CURRENT_BINARY_DIR})
if (HAVE_DOT)
set(DOT ${LLVM_PATH_DOT})
endif()
if (LLVM_DOXYGEN_EXTERNAL_SEARCH)
set(enable_searchengine "YES")
set(searchengine_url "${LLVM_DOXYGEN_SEARCHENGINE_URL}")
set(enable_server_based_search "YES")
set(enable_external_search "YES")
set(extra_search_mappings "${LLVM_DOXYGEN_SEARCH_MAPPINGS}")
else()
set(enable_searchengine "NO")
set(searchengine_url "")
set(enable_server_based_search "NO")
set(enable_external_search "NO")
set(extra_search_mappings "")
endif()
# If asked, configure doxygen for the creation of a Qt Compressed Help file.
if (LLVM_ENABLE_DOXYGEN_QT_HELP)
set(CLANG_TOOLS_DOXYGEN_QCH_FILENAME "org.llvm.clang.qch" CACHE STRING
"Filename of the Qt Compressed help file")
set(CLANG_TOOLS_DOXYGEN_QHP_NAMESPACE "org.llvm.clang" CACHE STRING
"Namespace under which the intermediate Qt Help Project file lives")
set(CLANG_TOOLS_DOXYGEN_QHP_CUST_FILTER_NAME "Clang ${CLANG_VERSION}" CACHE STRING
"See http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters")
set(CLANG_TOOLS_DOXYGEN_QHP_CUST_FILTER_ATTRS "Clang,${CLANG_VERSION}" CACHE STRING
"See http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes")
set(clang_tools_doxygen_generate_qhp "YES")
set(clang_tools_doxygen_qch_filename "${CLANG_DOXYGEN_QCH_FILENAME}")
set(clang_tools_doxygen_qhp_namespace "${CLANG_DOXYGEN_QHP_NAMESPACE}")
set(clang_tools_doxygen_qhelpgenerator_path "${LLVM_DOXYGEN_QHELPGENERATOR_PATH}")
set(clang_tools_doxygen_qhp_cust_filter_name "${CLANG_DOXYGEN_QHP_CUST_FILTER_NAME}")
set(clang_tools_doxygen_qhp_cust_filter_attrs "${CLANG_DOXYGEN_QHP_CUST_FILTER_ATTRS}")
else()
set(clang_tools_doxygen_generate_qhp "NO")
set(clang_tools_doxygen_qch_filename "")
set(clang_tools_doxygen_qhp_namespace "")
set(clang_tools_doxygen_qhelpgenerator_path "")
set(clang_tools_doxygen_qhp_cust_filter_name "")
set(clang_tools_doxygen_qhp_cust_filter_attrs "")
endif()
option(LLVM_DOXYGEN_SVG
"Use svg instead of png files for doxygen graphs." OFF)
if (LLVM_DOXYGEN_SVG)
set(DOT_IMAGE_FORMAT "svg")
else()
set(DOT_IMAGE_FORMAT "png")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
set(abs_top_srcdir)
set(abs_top_builddir)
set(DOT)
set(enable_searchengine)
set(searchengine_url)
set(enable_server_based_search)
set(enable_external_search)
set(extra_search_mappings)
set(clang_tools_doxygen_generate_qhp)
set(clang_tools_doxygen_qch_filename)
set(clang_tools_doxygen_qhp_namespace)
set(clang_tools_doxygen_qhelpgenerator_path)
set(clang_tools_doxygen_qhp_cust_filter_name)
set(clang_tools_doxygen_qhp_cust_filter_attrs)
set(DOT_IMAGE_FORMAT)
add_custom_target(doxygen-clang-tools
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating clang doxygen documentation." VERBATIM)
if (LLVM_BUILD_DOCS)
add_dependencies(doxygen doxygen-clang-tools)
endif()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
DESTINATION docs/html)
endif()
endif()
endif()
if (LLVM_ENABLE_SPHINX)
include(AddSphinxTarget)
if (SPHINX_FOUND)
if (${SPHINX_OUTPUT_HTML})
add_sphinx_target(html clang-tools)
endif()
if (${SPHINX_OUTPUT_MAN})
add_sphinx_target(man clang-tools)
endif()
endif()
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
================
Modularize Usage
================
``modularize [<modularize-options>] [<module-map>|<include-files-list>]*
[<front-end-options>...]``
``<modularize-options>`` is a place-holder for options
specific to modularize, which are described below in
`Modularize Command Line Options`.
``<module-map>`` specifies the path of a file name for an
existing module map. The module map must be well-formed in
terms of syntax. Modularize will extract the header file names
from the map. Only normal headers are checked, assuming headers
marked "private", "textual", or "exclude" are not to be checked
as a top-level include, assuming they either are included by
other headers which are checked, or they are not suitable for
modules.
``<include-files-list>`` specifies the path of a file name for a
file containing the newline-separated list of headers to check
with respect to each other. Lines beginning with '#' and empty
lines are ignored. Header file names followed by a colon and
other space-separated file names will include those extra files
as dependencies. The file names can be relative or full paths,
but must be on the same line. For example::
header1.h
header2.h
header3.h: header1.h header2.h
Note that unless a ``-prefix (header path)`` option is specified,
non-absolute file paths in the header list file will be relative
to the header list file directory. Use -prefix to specify a different
directory.
``<front-end-options>`` is a place-holder for regular Clang
front-end arguments, which must follow the <include-files-list>.
Note that by default, modularize assumes .h files
contain C++ source, so if you are using a different language,
you might need to use a ``-x`` option to tell Clang that the
header contains another language, i.e.: ``-x c``
Note also that because modularize does not use the clang driver,
you will likely need to pass in additional compiler front-end
arguments to match those passed in by default by the driver.
Modularize Command Line Options
===============================
.. option:: -prefix=<header-path>
Prepend the given path to non-absolute file paths in the header list file.
By default, headers are assumed to be relative to the header list file
directory. Use ``-prefix`` to specify a different directory.
.. option:: -module-map-path=<module-map-path>
Generate a module map and output it to the given file. See the description
in :ref:`module-map-generation`.
.. option:: -problem-files-list=<problem-files-list-file-name>
For use only with module map assistant. Input list of files that
have problems with respect to modules. These will still be
included in the generated module map, but will be marked as
"excluded" headers.
.. option:: -root-module=<root-name>
Put modules generated by the -module-map-path option in an enclosing
module with the given name. See the description in :ref:`module-map-generation`.
.. option:: -block-check-header-list-only
Limit the #include-inside-extern-or-namespace-block
check to only those headers explicitly listed in the header list.
This is a work-around for avoiding error messages for private includes that
purposefully get included inside blocks.
.. option:: -no-coverage-check
Don't do the coverage check for a module map.
.. option:: -coverage-check-only
Only do the coverage check for a module map.
.. option:: -display-file-lists
Display lists of good files (no compile errors), problem files,
and a combined list with problem files preceded by a '#'.
This can be used to quickly determine which files have problems.
The latter combined list might be useful in starting to modularize
a set of headers. You can start with a full list of headers,
use -display-file-lists option, and then use the combined list as
your intermediate list, uncommenting-out headers as you fix them.

View File

@@ -0,0 +1,11 @@
-------------------------------------------------------------
Documentation for the tools of clang-tools-extra repo project
-------------------------------------------------------------
Sphinx and doxygen documentation is generated by executing make.
Sphinx html files can be generated separately using make html.
Doxygen html files can also be generated using make doxygen.
The generated documentation will be placed in _build/html.

View File

@@ -0,0 +1,257 @@
=====================================
Extra Clang Tools 6.0.0 Release Notes
=====================================
.. contents::
:local:
:depth: 3
Written by the `LLVM Team <http://llvm.org/>`_
Introduction
============
This document contains the release notes for the Extra Clang Tools, part of the
Clang release 6.0.0. Here we describe the status of the Extra Clang Tools in
some detail, including major improvements from the previous release and new
feature work. All LLVM releases may be downloaded from the `LLVM releases web
site <http://llvm.org/releases/>`_.
For more information about Clang or LLVM, including information about
the latest release, please see the `Clang Web Site <http://clang.llvm.org>`_ or
the `LLVM Web Site <http://llvm.org>`_.
What's New in Extra Clang Tools 6.0.0?
======================================
Some of the major new features and improvements to Extra Clang Tools are listed
here. Generic improvements to Extra Clang Tools as a whole or to its underlying
infrastructure are described first, followed by tool-specific sections.
Improvements to clang-tidy
--------------------------
- New module `fuchsia` for Fuchsia style checks.
- New module `objc` for Objective-C style checks.
- New `android-cloexec-accept
<clang-tidy/checks/android-cloexec-accept.html>`_ check
Detects usage of ``accept()``.
- New `android-cloexec-accept4
<clang-tidy/checks/android-cloexec-accept4.html>`_ check
Checks if the required file flag ``SOCK_CLOEXEC`` is present in the argument of
``accept4()``.
- New `android-cloexec-dup
<clang-tidy/checks/android-cloexec-dup.html>`_ check
Detects usage of ``dup()``.
- New `android-cloexec-epoll-create
<clang-tidy/checks/android-cloexec-epoll-create.html>`_ check
Detects usage of ``epoll_create()``.
- New `android-cloexec-epoll-create1
<clang-tidy/checks/android-cloexec-epoll-create1.html>`_ check
Checks if the required file flag ``EPOLL_CLOEXEC`` is present in the argument of
``epoll_create1()``.
- New `android-cloexec-inotify-init
<clang-tidy/checks/android-cloexec-inotify-init.html>`_ check
Detects usage of ``inotify_init()``.
- New `android-cloexec-inotify-init1
<clang-tidy/checks/android-cloexec-inotify-init1.html>`_ check
Checks if the required file flag ``IN_CLOEXEC`` is present in the argument of
``inotify_init1()``.
- New `android-cloexec-memfd_create
<clang-tidy/checks/android-cloexec-memfd-create.html>`_ check
Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument
of ``memfd_create()``.
- New `bugprone-copy-constructor-init
<clang-tidy/checks/bugprone-copy-constructor-init.html>`_ check
Finds copy constructors which don't call the copy constructor of the base class.
- New `bugprone-integer-division
<clang-tidy/checks/bugprone-integer-division.html>`_ check
Finds cases where integer division in a floating point context is likely to
cause unintended loss of precision.
- New `bugprone-misplaced-operator-in-strlen-in-alloc
<clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.html>`_ check
Finds cases where ``1`` is added to the string in the argument to
``strlen()``, ``strnlen()``, ``strnlen_s()``, ``wcslen()``, ``wcsnlen()``, and
``wcsnlen_s()`` instead of the result and the value is used as an argument to
a memory allocation function (``malloc()``, ``calloc()``, ``realloc()``,
``alloca()``) or the ``new[]`` operator in `C++`.
- New `cppcoreguidelines-owning-memory <clang-tidy/checks/cppcoreguidelines-owning-memory.html>`_ check
This check implements the type-based semantic of ``gsl::owner<T*>``, but without
flow analysis.
- New `fuchsia-default-arguments
<clang-tidy/checks/fuchsia-default-arguments.html>`_ check
Warns if a function or method is declared or called with default arguments.
- New `fuchsia-overloaded-operator
<clang-tidy/checks/fuchsia-overloaded-operator.html>`_ check
Warns if an operator is overloaded, except for the assignment (copy and move) operators.
- New `fuchsia-virtual-inheritance
<clang-tidy/checks/fuchsia-virtual-inheritance.html>`_ check
Warns if classes are defined with virtual inheritance.
- New `google-objc-avoid-throwing-exception
<clang-tidy/checks/google-objc-avoid-throwing-exception.html>`_ check
Finds uses of throwing exceptions usages in Objective-C files.
- New `google-objc-global-variable-declaration
<clang-tidy/checks/google-objc-global-variable-declaration.html>`_ check
Finds global variable declarations in Objective-C files that do not follow the
pattern of variable names in Google's Objective-C Style Guide.
- New `hicpp-exception-baseclass
<clang-tidy/checks/hicpp-exception-baseclass.html>`_ check
Ensures that all exception will be instances of ``std::exception`` and classes
that are derived from it.
- New `hicpp-signed-bitwise
<clang-tidy/checks/hicpp-signed-bitwise.html>`_ check
Finds uses of bitwise operations on signed integer types, which may lead to
undefined or implementation defined behaviour.
- New `objc-avoid-nserror-init
<clang-tidy/checks/objc-avoid-nserror-init.html>`_ check
Finds improper initialization of ``NSError`` objects.
- New `objc-avoid-spinlock
<clang-tidy/checks/objc-avoid-spinlock.html>`_ check
Finds usages of ``OSSpinlock``, which is deprecated due to potential livelock
problems.
- New `objc-forbidden-subclassing
<clang-tidy/checks/objc-forbidden-subclassing.html>`_ check
Finds Objective-C classes which are subclasses of classes which are not
designed to be subclassed.
- New `objc-property-declaration
<clang-tidy/checks/objc-property-declaration.html>`_ check
Finds property declarations in Objective-C files that do not follow the
pattern of property names in Apple's programming guide.
- New `readability-static-accessed-through-instance
<clang-tidy/checks/readability-static-accessed-through-instance.html>`_ check
Finds member expressions that access static members through instances and
replaces them with uses of the appropriate qualified-id.
- The 'misc-argument-comment' check was renamed to `bugprone-argument-comment
<clang-tidy/checks/bugprone-argument-comment.html>`_
- The 'misc-assert-side-effect' check was renamed to `bugprone-assert-side-effect
<clang-tidy/checks/bugprone-assert-side-effect.html>`_
- The 'misc-bool-pointer-implicit-conversion' check was renamed to `bugprone-bool-pointer-implicit-conversion
<clang-tidy/checks/bugprone-bool-pointer-implicit-conversion.html>`_
- The 'misc-dangling-handle' check was renamed to `bugprone-dangling-handle
<clang-tidy/checks/bugprone-dangling-handle.html>`_
- The 'misc-fold-init-type' check was renamed to `bugprone-fold-init-type
<clang-tidy/checks/bugprone-fold-init-type.html>`_
- The 'misc-forward-declaration-namespace' check was renamed to `bugprone-forward-declaration-namespace
<clang-tidy/checks/bugprone-forward-declaration-namespace.html>`_
- The 'misc-inaccurate-erase' check was renamed to `bugprone-inaccurate-erase
<clang-tidy/checks/bugprone-inaccurate-erase.html>`_
- The 'misc-inefficient-algorithm' check was renamed to `performance-inefficient-algorithm
<clang-tidy/checks/performance-inefficient-algorithm.html>`_
- The 'misc-move-const-arg' check was renamed to `performance-move-const-arg
<clang-tidy/checks/performance-move-const-arg.html>`_
- The 'misc-move-constructor-init' check was renamed to `performance-move-constructor-init
<clang-tidy/checks/performance-move-constructor-init.html>`_
- The 'misc-move-forwarding-reference' check was renamed to `bugprone-move-forwarding-reference
<clang-tidy/checks/bugprone-move-forwarding-reference.html>`_
- The 'misc-multiple-statement-macro' check was renamed to `bugprone-multiple-statement-macro
<clang-tidy/checks/bugprone-multiple-statement-macro.html>`_
- The 'misc-noexcept-move-constructor' check was renamed to `performance-noexcept-move-constructor
<clang-tidy/checks/performance-noexcept-move-constructor.html>`_
- The 'misc-string-constructor' check was renamed to `bugprone-string-constructor
<clang-tidy/checks/bugprone-string-constructor.html>`_
- The 'misc-use-after-move' check was renamed to `bugprone-use-after-move
<clang-tidy/checks/bugprone-use-after-move.html>`_
- The 'performance-implicit-cast-in-loop' check was renamed to `performance-implicit-conversion-in-loop
<clang-tidy/checks/performance-implicit-conversion-in-loop.html>`_
- The 'readability-implicit-bool-cast' check was renamed to `readability-implicit-bool-conversion
<clang-tidy/checks/readability-implicit-bool-conversion.html>`_
The check's options were renamed as follows:
- `AllowConditionalIntegerCasts` -> `AllowIntegerConditions`,
- `AllowConditionalPointerCasts` -> `AllowPointerConditions`.
- Added `modernize-use-emplace.IgnoreImplicitConstructors
<clang-tidy/checks/modernize-use-emplace.html#cmdoption-arg-IgnoreImplicitConstructors>`_
option.
- Added aliases for the `High Integrity C++ Coding Standard <http://www.codingstandard.com/section/index/>`_
to already implemented checks in other modules.
- `hicpp-deprecated-headers <clang-tidy/checks/hicpp-deprecated-headers.html>`_
- `hicpp-move-const-arg <clang-tidy/checks/hicpp-move-const-arg.html>`_
- `hicpp-no-array-decay <clang-tidy/checks/hicpp-no-array-decay.html>`_
- `hicpp-no-malloc <clang-tidy/checks/hicpp-no-malloc.html>`_
- `hicpp-static-assert <clang-tidy/checks/hicpp-static-assert.html>`_
- `hicpp-use-auto <clang-tidy/checks/hicpp-use-auto.html>`_
- `hicpp-use-emplace <clang-tidy/checks/hicpp-use-emplace.html>`_
- `hicpp-use-noexcept <clang-tidy/checks/hicpp-use-noexcept.html>`_
- `hicpp-use-nullptr <clang-tidy/checks/hicpp-use-nullptr.html>`_
- `hicpp-vararg <clang-tidy/checks/hicpp-vararg.html>`_
- Added the ability to suppress specific checks (or all checks) in a ``NOLINT`` or ``NOLINTNEXTLINE`` comment.
- Added new functionality to `misc-redundant-expression
<clang-tidy/checks/misc-redundant-expression.html>`_ check
Finds redundant binary operator expressions where the operators are overloaded,
and ones that contain the same macros twice.
Also checks for assignment expressions that do not change the value of the
assigned variable, and expressions that always evaluate to the same value
because of possible operator confusion.

View File

@@ -0,0 +1,4 @@
:orphan:
All :program:`clang-modernize` transforms have moved to :doc:`clang-tidy/index`
(see the ``modernize`` module).

View File

@@ -0,0 +1,166 @@
============
Clang-Rename
============
.. contents::
See also:
.. toctree::
:maxdepth: 1
:program:`clang-rename` is a C++ refactoring tool. Its purpose is to perform
efficient renaming actions in large-scale projects such as renaming classes,
functions, variables, arguments, namespaces etc.
The tool is in a very early development stage, so you might encounter bugs and
crashes. Submitting reports with information about how to reproduce the issue
to `the LLVM bugtracker <https://llvm.org/bugs>`_ will definitely help the
project. If you have any ideas or suggestions, you might want to put a feature
request there.
Using Clang-Rename
==================
:program:`clang-rename` is a `LibTooling
<http://clang.llvm.org/docs/LibTooling.html>`_-based tool, and it's easier to
work with if you set up a compile command database for your project (for an
example of how to do this see `How To Setup Tooling For LLVM
<http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html>`_). You can also
specify compilation options on the command line after `--`:
.. code-block:: console
$ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
To get an offset of a symbol in a file run
.. code-block:: console
$ grep -FUbo 'foo' file.cpp
The tool currently supports renaming actions inside a single translation unit
only. It is planned to extend the tool's functionality to support multi-TU
renaming actions in the future.
:program:`clang-rename` also aims to be easily integrated into popular text
editors, such as Vim and Emacs, and improve the workflow of users.
Although a command line interface exists, it is highly recommended to use the
text editor interface instead for better experience.
You can also identify one or more symbols to be renamed by giving the fully
qualified name:
.. code-block:: console
$ clang-rename -qualified-name=foo -new-name=bar test.cpp
Renaming multiple symbols at once is supported, too. However,
:program:`clang-rename` doesn't accept both `-offset` and `-qualified-name` at
the same time. So, you can either specify multiple `-offset` or
`-qualified-name`.
.. code-block:: console
$ clang-rename -offset=42 -new-name=bar1 -offset=150 -new-name=bar2 test.cpp
or
.. code-block:: console
$ clang-rename -qualified-name=foo1 -new-name=bar1 -qualified-name=foo2 -new-name=bar2 test.cpp
Alternatively, {offset | qualified-name} / new-name pairs can be put into a YAML
file:
.. code-block:: yaml
---
- Offset: 42
NewName: bar1
- Offset: 150
NewName: bar2
...
or
.. code-block:: yaml
---
- QualifiedName: foo1
NewName: bar1
- QualifiedName: foo2
NewName: bar2
...
That way you can avoid spelling out all the names as command line arguments:
.. code-block:: console
$ clang-rename -input=test.yaml test.cpp
:program:`clang-rename` offers the following options:
.. code-block:: console
$ clang-rename --help
USAGE: clang-rename [subcommand] [options] <source0> [... <sourceN>]
OPTIONS:
Generic Options:
-help - Display available options (-help-hidden for more)
-help-list - Display list of available options (-help-list-hidden for more)
-version - Display the version of this program
clang-rename common options:
-export-fixes=<filename> - YAML file to store suggested fixes in.
-extra-arg=<string> - Additional argument to append to the compiler command line
-extra-arg-before=<string> - Additional argument to prepend to the compiler command line
-force - Ignore nonexistent qualified names.
-i - Overwrite edited <file>s.
-input=<string> - YAML file to load oldname-newname pairs from.
-new-name=<string> - The new name to change the symbol to.
-offset=<uint> - Locates the symbol by offset as opposed to <line>:<column>.
-p=<string> - Build path
-pl - Print the locations affected by renaming to stderr.
-pn - Print the found symbol's name prior to renaming to stderr.
-qualified-name=<string> - The fully qualified name of the symbol.
Vim Integration
===============
You can call :program:`clang-rename` directly from Vim! To set up
:program:`clang-rename` integration for Vim see
`clang-rename/tool/clang-rename.py
<http://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/clang-rename/tool/clang-rename.py>`_.
Please note that **you have to save all buffers, in which the replacement will
happen before running the tool**.
Once installed, you can point your cursor to symbols you want to rename, press
`<leader>cr` and type new desired name. The `<leader> key
<http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader>`_
is a reference to a specific key defined by the mapleader variable and is bound
to backslash by default.
Emacs Integration
=================
You can also use :program:`clang-rename` while using Emacs! To set up
:program:`clang-rename` integration for Emacs see
`clang-rename/tool/clang-rename.el
<http://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/clang-rename/tool/clang-rename.el>`_.
Once installed, you can point your cursor to symbols you want to rename, press
`M-X`, type `clang-rename` and new desired name.
Please note that **you have to save all buffers, in which the replacement will
happen before running the tool**.

View File

@@ -0,0 +1,6 @@
:orphan:
.. meta::
:http-equiv=refresh: 0;URL='clang-tidy/'
clang-tidy documentation has moved here: http://clang.llvm.org/extra/clang-tidy/

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-accept
android-cloexec-accept
======================
The usage of ``accept()`` is not recommended, it's better to use ``accept4()``.
Without this flag, an opened sensitive file descriptor would remain open across
a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
accept(sockfd, addr, addrlen);
// becomes
accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-accept4
android-cloexec-accept4
=======================
``accept4()`` should include ``SOCK_CLOEXEC`` in its type argument to avoid the
file descriptor leakage. Without this flag, an opened sensitive file would
remain open across a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
accept4(sockfd, addr, addrlen, SOCK_NONBLOCK);
// becomes
accept4(sockfd, addr, addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC);

View File

@@ -0,0 +1,16 @@
.. title:: clang-tidy - android-cloexec-creat
android-cloexec-creat
=====================
The usage of ``creat()`` is not recommended, it's better to use ``open()``.
Examples:
.. code-block:: c++
int fd = creat(path, mode);
// becomes
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-dup
android-cloexec-dup
===================
The usage of ``dup()`` is not recommended, it's better to use ``fcntl()``,
which can set the close-on-exec flag. Otherwise, an opened sensitive file would
remain open across a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
int fd = dup(oldfd);
// becomes
int fd = fcntl(oldfd, F_DUPFD_CLOEXEC);

View File

@@ -0,0 +1,17 @@
.. title:: clang-tidy - android-cloexec-epoll-create
android-cloexec-epoll-create
============================
The usage of ``epoll_create()`` is not recommended, it's better to use
``epoll_create1()``, which allows close-on-exec.
Examples:
.. code-block:: c++
epoll_create(size);
// becomes
epoll_create1(EPOLL_CLOEXEC);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-epoll-create1
android-cloexec-epoll-create1
=============================
``epoll_create1()`` should include ``EPOLL_CLOEXEC`` in its type argument to
avoid the file descriptor leakage. Without this flag, an opened sensitive file
would remain open across a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
epoll_create1(0);
// becomes
epoll_create1(EPOLL_CLOEXEC);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-fopen
android-cloexec-fopen
=====================
``fopen()`` should include ``e`` in their mode string; so ``re`` would be
valid. This is equivalent to having set ``FD_CLOEXEC on`` that descriptor.
Examples:
.. code-block:: c++
fopen("fn", "r");
// becomes
fopen("fn", "re");

View File

@@ -0,0 +1,17 @@
.. title:: clang-tidy - android-cloexec-inotify-init
android-cloexec-inotify-init
============================
The usage of ``inotify_init()`` is not recommended, it's better to use
``inotify_init1()``.
Examples:
.. code-block:: c++
inotify_init();
// becomes
inotify_init1(IN_CLOEXEC);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-inotify-init1
android-cloexec-inotify-init1
=============================
``inotify_init1()`` should include ``IN_CLOEXEC`` in its type argument to avoid the
file descriptor leakage. Without this flag, an opened sensitive file would
remain open across a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
inotify_init1(IN_NONBLOCK);
// becomes
inotify_init1(IN_NONBLOCK | IN_CLOEXEC);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-memfd-create
android-cloexec-memfd-create
============================
``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
the file descriptor leakage. Without this flag, an opened sensitive file would
remain open across a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
memfd_create(name, MFD_ALLOW_SEALING);
// becomes
memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);

View File

@@ -0,0 +1,24 @@
.. title:: clang-tidy - android-cloexec-open
android-cloexec-open
====================
A common source of security bugs is code that opens a file without using the
``O_CLOEXEC`` flag. Without that flag, an opened sensitive file would remain
open across a fork+exec to a lower-privileged SELinux domain, leaking that
sensitive data. Open-like functions including ``open()``, ``openat()``, and
``open64()`` should include ``O_CLOEXEC`` in their flags argument.
Examples:
.. code-block:: c++
open("filename", O_RDWR);
open64("filename", O_RDWR);
openat(0, "filename", O_RDWR);
// becomes
open("filename", O_RDWR | O_CLOEXEC);
open64("filename", O_RDWR | O_CLOEXEC);
openat(0, "filename", O_RDWR | O_CLOEXEC);

View File

@@ -0,0 +1,18 @@
.. title:: clang-tidy - android-cloexec-socket
android-cloexec-socket
======================
``socket()`` should include ``SOCK_CLOEXEC`` in its type argument to avoid the
file descriptor leakage. Without this flag, an opened sensitive file would
remain open across a fork+exec to a lower-privileged SELinux domain.
Examples:
.. code-block:: c++
socket(domain, type, SOCK_STREAM);
// becomes
socket(domain, type, SOCK_STREAM | SOCK_CLOEXEC);

Some files were not shown because too many files have changed in this diff Show More