diff --git a/.gitignore b/.gitignore index fc842489a038..3ea38b6e0054 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ #==============================================================================# cscope.files cscope.out +/tags #==============================================================================# # Directories to ignore (do not add trailing '/'s, they skip symlinks). @@ -35,3 +36,8 @@ docs/_build docs/analyzer/_build # debug info testsuite test/debuginfo-tests + +# VS2017 and VSCode config files. +.vscode +.vs + diff --git a/CMakeLists.txt b/CMakeLists.txt index 52b881939499..c2016a45ca6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.4.3) +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) +endif() + # If we are not building as a part of LLVM, build Clang as an # standalone project, using LLVM as an external library: if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) @@ -7,9 +11,14 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) # Rely on llvm-config. set(CONFIG_OUTPUT) - find_program(LLVM_CONFIG "llvm-config") if(LLVM_CONFIG) + set (LLVM_CONFIG_FOUND 1) message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") + message(DEPRECATION "Using llvm-config to detect the LLVM installation is \ + deprecated. The installed cmake files should be used \ + instead. CMake should be able to detect your LLVM install \ + automatically, but you can also use LLVM_DIR to specify \ + the path containing LLVMConfig.cmake.") set(CONFIG_COMMAND ${LLVM_CONFIG} "--assertion-mode" "--bindir" @@ -32,17 +41,20 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) message(STATUS "${CONFIG_COMMAND_STR}") message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") endif() - else() - message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}") + + list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) + list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) + list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) + list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) + list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) + list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) + list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH) + + # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. + # CMake assumes slashes as PATH. + file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH) endif() - list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) - list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) - list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) - list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) - list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) - list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) - list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH) if(NOT MSVC_IDE) set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} @@ -51,27 +63,29 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) mark_as_advanced(LLVM_ENABLE_ASSERTIONS) endif() + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}") + list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR}) + + # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets + # LLVM_CONFIG. + if (NOT LLVM_CONFIG_FOUND) + # Pull values from LLVMConfig.cmake. We can drop this once the llvm-config + # path is removed. + set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR}) + set(LIBRARY_DIR ${LLVM_LIBRARY_DIR}) + set(INCLUDE_DIR ${LLVM_INCLUDE_DIR}) + set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR}) + endif() + set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") - # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. - # CMake assumes slashes as PATH. - file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH) - find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) - set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") - if(EXISTS ${LLVMCONFIG_FILE}) - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") - include(${LLVMCONFIG_FILE}) - else() - message(FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}") - endif() - # They are used as destination of target generators. set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) @@ -89,6 +103,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN "Set to ON to force using an old, unsupported host toolchain." OFF) option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF) + option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON) include(AddLLVM) include(TableGen) @@ -184,13 +199,15 @@ endif() # we can include cmake files from this directory. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -# Don't look for libxml if we're using MSan, since uninstrumented third party -# code may call MSan interceptors like strlen, leading to false positives. -if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") - set (LIBXML2_FOUND 0) - find_package(LibXml2 2.5.3 QUIET) - if (LIBXML2_FOUND) - set(CLANG_HAVE_LIBXML 1) +if(LLVM_ENABLE_LIBXML2) + # Don't look for libxml if we're using MSan, since uninstrumented third party + # code may call MSan interceptors like strlen, leading to false positives. + if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*") + set (LIBXML2_FOUND 0) + find_package(LibXml2 2.5.3 QUIET) + if (LIBXML2_FOUND) + set(CLANG_HAVE_LIBXML 1) + endif() endif() endif() @@ -279,6 +296,9 @@ endif() set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING "Vendor-specific uti.") +set(CLANG_PYTHON_BINDINGS_VERSIONS "" CACHE STRING + "Python versions to install libclang python bindings for") + # The libdir suffix must exactly match whatever LLVM's configuration used. set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}") @@ -286,25 +306,13 @@ set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) - message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite " -"the makefiles distributed with LLVM. Please create a directory and run cmake " + message(FATAL_ERROR "In-source builds are not allowed. " +"Please create a directory and run cmake " "from there, passing the path to this source directory as the last argument. " "This process created the file `CMakeCache.txt' and the directory " "`CMakeFiles'. Please delete them.") endif() -if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) - file(GLOB_RECURSE - tablegenned_files_on_include_dir - "${CLANG_SOURCE_DIR}/include/clang/*.inc") - if( tablegenned_files_on_include_dir ) - message(FATAL_ERROR "Apparently there is a previous in-source build, " -"probably as the result of running `configure' and `make' on " -"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n" -"${tablegenned_files_on_include_dir}\nPlease clean the source directory.") - endif() -endif() - # If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*. if(NOT DEFINED CLANG_VERSION_MAJOR) set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR}) @@ -403,24 +411,37 @@ option(CLANG_BUILD_TOOLS option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON) -option(CLANG_ANALYZER_BUILD_Z3 - "Build the static analyzer with the Z3 constraint manager." OFF) +set(CLANG_ANALYZER_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.") + +find_package(Z3 4.7.1) + +if (CLANG_ANALYZER_Z3_INSTALL_DIR) + if (NOT Z3_FOUND) + message(FATAL_ERROR "Z3 4.7.1 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR: ${CLANG_ANALYZER_Z3_INSTALL_DIR}.") + endif() +endif() + +set(CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}") + +option(CLANG_ANALYZER_ENABLE_Z3_SOLVER + "Enable Support for the Z3 constraint solver in the Clang Static Analyzer." + ${CLANG_ANALYZER_ENABLE_Z3_SOLVER_DEFAULT} +) + +if (CLANG_ANALYZER_ENABLE_Z3_SOLVER) + if (NOT Z3_FOUND) + message(FATAL_ERROR "CLANG_ANALYZER_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available.") + endif() + + set(CLANG_ANALYZER_WITH_Z3 1) +endif() option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF) -if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3)) +if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_ENABLE_Z3_SOLVER)) message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3") endif() -if(CLANG_ANALYZER_BUILD_Z3) - find_package(Z3 4.5) - if(Z3_FOUND) - set(CLANG_ANALYZER_WITH_Z3 1) - else() - message(FATAL_ERROR "Cannot find Z3 header file or shared library") - endif() -endif() - if(CLANG_ENABLE_ARCMT) set(CLANG_ENABLE_OBJC_REWRITER ON) endif() @@ -494,6 +515,7 @@ if( CLANG_INCLUDE_TESTS ) ) endif() add_subdirectory(test) + add_subdirectory(bindings/python/tests) if(CLANG_BUILT_STANDALONE) # Add a global check rule now that all subdirectories have been traversed @@ -502,11 +524,13 @@ if( CLANG_INCLUDE_TESTS ) get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS) get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS) get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS) + get_property(LLVM_ADDITIONAL_TEST_TARGETS + GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS) add_lit_target(check-all "Running all regression tests" ${LLVM_LIT_TESTSUITES} PARAMS ${LLVM_LIT_PARAMS} - DEPENDS ${LLVM_LIT_DEPENDS} + DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) endif() @@ -578,8 +602,8 @@ if (CLANG_ENABLE_BOOTSTRAP) if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR) add_dependencies(clang-bootstrap-deps LLVMgold) endif() - set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar) - set(LTO_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib) + set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar) + set(${CLANG_STAGE}_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib) endif() endif() @@ -645,6 +669,26 @@ if (CLANG_ENABLE_BOOTSTRAP) -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER} -DCMAKE_ASM_COMPILER_ID=Clang) + if(BOOTSTRAP_CMAKE_SYSTEM_NAME) + set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config) + set(${CLANG_STAGE}_TABLEGEN + -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen + -DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen) + if(BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Linux") + if(BOOTSTRAP_LLVM_ENABLE_LLD) + set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld) + endif() + if(NOT BOOTSTRAP_LLVM_ENABLE_LTO) + add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib) + set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar) + set(${CLANG_STAGE}_RANLIB -DCMAKE_RANLIB=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ranlib) + endif() + add_dependencies(clang-bootstrap-deps llvm-objcopy llvm-strip) + set(${CLANG_STAGE}_OBJCOPY -DCMAKE_OBJCOPY=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-objcopy) + set(${CLANG_STAGE}_STRIP -DCMAKE_STRIP=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-strip) + endif() + endif() + if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED) add_dependencies(clang-bootstrap-deps llvm-profdata) set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata) @@ -713,7 +757,14 @@ if (CLANG_ENABLE_BOOTSTRAP) ${PASSTHROUGH_VARIABLES} -DCLANG_STAGE=${NEXT_CLANG_STAGE} ${COMPILER_OPTIONS} - ${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${PGO_OPT} + ${${CLANG_STAGE}_CONFIG} + ${${CLANG_STAGE}_TABLEGEN} + ${LTO_LIBRARY} ${verbose} ${PGO_OPT} + ${${CLANG_STAGE}_LINKER} + ${${CLANG_STAGE}_AR} + ${${CLANG_STAGE}_RANLIB} + ${${CLANG_STAGE}_OBJCOPY} + ${${CLANG_STAGE}_STRIP} INSTALL_COMMAND "" STEP_TARGETS configure build USES_TERMINAL_CONFIGURE 1 diff --git a/CODE_OWNERS.TXT b/CODE_OWNERS.TXT index 2fa9f215b66d..faf9575a2898 100644 --- a/CODE_OWNERS.TXT +++ b/CODE_OWNERS.TXT @@ -49,6 +49,10 @@ N: John McCall E: rjmccall@apple.com D: Clang LLVM IR generation +N: Brad Smith +E: brad@comstyle.com +D: OpenBSD driver + N: Richard Smith E: richard@metafoo.co.uk D: All parts of Clang not covered by someone else diff --git a/LICENSE.TXT b/LICENSE.TXT index 547f6a489382..9e71121218a6 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -4,7 +4,7 @@ LLVM Release License University of Illinois/NCSA Open Source License -Copyright (c) 2007-2018 University of Illinois at Urbana-Champaign. +Copyright (c) 2007-2019 University of Illinois at Urbana-Champaign. All rights reserved. Developed by: diff --git a/NOTES.txt b/NOTES.txt index 53f35a01863a..f06ea8c70cd3 100644 --- a/NOTES.txt +++ b/NOTES.txt @@ -8,13 +8,6 @@ To time GCC preprocessing speed without output, use: "time gcc -MM file" This is similar to -Eonly. -//===---------------------------------------------------------------------===// - -Creating and using a PTH file for performance measurement (use a release build). - -$ clang -ccc-pch-is-pth -x objective-c-header INPUTS/Cocoa_h.m -o /tmp/tokencache -$ clang -cc1 -token-cache /tmp/tokencache INPUTS/Cocoa_h.m - //===---------------------------------------------------------------------===// C++ Template Instantiation benchmark: diff --git a/bindings/python/README.txt b/bindings/python/README.txt index 8a0bf99b30e3..b0f0142a56f1 100644 --- a/bindings/python/README.txt +++ b/bindings/python/README.txt @@ -4,12 +4,12 @@ This directory implements Python bindings for Clang. -You may need to alter LD_LIBRARY_PATH so that the Clang library can be +You may need to set CLANG_LIBRARY_PATH so that the Clang library can be found. The unit tests are designed to be run with any standard test runner. For example: -- $ env PYTHONPATH=$(echo ~/llvm/tools/clang/bindings/python/) \ - LD_LIBRARY_PATH=$(llvm-config --libdir) \ + CLANG_LIBRARY_PATH=$(llvm-config --libdir) \ python -m unittest discover -v tests.cindex.test_index.test_create ... ok ... diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 56fcc78763e3..8b23ae90b982 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -44,6 +44,7 @@ The major indexing objects are: Most object information is exposed using properties, when the underlying API call is efficient. """ +from __future__ import absolute_import, division, print_function # TODO # ==== @@ -63,10 +64,10 @@ call is efficient. # o implement additional SourceLocation, SourceRange, and File methods. from ctypes import * -import collections import clang.enumerations +import os import sys if sys.version_info[0] == 3: # Python 3 strings are unicode, translate them to/from utf8 for C-interop. @@ -108,8 +109,6 @@ if sys.version_info[0] == 3: return x return x.encode('utf8') - xrange = range - elif sys.version_info[0] == 2: # Python 2 strings are utf8 byte strings, no translation is needed for # C-interop. @@ -123,6 +122,22 @@ elif sys.version_info[0] == 2: def b(x): return x +# Importing ABC-s directly from collections is deprecated since Python 3.7, +# will stop working in Python 3.8. +# See: https://docs.python.org/dev/whatsnew/3.7.html#id3 +if sys.version_info[:2] >= (3, 7): + from collections import abc as collections_abc +else: + import collections as collections_abc + +# We only support PathLike objects on Python version with os.fspath present +# to be consistent with the Python standard library. On older Python versions +# we only support strings and we have dummy fspath to just pass them through. +try: + fspath = os.fspath +except AttributeError: + def fspath(x): + return x # ctypes doesn't implicitly convert c_void_p to the appropriate wrapper # object. This is a problem, because it means that from_parameter will see an @@ -391,7 +406,7 @@ class Diagnostic(object): @property def ranges(self): - class RangeIterator: + class RangeIterator(object): def __init__(self, diag): self.diag = diag @@ -407,7 +422,7 @@ class Diagnostic(object): @property def fixits(self): - class FixItIterator: + class FixItIterator(object): def __init__(self, diag): self.diag = diag @@ -427,7 +442,7 @@ class Diagnostic(object): @property def children(self): - class ChildDiagnosticsIterator: + class ChildDiagnosticsIterator(object): def __init__(self, diag): self.diag_set = conf.lib.clang_getChildDiagnostics(diag) @@ -547,7 +562,7 @@ class TokenGroup(object): token_group = TokenGroup(tu, tokens_memory, tokens_count) - for i in xrange(0, count): + for i in range(0, count): token = Token() token.int_data = tokens_array[i].int_data token.ptr_data = tokens_array[i].ptr_data @@ -2173,7 +2188,7 @@ class Type(Structure): The returned object is iterable and indexable. Each item in the container is a Type instance. """ - class ArgumentsIterator(collections.Sequence): + class ArgumentsIterator(collections_abc.Sequence): def __init__(self, parent): self.parent = parent self.length = None @@ -2254,6 +2269,12 @@ class Type(Structure): return res + def get_num_template_arguments(self): + return conf.lib.clang_Type_getNumTemplateArguments(self) + + def get_template_argument_type(self, num): + return conf.lib.clang_Type_getTemplateArgumentAsType(self, num) + def get_canonical(self): """ Return the canonical type for a Type. @@ -2460,8 +2481,8 @@ SpellingCache = { # 20: CompletionChunk.Kind("VerticalSpace") } -class CompletionChunk: - class Kind: +class CompletionChunk(object): + class Kind(object): def __init__(self, name): self.name = name @@ -2548,7 +2569,7 @@ completionChunkKindMap = { 20: CompletionChunk.Kind("VerticalSpace")} class CompletionString(ClangObject): - class Availability: + class Availability(object): def __init__(self, name): self.name = name @@ -2641,7 +2662,7 @@ class CodeCompletionResults(ClangObject): @property def diagnostics(self): - class DiagnosticsItr: + class DiagnosticsItr(object): def __init__(self, ccr): self.ccr= ccr @@ -2746,11 +2767,11 @@ class TranslationUnit(ClangObject): etc. e.g. ["-Wall", "-I/path/to/include"]. In-memory file content can be provided via unsaved_files. This is an - iterable of 2-tuples. The first element is the str filename. The - second element defines the content. Content can be provided as str - source code or as file objects (anything with a read() method). If - a file object is being used, content will be read until EOF and the - read cursor will not be reset to its original position. + iterable of 2-tuples. The first element is the filename (str or + PathLike). The second element defines the content. Content can be + provided as str source code or as file objects (anything with a read() + method). If a file object is being used, content will be read until EOF + and the read cursor will not be reset to its original position. options is a bitwise or of TranslationUnit.PARSE_XXX flags which will control parsing behavior. @@ -2795,11 +2816,13 @@ class TranslationUnit(ClangObject): if hasattr(contents, "read"): contents = contents.read() - unsaved_array[i].name = b(name) + unsaved_array[i].name = b(fspath(name)) unsaved_array[i].contents = b(contents) unsaved_array[i].length = len(contents) - ptr = conf.lib.clang_parseTranslationUnit(index, filename, args_array, + ptr = conf.lib.clang_parseTranslationUnit(index, + fspath(filename) if filename is not None else None, + args_array, len(args), unsaved_array, len(unsaved_files), options) @@ -2820,11 +2843,13 @@ class TranslationUnit(ClangObject): index is optional and is the Index instance to use. If not provided, a default Index will be created. + + filename can be str or PathLike. """ if index is None: index = Index.create() - ptr = conf.lib.clang_createTranslationUnit(index, filename) + ptr = conf.lib.clang_createTranslationUnit(index, fspath(filename)) if not ptr: raise TranslationUnitLoadError(filename) @@ -2939,7 +2964,7 @@ class TranslationUnit(ClangObject): """ Return an iterable (and indexable) object containing the diagnostics. """ - class DiagIterator: + class DiagIterator(object): def __init__(self, tu): self.tu = tu @@ -2977,7 +3002,7 @@ class TranslationUnit(ClangObject): print(value) if not isinstance(value, str): raise TypeError('Unexpected unsaved file contents.') - unsaved_files_array[i].name = name + unsaved_files_array[i].name = fspath(name) unsaved_files_array[i].contents = value unsaved_files_array[i].length = len(value) ptr = conf.lib.clang_reparseTranslationUnit(self, len(unsaved_files), @@ -2996,10 +3021,10 @@ class TranslationUnit(ClangObject): case, the reason(s) why should be available via TranslationUnit.diagnostics(). - filename -- The path to save the translation unit to. + filename -- The path to save the translation unit to (str or PathLike). """ options = conf.lib.clang_defaultSaveOptions(self) - result = int(conf.lib.clang_saveTranslationUnit(self, filename, + result = int(conf.lib.clang_saveTranslationUnit(self, fspath(filename), options)) if result != 0: raise TranslationUnitSaveError(result, @@ -3041,10 +3066,10 @@ class TranslationUnit(ClangObject): print(value) if not isinstance(value, str): raise TypeError('Unexpected unsaved file contents.') - unsaved_files_array[i].name = b(name) + unsaved_files_array[i].name = b(fspath(name)) unsaved_files_array[i].contents = b(value) unsaved_files_array[i].length = len(value) - ptr = conf.lib.clang_codeCompleteAt(self, path, line, column, + ptr = conf.lib.clang_codeCompleteAt(self, fspath(path), line, column, unsaved_files_array, len(unsaved_files), options) if ptr: return CodeCompletionResults(ptr) @@ -3072,7 +3097,7 @@ class File(ClangObject): @staticmethod def from_name(translation_unit, file_name): """Retrieve a file handle within the given translation unit.""" - return File(conf.lib.clang_getFile(translation_unit, file_name)) + return File(conf.lib.clang_getFile(translation_unit, fspath(file_name))) @property def name(self): @@ -3171,7 +3196,7 @@ class CompileCommand(object): Invariant : the first argument is the compiler executable """ length = conf.lib.clang_CompileCommand_getNumArgs(self.cmd) - for i in xrange(length): + for i in range(length): yield conf.lib.clang_CompileCommand_getArg(self.cmd, i) class CompileCommands(object): @@ -3223,7 +3248,7 @@ class CompilationDatabase(ClangObject): """Builds a CompilationDatabase from the database found in buildDir""" errorCode = c_uint() try: - cdb = conf.lib.clang_CompilationDatabase_fromDirectory(buildDir, + cdb = conf.lib.clang_CompilationDatabase_fromDirectory(fspath(buildDir), byref(errorCode)) except CompilationDatabaseError as e: raise CompilationDatabaseError(int(errorCode.value), @@ -3236,7 +3261,7 @@ class CompilationDatabase(ClangObject): build filename. Returns None if filename is not found in the database. """ return conf.lib.clang_CompilationDatabase_getCompileCommands(self, - filename) + fspath(filename)) def getAllCompileCommands(self): """ @@ -3999,6 +4024,15 @@ functionList = [ Type, Type.from_result), + ("clang_Type_getNumTemplateArguments", + [Type], + c_int), + + ("clang_Type_getTemplateArgumentAsType", + [Type, c_uint], + Type, + Type.from_result), + ("clang_Type_getOffsetOf", [Type, c_interop_string], c_longlong), @@ -4062,7 +4096,7 @@ def register_functions(lib, ignore_errors): for f in functionList: register(f) -class Config: +class Config(object): library_path = None library_file = None compatibility_check = True @@ -4075,7 +4109,7 @@ class Config: raise Exception("library path must be set before before using " \ "any other functionalities in libclang.") - Config.library_path = path + Config.library_path = fspath(path) @staticmethod def set_library_file(filename): @@ -4084,7 +4118,7 @@ class Config: raise Exception("library file must be set before before using " \ "any other functionalities in libclang.") - Config.library_file = filename + Config.library_file = fspath(filename) @staticmethod def set_compatibility_check(check_status): diff --git a/bindings/python/examples/cindex/cindex-dump.py b/bindings/python/examples/cindex/cindex-dump.py index 5556ad121a3e..acec7e0e0054 100644 --- a/bindings/python/examples/cindex/cindex-dump.py +++ b/bindings/python/examples/cindex/cindex-dump.py @@ -79,7 +79,7 @@ def main(): if not tu: parser.error("unable to load input") - pprint(('diags', map(get_diag_info, tu.diagnostics))) + pprint(('diags', [get_diag_info(d) for d in tu.diagnostics])) pprint(('nodes', get_info(tu.cursor))) if __name__ == '__main__': diff --git a/bindings/python/tests/CMakeLists.txt b/bindings/python/tests/CMakeLists.txt new file mode 100644 index 000000000000..7af6503f1588 --- /dev/null +++ b/bindings/python/tests/CMakeLists.txt @@ -0,0 +1,46 @@ +# Test target to run Python test suite from main build. + +add_custom_target(check-clang-python + COMMAND ${CMAKE_COMMAND} -E env + CLANG_LIBRARY_PATH=$ + ${PYTHON_EXECUTABLE} -m unittest discover + DEPENDS libclang + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..) + +set(RUN_PYTHON_TESTS TRUE) +set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests") + +# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON +if(NOT LLVM_ENABLE_PIC) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Do not try to run if libclang was built with ASan because +# the sanitizer library will likely be loaded too late to perform +# interception and will then fail. +# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't +# portable so its easier just to not run the tests when building +# with ASan. +list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) +if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# Tests fail on Windows, and need someone knowledgeable to fix. +# It's not clear whether it's a test or a valid binding problem. +if(WIN32) + set(RUN_PYTHON_TESTS FALSE) +endif() + +# AArch64 and Hexagon have known test failures that need to be +# addressed. +# SystemZ has broken Python/FFI interface: +# https://reviews.llvm.org/D52840#1265716 +if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") + set(RUN_PYTHON_TESTS FALSE) +endif() + +if(RUN_PYTHON_TESTS) + set_property(GLOBAL APPEND PROPERTY + LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) +endif() diff --git a/bindings/python/tests/cindex/test_access_specifiers.py b/bindings/python/tests/cindex/test_access_specifiers.py index 2f6144be082c..e36424f240aa 100644 --- a/bindings/python/tests/cindex/test_access_specifiers.py +++ b/bindings/python/tests/cindex/test_access_specifiers.py @@ -1,3 +1,7 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) from clang.cindex import AccessSpecifier from clang.cindex import Cursor diff --git a/bindings/python/tests/cindex/test_cdb.py b/bindings/python/tests/cindex/test_cdb.py index 64651af31732..589fc72856bd 100644 --- a/bindings/python/tests/cindex/test_cdb.py +++ b/bindings/python/tests/cindex/test_cdb.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import CompilationDatabase from clang.cindex import CompilationDatabaseError from clang.cindex import CompileCommands @@ -6,6 +11,8 @@ import os import gc import unittest import sys +from .util import skip_if_no_fspath +from .util import str_to_path kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS') @@ -26,17 +33,19 @@ class TestCDB(unittest.TestCase): """Check we can load a compilation database""" cdb = CompilationDatabase.fromDirectory(kInputsDir) - def test_lookup_fail(self): - """Check file lookup failure""" - cdb = CompilationDatabase.fromDirectory(kInputsDir) - self.assertIsNone(cdb.getCompileCommands('file_do_not_exist.cpp')) - def test_lookup_succeed(self): """Check we get some results if the file exists in the db""" cdb = CompilationDatabase.fromDirectory(kInputsDir) cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp') self.assertNotEqual(len(cmds), 0) + @skip_if_no_fspath + def test_lookup_succeed_pathlike(self): + """Same as test_lookup_succeed, but with PathLikes""" + cdb = CompilationDatabase.fromDirectory(str_to_path(kInputsDir)) + cmds = cdb.getCompileCommands(str_to_path('/home/john.doe/MyProject/project.cpp')) + self.assertNotEqual(len(cmds), 0) + def test_all_compilecommand(self): """Check we get all results from the db""" cdb = CompilationDatabase.fromDirectory(kInputsDir) diff --git a/bindings/python/tests/cindex/test_code_completion.py b/bindings/python/tests/cindex/test_code_completion.py index a56bb304cd71..e0b41577aeb3 100644 --- a/bindings/python/tests/cindex/test_code_completion.py +++ b/bindings/python/tests/cindex/test_code_completion.py @@ -1,6 +1,13 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import TranslationUnit import unittest +from .util import skip_if_no_fspath +from .util import str_to_path class TestCodeCompletion(unittest.TestCase): @@ -38,6 +45,32 @@ void f() { ] self.check_completion_results(cr, expected) + @skip_if_no_fspath + def test_code_complete_pathlike(self): + files = [(str_to_path('fake.c'), """ +/// Aaa. +int test1; + +/// Bbb. +void test2(void); + +void f() { + +} +""")] + + tu = TranslationUnit.from_source(str_to_path('fake.c'), ['-std=c99'], unsaved_files=files, + options=TranslationUnit.PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETION) + + cr = tu.codeComplete(str_to_path('fake.c'), 9, 1, unsaved_files=files, include_brief_comments=True) + + expected = [ + "{'int', ResultType} | {'test1', TypedText} || Priority: 50 || Availability: Available || Brief comment: Aaa.", + "{'void', ResultType} | {'test2', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 50 || Availability: Available || Brief comment: Bbb.", + "{'return', TypedText} || Priority: 40 || Availability: Available || Brief comment: None" + ] + self.check_completion_results(cr, expected) + def test_code_complete_availability(self): files = [('fake.cpp', """ class P { @@ -61,11 +94,11 @@ void f(P x, Q y) { cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files) expected = [ - "{'const', TypedText} || Priority: 40 || Availability: Available || Brief comment: None", - "{'volatile', TypedText} || Priority: 40 || Availability: Available || Brief comment: None", + "{'const', TypedText} || Priority: 50 || Availability: Available || Brief comment: None", + "{'volatile', TypedText} || Priority: 50 || Availability: Available || Brief comment: None", "{'operator', TypedText} || Priority: 40 || Availability: Available || Brief comment: None", - "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None", - "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None" + "{'P', TypedText} || Priority: 50 || Availability: Available || Brief comment: None", + "{'Q', TypedText} || Priority: 50 || Availability: Available || Brief comment: None" ] self.check_completion_results(cr, expected) diff --git a/bindings/python/tests/cindex/test_comment.py b/bindings/python/tests/cindex/test_comment.py index d6c6d8e5c5b0..73fb617ae168 100644 --- a/bindings/python/tests/cindex/test_comment.py +++ b/bindings/python/tests/cindex/test_comment.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import TranslationUnit from tests.cindex.util import get_cursor diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py index f5733fd15879..ef875e972474 100644 --- a/bindings/python/tests/cindex/test_cursor.py +++ b/bindings/python/tests/cindex/test_cursor.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + import ctypes import gc import unittest diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py index f1ee753ef8b1..e6b9558b3cc1 100644 --- a/bindings/python/tests/cindex/test_cursor_kind.py +++ b/bindings/python/tests/cindex/test_cursor_kind.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import CursorKind import unittest diff --git a/bindings/python/tests/cindex/test_diagnostics.py b/bindings/python/tests/cindex/test_diagnostics.py index 78b327daa72c..c17d5b28efe9 100644 --- a/bindings/python/tests/cindex/test_diagnostics.py +++ b/bindings/python/tests/cindex/test_diagnostics.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import * from .util import get_tu @@ -46,7 +51,7 @@ class TestDiagnostics(unittest.TestCase): self.assertEqual(tu.diagnostics[0].fixits[0].value, '.f0 = ') def test_diagnostic_range(self): - tu = get_tu('void f() { int i = "a" + 1; }') + tu = get_tu('void f() { int i = "a"; }') self.assertEqual(len(tu.diagnostics), 1) self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Warning) self.assertEqual(tu.diagnostics[0].location.line, 1) @@ -58,7 +63,7 @@ class TestDiagnostics(unittest.TestCase): self.assertEqual(tu.diagnostics[0].ranges[0].start.line, 1) self.assertEqual(tu.diagnostics[0].ranges[0].start.column, 20) self.assertEqual(tu.diagnostics[0].ranges[0].end.line, 1) - self.assertEqual(tu.diagnostics[0].ranges[0].end.column, 27) + self.assertEqual(tu.diagnostics[0].ranges[0].end.column, 23) with self.assertRaises(IndexError): tu.diagnostics[0].ranges[1].start.line diff --git a/bindings/python/tests/cindex/test_exception_specification_kind.py b/bindings/python/tests/cindex/test_exception_specification_kind.py index 80b3639a8ab3..6c13f70fb256 100644 --- a/bindings/python/tests/cindex/test_exception_specification_kind.py +++ b/bindings/python/tests/cindex/test_exception_specification_kind.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + import clang.cindex from clang.cindex import ExceptionSpecificationKind from .util import get_tu diff --git a/bindings/python/tests/cindex/test_file.py b/bindings/python/tests/cindex/test_file.py index 98f6575262cc..a146fe5c9239 100644 --- a/bindings/python/tests/cindex/test_file.py +++ b/bindings/python/tests/cindex/test_file.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import Index, File import unittest diff --git a/bindings/python/tests/cindex/test_index.py b/bindings/python/tests/cindex/test_index.py index cfdf98e628ac..46aafcf222e7 100644 --- a/bindings/python/tests/cindex/test_index.py +++ b/bindings/python/tests/cindex/test_index.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import * import os import unittest diff --git a/bindings/python/tests/cindex/test_linkage.py b/bindings/python/tests/cindex/test_linkage.py index 6b482f8081b3..cdd97fc2df0d 100644 --- a/bindings/python/tests/cindex/test_linkage.py +++ b/bindings/python/tests/cindex/test_linkage.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import LinkageKind from clang.cindex import Cursor from clang.cindex import TranslationUnit diff --git a/bindings/python/tests/cindex/test_location.py b/bindings/python/tests/cindex/test_location.py index cbc32deb4bd5..fbe9770d7ebc 100644 --- a/bindings/python/tests/cindex/test_location.py +++ b/bindings/python/tests/cindex/test_location.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import Cursor from clang.cindex import File from clang.cindex import SourceLocation diff --git a/bindings/python/tests/cindex/test_tls_kind.py b/bindings/python/tests/cindex/test_tls_kind.py index fbc3418a64ef..c828ac83a468 100644 --- a/bindings/python/tests/cindex/test_tls_kind.py +++ b/bindings/python/tests/cindex/test_tls_kind.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import TLSKind from clang.cindex import Cursor from clang.cindex import TranslationUnit diff --git a/bindings/python/tests/cindex/test_token_kind.py b/bindings/python/tests/cindex/test_token_kind.py index 700f95a64624..904e007cafc5 100644 --- a/bindings/python/tests/cindex/test_token_kind.py +++ b/bindings/python/tests/cindex/test_token_kind.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import TokenKind import unittest diff --git a/bindings/python/tests/cindex/test_tokens.py b/bindings/python/tests/cindex/test_tokens.py index c93353dc9da2..dd6d3a3259ed 100644 --- a/bindings/python/tests/cindex/test_tokens.py +++ b/bindings/python/tests/cindex/test_tokens.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from clang.cindex import CursorKind from clang.cindex import Index from clang.cindex import SourceLocation diff --git a/bindings/python/tests/cindex/test_translation_unit.py b/bindings/python/tests/cindex/test_translation_unit.py index d3ee535f4d0d..f3e770a93611 100644 --- a/bindings/python/tests/cindex/test_translation_unit.py +++ b/bindings/python/tests/cindex/test_translation_unit.py @@ -1,6 +1,12 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + from contextlib import contextmanager import gc import os +import sys import tempfile import unittest @@ -15,6 +21,8 @@ from clang.cindex import TranslationUnitLoadError from clang.cindex import TranslationUnit from .util import get_cursor from .util import get_tu +from .util import skip_if_no_fspath +from .util import str_to_path kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS') @@ -31,6 +39,17 @@ def save_tu(tu): yield t.name +@contextmanager +def save_tu_pathlike(tu): + """Convenience API to save a TranslationUnit to a file. + + Returns the filename it was saved to. + """ + with tempfile.NamedTemporaryFile() as t: + tu.save(str_to_path(t.name)) + yield t.name + + class TestTranslationUnit(unittest.TestCase): def test_spelling(self): path = os.path.join(kInputsDir, 'hello.cpp') @@ -75,15 +94,31 @@ int SOME_DEFINE; self.assertEqual(spellings[-1], 'y') def test_unsaved_files_2(self): - try: - from StringIO import StringIO - except: + if sys.version_info.major >= 3: from io import StringIO + else: + from io import BytesIO as StringIO tu = TranslationUnit.from_source('fake.c', unsaved_files = [ ('fake.c', StringIO('int x;'))]) spellings = [c.spelling for c in tu.cursor.get_children()] self.assertEqual(spellings[-1], 'x') + @skip_if_no_fspath + def test_from_source_accepts_pathlike(self): + tu = TranslationUnit.from_source(str_to_path('fake.c'), ['-Iincludes'], unsaved_files = [ + (str_to_path('fake.c'), """ +#include "fake.h" + int x; + int SOME_DEFINE; + """), + (str_to_path('includes/fake.h'), """ +#define SOME_DEFINE y + """) + ]) + spellings = [c.spelling for c in tu.cursor.get_children()] + self.assertEqual(spellings[-2], 'x') + self.assertEqual(spellings[-1], 'y') + def assert_normpaths_equal(self, path1, path2): """ Compares two paths for equality after normalizing them with os.path.normpath @@ -130,6 +165,16 @@ int SOME_DEFINE; self.assertTrue(os.path.exists(path)) self.assertGreater(os.path.getsize(path), 0) + @skip_if_no_fspath + def test_save_pathlike(self): + """Ensure TranslationUnit.save() works with PathLike filename.""" + + tu = get_tu('int foo();') + + with save_tu_pathlike(tu) as path: + self.assertTrue(os.path.exists(path)) + self.assertGreater(os.path.getsize(path), 0) + def test_save_translation_errors(self): """Ensure that saving to an invalid directory raises.""" @@ -162,6 +207,22 @@ int SOME_DEFINE; # Just in case there is an open file descriptor somewhere. del tu2 + @skip_if_no_fspath + def test_load_pathlike(self): + """Ensure TranslationUnits can be constructed from saved files - + PathLike variant.""" + tu = get_tu('int foo();') + self.assertEqual(len(tu.diagnostics), 0) + with save_tu(tu) as path: + tu2 = TranslationUnit.from_ast_file(filename=str_to_path(path)) + self.assertEqual(len(tu2.diagnostics), 0) + + foo = get_cursor(tu2, 'foo') + self.assertIsNotNone(foo) + + # Just in case there is an open file descriptor somewhere. + del tu2 + def test_index_parse(self): path = os.path.join(kInputsDir, 'hello.cpp') index = Index.create() @@ -180,6 +241,19 @@ int SOME_DEFINE; with self.assertRaises(Exception): f = tu.get_file('foobar.cpp') + @skip_if_no_fspath + def test_get_file_pathlike(self): + """Ensure tu.get_file() works appropriately with PathLike filenames.""" + + tu = get_tu('int foo();') + + f = tu.get_file(str_to_path('t.c')) + self.assertIsInstance(f, File) + self.assertEqual(f.name, 't.c') + + with self.assertRaises(Exception): + f = tu.get_file(str_to_path('foobar.cpp')) + def test_get_source_location(self): """Ensure tu.get_source_location() works.""" diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py index 4dec0583c7b0..bcdbeff9d99c 100644 --- a/bindings/python/tests/cindex/test_type.py +++ b/bindings/python/tests/cindex/test_type.py @@ -1,3 +1,8 @@ +import os +from clang.cindex import Config +if 'CLANG_LIBRARY_PATH' in os.environ: + Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) + import gc import unittest @@ -436,3 +441,28 @@ class TestType(unittest.TestCase): self.assertIsNotNone(testInteger, "Could not find testInteger.") self.assertEqual(testInteger.type.get_address_space(), 2) + + def test_template_arguments(self): + source = """ + class Foo { + }; + template + class Template { + }; + Template instance; + int bar; + """ + tu = get_tu(source, lang='cpp') + + # Varible with a template argument. + cursor = get_cursor(tu, 'instance') + cursor_type = cursor.type + self.assertEqual(cursor.kind, CursorKind.VAR_DECL) + self.assertEqual(cursor_type.spelling, 'Template') + self.assertEqual(cursor_type.get_num_template_arguments(), 1) + template_type = cursor_type.get_template_argument_type(0) + self.assertEqual(template_type.spelling, 'Foo') + + # Variable without a template argument. + cursor = get_cursor(tu, 'bar') + self.assertEqual(cursor.get_num_template_arguments(), -1) diff --git a/bindings/python/tests/cindex/util.py b/bindings/python/tests/cindex/util.py index c53ba7c81bde..57e17941c558 100644 --- a/bindings/python/tests/cindex/util.py +++ b/bindings/python/tests/cindex/util.py @@ -1,5 +1,15 @@ # This file provides common utility functions for the test suite. +import os +HAS_FSPATH = hasattr(os, 'fspath') + +if HAS_FSPATH: + from pathlib import Path as str_to_path +else: + str_to_path = None + +import unittest + from clang.cindex import Cursor from clang.cindex import TranslationUnit @@ -68,8 +78,13 @@ def get_cursors(source, spelling): return cursors +skip_if_no_fspath = unittest.skipUnless(HAS_FSPATH, + "Requires file system path protocol / Python 3.6+") + __all__ = [ 'get_cursor', 'get_cursors', 'get_tu', + 'skip_if_no_fspath', + 'str_to_path', ] diff --git a/cmake/caches/Fuchsia-stage2.cmake b/cmake/caches/Fuchsia-stage2.cmake index 28e179513475..8708231a6af1 100644 --- a/cmake/caches/Fuchsia-stage2.cmake +++ b/cmake/caches/Fuchsia-stage2.cmake @@ -1,29 +1,33 @@ -# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain -# build. +# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain build. set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "") set(PACKAGE_VENDOR Fuchsia CACHE STRING "") -set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") -set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") +if(NOT APPLE) + set(LLVM_ENABLE_LLD ON CACHE BOOL "") +endif() +set(LLVM_ENABLE_LTO ON CACHE BOOL "") +set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "") set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "") set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") -set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") +set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") +set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") -set(LLVM_ENABLE_LTO ON CACHE BOOL "") +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") if(NOT APPLE) - set(LLVM_ENABLE_LLD ON CACHE BOOL "") set(CLANG_DEFAULT_LINKER lld CACHE STRING "") set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") endif() -set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") +set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") + +set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "") +set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") -set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "") @@ -31,39 +35,50 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRIN if(APPLE) list(APPEND BUILTIN_TARGETS "default") list(APPEND RUNTIME_TARGETS "default") -elseif(UNIX) - foreach(target i386;x86_64;armhf;aarch64) - if(LINUX_${target}_SYSROOT) - # Set the per-target builtins options. - list(APPEND BUILTIN_TARGETS "${target}-linux-gnu") - set(BUILTINS_${target}-linux-gnu_CMAKE_SYSTEM_NAME Linux CACHE STRING "") - set(BUILTINS_${target}-linux-gnu_CMAKE_BUILD_TYPE Release CACHE STRING "") - set(BUILTINS_${target}-linux-gnu_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") - # Set the per-target runtimes options. - list(APPEND RUNTIME_TARGETS "${target}-linux-gnu") - set(RUNTIMES_${target}-linux-gnu_CMAKE_SYSTEM_NAME Linux CACHE STRING "") - set(RUNTIMES_${target}-linux-gnu_CMAKE_BUILD_TYPE Release CACHE STRING "") - set(RUNTIMES_${target}-linux-gnu_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") - set(RUNTIMES_${target}-linux-gnu_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_SANITIZER_CXX_ABI "libc++" CACHE STRING "") - set(RUNTIMES_${target}-linux-gnu_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") - set(RUNTIMES_${target}-linux-gnu_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") - endif() - endforeach() + set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") + set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") + set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "") endif() +foreach(target aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;x86_64-linux-gnu) + if(LINUX_${target}_SYSROOT) + # Set the per-target builtins options. + list(APPEND BUILTIN_TARGETS "${target}") + set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") + set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "") + set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") + set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") + set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") + set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAG "-fuse-ld=lld" CACHE STRING "") + + # Set the per-target runtimes options. + list(APPEND RUNTIME_TARGETS "${target}") + set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") + set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "") + set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") + set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") + endif() +endforeach() + if(FUCHSIA_SDK) set(FUCHSIA_aarch64_NAME arm64) set(FUCHSIA_x86_64_NAME x64) @@ -78,25 +93,25 @@ if(FUCHSIA_SDK) list(APPEND BUILTIN_TARGETS "${target}-fuchsia") set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "") set(BUILTINS_${target}-fuchsia_CMAKE_BUILD_TYPE Release CACHE STRING "") - set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "") - set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "") - set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "") - set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "") - set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "") - set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "") + set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "") + set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "") + set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "") + set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "") + set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "") + set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "") set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") # Set the per-target runtimes options. list(APPEND RUNTIME_TARGETS "${target}-fuchsia") set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "") set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_TYPE Release CACHE STRING "") - set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE STRING "") - set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "") - set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "") - set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "") - set(RUNTIMES_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "") - set(RUNTIMES_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "") - set(RUNTIMES_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "") + set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "") + set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "") + set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "") + set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "") + set(RUNTIMES_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "") + set(RUNTIMES_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "") + set(RUNTIMES_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "") set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "") set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") @@ -109,6 +124,8 @@ if(FUCHSIA_SDK) set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}-fuchsia_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "") + set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "") endforeach() set(LLVM_RUNTIME_SANITIZERS "Address" CACHE STRING "") @@ -127,6 +144,7 @@ set(LLVM_TOOLCHAIN_TOOLS llvm-cov llvm-cxxfilt llvm-dwarfdump + llvm-dwp llvm-lib llvm-nm llvm-objcopy @@ -138,6 +156,7 @@ set(LLVM_TOOLCHAIN_TOOLS llvm-size llvm-strip llvm-symbolizer + llvm-xray opt sancov CACHE STRING "") @@ -147,6 +166,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS libclang lld LTO + clang-apply-replacements clang-format clang-headers clang-include-fixer diff --git a/cmake/caches/Fuchsia.cmake b/cmake/caches/Fuchsia.cmake index fc7dae849935..e4a130ecfcfe 100644 --- a/cmake/caches/Fuchsia.cmake +++ b/cmake/caches/Fuchsia.cmake @@ -1,30 +1,30 @@ # This file sets up a CMakeCache for a Fuchsia toolchain build. -set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") +set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "") set(PACKAGE_VENDOR Fuchsia CACHE STRING "") -set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") -set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") -set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "") set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "") set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "") -set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "") +set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") +set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") + +set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") +if(NOT APPLE) + set(CLANG_DEFAULT_LINKER lld CACHE STRING "") + set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") +endif() +set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") +set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "") +set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") + set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") set(CMAKE_BUILD_TYPE Release CACHE STRING "") -set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") -if(NOT APPLE) - set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") -endif() - -set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") -set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "") - if(APPLE) set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "") set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "") @@ -43,18 +43,57 @@ elseif(UNIX) set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") endif() +if(BOOTSTRAP_CMAKE_SYSTEM_NAME) + set(target "${BOOTSTRAP_CMAKE_CXX_COMPILER_TARGET}") + if(STAGE2_LINUX_${target}_SYSROOT) + set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") + set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "") + set(BUILTINS_${target}_CMAKE_SYSROOT ${STAGE2_LINUX_${target}_SYSROOT} CACHE STRING "") + set(LLVM_BUILTIN_TARGETS "${target}" CACHE STRING "") + + set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_SYSROOT ${STAGE2_LINUX_${target}_SYSROOT} CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") + set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "") + set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") + set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "") + set(LLVM_RUNTIME_TARGETS "${target}" CACHE STRING "") + endif() +endif() + +set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") +if(NOT APPLE) + set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "") +endif() + set(CLANG_BOOTSTRAP_TARGETS check-all check-llvm check-clang + check-lld llvm-config test-suite test-depends llvm-test-depends clang-test-depends + lld-test-depends distribution install-distribution install-distribution-stripped + install-distribution-toolchain clang CACHE STRING "") get_cmake_property(variableNames VARIABLES) diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake index c09a8423f9f6..7e22f16f365b 100644 --- a/cmake/modules/AddClang.cmake +++ b/cmake/modules/AddClang.cmake @@ -131,6 +131,7 @@ macro(add_clang_tool name) endif() add_clang_executable(${name} ${ARGN}) + add_dependencies(${name} clang-headers) if (CLANG_BUILD_TOOLS) if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR diff --git a/cmake/modules/FindZ3.cmake b/cmake/modules/FindZ3.cmake index 779ef928da1b..7a224f789ec1 100644 --- a/cmake/modules/FindZ3.cmake +++ b/cmake/modules/FindZ3.cmake @@ -1,13 +1,36 @@ +# Looking for Z3 in CLANG_ANALYZER_Z3_INSTALL_DIR +find_path(Z3_INCLUDE_DIR NAMES z3.h + NO_DEFAULT_PATH + PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR}/include + PATH_SUFFIXES libz3 z3 + ) + +find_library(Z3_LIBRARIES NAMES z3 libz3 + NO_DEFAULT_PATH + PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR} + PATH_SUFFIXES lib bin + ) + +find_program(Z3_EXECUTABLE z3 + NO_DEFAULT_PATH + PATHS ${CLANG_ANALYZER_Z3_INSTALL_DIR} + PATH_SUFFIXES bin + ) + +# If Z3 has not been found in CLANG_ANALYZER_Z3_INSTALL_DIR look in the default directories find_path(Z3_INCLUDE_DIR NAMES z3.h PATH_SUFFIXES libz3 z3 ) find_library(Z3_LIBRARIES NAMES z3 libz3 + PATH_SUFFIXES lib bin ) -find_program(Z3_EXECUTABLE z3) +find_program(Z3_EXECUTABLE z3 + PATH_SUFFIXES bin + ) -if(Z3_INCLUDE_DIR AND Z3_EXECUTABLE) +if(Z3_INCLUDE_DIR AND Z3_LIBRARIES AND Z3_EXECUTABLE) execute_process (COMMAND ${Z3_EXECUTABLE} -version OUTPUT_VARIABLE libz3_version_str ERROR_QUIET diff --git a/docs/AddressSanitizer.rst b/docs/AddressSanitizer.rst index 7549159a39ab..67ef59b5ea2a 100644 --- a/docs/AddressSanitizer.rst +++ b/docs/AddressSanitizer.rst @@ -24,7 +24,7 @@ Typical slowdown introduced by AddressSanitizer is **2x**. How to build ============ -Build LLVM/Clang with `CMake `_. +Build LLVM/Clang with `CMake `_. Usage ===== @@ -265,7 +265,7 @@ Limitations * On 64-bit platforms AddressSanitizer maps (but not reserves) 16+ Terabytes of virtual address space. This means that tools like ``ulimit`` may not work as usually expected. -* Static linking is not supported. +* Static linking of executables is not supported. Supported Platforms =================== @@ -278,6 +278,7 @@ AddressSanitizer is supported on: * Android ARM * NetBSD i386/x86\_64 * FreeBSD i386/x86\_64 (tested on FreeBSD 11-current) +* Windows 8.1+ (i386/x86\_64) Ports to various other platforms are in progress. @@ -288,6 +289,9 @@ AddressSanitizer is fully functional on supported platforms starting from LLVM 3.1. The test suite is integrated into CMake build and can be run with ``make check-asan`` command. +The Windows port is functional and is used by Chrome and Firefox, but it is not +as well supported as the other ports. + More Information ================ diff --git a/docs/AutomaticReferenceCounting.rst b/docs/AutomaticReferenceCounting.rst index bf4d0945672a..3e51d2f5d79e 100644 --- a/docs/AutomaticReferenceCounting.rst +++ b/docs/AutomaticReferenceCounting.rst @@ -1734,20 +1734,78 @@ A program is ill-formed if it refers to the ``NSAutoreleasePool`` class. rest of the language. Not draining the pool during an unwind is apparently required by the Objective-C exceptions implementation. +.. _arc.misc.externally_retained: + +Externally-Retained Variables +----------------------------- + +In some situations, variables with strong ownership are considered +externally-retained by the implementation. This means that the variable is +retained elsewhere, and therefore the implementation can elide retaining and +releasing its value. Such a variable is implicitly ``const`` for safety. In +contrast with ``__unsafe_unretained``, an externally-retained variable still +behaves as a strong variable outside of initialization and destruction. For +instance, when an externally-retained variable is captured in a block the value +of the variable is retained and released on block capture and destruction. It +also affects C++ features such as lambda capture, ``decltype``, and template +argument deduction. + +Implicitly, the implementation assumes that the :ref:`self parameter in a +non-init method ` and the :ref:`variable in a for-in loop +` are externally-retained. + +Externally-retained semantics can also be opted into with the +``objc_externally_retained`` attribute. This attribute can apply to strong local +variables, functions, methods, or blocks: + +.. code-block:: objc + + @class WobbleAmount; + + @interface Widget : NSObject + -(void)wobble:(WobbleAmount *)amount; + @end + + @implementation Widget + + -(void)wobble:(WobbleAmount *)amount + __attribute__((objc_externally_retained)) { + // 'amount' and 'alias' aren't retained on entry, nor released on exit. + __attribute__((objc_externally_retained)) WobbleAmount *alias = amount; + } + @end + +Annotating a function with this attribute makes every parameter with strong +retainable object pointer type externally-retained, unless the variable was +explicitly qualified with ``__strong``. For instance, ``first_param`` is +externally-retained (and therefore ``const``) below, but not ``second_param``: + +.. code-block:: objc + + __attribute__((objc_externally_retained)) + void f(NSArray *first_param, __strong NSArray *second_param) { + // ... + } + +You can test if your compiler has support for ``objc_externally_retained`` with +``__has_attribute``: + +.. code-block:: objc + + #if __has_attribute(objc_externally_retained) + // Use externally retained... + #endif + .. _arc.misc.self: ``self`` -------- -The ``self`` parameter variable of an Objective-C method is never actually -retained by the implementation. It is undefined behavior, or at least -dangerous, to cause an object to be deallocated during a message send to that -object. - -To make this safe, for Objective-C instance methods ``self`` is implicitly -``const`` unless the method is in the :ref:`init family -`. Further, ``self`` is **always** implicitly -``const`` within a class method. +The ``self`` parameter variable of an non-init Objective-C method is considered +:ref:`externally-retained ` by the implementation. +It is undefined behavior, or at least dangerous, to cause an object to be +deallocated during a message send to that object. In an init method, ``self`` +follows the :ref:``init family rules ``. .. admonition:: Rationale @@ -1758,9 +1816,9 @@ To make this safe, for Objective-C instance methods ``self`` is implicitly without this retain and release. Since it's extremely uncommon to actually do so, even unintentionally, and since there's no natural way for the programmer to remove this retain/release pair otherwise (as there is for - other parameters by, say, making the variable ``__unsafe_unretained``), we - chose to make this optimizing assumption and shift some amount of risk to the - user. + other parameters by, say, making the variable ``objc_externally_retained`` or + qualifying it with ``__unsafe_unretained``), we chose to make this optimizing + assumption and shift some amount of risk to the user. .. _arc.misc.enumeration: @@ -1769,8 +1827,9 @@ Fast enumeration iteration variables If a variable is declared in the condition of an Objective-C fast enumeration loop, and the variable has no explicit ownership qualifier, then it is -qualified with ``const __strong`` and objects encountered during the -enumeration are not actually retained. +implicitly :ref:`externally-retained ` so that +objects encountered during the enumeration are not actually retained and +released. .. admonition:: Rationale @@ -2284,8 +2343,8 @@ block exactly as if it had been sent the ``retain`` message. .. _arc.runtime.objc_storeStrong: -``id objc_storeStrong(id *object, id value);`` ----------------------------------------------- +``void objc_storeStrong(id *object, id value);`` +------------------------------------------------ *Precondition:* ``object`` is a valid pointer to a ``__strong`` object which is adequately aligned for a pointer. ``value`` is null or a pointer to a valid diff --git a/docs/Block-ABI-Apple.txt b/docs/Block-ABI-Apple.txt index 94a4d18e08f0..1b04cc9e133c 100644 --- a/docs/Block-ABI-Apple.txt +++ b/docs/Block-ABI-Apple.txt @@ -1 +1 @@ -*NOTE* This document has moved to http://clang.llvm.org/docs/Block-ABI-Apple.html. +*NOTE* This document has moved to https://clang.llvm.org/docs/Block-ABI-Apple.html. diff --git a/docs/ClangCommandLineReference.rst b/docs/ClangCommandLineReference.rst index 5c15482cb251..e852c3e38798 100644 --- a/docs/ClangCommandLineReference.rst +++ b/docs/ClangCommandLineReference.rst @@ -36,7 +36,7 @@ Treat source input files as Objective-C inputs Treat source input files as Objective-C++ inputs -.. option:: -Qn +.. option:: -Qn, -fno-ident Do not emit metadata containing compiler name and version @@ -44,7 +44,7 @@ Do not emit metadata containing compiler name and version Don't emit warning for unused driver arguments -.. option:: -Qy +.. option:: -Qy, -fident Emit metadata containing compiler name and version @@ -158,7 +158,7 @@ Compile CUDA code for host only. Has no effect on non-CUDA compilations. .. option:: --cuda-include-ptx=, --no-cuda-include-ptx= -Include PTX for the follwing GPU architecture (e.g. sm\_35) or 'all'. May be specified more than once. +Include PTX for the following GPU architecture (e.g. sm\_35) or 'all'. May be specified more than once. .. option:: --cuda-noopt-device-debug, --no-cuda-noopt-device-debug @@ -214,9 +214,13 @@ Flush denormal floating point values to zero in CUDA device mode. Generate relocatable device code, also known as separate compilation mode. +.. option:: -fcuda-short-ptr, -fno-cuda-short-ptr + +Use 32-bit pointers for accessing const/local/shared address spaces. + .. option:: -ffixed-r19 -Reserve the r19 register (Hexagon only) +Reserve register r19 (Hexagon only) .. option:: -fheinous-gnu-extensions @@ -260,6 +264,10 @@ Display available options Display help for hidden options +.. option:: --hip-link + +Link clang-offload-bundler bundles for HIP + .. option:: -image\_base .. option:: -index-header-map @@ -452,6 +460,10 @@ Use pipes between commands, when possible .. option:: --print-diagnostic-categories +.. option:: -print-effective-triple, --print-effective-triple + +Print the effective target triple + .. option:: -print-file-name=, --print-file-name=, --print-file-name Print the full library path of @@ -480,6 +492,10 @@ Print the resource directory pathname Print the paths used for finding libraries and programs +.. option:: -print-target-triple, --print-target-triple + +Print the normalized target triple + .. option:: -private\_bundle .. option:: -pthread, -no-pthread @@ -558,6 +574,8 @@ Serialize compiler diagnostics to a file .. option:: -shared-libsan, -shared-libasan +Dynamically link the sanitizer runtime + .. option:: -single\_module .. option:: -specs=, --specs= @@ -568,6 +586,8 @@ Serialize compiler diagnostics to a file .. option:: -static-libsan +Statically link the sanitizer runtime + .. option:: -static-libstdc++ .. option:: -std-default= @@ -712,6 +732,12 @@ Attempt to match the ABI of Clang Treat each comma separated argument in as a documentation comment block command +.. option:: -fcomplete-member-pointers, -fno-complete-member-pointers + +Require member pointer base types to be complete if they would be significant under the Microsoft ABI + +.. option:: -fcrash-diagnostics-dir= + .. option:: -fdeclspec, -fno-declspec Allow \_\_declspec as a keyword @@ -746,7 +772,7 @@ Enables an experimental new pass manager in LLVM. .. option:: -ffine-grained-bitfield-accesses, -fno-fine-grained-bitfield-accesses -Use separate accesses for bitfields with legal widths and alignments. +Use separate accesses for consecutive bitfield runs with legal widths and alignments. .. option:: -finline-functions, -fno-inline-functions @@ -766,6 +792,16 @@ Don't use blacklist file for sanitizers .. option:: -fparse-all-comments +.. option:: -frecord-command-line, -frecord-gcc-switches, -fno-record-command-line, -fno-record-gcc-switches + +Generate a section named ".GCC.command.line" containing the clang driver +command-line. After linking, the section may contain multiple command lines, +which will be individually terminated by null bytes. Separate arguments within +a command line are combined with spaces; spaces and backslashes within an +argument are escaped with backslashes. This format differs from the format of +the equivalent section produced by GCC with the -frecord-gcc-switches flag. +This option is currently only supported on ELF targets. + .. option:: -fsanitize-address-field-padding= Level of field padding for AddressSanitizer @@ -774,9 +810,15 @@ Level of field padding for AddressSanitizer Enable linker dead stripping of globals in AddressSanitizer -.. option:: -fsanitize-address-poison-class-member-array-new-cookie, -fno-sanitize-address-poison-class-member-array-new-cookie +.. option:: -fsanitize-address-use-odr-indicator, -fno-sanitize-address-use-odr-indicator -Enable poisoning array cookies when using class member operator new\[\] in AddressSanitizer +Enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size + +.. option:: -fsanitize-address-poison-custom-array-cookie, -fno-sanitize-address-poison-custom-array-cookie + +Enable "poisoning" array cookies when allocating arrays with a custom operator new\[\] in Address Sanitizer, preventing accesses to the cookies from user code. An array cookie is a small implementation-defined header added to certain array allocations to record metadata such as the length of the array. Accesses to array cookies from user code are technically allowed by the standard but are more likely to be the result of an out-of-bounds array access. + +An operator new\[\] is "custom" if it is not one of the allocation functions provided by the C++ standard library. Array cookies from non-custom allocation functions are always poisoned. .. option:: -fsanitize-address-use-after-scope, -fno-sanitize-address-use-after-scope @@ -854,6 +896,10 @@ Strip (or keep only, if negative) a given number of path components when emittin Turn on runtime checks for various forms of undefined or suspicious behavior. See user manual for available checks +.. option:: -moutline, -mno-outline + +Enable function outlining (AArch64 only) + .. option:: --param , --param= .. option:: -std=, --std=, --std @@ -1151,6 +1197,10 @@ Target-independent compilation options .. option:: -faccess-control, -fno-access-control +.. option:: -faddrsig, -fno-addrsig + +Emit an address-significance table + .. option:: -falign-functions, -fno-align-functions .. program:: clang1 @@ -1223,12 +1273,20 @@ Accept non-standard constructs supported by the Borland compiler Load the clang builtins module map file. +.. option:: -fc++-static-destructors, -fno-c++-static-destructors + +Enable C++ static destructor registration (the default) + .. option:: -fcaret-diagnostics, -fno-caret-diagnostics .. option:: -fcf-protection=, -fcf-protection (equivalent to -fcf-protection=full) Instrument control-flow architecture protection. Options: return, branch, full, none. +.. option:: -fchar8\_t, -fno-char8\_t + +Enable C++ builtin type char8\_t + .. option:: -fclasspath=, --CLASSPATH , --CLASSPATH=, --classpath , --classpath= .. option:: -fcolor-diagnostics, -fno-color-diagnostics @@ -1293,6 +1351,10 @@ Place debug types in their own section (ELF Only) Parse templated function definitions at the end of the translation unit +.. option:: -fdelete-null-pointer-checks, -fno-delete-null-pointer-checks + +Treat usage of null pointers as undefined behavior. + .. option:: -fdenormal-fp-math= .. option:: -fdiagnostics-absolute-paths @@ -1325,6 +1387,10 @@ Print option name with mappable diagnostics Print a template comparison tree for differing templates +.. option:: -fdigraphs, -fno-digraphs + +Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default) + .. option:: -fdollars-in-identifiers, -fno-dollars-in-identifiers Allow '$' in identifiers @@ -1375,8 +1441,16 @@ Allow aggressive, lossy floating-point optimizations .. option:: -ffinite-math-only, -fno-finite-math-only +.. option:: -ffixed-point, -fno-fixed-point + +Enable fixed point types + .. option:: -ffor-scope, -fno-for-scope +.. option:: -fforce-emit-vtables, -fno-force-emit-vtables + +Emits more virtual tables to improve devirtualization + .. option:: -fforce-enable-int128, -fno-force-enable-int128 Enable support for int128\_t type @@ -1439,6 +1513,10 @@ Enable the integrated assembler .. option:: -fjump-tables, -fno-jump-tables +.. option:: -fkeep-static-consts + +Keep static const variables even if unused + .. option:: -flax-vector-conversions, -fno-lax-vector-conversions .. option:: -flimited-precision= @@ -1543,14 +1621,6 @@ Specifies the largest alignment guaranteed by '::operator new(size\_t)' Disable implicit builtin knowledge of a specific function -.. option:: -fdelete-null-pointer-checks, -fno-delete-null-pointer-checks - -When enabled, treat null pointer dereference, creation of a reference to null, -or passing a null pointer to a function parameter annotated with the "nonnull" -attribute as undefined behavior. (And, thus the optimizer may assume that any -pointer used in such a way must not have been null and optimize away the -branches accordingly.) On by default. - .. option:: -fno-elide-type Do not elide types when printing diagnostics @@ -1834,6 +1904,10 @@ Emit full debug info for all types used by the program Enable optimizations based on the strict definition of an enum's value range +.. option:: -fstrict-float-cast-overflow, -fno-strict-float-cast-overflow + +Assume that overflowing float-to-int casts are undefined (default) + .. option:: -fstrict-overflow, -fno-strict-overflow .. option:: -fstrict-return, -fno-strict-return @@ -1942,12 +2016,6 @@ Set the default symbol visibility for all global declarations Enables whole-program vtable optimization. Requires -flto -.. option:: -fforce-emit-vtables, -fno-force-emit-vtables - -In order to improve devirtualization, forces emitting of vtables even in -modules where it isn't necessary. It causes more inline virtual functions -to be emitted. - .. option:: -fwrapv, -fno-wrapv Treat signed integer overflow as two's complement @@ -2078,12 +2146,6 @@ Put objects of at most bytes into small data section (MIPS / Hexagon) .. option:: -mabi= -.. option:: -mabicalls, -mno-abicalls - -Enable SVR4-style position-independent code (Mips only) - -.. option:: -mabs= - .. option:: -malign-double Align doubles to two words in structs (x86 only) @@ -2096,54 +2158,32 @@ Align doubles to two words in structs (x86 only) Link stack frames through backchain on System Z -.. option:: -mcheck-zero-division, -mno-check-zero-division - .. option:: -mcmodel= -.. option:: -mcompact-branches= - .. option:: -mconsole -.. option:: -mcpu=, -mv4 (equivalent to -mcpu=hexagonv4), -mv5 (equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 (equivalent to -mcpu=hexagonv60), -mv62 (equivalent to -mcpu=hexagonv62), -mv65 (equivalent to -mcpu=hexagonv65) +.. option:: -mcpu=, -mv5 (equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 (equivalent to -mcpu=hexagonv60), -mv62 (equivalent to -mcpu=hexagonv62), -mv65 (equivalent to -mcpu=hexagonv65) + +.. option:: -mcrc, -mno-crc + +Allow use of CRC instructions (ARM/Mips only) .. option:: -mdefault-build-attributes, -mno-default-build-attributes .. option:: -mdll -.. option:: -mdouble-float - -.. option:: -mdsp, -mno-dsp - -.. option:: -mdspr2, -mno-dspr2 - .. option:: -mdynamic-no-pic .. option:: -meabi Set EABI type, e.g. 4, 5 or gnu (default depends on triple) -.. option:: -membedded-data, -mno-embedded-data - -Place constants in the .rodata section instead of the .sdata section even if they meet the -G threshold (MIPS) - -.. option:: -mextern-sdata, -mno-extern-sdata - -Assume that externally defined data is in the small data if it meets the -G threshold (MIPS) - .. option:: -mfentry Insert calls to fentry at function entry (x86 only) .. option:: -mfloat-abi= -.. option:: -mfp32 - -Use 32-bit floating point registers (MIPS only) - -.. option:: -mfp64 - -Use 64-bit floating point registers (MIPS only) - .. option:: -mfpmath= .. option:: -mfpu= @@ -2152,10 +2192,6 @@ Use 64-bit floating point registers (MIPS only) Enable merging of globals -.. option:: -mgpopt, -mno-gpopt - -Use GP relative accesses for symbols known to be in a small data section (MIPS) - .. option:: -mhard-float .. option:: -mhwdiv=, --mhwdiv , --mhwdiv= @@ -2172,22 +2208,10 @@ Use Intel MCU ABI (integrated-as) Emit an object file which can be used with an incremental linker -.. option:: -mindirect-jump= - -Change indirect jump instructions to inhibit speculation - .. option:: -miphoneos-version-min=, -mios-version-min= -.. option:: -mips16 - .. option:: -mkernel -.. option:: -mldc1-sdc1, -mno-ldc1-sdc1 - -.. option:: -mlocal-sdata, -mno-local-sdata - -Extend the -G behaviour to object local data (MIPS) - .. option:: -mlong-calls, -mno-long-calls Generate branches with extended addressability, usually via indirect jumps. @@ -2196,30 +2220,12 @@ Generate branches with extended addressability, usually via indirect jumps. Set Mac OS X deployment target -.. option:: -mmadd4, -mno-madd4 - -Enable the generation of 4-operand madd.s, madd.d and related instructions. - .. option:: -mmcu= -.. option:: -mmicromips, -mno-micromips - .. option:: -mms-bitfields, -mno-ms-bitfields Set the default structure layout to be compatible with the Microsoft compiler standard -.. option:: -mmsa, -mno-msa - -Enable MSA ASE (MIPS only) - -.. option:: -mmt, -mno-mt - -Enable MT ASE (MIPS only) - -.. option:: -mnan= - -.. option:: -mno-mips16 - .. option:: -momit-leaf-frame-pointer, -mno-omit-leaf-frame-pointer Omit frame pointer setup for leaf functions @@ -2252,11 +2258,15 @@ Enable hexagon-qdsp6 backward compatibility (integrated-as) Relax all machine instructions +.. option:: -mretpoline, -mno-retpoline + .. option:: -mrtd, -mno-rtd Make StdCall calling convention the default -.. option:: -msingle-float +.. option:: -msign-return-address= + +Select return address signing scope .. option:: -msoft-float, -mno-soft-float @@ -2302,10 +2312,36 @@ The thread model to use, e.g. posix, single (posix by default) .. option:: -mx32 -.. option:: -mxgot, -mno-xgot - AARCH64 ------- +.. option:: -ffixed-x1 + +Reserve the x1 register (AArch64 only) + +.. option:: -ffixed-x2 + +Reserve the x2 register (AArch64 only) + +.. option:: -ffixed-x3 + +Reserve the x3 register (AArch64 only) + +.. option:: -ffixed-x4 + +Reserve the x4 register (AArch64 only) + +.. option:: -ffixed-x5 + +Reserve the x5 register (AArch64 only) + +.. option:: -ffixed-x6 + +Reserve the x6 register (AArch64 only) + +.. option:: -ffixed-x7 + +Reserve the x7 register (AArch64 only) + .. option:: -ffixed-x18 Reserve the x18 register (AArch64 only) @@ -2314,6 +2350,42 @@ Reserve the x18 register (AArch64 only) Reserve the x20 register (AArch64 only) +.. option:: -fcall-saved-x8 + +Make the x8 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x9 + +Make the x9 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x10 + +Make the x10 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x11 + +Make the x11 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x12 + +Make the x12 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x13 + +Make the x13 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x14 + +Make the x14 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x15 + +Make the x15 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x18 + +Make the x18 register call-saved (AArch64 only) + .. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769 Workaround Cortex-A53 erratum 835769 (AArch64 only) @@ -2334,10 +2406,6 @@ ARM Reserve the r9 register (ARM only) -.. option:: -mcrc - -Allow use of CRC instructions (ARM only) - .. option:: -mexecute-only, -mno-execute-only, -mpure-code Disallow generation of data access to code sections (ARM only) @@ -2370,6 +2438,18 @@ Hexagon ------- .. option:: -mieee-rnd-near +.. option:: -mmemops, -mno-memops + +Enable generation of memop instructions + +.. option:: -mnvj, -mno-nvj + +Enable generation of new-value jumps + +.. option:: -mnvs, -mno-nvs + +Enable generation of new-value stores + .. option:: -mpackets, -mno-packets Enable generation of instruction packets @@ -2390,6 +2470,82 @@ Set Hexagon Vector Length Enable Hexagon Vector eXtensions +MIPS +---- +.. option:: -mabicalls, -mno-abicalls + +Enable SVR4-style position-independent code (Mips only) + +.. option:: -mabs= + +.. option:: -mcheck-zero-division, -mno-check-zero-division + +.. option:: -mcompact-branches= + +.. option:: -mdouble-float + +.. option:: -mdsp, -mno-dsp + +.. option:: -mdspr2, -mno-dspr2 + +.. option:: -membedded-data, -mno-embedded-data + +Place constants in the .rodata section instead of the .sdata section even if they meet the -G threshold (MIPS) + +.. option:: -mextern-sdata, -mno-extern-sdata + +Assume that externally defined data is in the small data if it meets the -G threshold (MIPS) + +.. option:: -mfp32 + +Use 32-bit floating point registers (MIPS only) + +.. option:: -mfp64 + +Use 64-bit floating point registers (MIPS only) + +.. option:: -mginv, -mno-ginv + +.. option:: -mgpopt, -mno-gpopt + +Use GP relative accesses for symbols known to be in a small data section (MIPS) + +.. option:: -mindirect-jump= + +Change indirect jump instructions to inhibit speculation + +.. option:: -mips16 + +.. option:: -mldc1-sdc1, -mno-ldc1-sdc1 + +.. option:: -mlocal-sdata, -mno-local-sdata + +Extend the -G behaviour to object local data (MIPS) + +.. option:: -mmadd4, -mno-madd4 + +Enable the generation of 4-operand madd.s, madd.d and related instructions. + +.. option:: -mmicromips, -mno-micromips + +.. option:: -mmsa, -mno-msa + +Enable MSA ASE (MIPS only) + +.. option:: -mmt, -mno-mt + +Enable MT ASE (MIPS only) + +.. option:: -mnan= + +.. option:: -mno-mips16 + +.. option:: -msingle-float + +.. option:: -mvirt, -mno-virt + +.. option:: -mxgot, -mno-xgot + PowerPC ------- .. option:: -maltivec, -mno-altivec @@ -2504,6 +2660,8 @@ X86 .. option:: -mgfni, -mno-gfni +.. option:: -minvpcid, -mno-invpcid + .. option:: -mlwp, -mno-lwp .. option:: -mlzcnt, -mno-lzcnt @@ -2512,16 +2670,18 @@ X86 .. option:: -mmovbe, -mno-movbe -.. option:: -mmovdiri, -mno-movdiri - .. option:: -mmovdir64b, -mno-movdir64b +.. option:: -mmovdiri, -mno-movdiri + .. option:: -mmpx, -mno-mpx .. option:: -mmwaitx, -mno-mwaitx .. option:: -mpclmul, -mno-pclmul +.. option:: -mpconfig, -mno-pconfig + .. option:: -mpku, -mno-pku .. option:: -mpopcnt, -mno-popcnt @@ -2530,14 +2690,14 @@ X86 .. option:: -mprfchw, -mno-prfchw +.. option:: -mptwrite, -mno-ptwrite + .. option:: -mrdpid, -mno-rdpid .. option:: -mrdrnd, -mno-rdrnd .. option:: -mrdseed, -mno-rdseed -.. option:: -mretpoline, -mno-retpoline - .. option:: -mretpoline-external-thunk, -mno-retpoline-external-thunk .. option:: -mrtm, -mno-rtm @@ -2588,6 +2748,12 @@ X86 .. option:: -mxsaves, -mno-xsaves +RISCV +----- +.. option:: -mrelax, -mno-relax + +Enable linker relaxation + Optimization level ~~~~~~~~~~~~~~~~~~ @@ -2671,9 +2837,11 @@ Debug information flags Embed source text in DWARF debug sections -.. option:: -ggnu-pubnames +.. option:: -ggnu-pubnames, -gno-gnu-pubnames -.. option:: -grecord-gcc-switches, -gno-record-gcc-switches +.. option:: -gpubnames, -gno-pubnames + +.. option:: -grecord-command-line, -grecord-gcc-switches, -gno-record-command-line, -gno-record-gcc-switches .. option:: -gsplit-dwarf @@ -2886,6 +3054,14 @@ Pass to the linker .. option:: -filelist +.. option:: --hip-device-lib-path= + +HIP device library path + +.. option:: --hip-device-lib= + +HIP device library + .. option:: -l .. option:: -r diff --git a/docs/ClangFormat.rst b/docs/ClangFormat.rst index f53c02ae90d7..f2228c57505b 100644 --- a/docs/ClangFormat.rst +++ b/docs/ClangFormat.rst @@ -169,7 +169,7 @@ Visual Studio Integration ========================= Download the latest Visual Studio extension from the `alpha build site -`_. The default key-binding is Ctrl-R,Ctrl-F. +`_. The default key-binding is Ctrl-R,Ctrl-F. Script for patch reformatting @@ -200,6 +200,12 @@ So to reformat all the lines in the latest :program:`git` commit, just do: git diff -U0 --no-color HEAD^ | clang-format-diff.py -i -p1 +With Mercurial/:program:`hg`: + +.. code-block:: console + + hg diff -U0 --color=never | clang-format-diff.py -i -p1 + In an SVN client, you can do: .. code-block:: console diff --git a/docs/ClangFormatStyleOptions.rst b/docs/ClangFormatStyleOptions.rst index 49f9f68088bc..054d5c32c6f2 100644 --- a/docs/ClangFormatStyleOptions.rst +++ b/docs/ClangFormatStyleOptions.rst @@ -108,7 +108,7 @@ Configuring Style in Code When using ``clang::format::reformat(...)`` functions, the format is specified by supplying the `clang::format::FormatStyle -`_ +`_ structure. @@ -131,7 +131,7 @@ the configuration (without a prefix: ``Auto``). * ``LLVM`` A style complying with the `LLVM coding standards - `_ + `_ * ``Google`` A style complying with `Google's C++ style guide `_ @@ -908,20 +908,17 @@ the configuration (without a prefix: ``Auto``). try { foo(); - } catch () { + } + catch () { } void foo() { bar(); } - class foo - { + class foo { }; if (foo()) { - } else { } - enum X : int - { - A, - B - }; + else { + } + enum X : int { A, B }; * ``BS_Allman`` (in configuration: ``Allman``) Always break before braces. @@ -1134,21 +1131,17 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ true: - FitsOnOneLine::Constructor() - : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {} - - DoesntFit::Constructor() - : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), - aaaaaaaaaaaaa(aaaaaaaaaaaaaa), - aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {} + SomeClass::Constructor() + : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) { + return 0; + } false: - FitsOnOneLine::Constructor() - : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {} - - DoesntFit::Constructor() - : aaaaaaaaaaaaa(aaaaaaaaaaaaaa), aaaaaaaaaaaaa(aaaaaaaaaaaaaa), - aaaaaaaaaaaaa(aaaaaaaaaaaaaa) {} + SomeClass::Constructor() + : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), + aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) { + return 0; + } **ConstructorInitializerIndentWidth** (``unsigned``) The number of characters to use for indentation of constructor @@ -1297,7 +1290,7 @@ the configuration (without a prefix: ``Auto``). If none of the regular expressions match, INT_MAX is assigned as category. The main header for a source file automatically gets category 0. so that it is generally kept at the beginning of the ``#includes`` - (http://llvm.org/docs/CodingStandards.html#include-style). However, you + (https://llvm.org/docs/CodingStandards.html#include-style). However, you can also assign negative priorities if you have certain headers that always need to be first. @@ -1402,6 +1395,39 @@ the configuration (without a prefix: ``Auto``). LoooooooooooooooooooooooooooooooooooooooongReturnType LoooooooooooooooooooooooooooooooongFunctionDeclaration(); +**JavaImportGroups** (``std::vector``) + A vector of prefixes ordered by the desired groups for Java imports. + + Each group is separated by a newline. Static imports will also follow the + same grouping convention above all non-static imports. One group's prefix + can be a subset of another - the longest prefix is always matched. Within + a group, the imports are ordered lexicographically. + + In the .clang-format configuration file, this can be configured like + in the following yaml example. This will result in imports being + formatted as in the Java example below. + + .. code-block:: yaml + + JavaImportGroups: ['com.example', 'com', 'org'] + + + .. code-block:: java + + import static com.example.function1; + + import static com.test.function2; + + import static org.example.function3; + + import com.example.ClassA; + import com.example.Test; + import com.example.a.ClassB; + + import com.test.ClassC; + + import org.example.ClassD; + **JavaScriptQuotes** (``JavaScriptQuoteStyle``) The JavaScriptQuoteStyle to use for JavaScript strings. @@ -1979,6 +2005,16 @@ the configuration (without a prefix: ``Auto``). +**StatementMacros** (``std::vector``) + A vector of macros that should be interpreted as complete + statements. + + Typical macros are expressions, and require a semi-colon to be + added; sometimes this is not the case, and this allows to make + clang-format aware of such cases. + + For example: Q_UNUSED + **TabWidth** (``unsigned``) The number of columns used for tab stops. diff --git a/docs/ClangPlugins.rst b/docs/ClangPlugins.rst index 833f0dd39f77..5e6082e90340 100644 --- a/docs/ClangPlugins.rst +++ b/docs/ClangPlugins.rst @@ -69,7 +69,7 @@ Putting it all together Let's look at an example plugin that prints top-level function names. This example is checked into the clang repository; please take a look at the `latest version of PrintFunctionNames.cpp -`_. +`_. Running the plugin ================== @@ -110,7 +110,7 @@ source tree: -plugin -Xclang print-fns Also see the print-function-name plugin example's -`README `_ +`README `_ Using the clang command line diff --git a/docs/ClangTools.rst b/docs/ClangTools.rst index e371596b240c..99e8a5e4f685 100644 --- a/docs/ClangTools.rst +++ b/docs/ClangTools.rst @@ -19,12 +19,12 @@ LLVM/Clang checkout: - With Subversion: - ``cd llvm/tools/clang/tools`` - - ``svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra`` + - ``svn co https://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra`` - Or with Git: - ``cd llvm/tools/clang/tools`` - - ``git clone http://llvm.org/git/clang-tools-extra.git extra`` + - ``git clone https://llvm.org/git/clang-tools-extra.git extra`` This document describes a high-level overview of the organization of Clang Tools within the project as well as giving an introduction to some @@ -105,7 +105,7 @@ provide its own user-focused documentation. ``clang-tidy`` -------------- -`clang-tidy `_ is a clang-based C++ +`clang-tidy `_ is a clang-based C++ linter tool. It provides an extensible framework for building compiler-based static analyses detecting and fixing bug-prone patterns, performance, portability and maintainability issues. diff --git a/docs/CommandGuide/clang.rst b/docs/CommandGuide/clang.rst index d440d915d686..a75b6c911571 100644 --- a/docs/CommandGuide/clang.rst +++ b/docs/CommandGuide/clang.rst @@ -60,7 +60,7 @@ Linker The Clang Static Analyzer is a tool that scans source code to try to find bugs through code analysis. This tool uses many parts of Clang and is built into -the same driver. Please see for more details +the same driver. Please see for more details on how to use the static analyzer. OPTIONS @@ -361,7 +361,7 @@ Code Generation Options :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code size further. - :option:`-Og` Like :option:`-O1`. In future versions, this option might + :option:`-Og` Like :option:`-O1`. In future versions, this option might disable different optimizations in order to improve debuggability. :option:`-O` Equivalent to :option:`-O2`. @@ -625,7 +625,7 @@ ENVIRONMENT BUGS ---- -To report bugs, please visit . Most bug reports should +To report bugs, please visit . Most bug reports should include preprocessed source files (use the :option:`-E` option) and the full output of the compiler, along with information to reproduce. @@ -633,4 +633,3 @@ SEE ALSO -------- :manpage:`as(1)`, :manpage:`ld(1)` - diff --git a/docs/ControlFlowIntegrity.rst b/docs/ControlFlowIntegrity.rst index fcc640988897..b0b37f83f1c7 100644 --- a/docs/ControlFlowIntegrity.rst +++ b/docs/ControlFlowIntegrity.rst @@ -45,7 +45,7 @@ Experimental support for :ref:`cross-DSO control flow integrity ` exists that does not require classes to have hidden LTO visibility. This cross-DSO support has unstable ABI at this time. -.. _gold plugin: http://llvm.org/docs/GoldPlugin.html +.. _gold plugin: https://llvm.org/docs/GoldPlugin.html .. _cfi-schemes: diff --git a/docs/ControlFlowIntegrityDesign.rst b/docs/ControlFlowIntegrityDesign.rst index 15e20e1e1d8e..bb1770da5af4 100644 --- a/docs/ControlFlowIntegrityDesign.rst +++ b/docs/ControlFlowIntegrityDesign.rst @@ -93,8 +93,8 @@ the bit vectors for the whole program. It currently does this using LLVM's `type metadata`_ mechanism together with link-time optimization. .. _address point: http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-general -.. _type metadata: http://llvm.org/docs/TypeMetadata.html -.. _ByteArrayBuilder: http://llvm.org/docs/doxygen/html/structllvm_1_1ByteArrayBuilder.html +.. _type metadata: https://llvm.org/docs/TypeMetadata.html +.. _ByteArrayBuilder: https://llvm.org/docs/doxygen/html/structllvm_1_1ByteArrayBuilder.html Optimizations ------------- @@ -196,7 +196,7 @@ those sub-hierarchies need to be (see "Stripping Leading/Trailing Zeros in Bit Vectors" above). The `GlobalLayoutBuilder`_ class is responsible for laying out the globals efficiently to minimize the sizes of the underlying bitsets. -.. _GlobalLayoutBuilder: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/LowerTypeTests.h?view=markup +.. _GlobalLayoutBuilder: https://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/LowerTypeTests.h?view=markup Alignment ~~~~~~~~~ @@ -274,6 +274,154 @@ If the bit vector is all ones, the bit vector check is redundant; we simply need to check that the address is in range and well aligned. This is more likely to occur if the virtual tables are padded. +Forward-Edge CFI for Virtual Calls by Interleaving Virtual Tables +----------------------------------------------------------------- + +Dimitar et. al. proposed a novel approach that interleaves virtual tables in [1]_. +This approach is more efficient in terms of space because padding and bit vectors are no longer needed. +At the same time, it is also more efficient in terms of performance because in the interleaved layout +address points of the virtual tables are consecutive, thus the validity check of a virtual +vtable pointer is always a range check. + +At a high level, the interleaving scheme consists of three steps: 1) split virtual table groups into +separate virtual tables, 2) order virtual tables by a pre-order traversal of the class hierarchy +and 3) interleave virtual tables. + +The interleaving scheme implemented in LLVM is inspired by [1]_ but has its own +enhancements (more in `Interleave virtual tables`_). + +.. [1] `Protecting C++ Dynamic Dispatch Through VTable Interleaving `_. Dimitar Bounov, Rami Gökhan Kıcı, Sorin Lerner. + +Split virtual table groups into separate virtual tables +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Itanium C++ ABI glues multiple individual virtual tables for a class into a combined virtual table (virtual table group). +The interleaving scheme, however, can only work with individual virtual tables so it must split the combined virtual tables first. +In comparison, the old scheme does not require the splitting but it is more efficient when the combined virtual tables have been split. +The `GlobalSplit`_ pass is responsible for splitting combined virtual tables into individual ones. + +.. _GlobalSplit: https://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalSplit.cpp?view=markup + +Order virtual tables by a pre-order traversal of the class hierarchy +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is common to both the old scheme described above and the interleaving scheme. +For the interleaving scheme, since the combined virtual tables have been split in the previous step, +this step ensures that for any class all the compatible virtual tables will appear consecutively. +For the old scheme, the same property may not hold since it may work on combined virtual tables. + +For example, consider the following four C++ classes: + +.. code-block:: c++ + + struct A { + virtual void f1(); + }; + + struct B : A { + virtual void f1(); + virtual void f2(); + }; + + struct C : A { + virtual void f1(); + virtual void f3(); + }; + + struct D : B { + virtual void f1(); + virtual void f2(); + }; + +This step will arrange the virtual tables for A, B, C, and D in the order of *vtable-of-A, vtable-of-B, vtable-of-D, vtable-of-C*. + +Interleave virtual tables +~~~~~~~~~~~~~~~~~~~~~~~~~ + +This step is where the interleaving scheme deviates from the old scheme. Instead of laying out +whole virtual tables in the previously computed order, the interleaving scheme lays out table +entries of the virtual tables strategically to ensure the following properties: + +(1) offset-to-top and RTTI fields layout property + +The Itanium C++ ABI specifies that offset-to-top and RTTI fields appear at the offsets behind the +address point. Note that libraries like libcxxabi do assume this property. + +(2) virtual function entry layout property + +For each virtual function the distance between an virtual table entry for this function and the corresponding +address point is always the same. This property ensures that dynamic dispatch still works with the interleaving layout. + +Note that the interleaving scheme in the CFI implementation guarantees both properties above whereas the original scheme proposed +in [1]_ only guarantees the second property. + +To illustrate how the interleaving algorithm works, let us continue with the running example. +The algorithm first separates all the virtual table entries into two work lists. To do so, +it starts by allocating two work lists, one initialized with all the offset-to-top entries of virtual tables in the order +computed in the last step, one initialized with all the RTTI entries in the same order. + +.. csv-table:: Work list 1 Layout + :header: 0, 1, 2, 3 + + A::offset-to-top, B::offset-to-top, D::offset-to-top, C::offset-to-top + + +.. csv-table:: Work list 2 layout + :header: 0, 1, 2, 3, + + &A::rtti, &B::rtti, &D::rtti, &C::rtti + +Then for each virtual function the algorithm goes through all the virtual tables in the previously computed order +to collect all the related entries into a virtual function list. +After this step, there are the following virtual function lists: + +.. csv-table:: f1 list + :header: 0, 1, 2, 3 + + &A::f1, &B::f1, &D::f1, &C::f1 + + +.. csv-table:: f2 list + :header: 0, 1 + + &B::f2, &D::f2 + + +.. csv-table:: f3 list + :header: 0 + + &C::f3 + +Next, the algorithm picks the longest remaining virtual function list and appends the whole list to the shortest work list +until no function lists are left, and pads the shorter work list so that they are of the same length. +In the example, f1 list will be first added to work list 1, then f2 list will be added +to work list 2, and finally f3 list will be added to the work list 2. Since work list 1 now has one more entry than +work list 2, a padding entry is added to the latter. After this step, the two work lists look like: + +.. csv-table:: Work list 1 Layout + :header: 0, 1, 2, 3, 4, 5, 6, 7 + + A::offset-to-top, B::offset-to-top, D::offset-to-top, C::offset-to-top, &A::f1, &B::f1, &D::f1, &C::f1 + + +.. csv-table:: Work list 2 layout + :header: 0, 1, 2, 3, 4, 5, 6, 7 + + &A::rtti, &B::rtti, &D::rtti, &C::rtti, &B::f2, &D::f2, &C::f3, padding + +Finally, the algorithm merges the two work lists into the interleaved layout by alternatingly +moving the head of each list to the final layout. After this step, the final interleaved layout looks like: + +.. csv-table:: Interleaved layout + :header: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + + A::offset-to-top, &A::rtti, B::offset-to-top, &B::rtti, D::offset-to-top, &D::rtti, C::offset-to-top, &C::rtti, &A::f1, &B::f2, &B::f1, &D::f2, &D::f1, &C::f3, &C::f1, padding + +In the above interleaved layout, each virtual table's offset-to-top and RTTI are always adjacent, which shows that the layout has the first property. +For the second property, let us look at f2 as an example. In the interleaved layout, +there are two entries for f2: B::f2 and D::f2. The distance between &B::f2 +and its address point D::offset-to-top (the entry immediately after &B::rtti) is 5 entry-length, so is the distance between &D::f2 and C::offset-to-top (the entry immediately after &D::rtti). + Forward-Edge CFI for Indirect Function Calls ============================================ diff --git a/docs/CrossCompilation.rst b/docs/CrossCompilation.rst index 5e1253ddf853..932e0525366e 100644 --- a/docs/CrossCompilation.rst +++ b/docs/CrossCompilation.rst @@ -15,7 +15,7 @@ build system or Makefiles, nor choosing the right CMake options, etc. Also, it does not cover all the possible options, nor does it contain specific examples for specific architectures. For a concrete example, the `instructions for cross-compiling LLVM itself -`_ may be of interest. +`_ may be of interest. After reading this document, you should be familiar with the main issues related to cross-compilation, and what main compiler options Clang provides diff --git a/docs/DiagnosticsReference.rst b/docs/DiagnosticsReference.rst index 734a45902484..7d9b1e8359a8 100644 --- a/docs/DiagnosticsReference.rst +++ b/docs/DiagnosticsReference.rst @@ -7885,6 +7885,10 @@ This diagnostic is enabled by default. | |+---------------------+| +-----------------------------------------------------------------------------------------------+-----------------------+ +-Woverride-init +--------------- +Synonym for `-Winitializer-overrides`_. + -Woverride-module ----------------- @@ -8637,9 +8641,9 @@ Also controls `-Wpragma-pack-suspicious-include`_. **Diagnostic text:** -+---------------------------------------------------------------------------------------------------------------+ -|:warning:`warning:` |nbsp| :diagtext:`the current #pragma pack aligment value is modified in the included file`| -+---------------------------------------------------------------------------------------------------------------+ ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`the current #pragma pack alignment value is modified in the included file`| ++----------------------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------+ |:warning:`warning:` |nbsp| :diagtext:`unterminated '#pragma pack (push, ...)' at end of file`| diff --git a/docs/HardwareAssistedAddressSanitizerDesign.rst b/docs/HardwareAssistedAddressSanitizerDesign.rst index 2578914376ae..4e6f5d14cde4 100644 --- a/docs/HardwareAssistedAddressSanitizerDesign.rst +++ b/docs/HardwareAssistedAddressSanitizerDesign.rst @@ -47,21 +47,21 @@ All memory accesses are prefixed with an inline instruction sequence that verifies the tags. Currently, the following sequence is used: -.. code-block:: asm +.. code-block:: none // int foo(int *a) { return *a; } // clang -O2 --target=aarch64-linux -fsanitize=hwaddress -c load.c foo: 0: 08 00 00 90 adrp x8, 0 <__hwasan_shadow> - 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) - 8: 09 dc 44 d3 ubfx x9, x0, #4, #52 // shadow offset - c: 28 69 68 38 ldrb w8, [x9, x8] // load shadow tag - 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag - 14: 3f 01 08 6b cmp w9, w8 // compare tags - 18: 61 00 00 54 b.ne 24 // jump on mismatch - 1c: 00 00 40 b9 ldr w0, [x0] // original load + 4: 08 01 40 f9 ldr x8, [x8] // shadow base (to be resolved by the loader) + 8: 09 dc 44 d3 ubfx x9, x0, #4, #52 // shadow offset + c: 28 69 68 38 ldrb w8, [x9, x8] // load shadow tag + 10: 09 fc 78 d3 lsr x9, x0, #56 // extract address tag + 14: 3f 01 08 6b cmp w9, w8 // compare tags + 18: 61 00 00 54 b.ne 24 // jump on mismatch + 1c: 00 00 40 b9 ldr w0, [x0] // original load 20: c0 03 5f d6 ret - 24: 40 20 21 d4 brk #0x902 // trap + 24: 40 20 21 d4 brk #0x902 // trap Alternatively, memory accesses are prefixed with a function call. diff --git a/docs/InternalsManual.rst b/docs/InternalsManual.rst index af15b2e51e1c..b6b49d7547b0 100644 --- a/docs/InternalsManual.rst +++ b/docs/InternalsManual.rst @@ -19,7 +19,7 @@ LLVM Support Library ==================== The LLVM ``libSupport`` library provides many underlying libraries and -`data-structures `_, including +`data-structures `_, including command line option processing, various containers and a system abstraction layer, which is used for file system access. @@ -559,13 +559,9 @@ The clang Driver and library are documented :doc:`here `. Precompiled Headers =================== -Clang supports two implementations of precompiled headers. The default -implementation, precompiled headers (:doc:`PCH `) uses a +Clang supports precompiled headers (:doc:`PCH `), which uses a serialized representation of Clang's internal data structures, encoded with the -`LLVM bitstream format `_. -Pretokenized headers (:doc:`PTH `), on the other hand, contain a -serialized representation of the tokens encountered when preprocessing a header -(and anything that header includes). +`LLVM bitstream format `_. The Frontend Library ==================== @@ -1690,7 +1686,7 @@ semantic checking for some attributes, etc. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The first step to adding a new attribute to Clang is to add its definition to `include/clang/Basic/Attr.td -`_. +`_. This tablegen definition must derive from the ``Attr`` (tablegen, not semantic) type, or one of its derivatives. Most attributes will derive from the ``InheritableAttr`` type, which specifies that the attribute can be inherited by @@ -1752,10 +1748,10 @@ the ``SubjectList``. The diagnostics generated for subject list violations are either ``diag::warn_attribute_wrong_decl_type`` or ``diag::err_attribute_wrong_decl_type``, and the parameter enumeration is found in `include/clang/Sema/ParsedAttr.h -`_ +`_ If a previously unused Decl node is added to the ``SubjectList``, the logic used to automatically determine the diagnostic parameter in `utils/TableGen/ClangAttrEmitter.cpp -`_ +`_ may need to be updated. By default, all subjects in the SubjectList must either be a Decl node defined @@ -1777,7 +1773,7 @@ All attributes must have some form of documentation associated with them. Documentation is table generated on the public web server by a server-side process that runs daily. Generally, the documentation for an attribute is a stand-alone definition in `include/clang/Basic/AttrDocs.td -`_ +`_ that is named after the attribute being documented. If the attribute is not for public consumption, or is an implicitly-created @@ -1828,7 +1824,7 @@ All arguments have a name and a flag that specifies whether the argument is optional. The associated C++ type of the argument is determined by the argument definition type. If the existing argument types are insufficient, new types can be created, but it requires modifying `utils/TableGen/ClangAttrEmitter.cpp -`_ +`_ to properly support the type. Other Properties @@ -1840,7 +1836,7 @@ document, however a few deserve mention. If the parsed form of the attribute is more complex, or differs from the semantic form, the ``HasCustomParsing`` bit can be set to ``1`` for the class, and the parsing code in `Parser::ParseGNUAttributeArgs() -`_ +`_ can be updated for the special case. Note that this only applies to arguments with a GNU spelling -- attributes with a __declspec spelling currently ignore this flag and are handled by ``Parser::ParseMicrosoftDeclSpec``. @@ -1903,7 +1899,7 @@ semantic attribute class object, with ``public`` access. Boilerplate ^^^^^^^^^^^ All semantic processing of declaration attributes happens in `lib/Sema/SemaDeclAttr.cpp -`_, +`_, and generally starts in the ``ProcessDeclAttribute()`` function. If the attribute is a "simple" attribute -- meaning that it requires no custom semantic processing aside from what is automatically provided, add a call to @@ -1919,11 +1915,11 @@ correct minimum number of arguments are passed, etc. If the attribute adds additional warnings, define a ``DiagGroup`` in `include/clang/Basic/DiagnosticGroups.td -`_ +`_ named after the attribute's ``Spelling`` with "_"s replaced by "-"s. If there is only a single diagnostic, it is permissible to use ``InGroup>`` directly in `DiagnosticSemaKinds.td -`_ +`_ All semantic diagnostics generated for your attribute, including automatically- generated ones (such as subjects and argument counts), should have a @@ -2075,7 +2071,7 @@ are similar. exception-handling directly. * Testing is extremely important in IR generation. Use ``clang -cc1 -emit-llvm`` and `FileCheck - `_ to verify that you're + `_ to verify that you're generating the right IR. #. Teach template instantiation how to cope with your AST node, which requires diff --git a/docs/IntroductionToTheClangAST.rst b/docs/IntroductionToTheClangAST.rst index 600a6c884cb9..f357c03507d3 100644 --- a/docs/IntroductionToTheClangAST.rst +++ b/docs/IntroductionToTheClangAST.rst @@ -11,7 +11,7 @@ matchers.
-`Slides `_ +`Slides `_ Introduction ============ @@ -23,7 +23,7 @@ constants are available in an unreduced form in the AST. This makes Clang's AST a good fit for refactoring tools. Documentation for all Clang AST nodes is available via the generated -`Doxygen `_. The doxygen online +`Doxygen `_. The doxygen online documentation is also indexed by your favorite search engine, which will make a search for clang and the AST node's class name usually turn up the doxygen of the class you're looking for (for example, search for: @@ -67,26 +67,26 @@ Let's look at a simple example AST: The toplevel declaration in a translation unit is always the `translation unit -declaration `_. +declaration `_. In this example, our first user written declaration is the `function -declaration `_ +declaration `_ of "``f``". The body of "``f``" is a `compound -statement `_, +statement `_, whose child nodes are a `declaration -statement `_ +statement `_ that declares our result variable, and the `return -statement `_. +statement `_. AST Context =========== All information about the AST for a translation unit is bundled up in the class -`ASTContext `_. +`ASTContext `_. It allows traversal of the whole translation unit starting from -`getTranslationUnitDecl `_, +`getTranslationUnitDecl `_, or to access Clang's `table of -identifiers `_ +identifiers `_ for the parsed translation unit. AST Nodes @@ -95,32 +95,32 @@ AST Nodes Clang's AST nodes are modeled on a class hierarchy that does not have a common ancestor. Instead, there are multiple larger hierarchies for basic node types like -`Decl `_ and -`Stmt `_. Many +`Decl `_ and +`Stmt `_. Many important AST nodes derive from -`Type `_, -`Decl `_, -`DeclContext `_ -or `Stmt `_, with +`Type `_, +`Decl `_, +`DeclContext `_ +or `Stmt `_, with some classes deriving from both Decl and DeclContext. There are also a multitude of nodes in the AST that are not part of a larger hierarchy, and are only reachable from specific other nodes, like -`CXXBaseSpecifier `_. +`CXXBaseSpecifier `_. Thus, to traverse the full AST, one starts from the -`TranslationUnitDecl `_ +`TranslationUnitDecl `_ and then recursively traverses everything that can be reached from that node - this information has to be encoded for each specific node type. This algorithm is encoded in the -`RecursiveASTVisitor `_. +`RecursiveASTVisitor `_. See the `RecursiveASTVisitor -tutorial `_. +tutorial `_. The two most basic nodes in the Clang AST are statements -(`Stmt `_) and +(`Stmt `_) and declarations -(`Decl `_). Note +(`Decl `_). Note that expressions -(`Expr `_) are +(`Expr `_) are also statements in Clang's AST. diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index 1aef265a8589..e155cefb7890 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -112,18 +112,22 @@ of ``cxx_rvalue_references``. ``__has_cpp_attribute`` ----------------------- -This function-like macro takes a single argument that is the name of a -C++11-style attribute. The argument can either be a single identifier, or a -scoped identifier. If the attribute is supported, a nonzero value is returned. -If the attribute is a standards-based attribute, this macro returns a nonzero -value based on the year and month in which the attribute was voted into the -working draft. If the attribute is not supported by the current compliation -target, this macro evaluates to 0. It can be used like this: +This function-like macro is available in C++2a by default, and is provided as an +extension in earlier language standards. It takes a single argument that is the +name of a double-square-bracket-style attribute. The argument can either be a +single identifier or a scoped identifier. If the attribute is supported, a +nonzero value is returned. If the attribute is a standards-based attribute, this +macro returns a nonzero value based on the year and month in which the attribute +was voted into the working draft. See `WG21 SD-6 +`_ +for the list of values returned for standards-based attributes. If the attribute +is not supported by the current compliation target, this macro evaluates to 0. +It can be used like this: .. code-block:: c++ - #ifndef __has_cpp_attribute // Optional of course. - #define __has_cpp_attribute(x) 0 // Compatibility with non-clang compilers. + #ifndef __has_cpp_attribute // For backwards compatibility + #define __has_cpp_attribute(x) 0 #endif ... @@ -134,10 +138,11 @@ target, this macro evaluates to 0. It can be used like this: #endif ... -The attribute identifier (but not scope) can also be specified with a preceding -and following ``__`` (double underscore) to avoid interference from a macro with -the same name. For instance, ``gnu::__const__`` can be used instead of -``gnu::const``. +The attribute scope tokens ``clang`` and ``_Clang`` are interchangeable, as are +the attribute scope tokens ``gnu`` and ``__gnu__``. Attribute tokens in either +of these namespaces can be specified with a preceding and following ``__`` +(double underscore) to avoid interference from a macro with the same name. For +instance, ``gnu::__const__`` can be used instead of ``gnu::const``. ``__has_c_attribute`` --------------------- @@ -162,11 +167,11 @@ current compilation target, this macro evaluates to 0. It can be used like this: #endif ... -The attribute identifier (but not scope) can also be specified with a preceding -and following ``__`` (double underscore) to avoid interference from a macro with -the same name. For instance, ``gnu::__const__`` can be used instead of -``gnu::const``. - +The attribute scope tokens ``clang`` and ``_Clang`` are interchangeable, as are +the attribute scope tokens ``gnu`` and ``__gnu__``. Attribute tokens in either +of these namespaces can be specified with a preceding and following ``__`` +(double underscore) to avoid interference from a macro with the same name. For +instance, ``gnu::__const__`` can be used instead of ``gnu::const``. ``__has_attribute`` ------------------- @@ -590,7 +595,7 @@ which does not provide them. The features which can be tested are listed here. Since Clang 3.4, the C++ SD-6 feature test macros are also supported. These are macros with names of the form ``__cpp_``, and are intended to be a portable way to query the supported features of the compiler. -See `the C++ status page `_ for +See `the C++ status page `_ for information on the version of SD-6 supported by each Clang release, and the macros provided by that revision of the recommendations. @@ -1013,7 +1018,7 @@ Modules Use ``__has_feature(modules)`` to determine if Modules have been enabled. For example, compiling code with ``-fmodules`` enables the use of Modules. -More information could be found `here `_. +More information could be found `here `_. Checks for Type Trait Primitives ================================ @@ -1353,7 +1358,7 @@ In Objective-C, functions and methods are generally assumed to follow the conventions for ownership of object arguments and return values. However, there are exceptions, and so Clang provides attributes to allow these exceptions to be documented. This are used by ARC and the -`static analyzer `_ Some exceptions may be +`static analyzer `_ Some exceptions may be better described using the ``objc_method_family`` attribute instead. **Usage**: The ``ns_returns_retained``, ``ns_returns_not_retained``, @@ -1390,7 +1395,7 @@ method; it specifies that the method expects its ``self`` parameter to have a - (void) baz:(id) __attribute__((ns_consumed)) x; Further examples of these attributes are available in the static analyzer's `list of annotations for analysis -`_. +`_. Query for these features with ``__has_attribute(ns_consumed)``, ``__has_attribute(ns_returns_retained)``, etc. @@ -1411,7 +1416,7 @@ Objective-C methods. If such a check was missed, the program would compile fine, run fine on newer systems, but crash on older systems. As of LLVM 5.0, ``-Wunguarded-availability`` uses the `availability attributes -`_ together +`_ together with the new ``@available()`` keyword to assist with this issue. When a method that's introduced in the OS newer than the target OS is called, a -Wunguarded-availability warning is emitted if that call is not guarded: @@ -1454,7 +1459,7 @@ More than one platform can be listed in ``@available()``: If the caller of ``my_fun()`` already checks that ``my_fun()`` is only called on 10.12, then add an `availability attribute -`_ to it, +`_ to it, which will also suppress the warning and require that calls to my_fun() are checked: @@ -1739,6 +1744,70 @@ The '``__builtin_bitreverse``' family of builtins is used to reverse the bitpattern of an integer value; for example ``0b10110110`` becomes ``0b01101101``. +``__builtin_rotateleft`` +------------------------ + +* ``__builtin_rotateleft8`` +* ``__builtin_rotateleft16`` +* ``__builtin_rotateleft32`` +* ``__builtin_rotateleft64`` + +**Syntax**: + +.. code-block:: c++ + + __builtin_rotateleft32(x, y) + +**Examples**: + +.. code-block:: c++ + + uint8_t rot_x = __builtin_rotateleft8(x, y); + uint16_t rot_x = __builtin_rotateleft16(x, y); + uint32_t rot_x = __builtin_rotateleft32(x, y); + uint64_t rot_x = __builtin_rotateleft64(x, y); + +**Description**: + +The '``__builtin_rotateleft``' family of builtins is used to rotate +the bits in the first argument by the amount in the second argument. +For example, ``0b10000110`` rotated left by 11 becomes ``0b00110100``. +The shift value is treated as an unsigned amount modulo the size of +the arguments. Both arguments and the result have the bitwidth specified +by the name of the builtin. + +``__builtin_rotateright`` +_------------------------ + +* ``__builtin_rotateright8`` +* ``__builtin_rotateright16`` +* ``__builtin_rotateright32`` +* ``__builtin_rotateright64`` + +**Syntax**: + +.. code-block:: c++ + + __builtin_rotateright32(x, y) + +**Examples**: + +.. code-block:: c++ + + uint8_t rot_x = __builtin_rotateright8(x, y); + uint16_t rot_x = __builtin_rotateright16(x, y); + uint32_t rot_x = __builtin_rotateright32(x, y); + uint64_t rot_x = __builtin_rotateright64(x, y); + +**Description**: + +The '``__builtin_rotateright``' family of builtins is used to rotate +the bits in the first argument by the amount in the second argument. +For example, ``0b10000110`` rotated right by 3 becomes ``0b11010000``. +The shift value is treated as an unsigned amount modulo the size of +the arguments. Both arguments and the result have the bitwidth specified +by the name of the builtin. + ``__builtin_unreachable`` ------------------------- @@ -1977,7 +2046,7 @@ Floating point builtins Returns the platform specific canonical encoding of a floating point number. This canonicalization is useful for implementing certain numeric primitives such as frexp. See `LLVM canonicalize intrinsic -`_ for +`_ for more information on the semantics. String builtins @@ -2191,7 +2260,7 @@ standard library to implement `std::experimental::coroutine_handle` type. Other coroutine builtins are either for internal clang use or for use during development of the coroutine feature. See `Coroutines in LLVM -`_ for +`_ for more information on their semantics. Note that builtins matching the intrinsics that take token as the first parameter (llvm.coro.begin, llvm.coro.alloc, llvm.coro.free and llvm.coro.suspend) omit the token parameter and fill it to @@ -2298,9 +2367,9 @@ Extensions for Static Analysis Clang supports additional attributes that are useful for documenting program invariants and rules for static analysis tools, such as the `Clang Static -Analyzer `_. These attributes are documented +Analyzer `_. These attributes are documented in the analyzer's `list of source-level annotations -`_. +`_. Extensions for Dynamic Analysis @@ -2587,17 +2656,19 @@ Specifying an attribute for multiple declarations (#pragma clang attribute) The ``#pragma clang attribute`` directive can be used to apply an attribute to multiple declarations. The ``#pragma clang attribute push`` variation of the -directive pushes a new attribute to the attribute stack. The declarations that -follow the pragma receive the attributes that are on the attribute stack, until -the stack is cleared using a ``#pragma clang attribute pop`` directive. Multiple -push directives can be nested inside each other. +directive pushes a new "scope" of ``#pragma clang attribute`` that attributes +can be added to. The ``#pragma clang attribute (...)`` variation adds an +attribute to that scope, and the ``#pragma clang attribute pop`` variation pops +the scope. You can also use ``#pragma clang attribute push (...)``, which is a +shorthand for when you want to add one attribute to a new scope. Multiple push +directives can be nested inside each other. The attributes that are used in the ``#pragma clang attribute`` directives can be written using the GNU-style syntax: .. code-block:: c++ - #pragma clang attribute push(__attribute__((annotate("custom"))), apply_to = function) + #pragma clang attribute push (__attribute__((annotate("custom"))), apply_to = function) void function(); // The function now has the annotate("custom") attribute @@ -2607,7 +2678,7 @@ The attributes can also be written using the C++11 style syntax: .. code-block:: c++ - #pragma clang attribute push([[noreturn]], apply_to = function) + #pragma clang attribute push ([[noreturn]], apply_to = function) void function(); // The function now has the [[noreturn]] attribute @@ -2617,7 +2688,7 @@ The ``__declspec`` style syntax is also supported: .. code-block:: c++ - #pragma clang attribute push(__declspec(dllexport), apply_to = function) + #pragma clang attribute push (__declspec(dllexport), apply_to = function) void function(); // The function now has the __declspec(dllexport) attribute @@ -2626,6 +2697,38 @@ The ``__declspec`` style syntax is also supported: A single push directive accepts only one attribute regardless of the syntax used. +Because multiple push directives can be nested, if you're writing a macro that +expands to ``_Pragma("clang attribute")`` it's good hygiene (though not +required) to add a namespace to your push/pop directives. A pop directive with a +namespace will pop the innermost push that has that same namespace. This will +ensure that another macro's ``pop`` won't inadvertently pop your attribute. Note +that an ``pop`` without a namespace will pop the innermost ``push`` without a +namespace. ``push``es with a namespace can only be popped by ``pop`` with the +same namespace. For instance: + +.. code-block:: c++ + + #define ASSUME_NORETURN_BEGIN _Pragma("clang attribute AssumeNoreturn.push ([[noreturn]], apply_to = function)") + #define ASSUME_NORETURN_END _Pragma("clang attribute AssumeNoreturn.pop") + + #define ASSUME_UNAVAILABLE_BEGIN _Pragma("clang attribute Unavailable.push (__attribute__((unavailable)), apply_to=function)") + #define ASSUME_UNAVAILABLE_END _Pragma("clang attribute Unavailable.pop") + + + ASSUME_NORETURN_BEGIN + ASSUME_UNAVAILABLE_BEGIN + void function(); // function has [[noreturn]] and __attribute__((unavailable)) + ASSUME_NORETURN_END + void other_function(); // function has __attribute__((unavailable)) + ASSUME_UNAVAILABLE_END + +Without the namespaces on the macros, ``other_function`` will be annotated with +``[[noreturn]]`` instead of ``__attribute__((unavailable))``. This may seem like +a contrived example, but its very possible for this kind of situation to appear +in real code if the pragmas are spread out across a large file. You can test if +your version of clang supports namespaces on ``#pragma clang attribute`` with +``__has_extension(pragma_clang_attribute_namespaces)``. + Subject Match Rules ------------------- diff --git a/docs/LibASTMatchers.rst b/docs/LibASTMatchers.rst index aea9f3233b4b..3b9f0a66db13 100644 --- a/docs/LibASTMatchers.rst +++ b/docs/LibASTMatchers.rst @@ -81,7 +81,7 @@ To that end, matchers that match specific AST nodes (so called node matchers) are bindable; for example, ``recordDecl(hasName("MyClass")).bind("id")`` will bind the matched ``recordDecl`` node to the string "``id``", to be later retrieved in the `match callback -`_. +`_. .. FIXME: Introduce link to ASTMatchersTutorial.html .. FIXME: Introduce link to ASTMatchersCookbook.html @@ -116,7 +116,7 @@ corresponding matcher. There are multiple matcher definition macros that deal with polymorphic return values and different parameter counts. See `ASTMatchersMacros.h -`_. +`_. .. _astmatchers-writing: diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html index cf32a5ce4a0f..2af0a7c9e33d 100644 --- a/docs/LibASTMatchersReference.html +++ b/docs/LibASTMatchersReference.html @@ -100,7 +100,7 @@ recordDecl(decl().bind("id"), hasName("::MyClass")) Return typeNameParameters -Matcher<CXXCtorInitializer>cxxCtorInitializerMatcher<CXXCtorInitializer>... +Matcher<CXXCtorInitializer>cxxCtorInitializerMatcher<CXXCtorInitializer>...
Matches constructor initializers.
 
 Examples matches i(42).
@@ -111,7 +111,7 @@ Examples matches i(42).
 
-Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>... +Matcher<Decl>accessSpecDeclMatcher<AccessSpecDecl>...
Matches C++ access specifier declarations.
 
 Given
@@ -124,7 +124,7 @@ accessSpecDecl()
 
-Matcher<Decl>blockDeclMatcher<BlockDecl>... +Matcher<Decl>blockDeclMatcher<BlockDecl>...
Matches block declarations.
 
 Example matches the declaration of the nameless block printing an input
@@ -136,7 +136,7 @@ integer.
 
-Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>... +Matcher<Decl>classTemplateDeclMatcher<ClassTemplateDecl>...
Matches C++ class template declarations.
 
 Example matches Z
@@ -144,7 +144,24 @@ Example matches Z
 
-Matcher<Decl>classTemplateSpecializationDeclMatcher<ClassTemplateSpecializationDecl>... +Matcher<Decl>classTemplatePartialSpecializationDeclMatcher<ClassTemplatePartialSpecializationDecl>... +
Matches C++ class template partial specializations.
+
+Given
+  template<class T1, class T2, int I>
+  class A {};
+
+  template<class T, int I>
+  class A<T, T*, I> {};
+
+  template<>
+  class A<int, int, 1> {};
+classTemplatePartialSpecializationDecl()
+  matches the specialization A<T,T*,I> but not A<int,int,1>
+
+ + +Matcher<Decl>classTemplateSpecializationDeclMatcher<ClassTemplateSpecializationDecl>...
Matches C++ class template specializations.
 
 Given
@@ -156,7 +173,7 @@ classTemplateSpecializationDecl()
 
-Matcher<Decl>cxxConstructorDeclMatcher<CXXConstructorDecl>... +Matcher<Decl>cxxConstructorDeclMatcher<CXXConstructorDecl>...
Matches C++ constructor declarations.
 
 Example matches Foo::Foo() and Foo::Foo(int)
@@ -169,7 +186,7 @@ Example matches Foo::Foo() and Foo::Foo(int)
 
-Matcher<Decl>cxxConversionDeclMatcher<CXXConversionDecl>... +Matcher<Decl>cxxConversionDeclMatcher<CXXConversionDecl>...
Matches conversion operator declarations.
 
 Example matches the operator.
@@ -177,7 +194,7 @@ Example matches the operator.
 
-Matcher<Decl>cxxDestructorDeclMatcher<CXXDestructorDecl>... +Matcher<Decl>cxxDestructorDeclMatcher<CXXDestructorDecl>...
Matches explicit C++ destructor declarations.
 
 Example matches Foo::~Foo()
@@ -188,7 +205,7 @@ Example matches Foo::~Foo()
 
-Matcher<Decl>cxxMethodDeclMatcher<CXXMethodDecl>... +Matcher<Decl>cxxMethodDeclMatcher<CXXMethodDecl>...
Matches method declarations.
 
 Example matches y
@@ -196,7 +213,7 @@ Example matches y
 
-Matcher<Decl>cxxRecordDeclMatcher<CXXRecordDecl>... +Matcher<Decl>cxxRecordDeclMatcher<CXXRecordDecl>...
Matches C++ class declarations.
 
 Example matches X, Z
@@ -205,7 +222,7 @@ Example matches X, Z
 
-Matcher<Decl>declMatcher<Decl>... +Matcher<Decl>declMatcher<Decl>...
Matches declarations.
 
 Examples matches X, C, and the friend declaration inside C;
@@ -216,7 +233,7 @@ Examples matches X, C, and the friend declaration inside C;
 
-Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>... +Matcher<Decl>declaratorDeclMatcher<DeclaratorDecl>...
Matches declarator declarations (field, variable, function
 and non-type template parameter declarations).
 
@@ -227,7 +244,7 @@ declaratorDecl()
 
-Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>... +Matcher<Decl>enumConstantDeclMatcher<EnumConstantDecl>...
Matches enum constants.
 
 Example matches A, B, C
@@ -237,7 +254,7 @@ Example matches A, B, C
 
-Matcher<Decl>enumDeclMatcher<EnumDecl>... +Matcher<Decl>enumDeclMatcher<EnumDecl>...
Matches enum declarations.
 
 Example matches X
@@ -247,7 +264,7 @@ Example matches X
 
-Matcher<Decl>fieldDeclMatcher<FieldDecl>... +Matcher<Decl>fieldDeclMatcher<FieldDecl>...
Matches field declarations.
 
 Given
@@ -257,7 +274,7 @@ fieldDecl()
 
-Matcher<Decl>friendDeclMatcher<FriendDecl>... +Matcher<Decl>friendDeclMatcher<FriendDecl>...
Matches friend declarations.
 
 Given
@@ -267,7 +284,7 @@ friendDecl()
 
-Matcher<Decl>functionDeclMatcher<FunctionDecl>... +Matcher<Decl>functionDeclMatcher<FunctionDecl>...
Matches function declarations.
 
 Example matches f
@@ -275,7 +292,7 @@ Example matches f
 
-Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>... +Matcher<Decl>functionTemplateDeclMatcher<FunctionTemplateDecl>...
Matches C++ function template declarations.
 
 Example matches f
@@ -283,7 +300,17 @@ Example matches f
 
-Matcher<Decl>labelDeclMatcher<LabelDecl>... +Matcher<Decl>indirectFieldDeclMatcher<IndirectFieldDecl>... +
Matches indirect field declarations.
+
+Given
+  struct X { struct { int a; }; };
+indirectFieldDecl()
+  matches 'a'.
+
+ + +Matcher<Decl>labelDeclMatcher<LabelDecl>...
Matches a declaration of label.
 
 Given
@@ -294,7 +321,7 @@ labelDecl()
 
-Matcher<Decl>linkageSpecDeclMatcher<LinkageSpecDecl>... +Matcher<Decl>linkageSpecDeclMatcher<LinkageSpecDecl>...
Matches a declaration of a linkage specification.
 
 Given
@@ -304,7 +331,7 @@ linkageSpecDecl()
 
-Matcher<Decl>namedDeclMatcher<NamedDecl>... +Matcher<Decl>namedDeclMatcher<NamedDecl>...
Matches a declaration of anything that could have a name.
 
 Example matches X, S, the anonymous union type, i, and U;
@@ -317,7 +344,7 @@ Example matches X, S, the anonymous union type, i, and U;
 
-Matcher<Decl>namespaceAliasDeclMatcher<NamespaceAliasDecl>... +Matcher<Decl>namespaceAliasDeclMatcher<NamespaceAliasDecl>...
Matches a declaration of a namespace alias.
 
 Given
@@ -328,7 +355,7 @@ namespaceAliasDecl()
 
-Matcher<Decl>namespaceDeclMatcher<NamespaceDecl>... +Matcher<Decl>namespaceDeclMatcher<NamespaceDecl>...
Matches a declaration of a namespace.
 
 Given
@@ -339,7 +366,7 @@ namespaceDecl()
 
-Matcher<Decl>nonTypeTemplateParmDeclMatcher<NonTypeTemplateParmDecl>... +Matcher<Decl>nonTypeTemplateParmDeclMatcher<NonTypeTemplateParmDecl>...
Matches non-type template parameter declarations.
 
 Given
@@ -349,7 +376,7 @@ nonTypeTemplateParmDecl()
 
-Matcher<Decl>objcCategoryDeclMatcher<ObjCCategoryDecl>... +Matcher<Decl>objcCategoryDeclMatcher<ObjCCategoryDecl>...
Matches Objective-C category declarations.
 
 Example matches Foo (Additions)
@@ -358,7 +385,7 @@ Example matches Foo (Additions)
 
-Matcher<Decl>objcCategoryImplDeclMatcher<ObjCCategoryImplDecl>... +Matcher<Decl>objcCategoryImplDeclMatcher<ObjCCategoryImplDecl>...
Matches Objective-C category definitions.
 
 Example matches Foo (Additions)
@@ -367,7 +394,7 @@ Example matches Foo (Additions)
 
-Matcher<Decl>objcImplementationDeclMatcher<ObjCImplementationDecl>... +Matcher<Decl>objcImplementationDeclMatcher<ObjCImplementationDecl>...
Matches Objective-C implementation declarations.
 
 Example matches Foo
@@ -376,7 +403,7 @@ Example matches Foo
 
-Matcher<Decl>objcInterfaceDeclMatcher<ObjCInterfaceDecl>... +Matcher<Decl>objcInterfaceDeclMatcher<ObjCInterfaceDecl>...
Matches Objective-C interface declarations.
 
 Example matches Foo
@@ -385,7 +412,7 @@ Example matches Foo
 
-Matcher<Decl>objcIvarDeclMatcher<ObjCIvarDecl>... +Matcher<Decl>objcIvarDeclMatcher<ObjCIvarDecl>...
Matches Objective-C instance variable declarations.
 
 Example matches _enabled
@@ -396,7 +423,7 @@ Example matches _enabled
 
-Matcher<Decl>objcMethodDeclMatcher<ObjCMethodDecl>... +Matcher<Decl>objcMethodDeclMatcher<ObjCMethodDecl>...
Matches Objective-C method declarations.
 
 Example matches both declaration and definition of -[Foo method]
@@ -410,7 +437,7 @@ Example matches both declaration and definition of -[Foo method]
 
-Matcher<Decl>objcPropertyDeclMatcher<ObjCPropertyDecl>... +Matcher<Decl>objcPropertyDeclMatcher<ObjCPropertyDecl>...
Matches Objective-C property declarations.
 
 Example matches enabled
@@ -420,7 +447,7 @@ Example matches enabled
 
-Matcher<Decl>objcProtocolDeclMatcher<ObjCProtocolDecl>... +Matcher<Decl>objcProtocolDeclMatcher<ObjCProtocolDecl>...
Matches Objective-C protocol declarations.
 
 Example matches FooDelegate
@@ -429,7 +456,7 @@ Example matches FooDelegate
 
-Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>... +Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>...
Matches parameter variable declarations.
 
 Given
@@ -439,7 +466,7 @@ parmVarDecl()
 
-Matcher<Decl>recordDeclMatcher<RecordDecl>... +Matcher<Decl>recordDeclMatcher<RecordDecl>...
Matches class, struct, and union declarations.
 
 Example matches X, Z, U, and S
@@ -450,7 +477,7 @@ Example matches X, Z, U, and S
 
-Matcher<Decl>staticAssertDeclMatcher<StaticAssertDecl>... +Matcher<Decl>staticAssertDeclMatcher<StaticAssertDecl>...
Matches a C++ static_assert declaration.
 
 Example:
@@ -465,7 +492,7 @@ in
 
-Matcher<Decl>templateTypeParmDeclMatcher<TemplateTypeParmDecl>... +Matcher<Decl>templateTypeParmDeclMatcher<TemplateTypeParmDecl>...
Matches template type parameter declarations.
 
 Given
@@ -475,20 +502,20 @@ templateTypeParmDecl()
 
-Matcher<Decl>translationUnitDeclMatcher<TranslationUnitDecl>... +Matcher<Decl>translationUnitDeclMatcher<TranslationUnitDecl>...
Matches the top declaration context.
 
 Given
   int X;
   namespace NS {
   int Y;
-  }  namespace NS
+  }  // namespace NS
 decl(hasDeclContext(translationUnitDecl()))
   matches "int X", but not "int Y".
 
-Matcher<Decl>typeAliasDeclMatcher<TypeAliasDecl>... +Matcher<Decl>typeAliasDeclMatcher<TypeAliasDecl>...
Matches type alias declarations.
 
 Given
@@ -499,7 +526,7 @@ typeAliasDecl()
 
-Matcher<Decl>typeAliasTemplateDeclMatcher<TypeAliasTemplateDecl>... +Matcher<Decl>typeAliasTemplateDeclMatcher<TypeAliasTemplateDecl>...
Matches type alias template declarations.
 
 typeAliasTemplateDecl() matches
@@ -508,7 +535,7 @@ typeAliasTemplateDecl() matches
 
-Matcher<Decl>typedefDeclMatcher<TypedefDecl>... +Matcher<Decl>typedefDeclMatcher<TypedefDecl>...
Matches typedef declarations.
 
 Given
@@ -519,7 +546,7 @@ typedefDecl()
 
-Matcher<Decl>typedefNameDeclMatcher<TypedefNameDecl>... +Matcher<Decl>typedefNameDeclMatcher<TypedefNameDecl>...
Matches typedef name declarations.
 
 Given
@@ -530,7 +557,7 @@ typedefNameDecl()
 
-Matcher<Decl>unresolvedUsingTypenameDeclMatcher<UnresolvedUsingTypenameDecl>... +Matcher<Decl>unresolvedUsingTypenameDeclMatcher<UnresolvedUsingTypenameDecl>...
Matches unresolved using value declarations that involve the
 typename.
 
@@ -546,7 +573,7 @@ unresolvedUsingTypenameDecl()
   matches using Base<T>::Foo 
-Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>... +Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.
 
 Given
@@ -558,7 +585,7 @@ unresolvedUsingValueDecl()
   matches using X::x 
-Matcher<Decl>usingDeclMatcher<UsingDecl>... +Matcher<Decl>usingDeclMatcher<UsingDecl>...
Matches using declarations.
 
 Given
@@ -568,7 +595,7 @@ usingDecl()
   matches using X::x 
-Matcher<Decl>usingDirectiveDeclMatcher<UsingDirectiveDecl>... +Matcher<Decl>usingDirectiveDeclMatcher<UsingDirectiveDecl>...
Matches using namespace declarations.
 
 Given
@@ -578,7 +605,7 @@ usingDirectiveDecl()
   matches using namespace X 
-Matcher<Decl>valueDeclMatcher<ValueDecl>... +Matcher<Decl>valueDeclMatcher<ValueDecl>...
Matches any value declaration.
 
 Example matches A, B, C and F
@@ -587,7 +614,7 @@ Example matches A, B, C and F
 
-Matcher<Decl>varDeclMatcher<VarDecl>... +Matcher<Decl>varDeclMatcher<VarDecl>...
Matches variable declarations.
 
 Note: this does not match declarations of member variables, which are
@@ -598,12 +625,12 @@ Example matches a
 
-Matcher<NestedNameSpecifierLoc>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>... +Matcher<NestedNameSpecifierLoc>nestedNameSpecifierLocMatcher<NestedNameSpecifierLoc>...
Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
 
-Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<NestedNameSpecifier>... +Matcher<NestedNameSpecifier>nestedNameSpecifierMatcher<NestedNameSpecifier>...
Matches nested name specifiers.
 
 Given
@@ -618,12 +645,12 @@ nestedNameSpecifier()
 
-Matcher<QualType>qualTypeMatcher<QualType>... +Matcher<QualType>qualTypeMatcher<QualType>...
Matches QualTypes in the clang AST.
 
-Matcher<Stmt>addrLabelExprMatcher<AddrLabelExpr>... +Matcher<Stmt>addrLabelExprMatcher<AddrLabelExpr>...
Matches address of label statements (GNU extension).
 
 Given
@@ -635,7 +662,7 @@ addrLabelExpr()
 
-Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>... +Matcher<Stmt>arraySubscriptExprMatcher<ArraySubscriptExpr>...
Matches array subscript expressions.
 
 Given
@@ -645,7 +672,7 @@ arraySubscriptExpr()
 
-Matcher<Stmt>asmStmtMatcher<AsmStmt>... +Matcher<Stmt>asmStmtMatcher<AsmStmt>...
Matches asm statements.
 
  int i = 100;
@@ -655,14 +682,14 @@ asmStmt()
 
-Matcher<Stmt>atomicExprMatcher<AtomicExpr>... +Matcher<Stmt>atomicExprMatcher<AtomicExpr>...
Matches atomic builtins.
 Example matches __atomic_load_n(ptr, 1)
   void foo() { int *ptr; __atomic_load_n(ptr, 1); }
 
-Matcher<Stmt>autoreleasePoolStmtMatcher<ObjCAutoreleasePoolStmt>... +Matcher<Stmt>autoreleasePoolStmtMatcher<ObjCAutoreleasePoolStmt>...
Matches an Objective-C autorelease pool statement.
 
 Given
@@ -674,7 +701,7 @@ inside the autorelease pool.
 
-Matcher<Stmt>binaryConditionalOperatorMatcher<BinaryConditionalOperator>... +Matcher<Stmt>binaryConditionalOperatorMatcher<BinaryConditionalOperator>...
Matches binary conditional operator expressions (GNU extension).
 
 Example matches a ?: b
@@ -682,7 +709,7 @@ Example matches a ?: b
 
-Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>... +Matcher<Stmt>binaryOperatorMatcher<BinaryOperator>...
Matches binary operator expressions.
 
 Example matches a || b
@@ -690,7 +717,15 @@ Example matches a || b
 
-Matcher<Stmt>breakStmtMatcher<BreakStmt>... +Matcher<Stmt>blockExprMatcher<BlockExpr>... +
Matches a reference to a block.
+
+Example: matches "^{}":
+  void f() { ^{}(); }
+
+ + +Matcher<Stmt>breakStmtMatcher<BreakStmt>...
Matches break statements.
 
 Given
@@ -700,7 +735,7 @@ breakStmt()
 
-Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>... +Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>...
Matches a C-style cast expression.
 
 Example: Matches (int) 2.2f in
@@ -708,7 +743,7 @@ Example: Matches (int) 2.2f in
 
-Matcher<Stmt>callExprMatcher<CallExpr>... +Matcher<Stmt>callExprMatcher<CallExpr>...
Matches call expressions.
 
 Example matches x.y() and y()
@@ -718,7 +753,7 @@ Example matches x.y() and y()
 
-Matcher<Stmt>caseStmtMatcher<CaseStmt>... +Matcher<Stmt>caseStmtMatcher<CaseStmt>...
Matches case statements inside switch statements.
 
 Given
@@ -728,7 +763,7 @@ caseStmt()
 
-Matcher<Stmt>castExprMatcher<CastExpr>... +Matcher<Stmt>castExprMatcher<CastExpr>...
Matches any cast nodes of Clang's AST.
 
 Example: castExpr() matches each of the following:
@@ -741,7 +776,7 @@ but does not match
 
-Matcher<Stmt>characterLiteralMatcher<CharacterLiteral>... +Matcher<Stmt>characterLiteralMatcher<CharacterLiteral>...
Matches character literals (also matches wchar_t).
 
 Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
@@ -753,7 +788,7 @@ Example matches 'a', L'a'
 
-Matcher<Stmt>compoundLiteralExprMatcher<CompoundLiteralExpr>... +Matcher<Stmt>compoundLiteralExprMatcher<CompoundLiteralExpr>...
Matches compound (i.e. non-scalar) literals
 
 Example match: {1}, (1, 2)
@@ -762,7 +797,7 @@ Example match: {1}, (1, 2)
 
-Matcher<Stmt>compoundStmtMatcher<CompoundStmt>... +Matcher<Stmt>compoundStmtMatcher<CompoundStmt>...
Matches compound statements.
 
 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
@@ -770,7 +805,7 @@ Example matches '{}' and '{{}}' in 'for (;;) {{}}'
 
-Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>... +Matcher<Stmt>conditionalOperatorMatcher<ConditionalOperator>...
Matches conditional operator expressions.
 
 Example matches a ? b : c
@@ -778,7 +813,18 @@ Example matches a ? b : c
 
-Matcher<Stmt>continueStmtMatcher<ContinueStmt>... +Matcher<Stmt>constantExprMatcher<ConstantExpr>... +
Matches a constant expression wrapper.
+
+Example matches the constant in the case statement:
+    (matcher = constantExpr())
+  switch (a) {
+  case 37: break;
+  }
+
+ + +Matcher<Stmt>continueStmtMatcher<ContinueStmt>...
Matches continue statements.
 
 Given
@@ -788,7 +834,7 @@ continueStmt()
 
-Matcher<Stmt>cudaKernelCallExprMatcher<CUDAKernelCallExpr>... +Matcher<Stmt>cudaKernelCallExprMatcher<CUDAKernelCallExpr>...
Matches CUDA kernel call expression.
 
 Example matches,
@@ -796,7 +842,7 @@ Example matches,
 
-Matcher<Stmt>cxxBindTemporaryExprMatcher<CXXBindTemporaryExpr>... +Matcher<Stmt>cxxBindTemporaryExprMatcher<CXXBindTemporaryExpr>...
Matches nodes where temporaries are created.
 
 Example matches FunctionTakesString(GetStringByValue())
@@ -806,7 +852,7 @@ Example matches FunctionTakesString(GetStringByValue())
 
-Matcher<Stmt>cxxBoolLiteralMatcher<CXXBoolLiteralExpr>... +Matcher<Stmt>cxxBoolLiteralMatcher<CXXBoolLiteralExpr>...
Matches bool literals.
 
 Example matches true
@@ -814,7 +860,7 @@ Example matches true
 
-Matcher<Stmt>cxxCatchStmtMatcher<CXXCatchStmt>... +Matcher<Stmt>cxxCatchStmtMatcher<CXXCatchStmt>...
Matches catch statements.
 
   try {} catch(int i) {}
@@ -823,7 +869,7 @@ cxxCatchStmt()
 
-Matcher<Stmt>cxxConstCastExprMatcher<CXXConstCastExpr>... +Matcher<Stmt>cxxConstCastExprMatcher<CXXConstCastExpr>...
Matches a const_cast expression.
 
 Example: Matches const_cast<int*>(&r) in
@@ -833,7 +879,7 @@ Example: Matches const_cast<int*>(&r) in
 
-Matcher<Stmt>cxxConstructExprMatcher<CXXConstructExpr>... +Matcher<Stmt>cxxConstructExprMatcher<CXXConstructExpr>...
Matches constructor call expressions (including implicit ones).
 
 Example matches string(ptr, n) and ptr within arguments of f
@@ -845,7 +891,7 @@ Example matches string(ptr, n) and ptr within arguments of f
 
-Matcher<Stmt>cxxDefaultArgExprMatcher<CXXDefaultArgExpr>... +Matcher<Stmt>cxxDefaultArgExprMatcher<CXXDefaultArgExpr>...
Matches the value of a default argument at the call site.
 
 Example matches the CXXDefaultArgExpr placeholder inserted for the
@@ -856,7 +902,7 @@ Example matches the CXXDefaultArgExpr placeholder inserted for the
 
-Matcher<Stmt>cxxDeleteExprMatcher<CXXDeleteExpr>... +Matcher<Stmt>cxxDeleteExprMatcher<CXXDeleteExpr>...
Matches delete expressions.
 
 Given
@@ -866,7 +912,18 @@ cxxDeleteExpr()
 
-Matcher<Stmt>cxxDynamicCastExprMatcher<CXXDynamicCastExpr>... +Matcher<Stmt>cxxDependentScopeMemberExprMatcher<CXXDependentScopeMemberExpr>... +
Matches member expressions where the actual member referenced could not be
+resolved because the base expression or the member name was dependent.
+
+Given
+  template <class T> void f() { T t; t.g(); }
+cxxDependentScopeMemberExpr()
+  matches t.g
+
+ + +Matcher<Stmt>cxxDynamicCastExprMatcher<CXXDynamicCastExpr>...
Matches a dynamic_cast expression.
 
 Example:
@@ -880,7 +937,7 @@ in
 
-Matcher<Stmt>cxxForRangeStmtMatcher<CXXForRangeStmt>... +Matcher<Stmt>cxxForRangeStmtMatcher<CXXForRangeStmt>...
Matches range-based for statements.
 
 cxxForRangeStmt() matches 'for (auto a : i)'
@@ -889,7 +946,7 @@ cxxForRangeStmt() matches 'for (auto a : i)'
 
-Matcher<Stmt>cxxFunctionalCastExprMatcher<CXXFunctionalCastExpr>... +Matcher<Stmt>cxxFunctionalCastExprMatcher<CXXFunctionalCastExpr>...
Matches functional cast expressions
 
 Example: Matches Foo(bar);
@@ -899,7 +956,7 @@ Example: Matches Foo(bar);
 
-Matcher<Stmt>cxxMemberCallExprMatcher<CXXMemberCallExpr>... +Matcher<Stmt>cxxMemberCallExprMatcher<CXXMemberCallExpr>...
Matches member call expressions.
 
 Example matches x.y()
@@ -908,7 +965,7 @@ Example matches x.y()
 
-Matcher<Stmt>cxxNewExprMatcher<CXXNewExpr>... +Matcher<Stmt>cxxNewExprMatcher<CXXNewExpr>...
Matches new expressions.
 
 Given
@@ -918,12 +975,12 @@ cxxNewExpr()
 
-Matcher<Stmt>cxxNullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>... +Matcher<Stmt>cxxNullPtrLiteralExprMatcher<CXXNullPtrLiteralExpr>...
Matches nullptr literal.
 
-Matcher<Stmt>cxxOperatorCallExprMatcher<CXXOperatorCallExpr>... +Matcher<Stmt>cxxOperatorCallExprMatcher<CXXOperatorCallExpr>...
Matches overloaded operator calls.
 
 Note that if an operator isn't overloaded, it won't match. Instead, use
@@ -939,7 +996,7 @@ Example matches both operator<<((o << b), c) and operator<<(o,
 
-Matcher<Stmt>cxxReinterpretCastExprMatcher<CXXReinterpretCastExpr>... +Matcher<Stmt>cxxReinterpretCastExprMatcher<CXXReinterpretCastExpr>...
Matches a reinterpret_cast expression.
 
 Either the source expression or the destination type can be matched
@@ -951,7 +1008,7 @@ Example matches reinterpret_cast<char*>(&p) in
 
-Matcher<Stmt>cxxStaticCastExprMatcher<CXXStaticCastExpr>... +Matcher<Stmt>cxxStaticCastExprMatcher<CXXStaticCastExpr>...
Matches a C++ static_cast expression.
 
 See also: hasDestinationType
@@ -966,7 +1023,7 @@ in
 
-Matcher<Stmt>cxxStdInitializerListExprMatcher<CXXStdInitializerListExpr>... +Matcher<Stmt>cxxStdInitializerListExprMatcher<CXXStdInitializerListExpr>...
Matches C++ initializer list expressions.
 
 Given
@@ -979,7 +1036,7 @@ cxxStdInitializerListExpr()
 
-Matcher<Stmt>cxxTemporaryObjectExprMatcher<CXXTemporaryObjectExpr>... +Matcher<Stmt>cxxTemporaryObjectExprMatcher<CXXTemporaryObjectExpr>...
Matches functional cast expressions having N != 1 arguments
 
 Example: Matches Foo(bar, bar)
@@ -987,7 +1044,7 @@ Example: Matches Foo(bar, bar)
 
-Matcher<Stmt>cxxThisExprMatcher<CXXThisExpr>... +Matcher<Stmt>cxxThisExprMatcher<CXXThisExpr>...
Matches implicit and explicit this expressions.
 
 Example matches the implicit this expression in "return i".
@@ -999,7 +1056,7 @@ struct foo {
 
-Matcher<Stmt>cxxThrowExprMatcher<CXXThrowExpr>... +Matcher<Stmt>cxxThrowExprMatcher<CXXThrowExpr>...
Matches throw expressions.
 
   try { throw 5; } catch(int i) {}
@@ -1008,7 +1065,7 @@ cxxThrowExpr()
 
-Matcher<Stmt>cxxTryStmtMatcher<CXXTryStmt>... +Matcher<Stmt>cxxTryStmtMatcher<CXXTryStmt>...
Matches try statements.
 
   try {} catch(int i) {}
@@ -1017,7 +1074,7 @@ cxxTryStmt()
 
-Matcher<Stmt>cxxUnresolvedConstructExprMatcher<CXXUnresolvedConstructExpr>... +Matcher<Stmt>cxxUnresolvedConstructExprMatcher<CXXUnresolvedConstructExpr>...
Matches unresolved constructor call expressions.
 
 Example matches T(t) in return statement of f
@@ -1027,7 +1084,7 @@ Example matches T(t) in return statement of f
 
-Matcher<Stmt>declRefExprMatcher<DeclRefExpr>... +Matcher<Stmt>declRefExprMatcher<DeclRefExpr>...
Matches expressions that refer to declarations.
 
 Example matches x in if (x)
@@ -1036,7 +1093,7 @@ Example matches x in if (x)
 
-Matcher<Stmt>declStmtMatcher<DeclStmt>... +Matcher<Stmt>declStmtMatcher<DeclStmt>...
Matches declaration statements.
 
 Given
@@ -1046,7 +1103,7 @@ declStmt()
 
-Matcher<Stmt>defaultStmtMatcher<DefaultStmt>... +Matcher<Stmt>defaultStmtMatcher<DefaultStmt>...
Matches default statements inside switch statements.
 
 Given
@@ -1056,7 +1113,7 @@ defaultStmt()
 
-Matcher<Stmt>designatedInitExprMatcher<DesignatedInitExpr>... +Matcher<Stmt>designatedInitExprMatcher<DesignatedInitExpr>...
Matches C99 designated initializer expressions [C99 6.7.8].
 
 Example: Matches { [2].y = 1.0, [0].x = 1.0 }
@@ -1064,7 +1121,7 @@ Example: Matches { [2].y = 1.0, [0].x = 1.0 }
 
-Matcher<Stmt>doStmtMatcher<DoStmt>... +Matcher<Stmt>doStmtMatcher<DoStmt>...
Matches do statements.
 
 Given
@@ -1074,7 +1131,7 @@ doStmt()
 
-Matcher<Stmt>explicitCastExprMatcher<ExplicitCastExpr>... +Matcher<Stmt>explicitCastExprMatcher<ExplicitCastExpr>...
Matches explicit cast expressions.
 
 Matches any cast expression written in user code, whether it be a
@@ -1095,7 +1152,7 @@ but does not match the implicit conversion in
 
-Matcher<Stmt>exprMatcher<Expr>... +Matcher<Stmt>exprMatcher<Expr>...
Matches expressions.
 
 Example matches x()
@@ -1103,7 +1160,7 @@ Example matches x()
 
-Matcher<Stmt>exprWithCleanupsMatcher<ExprWithCleanups>... +Matcher<Stmt>exprWithCleanupsMatcher<ExprWithCleanups>...
Matches expressions that introduce cleanups to be run at the end
 of the sub-expression's evaluation.
 
@@ -1112,8 +1169,8 @@ Example matches std::string()
 
-Matcher<Stmt>floatLiteralMatcher<FloatingLiteral>... -
Matches float literals of all sizes encodings, e.g.
+Matcher<Stmt>floatLiteralMatcher<FloatingLiteral>...
+
Matches float literals of all sizes / encodings, e.g.
 1.0, 1.0f, 1.0L and 1e10.
 
 Does not match implicit conversions such as
@@ -1121,7 +1178,7 @@ Does not match implicit conversions such as
 
-Matcher<Stmt>forStmtMatcher<ForStmt>... +Matcher<Stmt>forStmtMatcher<ForStmt>...
Matches for statements.
 
 Example matches 'for (;;) {}'
@@ -1130,12 +1187,12 @@ Example matches 'for (;;) {}'
 
-Matcher<Stmt>gnuNullExprMatcher<GNUNullExpr>... +Matcher<Stmt>gnuNullExprMatcher<GNUNullExpr>...
Matches GNU __null expression.
 
-Matcher<Stmt>gotoStmtMatcher<GotoStmt>... +Matcher<Stmt>gotoStmtMatcher<GotoStmt>...
Matches goto statements.
 
 Given
@@ -1146,7 +1203,7 @@ gotoStmt()
 
-Matcher<Stmt>ifStmtMatcher<IfStmt>... +Matcher<Stmt>ifStmtMatcher<IfStmt>...
Matches if statements.
 
 Example matches 'if (x) {}'
@@ -1154,7 +1211,13 @@ Example matches 'if (x) {}'
 
-Matcher<Stmt>implicitCastExprMatcher<ImplicitCastExpr>... +Matcher<Stmt>imaginaryLiteralMatcher<ImaginaryLiteral>... +
Matches imaginary literals, which are based on integer and floating
+point literals e.g.: 1i, 1.0i
+
+ + +Matcher<Stmt>implicitCastExprMatcher<ImplicitCastExpr>...
Matches the implicit cast nodes of Clang's AST.
 
 This matches many different places, including function call return value
@@ -1162,7 +1225,7 @@ eliding, as well as any type conversions.
 
-Matcher<Stmt>implicitValueInitExprMatcher<ImplicitValueInitExpr>... +Matcher<Stmt>implicitValueInitExprMatcher<ImplicitValueInitExpr>...
Matches implicit initializers of init list expressions.
 
 Given
@@ -1172,7 +1235,7 @@ implicitValueInitExpr()
 
-Matcher<Stmt>initListExprMatcher<InitListExpr>... +Matcher<Stmt>initListExprMatcher<InitListExpr>...
Matches init list expressions.
 
 Given
@@ -1184,15 +1247,15 @@ initListExpr()
 
-Matcher<Stmt>integerLiteralMatcher<IntegerLiteral>... -
Matches integer literals of all sizes encodings, e.g.
+Matcher<Stmt>integerLiteralMatcher<IntegerLiteral>...
+
Matches integer literals of all sizes / encodings, e.g.
 1, 1L, 0x1 and 1U.
 
 Does not match character-encoded integers such as L'a'.
 
-Matcher<Stmt>labelStmtMatcher<LabelStmt>... +Matcher<Stmt>labelStmtMatcher<LabelStmt>...
Matches label statements.
 
 Given
@@ -1203,7 +1266,7 @@ labelStmt()
 
-Matcher<Stmt>lambdaExprMatcher<LambdaExpr>... +Matcher<Stmt>lambdaExprMatcher<LambdaExpr>...
Matches lambda expressions.
 
 Example matches [&](){return 5;}
@@ -1211,7 +1274,7 @@ Example matches [&](){return 5;}
 
-Matcher<Stmt>materializeTemporaryExprMatcher<MaterializeTemporaryExpr>... +Matcher<Stmt>materializeTemporaryExprMatcher<MaterializeTemporaryExpr>...
Matches nodes where temporaries are materialized.
 
 Example: Given
@@ -1227,7 +1290,7 @@ but does not match
 
-Matcher<Stmt>memberExprMatcher<MemberExpr>... +Matcher<Stmt>memberExprMatcher<MemberExpr>...
Matches member expressions.
 
 Given
@@ -1240,7 +1303,7 @@ memberExpr()
 
-Matcher<Stmt>nullStmtMatcher<NullStmt>... +Matcher<Stmt>nullStmtMatcher<NullStmt>...
Matches null statements.
 
   foo();;
@@ -1249,7 +1312,7 @@ nullStmt()
 
-Matcher<Stmt>objcCatchStmtMatcher<ObjCAtCatchStmt>... +Matcher<Stmt>objcCatchStmtMatcher<ObjCAtCatchStmt>...
Matches Objective-C @catch statements.
 
 Example matches @catch
@@ -1258,7 +1321,7 @@ Example matches @catch
 
-Matcher<Stmt>objcFinallyStmtMatcher<ObjCAtFinallyStmt>... +Matcher<Stmt>objcFinallyStmtMatcher<ObjCAtFinallyStmt>...
Matches Objective-C @finally statements.
 
 Example matches @finally
@@ -1267,7 +1330,7 @@ Example matches @finally
 
-Matcher<Stmt>objcIvarRefExprMatcher<ObjCIvarRefExpr>... +Matcher<Stmt>objcIvarRefExprMatcher<ObjCIvarRefExpr>...
Matches a reference to an ObjCIvar.
 
 Example: matches "a" in "init" method:
@@ -1277,11 +1340,10 @@ Example: matches "a" in "init" method:
 - (void) init {
   a = @"hello";
 }
-}
 
-Matcher<Stmt>objcMessageExprMatcher<ObjCMessageExpr>... +Matcher<Stmt>objcMessageExprMatcher<ObjCMessageExpr>...
Matches ObjectiveC Message invocation expressions.
 
 The innermost message send invokes the "alloc" class method on the
@@ -1292,14 +1354,14 @@ NSString's "alloc". This matcher should match both message sends.
 
-Matcher<Stmt>objcThrowStmtMatcher<ObjCAtThrowStmt>... +Matcher<Stmt>objcThrowStmtMatcher<ObjCAtThrowStmt>...
Matches Objective-C statements.
 
 Example matches @throw obj;
 
-Matcher<Stmt>objcTryStmtMatcher<ObjCAtTryStmt>... +Matcher<Stmt>objcTryStmtMatcher<ObjCAtTryStmt>...
Matches Objective-C @try statements.
 
 Example matches @try
@@ -1308,7 +1370,7 @@ Example matches @try
 
-Matcher<Stmt>opaqueValueExprMatcher<OpaqueValueExpr>... +Matcher<Stmt>opaqueValueExprMatcher<OpaqueValueExpr>...
Matches opaque value expressions. They are used as helpers
 to reference another expressions and can be met
 in BinaryConditionalOperators, for example.
@@ -1318,7 +1380,7 @@ Example matches 'a'
 
-Matcher<Stmt>parenExprMatcher<ParenExpr>... +Matcher<Stmt>parenExprMatcher<ParenExpr>...
Matches parentheses used in expressions.
 
 Example matches (foo() + 1)
@@ -1327,7 +1389,7 @@ Example matches (foo() + 1)
 
-Matcher<Stmt>parenListExprMatcher<ParenListExpr>... +Matcher<Stmt>parenListExprMatcher<ParenListExpr>...
Matches paren list expressions.
 ParenListExprs don't have a predefined type and are used for late parsing.
 In the final AST, they can be met in template declarations.
@@ -1344,7 +1406,7 @@ has a predefined type and is a ParenExpr, not a ParenListExpr.
 
-Matcher<Stmt>predefinedExprMatcher<PredefinedExpr>... +Matcher<Stmt>predefinedExprMatcher<PredefinedExpr>...
Matches predefined identifier expressions [C99 6.4.2.2].
 
 Example: Matches __func__
@@ -1352,7 +1414,7 @@ Example: Matches __func__
 
-Matcher<Stmt>returnStmtMatcher<ReturnStmt>... +Matcher<Stmt>returnStmtMatcher<ReturnStmt>...
Matches return statements.
 
 Given
@@ -1362,7 +1424,7 @@ returnStmt()
 
-Matcher<Stmt>stmtMatcher<Stmt>... +Matcher<Stmt>stmtMatcher<Stmt>...
Matches statements.
 
 Given
@@ -1372,7 +1434,7 @@ stmt()
 
-Matcher<Stmt>stmtExprMatcher<StmtExpr>... +Matcher<Stmt>stmtExprMatcher<StmtExpr>...
Matches statement expression (GNU extension).
 
 Example match: ({ int X = 4; X; })
@@ -1380,7 +1442,7 @@ Example match: ({ int X = 4; X; })
 
-Matcher<Stmt>stringLiteralMatcher<StringLiteral>... +Matcher<Stmt>stringLiteralMatcher<StringLiteral>...
Matches string literals (also matches wide string literals).
 
 Example matches "abcd", L"abcd"
@@ -1389,7 +1451,7 @@ Example matches "abcd", L"abcd"
 
-Matcher<Stmt>substNonTypeTemplateParmExprMatcher<SubstNonTypeTemplateParmExpr>... +Matcher<Stmt>substNonTypeTemplateParmExprMatcher<SubstNonTypeTemplateParmExpr>...
Matches substitutions of non-type template parameters.
 
 Given
@@ -1401,7 +1463,7 @@ substNonTypeTemplateParmExpr()
 
-Matcher<Stmt>switchCaseMatcher<SwitchCase>... +Matcher<Stmt>switchCaseMatcher<SwitchCase>...
Matches case and default statements inside switch statements.
 
 Given
@@ -1411,7 +1473,7 @@ switchCase()
 
-Matcher<Stmt>switchStmtMatcher<SwitchStmt>... +Matcher<Stmt>switchStmtMatcher<SwitchStmt>...
Matches switch statements.
 
 Given
@@ -1421,7 +1483,7 @@ switchStmt()
 
-Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<UnaryExprOrTypeTraitExpr>... +Matcher<Stmt>unaryExprOrTypeTraitExprMatcher<UnaryExprOrTypeTraitExpr>...
Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
 
 Given
@@ -1432,7 +1494,7 @@ unaryExprOrTypeTraitExpr()
 
-Matcher<Stmt>unaryOperatorMatcher<UnaryOperator>... +Matcher<Stmt>unaryOperatorMatcher<UnaryOperator>...
Matches unary operator expressions.
 
 Example matches !a
@@ -1440,7 +1502,7 @@ Example matches !a
 
-Matcher<Stmt>unresolvedLookupExprMatcher<UnresolvedLookupExpr>... +Matcher<Stmt>unresolvedLookupExprMatcher<UnresolvedLookupExpr>...
Matches reference to a name that can be looked up during parsing
 but could not be resolved to a specific declaration.
 
@@ -1455,14 +1517,28 @@ unresolvedLookupExpr()
   matches foo<T>() 
-Matcher<Stmt>userDefinedLiteralMatcher<UserDefinedLiteral>... +Matcher<Stmt>unresolvedMemberExprMatcher<UnresolvedMemberExpr>... +
Matches unresolved member expressions.
+
+Given
+  struct X {
+    template <class T> void f();
+    void g();
+  };
+  template <class T> void h() { X x; x.f<T>(); x.g(); }
+unresolvedMemberExpr()
+  matches x.f<T>
+
+ + +Matcher<Stmt>userDefinedLiteralMatcher<UserDefinedLiteral>...
Matches user defined literal operator call.
 
 Example match: "foo"_suffix
 
-Matcher<Stmt>whileStmtMatcher<WhileStmt>... +Matcher<Stmt>whileStmtMatcher<WhileStmt>...
Matches while statements.
 
 Given
@@ -1472,7 +1548,7 @@ whileStmt()
 
-Matcher<TemplateArgument>templateArgumentMatcher<TemplateArgument>... +Matcher<TemplateArgument>templateArgumentMatcher<TemplateArgument>...
Matches template arguments.
 
 Given
@@ -1483,7 +1559,7 @@ templateArgument()
 
-Matcher<TemplateName>templateNameMatcher<TemplateName>... +Matcher<TemplateName>templateNameMatcher<TemplateName>...
Matches template name.
 
 Given
@@ -1494,12 +1570,12 @@ templateName()
 
-Matcher<TypeLoc>typeLocMatcher<TypeLoc>... +Matcher<TypeLoc>typeLocMatcher<TypeLoc>...
Matches TypeLocs in the clang AST.
 
-Matcher<Type>arrayTypeMatcher<ArrayType>... +Matcher<Type>arrayTypeMatcher<ArrayType>...
Matches all kinds of arrays.
 
 Given
@@ -1511,7 +1587,7 @@ arrayType()
 
-Matcher<Type>atomicTypeMatcher<AtomicType>... +Matcher<Type>atomicTypeMatcher<AtomicType>...
Matches atomic types.
 
 Given
@@ -1521,7 +1597,7 @@ atomicType()
 
-Matcher<Type>autoTypeMatcher<AutoType>... +Matcher<Type>autoTypeMatcher<AutoType>...
Matches types nodes representing C++11 auto types.
 
 Given:
@@ -1533,7 +1609,7 @@ autoType()
 
-Matcher<Type>blockPointerTypeMatcher<BlockPointerType>... +Matcher<Type>blockPointerTypeMatcher<BlockPointerType>...
Matches block pointer types, i.e. types syntactically represented as
 "void (^)(int)".
 
@@ -1541,7 +1617,7 @@ The pointee is always required to be a FunctionType.
 
-Matcher<Type>builtinTypeMatcher<BuiltinType>... +Matcher<Type>builtinTypeMatcher<BuiltinType>...
Matches builtin Types.
 
 Given
@@ -1555,7 +1631,7 @@ builtinType()
 
-Matcher<Type>complexTypeMatcher<ComplexType>... +Matcher<Type>complexTypeMatcher<ComplexType>...
Matches C99 complex types.
 
 Given
@@ -1565,7 +1641,7 @@ complexType()
 
-Matcher<Type>constantArrayTypeMatcher<ConstantArrayType>... +Matcher<Type>constantArrayTypeMatcher<ConstantArrayType>...
Matches C arrays with a specified constant size.
 
 Given
@@ -1579,7 +1655,7 @@ constantArrayType()
 
-Matcher<Type>decayedTypeMatcher<DecayedType>... +Matcher<Type>decayedTypeMatcher<DecayedType>...
Matches decayed type
 Example matches i[] in declaration of f.
     (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
@@ -1591,19 +1667,19 @@ Example matches i[1].
 
-Matcher<Type>decltypeTypeMatcher<DecltypeType>... +Matcher<Type>decltypeTypeMatcher<DecltypeType>...
Matches types nodes representing C++11 decltype(<expr>) types.
 
 Given:
   short i = 1;
   int j = 42;
   decltype(i + j) result = i + j;
-decltypeType() 
+decltypeType()
   matches "decltype(i + j)"
 
-Matcher<Type>dependentSizedArrayTypeMatcher<DependentSizedArrayType>... +Matcher<Type>dependentSizedArrayTypeMatcher<DependentSizedArrayType>...
Matches C++ arrays whose size is a value-dependent expression.
 
 Given
@@ -1616,7 +1692,7 @@ dependentSizedArrayType
 
-Matcher<Type>elaboratedTypeMatcher<ElaboratedType>... +Matcher<Type>elaboratedTypeMatcher<ElaboratedType>...
Matches types specified with an elaborated type keyword or with a
 qualified name.
 
@@ -1636,7 +1712,7 @@ c and d.
 
-Matcher<Type>enumTypeMatcher<EnumType>... +Matcher<Type>enumTypeMatcher<EnumType>...
Matches enum types.
 
 Given
@@ -1651,7 +1727,7 @@ s.
 
-Matcher<Type>functionProtoTypeMatcher<FunctionProtoType>... +Matcher<Type>functionProtoTypeMatcher<FunctionProtoType>...
Matches FunctionProtoType nodes.
 
 Given
@@ -1663,7 +1739,7 @@ functionProtoType()
 
-Matcher<Type>functionTypeMatcher<FunctionType>... +Matcher<Type>functionTypeMatcher<FunctionType>...
Matches FunctionType nodes.
 
 Given
@@ -1674,7 +1750,7 @@ functionType()
 
-Matcher<Type>incompleteArrayTypeMatcher<IncompleteArrayType>... +Matcher<Type>incompleteArrayTypeMatcher<IncompleteArrayType>...
Matches C arrays with unspecified size.
 
 Given
@@ -1686,7 +1762,7 @@ incompleteArrayType()
 
-Matcher<Type>injectedClassNameTypeMatcher<InjectedClassNameType>... +Matcher<Type>injectedClassNameTypeMatcher<InjectedClassNameType>...
Matches injected class name types.
 
 Example matches S s, but not S<T> s.
@@ -1698,7 +1774,7 @@ Example matches S s, but not S<T> s.
 
-Matcher<Type>lValueReferenceTypeMatcher<LValueReferenceType>... +Matcher<Type>lValueReferenceTypeMatcher<LValueReferenceType>...
Matches lvalue reference types.
 
 Given:
@@ -1715,7 +1791,7 @@ matched since the type is deduced as int& by reference collapsing rules.
 
-Matcher<Type>memberPointerTypeMatcher<MemberPointerType>... +Matcher<Type>memberPointerTypeMatcher<MemberPointerType>...
Matches member pointer types.
 Given
   struct A { int i; }
@@ -1725,7 +1801,7 @@ memberPointerType()
 
-Matcher<Type>objcObjectPointerTypeMatcher<ObjCObjectPointerType>... +Matcher<Type>objcObjectPointerTypeMatcher<ObjCObjectPointerType>...
Matches an Objective-C object pointer type, which is different from
 a pointer type, despite being syntactically similar.
 
@@ -1740,7 +1816,7 @@ pointerType()
 
-Matcher<Type>parenTypeMatcher<ParenType>... +Matcher<Type>parenTypeMatcher<ParenType>...
Matches ParenType nodes.
 
 Given
@@ -1752,7 +1828,7 @@ array_of_ptrs.
 
-Matcher<Type>pointerTypeMatcher<PointerType>... +Matcher<Type>pointerTypeMatcher<PointerType>...
Matches pointer types, but does not match Objective-C object pointer
 types.
 
@@ -1769,7 +1845,7 @@ pointerType()
 
-Matcher<Type>rValueReferenceTypeMatcher<RValueReferenceType>... +Matcher<Type>rValueReferenceTypeMatcher<RValueReferenceType>...
Matches rvalue reference types.
 
 Given:
@@ -1786,7 +1862,7 @@ matched as it is deduced to int& by reference collapsing rules.
 
-Matcher<Type>recordTypeMatcher<RecordType>... +Matcher<Type>recordTypeMatcher<RecordType>...
Matches record types (e.g. structs, classes).
 
 Given
@@ -1801,7 +1877,7 @@ and s.
 
-Matcher<Type>referenceTypeMatcher<ReferenceType>... +Matcher<Type>referenceTypeMatcher<ReferenceType>...
Matches both lvalue and rvalue reference types.
 
 Given
@@ -1817,7 +1893,7 @@ referenceType() matches the types of b, c, d, e, and f.
 
-Matcher<Type>substTemplateTypeParmTypeMatcher<SubstTemplateTypeParmType>... +Matcher<Type>substTemplateTypeParmTypeMatcher<SubstTemplateTypeParmType>...
Matches types that represent the result of substituting a type for a
 template type parameter.
 
@@ -1831,7 +1907,7 @@ substTemplateTypeParmType() matches the type of 't' but not '1'
 
-Matcher<Type>tagTypeMatcher<TagType>... +Matcher<Type>tagTypeMatcher<TagType>...
Matches tag types (record and enum types).
 
 Given
@@ -1846,22 +1922,22 @@ and c.
 
-Matcher<Type>templateSpecializationTypeMatcher<TemplateSpecializationType>... +Matcher<Type>templateSpecializationTypeMatcher<TemplateSpecializationType>...
Matches template specialization types.
 
 Given
   template <typename T>
   class C { };
 
-  template class C<int>;  A
-  C<char> var;            B
+  template class C<int>;  // A
+  C<char> var;            // B
 
 templateSpecializationType() matches the type of the explicit
 instantiation in A and the type of the variable declaration in B.
 
-Matcher<Type>templateTypeParmTypeMatcher<TemplateTypeParmType>... +Matcher<Type>templateTypeParmTypeMatcher<TemplateTypeParmType>...
Matches template type parameter types.
 
 Example matches T, but not int.
@@ -1870,12 +1946,12 @@ Example matches T, but not int.
 
-Matcher<Type>typeMatcher<Type>... +Matcher<Type>typeMatcher<Type>...
Matches Types in the clang AST.
 
-Matcher<Type>typedefTypeMatcher<TypedefType>... +Matcher<Type>typedefTypeMatcher<TypedefType>...
Matches typedef types.
 
 Given
@@ -1885,7 +1961,7 @@ typedefType()
 
-Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>... +Matcher<Type>unaryTransformTypeMatcher<UnaryTransformType>...
Matches types nodes representing unary type transformations.
 
 Given:
@@ -1895,7 +1971,7 @@ unaryTransformType()
 
-Matcher<Type>variableArrayTypeMatcher<VariableArrayType>... +Matcher<Type>variableArrayTypeMatcher<VariableArrayType>...
Matches C arrays with a specified size that is not an
 integer-constant-expression.
 
@@ -1967,7 +2043,7 @@ Usable as: Any Matcher
 
-Matcher<BinaryOperator>hasOperatorNamestd::string Name +Matcher<BinaryOperator>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
 unary).
 
@@ -1976,7 +2052,7 @@ Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
 
-Matcher<BinaryOperator>isAssignmentOperator +Matcher<BinaryOperator>isAssignmentOperator
Matches all kinds of assignment operators.
 
 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
@@ -1990,11 +2066,11 @@ Example 2: matches s1 = s2
 
-Matcher<CXXBoolLiteralExpr>equalsbool Value +Matcher<CXXBoolLiteralExpr>equalsbool Value

 
 
-Matcher<CXXBoolLiteralExpr>equalsconst ValueT  Value
+Matcher<CXXBoolLiteralExpr>equalsconst ValueT  Value
 
Matches literals that are equal to the given value of type ValueT.
 
 Given
@@ -2015,36 +2091,35 @@ matcher to match the minus sign:
 unaryOperator(hasOperatorName("-"),
               hasUnaryOperand(integerLiteral(equals(13))))
 
-Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
-           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
+Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
+           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
 
-Matcher<CXXBoolLiteralExpr>equalsdouble Value +Matcher<CXXBoolLiteralExpr>equalsdouble Value

 
 
-Matcher<CXXBoolLiteralExpr>equalsunsigned Value
+Matcher<CXXBoolLiteralExpr>equalsunsigned Value
 

 
 
-Matcher<CXXCatchStmt>isCatchAll
+Matcher<CXXCatchStmt>isCatchAll
 
Matches a C++ catch statement that has a catch-all handler.
 
 Given
   try {
-    ...
+    // ...
   } catch (int) {
-    ...
+    // ...
   } catch (...) {
-    ...
+    // ...
   }
-endcode
 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
 
-Matcher<CXXConstructExpr>argumentCountIsunsigned N +Matcher<CXXConstructExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
 
@@ -2054,12 +2129,12 @@ Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
 
-Matcher<CXXConstructExpr>isListInitialization +Matcher<CXXConstructExpr>isListInitialization
Matches a constructor call expression which uses list initialization.
 
-Matcher<CXXConstructExpr>requiresZeroInitialization +Matcher<CXXConstructExpr>requiresZeroInitialization
Matches a constructor call expression which requires
 zero initialization.
 
@@ -2073,93 +2148,93 @@ will match the implicit array filler for pt[1].
 
-Matcher<CXXConstructorDecl>isCopyConstructor +Matcher<CXXConstructorDecl>isCopyConstructor
Matches constructor declarations that are copy constructors.
 
 Given
   struct S {
-    S(); #1
-    S(const S &); #2
-    S(S &&); #3
+    S(); // #1
+    S(const S &); // #2
+    S(S &&); // #3
   };
 cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
 
-Matcher<CXXConstructorDecl>isDefaultConstructor +Matcher<CXXConstructorDecl>isDefaultConstructor
Matches constructor declarations that are default constructors.
 
 Given
   struct S {
-    S(); #1
-    S(const S &); #2
-    S(S &&); #3
+    S(); // #1
+    S(const S &); // #2
+    S(S &&); // #3
   };
 cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
 
-Matcher<CXXConstructorDecl>isDelegatingConstructor +Matcher<CXXConstructorDecl>isDelegatingConstructor
Matches constructors that delegate to another constructor.
 
 Given
   struct S {
-    S(); #1
-    S(int) {} #2
-    S(S &&) : S() {} #3
+    S(); // #1
+    S(int) {} // #2
+    S(S &&) : S() {} // #3
   };
-  S::S() : S(0) {} #4
+  S::S() : S(0) {} // #4
 cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
 #1 or #2.
 
-Matcher<CXXConstructorDecl>isExplicit +Matcher<CXXConstructorDecl>isExplicit
Matches constructor and conversion declarations that are marked with
 the explicit keyword.
 
 Given
   struct S {
-    S(int); #1
-    explicit S(double); #2
-    operator int(); #3
-    explicit operator bool(); #4
+    S(int); // #1
+    explicit S(double); // #2
+    operator int(); // #3
+    explicit operator bool(); // #4
   };
 cxxConstructorDecl(isExplicit()) will match #2, but not #1.
 cxxConversionDecl(isExplicit()) will match #4, but not #3.
 
-Matcher<CXXConstructorDecl>isMoveConstructor +Matcher<CXXConstructorDecl>isMoveConstructor
Matches constructor declarations that are move constructors.
 
 Given
   struct S {
-    S(); #1
-    S(const S &); #2
-    S(S &&); #3
+    S(); // #1
+    S(const S &); // #2
+    S(S &&); // #3
   };
 cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
 
-Matcher<CXXConversionDecl>isExplicit +Matcher<CXXConversionDecl>isExplicit
Matches constructor and conversion declarations that are marked with
 the explicit keyword.
 
 Given
   struct S {
-    S(int); #1
-    explicit S(double); #2
-    operator int(); #3
-    explicit operator bool(); #4
+    S(int); // #1
+    explicit S(double); // #2
+    operator int(); // #3
+    explicit operator bool(); // #4
   };
 cxxConstructorDecl(isExplicit()) will match #2, but not #1.
 cxxConversionDecl(isExplicit()) will match #4, but not #3.
 
-Matcher<CXXCtorInitializer>isBaseInitializer +Matcher<CXXCtorInitializer>isBaseInitializer
Matches a constructor initializer if it is initializing a base, as
 opposed to a member.
 
@@ -2177,7 +2252,7 @@ cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
 
-Matcher<CXXCtorInitializer>isMemberInitializer +Matcher<CXXCtorInitializer>isMemberInitializer
Matches a constructor initializer if it is initializing a member, as
 opposed to a base.
 
@@ -2195,7 +2270,7 @@ cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
 
-Matcher<CXXCtorInitializer>isWritten +Matcher<CXXCtorInitializer>isWritten
Matches a constructor initializer if it is explicitly written in
 code (as opposed to implicitly added by the compiler).
 
@@ -2210,7 +2285,33 @@ cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
 
-Matcher<CXXMethodDecl>isConst +Matcher<CXXDependentScopeMemberExpr>isArrow +
Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+    void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+    template <class T> void f() { this->f<T>(); f<T>(); }
+    int a;
+    static int b;
+  };
+  template <class T>
+  class Z {
+    void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f<T>, f<T>
+
+ + +Matcher<CXXMethodDecl>isConst
Matches if the given method declaration is const.
 
 Given
@@ -2223,7 +2324,7 @@ cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
 
-Matcher<CXXMethodDecl>isCopyAssignmentOperator +Matcher<CXXMethodDecl>isCopyAssignmentOperator
Matches if the given method declaration declares a copy assignment
 operator.
 
@@ -2238,7 +2339,7 @@ the second one.
 
-Matcher<CXXMethodDecl>isFinal +Matcher<CXXMethodDecl>isFinal
Matches if the given method or class declaration is final.
 
 Given:
@@ -2255,7 +2356,7 @@ matches A and C::f, but not B, C, or B::f
 
-Matcher<CXXMethodDecl>isMoveAssignmentOperator +Matcher<CXXMethodDecl>isMoveAssignmentOperator
Matches if the given method declaration declares a move assignment
 operator.
 
@@ -2270,7 +2371,7 @@ the first one.
 
-Matcher<CXXMethodDecl>isOverride +Matcher<CXXMethodDecl>isOverride
Matches if the given method declaration overrides another method.
 
 Given
@@ -2286,7 +2387,7 @@ Given
 
-Matcher<CXXMethodDecl>isPure +Matcher<CXXMethodDecl>isPure
Matches if the given method declaration is pure.
 
 Given
@@ -2298,20 +2399,20 @@ Given
 
-Matcher<CXXMethodDecl>isUserProvided +Matcher<CXXMethodDecl>isUserProvided
Matches method declarations that are user-provided.
 
 Given
   struct S {
-    S(); #1
-    S(const S &) = default; #2
-    S(S &&) = delete; #3
+    S(); // #1
+    S(const S &) = default; // #2
+    S(S &&) = delete; // #3
   };
 cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
 
-Matcher<CXXMethodDecl>isVirtual +Matcher<CXXMethodDecl>isVirtual
Matches if the given method declaration is virtual.
 
 Given
@@ -2323,7 +2424,7 @@ Given
 
-Matcher<CXXMethodDecl>isVirtualAsWritten +Matcher<CXXMethodDecl>isVirtualAsWritten
Matches if the given method declaration has an explicit "virtual".
 
 Given
@@ -2339,7 +2440,7 @@ Given
 
-Matcher<CXXNewExpr>isArray +Matcher<CXXNewExpr>isArray
Matches array new expressions.
 
 Given:
@@ -2349,7 +2450,7 @@ cxxNewExpr(isArray())
 
-Matcher<CXXOperatorCallExpr>hasOverloadedOperatorNameStringRef Name +Matcher<CXXOperatorCallExpr>hasOverloadedOperatorNameStringRef Name
Matches overloaded operator names.
 
 Matches overloaded operator names specified in strings without the
@@ -2359,18 +2460,18 @@ Given:
   class A { int operator*(); };
   const A &operator<<(const A &a, const A &b);
   A a;
-  a << a;   <-- This matches
+  a << a;   // <-- This matches
 
 cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
 specified line and
 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
 matches the declaration of A.
 
-Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
+Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
 
-Matcher<CXXOperatorCallExpr>isAssignmentOperator +Matcher<CXXOperatorCallExpr>isAssignmentOperator
Matches all kinds of assignment operators.
 
 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
@@ -2384,7 +2485,7 @@ Example 2: matches s1 = s2
 
-Matcher<CXXRecordDecl>hasDefinition +Matcher<CXXRecordDecl>hasDefinition
Matches a class declaration that is defined.
 
 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
@@ -2393,12 +2494,12 @@ class y;
 
-Matcher<CXXRecordDecl>isDerivedFromstd::string BaseName +Matcher<CXXRecordDecl>isDerivedFromstd::string BaseName
Overloaded method as shortcut for isDerivedFrom(hasName(...)).
 
-Matcher<CXXRecordDecl>isExplicitTemplateSpecialization +Matcher<CXXRecordDecl>isExplicitTemplateSpecialization
Matches explicit template specializations of function, class, or
 static member variable template instantiations.
 
@@ -2408,11 +2509,11 @@ Given
 functionDecl(isExplicitTemplateSpecialization())
   matches the specialization A<int>().
 
-Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
+Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
 
-Matcher<CXXRecordDecl>isFinal +Matcher<CXXRecordDecl>isFinal
Matches if the given method or class declaration is final.
 
 Given:
@@ -2429,7 +2530,7 @@ matches A and C::f, but not B, C, or B::f
 
-Matcher<CXXRecordDecl>isLambda +Matcher<CXXRecordDecl>isLambda
Matches the generated class of lambda expressions.
 
 Given:
@@ -2440,13 +2541,13 @@ decltype(x)
 
-Matcher<CXXRecordDecl>isSameOrDerivedFromstd::string BaseName +Matcher<CXXRecordDecl>isSameOrDerivedFromstd::string BaseName
Overloaded method as shortcut for
 isSameOrDerivedFrom(hasName(...)).
 
-Matcher<CXXRecordDecl>isTemplateInstantiation +Matcher<CXXRecordDecl>isTemplateInstantiation
Matches template instantiations of function, class, or static
 member variable template instantiations.
 
@@ -2465,11 +2566,11 @@ But given
 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
   does not match, as X<A> is an explicit template specialization.
 
-Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
+Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
 
-Matcher<CallExpr>argumentCountIsunsigned N +Matcher<CallExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
 
@@ -2479,7 +2580,29 @@ Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
 
-Matcher<CastExpr>hasCastKindCastKind Kind +Matcher<CallExpr>usesADL +
Matches call expressions which were resolved using ADL.
+
+Example matches y(x) but not y(42) or NS::y(x).
+  namespace NS {
+    struct X {};
+    void y(X);
+  }
+
+  void y(...);
+
+  void test() {
+    NS::X x;
+    y(x); // Matches
+    NS::y(x); // Doesn't match
+    y(42); // Doesn't match
+    using NS::y;
+    y(x); // Found by both unqualified lookup and ADL, doesn't match
+   }
+
+ + +Matcher<CastExpr>hasCastKindCastKind Kind
Matches casts that has a given cast kind.
 
 Example: matches the implicit cast around 0
@@ -2488,11 +2611,11 @@ Example: matches the implicit cast around 0
 
-Matcher<CharacterLiteral>equalsbool Value +Matcher<CharacterLiteral>equalsbool Value

 
 
-Matcher<CharacterLiteral>equalsconst ValueT  Value
+Matcher<CharacterLiteral>equalsconst ValueT  Value
 
Matches literals that are equal to the given value of type ValueT.
 
 Given
@@ -2513,20 +2636,20 @@ matcher to match the minus sign:
 unaryOperator(hasOperatorName("-"),
               hasUnaryOperand(integerLiteral(equals(13))))
 
-Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
-           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
+Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
+           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
 
-Matcher<CharacterLiteral>equalsdouble Value +Matcher<CharacterLiteral>equalsdouble Value

 
 
-Matcher<CharacterLiteral>equalsunsigned Value
+Matcher<CharacterLiteral>equalsunsigned Value
 

 
 
-Matcher<ClassTemplateSpecializationDecl>templateArgumentCountIsunsigned N
+Matcher<ClassTemplateSpecializationDecl>templateArgumentCountIsunsigned N
 
Matches if the number of template arguments equals N.
 
 Given
@@ -2537,7 +2660,7 @@ classTemplateSpecializationDecl(templateArgumentCountIs(1))
 
-Matcher<CompoundStmt>statementCountIsunsigned N +Matcher<CompoundStmt>statementCountIsunsigned N
Checks that a compound statement contains a specific number of
 child statements.
 
@@ -2549,7 +2672,7 @@ compoundStmt(statementCountIs(0)))
 
-Matcher<ConstantArrayType>hasSizeunsigned N +Matcher<ConstantArrayType>hasSizeunsigned N
Matches nodes that have the specified size.
 
 Given
@@ -2566,7 +2689,7 @@ stringLiteral(hasSize(4))
 
-Matcher<DeclStmt>declCountIsunsigned N +Matcher<DeclStmt>declCountIsunsigned N
Matches declaration statements that contain a specific number of
 declarations.
 
@@ -2579,7 +2702,7 @@ declCountIs(2)
 
-Matcher<Decl>equalsBoundNodestd::string ID +Matcher<Decl>equalsBoundNodestd::string ID
Matches if a node equals a previously bound node.
 
 Matches a node if it equals the node previously bound to ID.
@@ -2602,14 +2725,14 @@ and reference to that variable declaration within a compound statement.
 
-Matcher<Decl>equalsNodeconst Decl* Other +Matcher<Decl>equalsNodeconst Decl* Other
Matches if a node equals another node.
 
 Decl has pointer identity in the AST.
 
-Matcher<Decl>hasAttrattr::Kind AttrKind +Matcher<Decl>hasAttrattr::Kind AttrKind
Matches declaration that has a given attribute.
 
 Given
@@ -2620,7 +2743,7 @@ passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
 
-Matcher<Decl>isExpansionInFileMatchingstd::string RegExp +Matcher<Decl>isExpansionInFileMatchingstd::string RegExp
Matches AST nodes that were expanded within files whose name is
 partially matching a given regex.
 
@@ -2631,11 +2754,11 @@ Example matches Y but not X
 ASTMatcher.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<Decl>isExpansionInMainFile +Matcher<Decl>isExpansionInMainFile
Matches AST nodes that were expanded within the main-file.
 
 Example matches X but not Y
@@ -2645,11 +2768,11 @@ Example matches X but not Y
 Y.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<Decl>isExpansionInSystemHeader +Matcher<Decl>isExpansionInSystemHeader
Matches AST nodes that were expanded within system-header-files.
 
 Example matches Y but not X
@@ -2659,17 +2782,17 @@ Example matches Y but not X
 SystemHeader.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<Decl>isImplicit +Matcher<Decl>isImplicit
Matches a declaration that has been implicitly added
-by the compiler (eg. implicit defaultcopy constructors).
+by the compiler (eg. implicit default/copy constructors).
 
-Matcher<Decl>isPrivate +Matcher<Decl>isPrivate
Matches private C++ declarations.
 
 Given
@@ -2683,7 +2806,7 @@ fieldDecl(isPrivate())
 
-Matcher<Decl>isProtected +Matcher<Decl>isProtected
Matches protected C++ declarations.
 
 Given
@@ -2697,7 +2820,7 @@ fieldDecl(isProtected())
 
-Matcher<Decl>isPublic +Matcher<Decl>isPublic
Matches public C++ declarations.
 
 Given
@@ -2711,7 +2834,7 @@ fieldDecl(isPublic())
 
-Matcher<DesignatedInitExpr>designatorCountIsunsigned N +Matcher<DesignatedInitExpr>designatorCountIsunsigned N
Matches designated initializer expressions that contain
 a specific number of designators.
 
@@ -2724,7 +2847,7 @@ designatorCountIs(2)
 
-Matcher<EnumDecl>isScoped +Matcher<EnumDecl>isScoped
Matches C++11 scoped enum declaration.
 
 Example matches Y (matcher = enumDecl(isScoped()))
@@ -2733,7 +2856,47 @@ enum class Y {};
 
-Matcher<FieldDecl>hasBitWidthunsigned Width +Matcher<Expr>isInstantiationDependent +
Matches expressions that are instantiation-dependent even if it is
+neither type- nor value-dependent.
+
+In the following example, the expression sizeof(sizeof(T() + T()))
+is instantiation-dependent (since it involves a template parameter T),
+but is neither type- nor value-dependent, since the type of the inner
+sizeof is known (std::size_t) and therefore the size of the outer
+sizeof is known.
+  template<typename T>
+  void f(T x, T y) { sizeof(sizeof(T() + T()); }
+expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
+
+ + +Matcher<Expr>isTypeDependent +
Matches expressions that are type-dependent because the template type
+is not yet instantiated.
+
+For example, the expressions "x" and "x + y" are type-dependent in
+the following code, but "y" is not type-dependent:
+  template<typename T>
+  void add(T x, int y) {
+    x + y;
+  }
+expr(isTypeDependent()) matches x + y
+
+ + +Matcher<Expr>isValueDependent +
Matches expression that are value-dependent because they contain a
+non-type template parameter.
+
+For example, the array bound of "Chars" in the following example is
+value-dependent.
+  template<int Size> int f() { return Size; }
+expr(isValueDependent()) matches return Size
+
+ + +Matcher<FieldDecl>hasBitWidthunsigned Width
Matches non-static data members that are bit-fields of the specified
 bit width.
 
@@ -2748,7 +2911,7 @@ fieldDecl(hasBitWidth(2))
 
-Matcher<FieldDecl>isBitField +Matcher<FieldDecl>isBitField
Matches non-static data members that are bit-fields.
 
 Given
@@ -2761,7 +2924,7 @@ fieldDecl(isBitField())
 
-Matcher<FloatingLiteral>equalsconst ValueT Value +Matcher<FloatingLiteral>equalsconst ValueT Value
Matches literals that are equal to the given value of type ValueT.
 
 Given
@@ -2782,16 +2945,16 @@ matcher to match the minus sign:
 unaryOperator(hasOperatorName("-"),
               hasUnaryOperand(integerLiteral(equals(13))))
 
-Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
-           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
+Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
+           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
 
-Matcher<FloatingLiteral>equalsdouble Value +Matcher<FloatingLiteral>equalsdouble Value

 
 
-Matcher<FunctionDecl>hasDynamicExceptionSpec
+Matcher<FunctionDecl>hasDynamicExceptionSpec
 
Matches functions that have a dynamic exception specification.
 
 Given:
@@ -2808,7 +2971,7 @@ functionDecl(hasDynamicExceptionSpec()) and
 
-Matcher<FunctionDecl>hasOverloadedOperatorNameStringRef Name +Matcher<FunctionDecl>hasOverloadedOperatorNameStringRef Name
Matches overloaded operator names.
 
 Matches overloaded operator names specified in strings without the
@@ -2818,18 +2981,18 @@ Given:
   class A { int operator*(); };
   const A &operator<<(const A &a, const A &b);
   A a;
-  a << a;   <-- This matches
+  a << a;   // <-- This matches
 
 cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the
 specified line and
 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
 matches the declaration of A.
 
-Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
+Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>
 
-Matcher<FunctionDecl>hasTrailingReturn +Matcher<FunctionDecl>hasTrailingReturn
Matches a function declared with a trailing return type.
 
 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
@@ -2838,7 +3001,7 @@ auto Y() -> int {}
 
-Matcher<FunctionDecl>isConstexpr +Matcher<FunctionDecl>isConstexpr
Matches constexpr variable and function declarations,
        and if constexpr.
 
@@ -2855,7 +3018,7 @@ ifStmt(isConstexpr())
 
-Matcher<FunctionDecl>isDefaulted +Matcher<FunctionDecl>isDefaulted
Matches defaulted function declarations.
 
 Given:
@@ -2866,29 +3029,29 @@ functionDecl(isDefaulted())
 
-Matcher<FunctionDecl>isDefinition +Matcher<FunctionDecl>isDefinition
Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
-  class B;  Doesn't match, as it has no body.
+  class B;  // Doesn't match, as it has no body.
   int va;
-  extern int vb;  Doesn't match, as it doesn't define the variable.
+  extern int vb;  // Doesn't match, as it doesn't define the variable.
   void fa() {}
-  void fb();  Doesn't match, as it has no body.
+  void fb();  // Doesn't match, as it has no body.
   @interface X
-  - (void)ma; Doesn't match, interface is declaration.
+  - (void)ma; // Doesn't match, interface is declaration.
   @end
   @implementation X
   - (void)ma {}
   @end
 
-Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
-  Matcher<ObjCMethodDecl>
+Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
+  Matcher<ObjCMethodDecl>
 
-Matcher<FunctionDecl>isDeleted +Matcher<FunctionDecl>isDeleted
Matches deleted function declarations.
 
 Given:
@@ -2899,7 +3062,7 @@ functionDecl(isDeleted())
 
-Matcher<FunctionDecl>isExplicitTemplateSpecialization +Matcher<FunctionDecl>isExplicitTemplateSpecialization
Matches explicit template specializations of function, class, or
 static member variable template instantiations.
 
@@ -2909,11 +3072,11 @@ Given
 functionDecl(isExplicitTemplateSpecialization())
   matches the specialization A<int>().
 
-Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
+Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
 
-Matcher<FunctionDecl>isExternC +Matcher<FunctionDecl>isExternC
Matches extern "C" function or variable declarations.
 
 Given:
@@ -2930,7 +3093,7 @@ varDecl(isExternC())
 
-Matcher<FunctionDecl>isInline +Matcher<FunctionDecl>isInline
Matches function and namespace declarations that are marked with
 the inline keyword.
 
@@ -2945,13 +3108,13 @@ namespaceDecl(isInline()) will match n::m.
 
-Matcher<FunctionDecl>isMain +Matcher<FunctionDecl>isMain
Determines whether the function is "main", which is the entry point
 into an executable program.
 
-Matcher<FunctionDecl>isNoReturn +Matcher<FunctionDecl>isNoReturn
Matches FunctionDecls that have a noreturn attribute.
 
 Given
@@ -2965,7 +3128,7 @@ functionDecl(isNoReturn())
 
-Matcher<FunctionDecl>isNoThrow +Matcher<FunctionDecl>isNoThrow
Matches functions that have a non-throwing exception specification.
 
 Given:
@@ -2979,8 +3142,8 @@ functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
 
-Matcher<FunctionDecl>isStaticStorageClass -
Matches variablefunction declarations that have "static" storage
+Matcher<FunctionDecl>isStaticStorageClass
+
Matches variable/function declarations that have "static" storage
 class specifier ("static" keyword) written in the source.
 
 Given:
@@ -2995,7 +3158,7 @@ varDecl(isStaticStorageClass())
 
-Matcher<FunctionDecl>isTemplateInstantiation +Matcher<FunctionDecl>isTemplateInstantiation
Matches template instantiations of function, class, or static
 member variable template instantiations.
 
@@ -3014,11 +3177,11 @@ But given
 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
   does not match, as X<A> is an explicit template specialization.
 
-Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
+Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
 
-Matcher<FunctionDecl>isVariadic +Matcher<FunctionDecl>isVariadic
Matches if a function declaration is variadic.
 
 Example matches f, but not g or h. The function i will not match, even when
@@ -3030,7 +3193,7 @@ compiled in C mode.
 
-Matcher<FunctionDecl>parameterCountIsunsigned N +Matcher<FunctionDecl>parameterCountIsunsigned N
Matches FunctionDecls and FunctionProtoTypes that have a
 specific parameter count.
 
@@ -3049,7 +3212,7 @@ functionProtoType(parameterCountIs(3))
 
-Matcher<FunctionProtoType>hasDynamicExceptionSpec +Matcher<FunctionProtoType>hasDynamicExceptionSpec
Matches functions that have a dynamic exception specification.
 
 Given:
@@ -3066,7 +3229,7 @@ functionDecl(hasDynamicExceptionSpec()) and
 
-Matcher<FunctionProtoType>isNoThrow +Matcher<FunctionProtoType>isNoThrow
Matches functions that have a non-throwing exception specification.
 
 Given:
@@ -3080,7 +3243,7 @@ functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
 
-Matcher<FunctionProtoType>parameterCountIsunsigned N +Matcher<FunctionProtoType>parameterCountIsunsigned N
Matches FunctionDecls and FunctionProtoTypes that have a
 specific parameter count.
 
@@ -3099,7 +3262,7 @@ functionProtoType(parameterCountIs(3))
 
-Matcher<IfStmt>isConstexpr +Matcher<IfStmt>isConstexpr
Matches constexpr variable and function declarations,
        and if constexpr.
 
@@ -3116,11 +3279,11 @@ ifStmt(isConstexpr())
 
-Matcher<IntegerLiteral>equalsbool Value +Matcher<IntegerLiteral>equalsbool Value

 
 
-Matcher<IntegerLiteral>equalsconst ValueT  Value
+Matcher<IntegerLiteral>equalsconst ValueT  Value
 
Matches literals that are equal to the given value of type ValueT.
 
 Given
@@ -3141,20 +3304,20 @@ matcher to match the minus sign:
 unaryOperator(hasOperatorName("-"),
               hasUnaryOperand(integerLiteral(equals(13))))
 
-Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
-           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
+Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>,
+           Matcher<FloatingLiteral>, Matcher<IntegerLiteral>
 
-Matcher<IntegerLiteral>equalsdouble Value +Matcher<IntegerLiteral>equalsdouble Value

 
 
-Matcher<IntegerLiteral>equalsunsigned Value
+Matcher<IntegerLiteral>equalsunsigned Value
 

 
 
-Matcher<MemberExpr>isArrow
+Matcher<MemberExpr>isArrow
 
Matches member expressions that are called with '->' as opposed
 to '.'.
 
@@ -3163,15 +3326,24 @@ Member calls on the implicit this pointer match as called with '->'.
 Given
   class Y {
     void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+    template <class T> void f() { this->f<T>(); f<T>(); }
     int a;
     static int b;
   };
+  template <class T>
+  class Z {
+    void x() { this->m; }
+  };
 memberExpr(isArrow())
   matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f<T>, f<T>
 
-Matcher<NamedDecl>hasExternalFormalLinkage +Matcher<NamedDecl>hasExternalFormalLinkage
Matches a declaration that has external formal linkage.
 
 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
@@ -3191,7 +3363,7 @@ void f() {}
 
-Matcher<NamedDecl>hasNameconst std::string Name +Matcher<NamedDecl>hasNameconst std::string Name
Matches NamedDecl nodes that have the specified name.
 
 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -3206,7 +3378,7 @@ Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
 
-Matcher<NamedDecl>matchesNamestd::string RegExp +Matcher<NamedDecl>matchesNamestd::string RegExp
Matches NamedDecl nodes whose fully qualified names contain
 a substring matched by the given RegExp.
 
@@ -3222,18 +3394,18 @@ Example matches X (regexp is one of "::X", "^foo::.*X", among others)
 
-Matcher<NamespaceDecl>isAnonymous +Matcher<NamespaceDecl>isAnonymous
Matches anonymous namespace declarations.
 
 Given
   namespace n {
-  namespace {} #1
+  namespace {} // #1
   }
 namespaceDecl(isAnonymous()) will match #1 but not ::n.
 
-Matcher<NamespaceDecl>isInline +Matcher<NamespaceDecl>isInline
Matches function and namespace declarations that are marked with
 the inline keyword.
 
@@ -3248,7 +3420,7 @@ namespaceDecl(isInline()) will match n::m.
 
-Matcher<ObjCMessageExpr>argumentCountIsunsigned N +Matcher<ObjCMessageExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
 
@@ -3258,7 +3430,7 @@ Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
 
-Matcher<ObjCMessageExpr>hasKeywordSelector +Matcher<ObjCMessageExpr>hasKeywordSelector
Matches when the selector is a keyword selector
 
 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
@@ -3268,11 +3440,11 @@ message expression in
   CGRect bodyFrame = webView.frame;
   bodyFrame.size.height = self.bodyContentHeight;
   webView.frame = bodyFrame;
-      ^---- matches here
+  //     ^---- matches here
 
-Matcher<ObjCMessageExpr>hasNullSelector +Matcher<ObjCMessageExpr>hasNullSelector
Matches when the selector is the empty selector
 
 Matches only when the selector of the objCMessageExpr is NULL. This may
@@ -3280,7 +3452,7 @@ represent an error condition in the tree!
 
-Matcher<ObjCMessageExpr>hasSelectorstd::string BaseName +Matcher<ObjCMessageExpr>hasSelectorstd::string BaseName
Matches when BaseName == Selector.getAsString()
 
  matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
@@ -3290,7 +3462,7 @@ represent an error condition in the tree!
 
-Matcher<ObjCMessageExpr>hasUnarySelector +Matcher<ObjCMessageExpr>hasUnarySelector
Matches when the selector is a Unary Selector
 
  matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
@@ -3300,7 +3472,7 @@ represent an error condition in the tree!
 
-Matcher<ObjCMessageExpr>isInstanceMessage +Matcher<ObjCMessageExpr>isInstanceMessage
Returns true when the Objective-C message is sent to an instance.
 
 Example
@@ -3313,7 +3485,7 @@ but not
 
-Matcher<ObjCMessageExpr>matchesSelectorstd::string RegExp +Matcher<ObjCMessageExpr>matchesSelectorstd::string RegExp
Matches ObjC selectors whose name contains
 a substring matched by the given RegExp.
  matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
@@ -3322,7 +3494,7 @@ a substring matched by the given RegExp.
 
-Matcher<ObjCMessageExpr>numSelectorArgsunsigned N +Matcher<ObjCMessageExpr>numSelectorArgsunsigned N
Matches when the selector has the specified number of arguments
 
  matcher = objCMessageExpr(numSelectorArgs(0));
@@ -3335,29 +3507,29 @@ a substring matched by the given RegExp.
 
-Matcher<ObjCMethodDecl>isDefinition +Matcher<ObjCMethodDecl>isDefinition
Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
-  class B;  Doesn't match, as it has no body.
+  class B;  // Doesn't match, as it has no body.
   int va;
-  extern int vb;  Doesn't match, as it doesn't define the variable.
+  extern int vb;  // Doesn't match, as it doesn't define the variable.
   void fa() {}
-  void fb();  Doesn't match, as it has no body.
+  void fb();  // Doesn't match, as it has no body.
   @interface X
-  - (void)ma; Doesn't match, interface is declaration.
+  - (void)ma; // Doesn't match, interface is declaration.
   @end
   @implementation X
   - (void)ma {}
   @end
 
-Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
-  Matcher<ObjCMethodDecl>
+Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
+  Matcher<ObjCMethodDecl>
 
-Matcher<ParmVarDecl>hasDefaultArgument +Matcher<ParmVarDecl>hasDefaultArgument
Matches a declaration that has default arguments.
 
 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
@@ -3366,7 +3538,7 @@ void y(int val = 0) {}
 
-Matcher<QualType>asStringstd::string Name +Matcher<QualType>asStringstd::string Name
Matches if the matched type is represented by the given string.
 
 Given
@@ -3377,7 +3549,7 @@ cxxMemberCallExpr(on(hasType(asString("class Y *"))))
 
-Matcher<QualType>equalsBoundNodestd::string ID +Matcher<QualType>equalsBoundNodestd::string ID
Matches if a node equals a previously bound node.
 
 Matches a node if it equals the node previously bound to ID.
@@ -3400,7 +3572,7 @@ and reference to that variable declaration within a compound statement.
 
-Matcher<QualType>hasLocalQualifiers +Matcher<QualType>hasLocalQualifiers
Matches QualType nodes that have local CV-qualifiers attached to
 the node, not hidden within a typedef.
 
@@ -3415,7 +3587,7 @@ i is const-qualified but the qualifier is not local.
 
-Matcher<QualType>isAnyCharacter +Matcher<QualType>isAnyCharacter
Matches QualType nodes that are of character type.
 
 Given
@@ -3427,7 +3599,7 @@ matches "a(char)", "b(wchar_t)", but not "c(double)".
 
-Matcher<QualType>isAnyPointer +Matcher<QualType>isAnyPointer
Matches QualType nodes that are of any pointer type; this includes
 the Objective-C object pointer type, which is different despite being
 syntactically similar.
@@ -3445,7 +3617,7 @@ varDecl(hasType(isAnyPointer()))
 
-Matcher<QualType>isConstQualified +Matcher<QualType>isConstQualified
Matches QualType nodes that are const-qualified, i.e., that
 include "top-level" const.
 
@@ -3462,7 +3634,7 @@ functionDecl(hasAnyParameter(hasType(isConstQualified())))
 
-Matcher<QualType>isInteger +Matcher<QualType>isInteger
Matches QualType nodes that are of integer type.
 
 Given
@@ -3474,7 +3646,7 @@ matches "a(int)", "b(long)", but not "c(double)".
 
-Matcher<QualType>isSignedInteger +Matcher<QualType>isSignedInteger
Matches QualType nodes that are of signed integer type.
 
 Given
@@ -3486,7 +3658,7 @@ matches "a(int)", but not "b(unsigned long)" and "c(double)".
 
-Matcher<QualType>isUnsignedInteger +Matcher<QualType>isUnsignedInteger
Matches QualType nodes that are of unsigned integer type.
 
 Given
@@ -3498,7 +3670,7 @@ matches "b(unsigned long)", but not "a(int)" and "c(double)".
 
-Matcher<QualType>isVolatileQualified +Matcher<QualType>isVolatileQualified
Matches QualType nodes that are volatile-qualified, i.e., that
 include "top-level" volatile.
 
@@ -3515,7 +3687,7 @@ functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
 
-Matcher<RecordDecl>isClass +Matcher<RecordDecl>isClass
Matches RecordDecl object that are spelled with "class."
 
 Example matches C, but not S or U.
@@ -3525,7 +3697,7 @@ Example matches C, but not S or U.
 
-Matcher<RecordDecl>isStruct +Matcher<RecordDecl>isStruct
Matches RecordDecl object that are spelled with "struct."
 
 Example matches S, but not C or U.
@@ -3535,7 +3707,7 @@ Example matches S, but not C or U.
 
-Matcher<RecordDecl>isUnion +Matcher<RecordDecl>isUnion
Matches RecordDecl object that are spelled with "union."
 
 Example matches U, but not C or S.
@@ -3545,7 +3717,7 @@ Example matches U, but not C or S.
 
-Matcher<Stmt>equalsBoundNodestd::string ID +Matcher<Stmt>equalsBoundNodestd::string ID
Matches if a node equals a previously bound node.
 
 Matches a node if it equals the node previously bound to ID.
@@ -3568,14 +3740,14 @@ and reference to that variable declaration within a compound statement.
 
-Matcher<Stmt>equalsNodeconst Stmt* Other +Matcher<Stmt>equalsNodeconst Stmt* Other
Matches if a node equals another node.
 
 Stmt has pointer identity in the AST.
 
-Matcher<Stmt>isExpansionInFileMatchingstd::string RegExp +Matcher<Stmt>isExpansionInFileMatchingstd::string RegExp
Matches AST nodes that were expanded within files whose name is
 partially matching a given regex.
 
@@ -3586,11 +3758,11 @@ Example matches Y but not X
 ASTMatcher.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<Stmt>isExpansionInMainFile +Matcher<Stmt>isExpansionInMainFile
Matches AST nodes that were expanded within the main-file.
 
 Example matches X but not Y
@@ -3600,11 +3772,11 @@ Example matches X but not Y
 Y.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<Stmt>isExpansionInSystemHeader +Matcher<Stmt>isExpansionInSystemHeader
Matches AST nodes that were expanded within system-header-files.
 
 Example matches Y but not X
@@ -3614,11 +3786,11 @@ Example matches Y but not X
 SystemHeader.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<StringLiteral>hasSizeunsigned N +Matcher<StringLiteral>hasSizeunsigned N
Matches nodes that have the specified size.
 
 Given
@@ -3635,29 +3807,29 @@ stringLiteral(hasSize(4))
 
-Matcher<TagDecl>isDefinition +Matcher<TagDecl>isDefinition
Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
-  class B;  Doesn't match, as it has no body.
+  class B;  // Doesn't match, as it has no body.
   int va;
-  extern int vb;  Doesn't match, as it doesn't define the variable.
+  extern int vb;  // Doesn't match, as it doesn't define the variable.
   void fa() {}
-  void fb();  Doesn't match, as it has no body.
+  void fb();  // Doesn't match, as it has no body.
   @interface X
-  - (void)ma; Doesn't match, interface is declaration.
+  - (void)ma; // Doesn't match, interface is declaration.
   @end
   @implementation X
   - (void)ma {}
   @end
 
-Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
-  Matcher<ObjCMethodDecl>
+Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
+  Matcher<ObjCMethodDecl>
 
-Matcher<TemplateArgument>equalsIntegralValuestd::string Value +Matcher<TemplateArgument>equalsIntegralValuestd::string Value
Matches a TemplateArgument of integral type with a given value.
 
 Note that 'Value' is a string as the template argument's value is
@@ -3673,7 +3845,7 @@ classTemplateSpecializationDecl(
 
-Matcher<TemplateArgument>isIntegral +Matcher<TemplateArgument>isIntegral
Matches a TemplateArgument that is an integral value.
 
 Given
@@ -3686,7 +3858,7 @@ classTemplateSpecializationDecl(
 
-Matcher<TemplateSpecializationType>templateArgumentCountIsunsigned N +Matcher<TemplateSpecializationType>templateArgumentCountIsunsigned N
Matches if the number of template arguments equals N.
 
 Given
@@ -3697,7 +3869,7 @@ classTemplateSpecializationDecl(templateArgumentCountIs(1))
 
-Matcher<TypeLoc>isExpansionInFileMatchingstd::string RegExp +Matcher<TypeLoc>isExpansionInFileMatchingstd::string RegExp
Matches AST nodes that were expanded within files whose name is
 partially matching a given regex.
 
@@ -3708,11 +3880,11 @@ Example matches Y but not X
 ASTMatcher.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<TypeLoc>isExpansionInMainFile +Matcher<TypeLoc>isExpansionInMainFile
Matches AST nodes that were expanded within the main-file.
 
 Example matches X but not Y
@@ -3722,11 +3894,11 @@ Example matches X but not Y
 Y.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<TypeLoc>isExpansionInSystemHeader +Matcher<TypeLoc>isExpansionInSystemHeader
Matches AST nodes that were expanded within system-header-files.
 
 Example matches Y but not X
@@ -3736,11 +3908,11 @@ Example matches Y but not X
 SystemHeader.h:
   class Y {};
 
-Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
+Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>
 
-Matcher<Type>booleanType +Matcher<Type>booleanType
Matches type bool.
 
 Given
@@ -3750,7 +3922,7 @@ functionDecl(returns(booleanType()))
 
-Matcher<Type>equalsBoundNodestd::string ID +Matcher<Type>equalsBoundNodestd::string ID
Matches if a node equals a previously bound node.
 
 Matches a node if it equals the node previously bound to ID.
@@ -3773,14 +3945,14 @@ and reference to that variable declaration within a compound statement.
 
-Matcher<Type>equalsNodeconst Type* Other +Matcher<Type>equalsNodeconst Type* Other
Matches if a node equals another node.
 
 Type has pointer identity in the AST.
 
-Matcher<Type>realFloatingPointType +Matcher<Type>realFloatingPointType
Matches any real floating-point type (float, double, long double).
 
 Given
@@ -3791,7 +3963,7 @@ realFloatingPointType()
 
-Matcher<Type>voidType +Matcher<Type>voidType
Matches type void.
 
 Given
@@ -3801,7 +3973,7 @@ functionDecl(returns(voidType()))
 
-Matcher<UnaryExprOrTypeTraitExpr>ofKindUnaryExprOrTypeTrait Kind +Matcher<UnaryExprOrTypeTraitExpr>ofKindUnaryExprOrTypeTrait Kind
Matches unary expressions of a certain kind.
 
 Given
@@ -3812,7 +3984,7 @@ unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
 
-Matcher<UnaryOperator>hasOperatorNamestd::string Name +Matcher<UnaryOperator>hasOperatorNamestd::string Name
Matches the operator Name of operator expressions (binary or
 unary).
 
@@ -3821,7 +3993,33 @@ Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
 
-Matcher<VarDecl>hasAutomaticStorageDuration +Matcher<UnresolvedMemberExpr>isArrow +
Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+  class Y {
+    void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+    template <class T> void f() { this->f<T>(); f<T>(); }
+    int a;
+    static int b;
+  };
+  template <class T>
+  class Z {
+    void x() { this->m; }
+  };
+memberExpr(isArrow())
+  matches this->x, x, y.x, a, this->b
+cxxDependentScopeMemberExpr(isArrow())
+  matches this->m
+unresolvedMemberExpr(isArrow())
+  matches this->f<T>, f<T>
+
+ + +Matcher<VarDecl>hasAutomaticStorageDuration
Matches a variable declaration that has automatic storage duration.
 
 Example matches x, but not y, z, or a.
@@ -3835,7 +4033,7 @@ int a;
 
-Matcher<VarDecl>hasGlobalStorage +Matcher<VarDecl>hasGlobalStorage
Matches a variable declaration that does not have local storage.
 
 Example matches y and z (matcher = varDecl(hasGlobalStorage())
@@ -3847,7 +4045,7 @@ int z;
 
-Matcher<VarDecl>hasLocalStorage +Matcher<VarDecl>hasLocalStorage
Matches a variable declaration that has function scope and is a
 non-static local variable.
 
@@ -3860,7 +4058,7 @@ int z;
 
-Matcher<VarDecl>hasStaticStorageDuration +Matcher<VarDecl>hasStaticStorageDuration
Matches a variable declaration that has static storage duration.
 It includes the variable declared at namespace scope and those declared
 with "static" and "extern" storage class specifiers.
@@ -3878,7 +4076,7 @@ varDecl(hasStaticStorageDuration())
 
-Matcher<VarDecl>hasThreadStorageDuration +Matcher<VarDecl>hasThreadStorageDuration
Matches a variable declaration that has thread storage duration.
 
 Example matches z, but not x, z, or a.
@@ -3892,7 +4090,7 @@ int a;
 
-Matcher<VarDecl>isConstexpr +Matcher<VarDecl>isConstexpr
Matches constexpr variable and function declarations,
        and if constexpr.
 
@@ -3909,29 +4107,29 @@ ifStmt(isConstexpr())
 
-Matcher<VarDecl>isDefinition +Matcher<VarDecl>isDefinition
Matches if a declaration has a body attached.
 
 Example matches A, va, fa
   class A {};
-  class B;  Doesn't match, as it has no body.
+  class B;  // Doesn't match, as it has no body.
   int va;
-  extern int vb;  Doesn't match, as it doesn't define the variable.
+  extern int vb;  // Doesn't match, as it doesn't define the variable.
   void fa() {}
-  void fb();  Doesn't match, as it has no body.
+  void fb();  // Doesn't match, as it has no body.
   @interface X
-  - (void)ma; Doesn't match, interface is declaration.
+  - (void)ma; // Doesn't match, interface is declaration.
   @end
   @implementation X
   - (void)ma {}
   @end
 
-Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
-  Matcher<ObjCMethodDecl>
+Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>,
+  Matcher<ObjCMethodDecl>
 
-Matcher<VarDecl>isExceptionVariable +Matcher<VarDecl>isExceptionVariable
Matches a variable declaration that is an exception variable from
 a C++ catch block, or an Objective-C statement.
 
@@ -3944,7 +4142,7 @@ void f(int y) {
 
-Matcher<VarDecl>isExplicitTemplateSpecialization +Matcher<VarDecl>isExplicitTemplateSpecialization
Matches explicit template specializations of function, class, or
 static member variable template instantiations.
 
@@ -3954,11 +4152,11 @@ Given
 functionDecl(isExplicitTemplateSpecialization())
   matches the specialization A<int>().
 
-Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
+Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
 
-Matcher<VarDecl>isExternC +Matcher<VarDecl>isExternC
Matches extern "C" function or variable declarations.
 
 Given:
@@ -3975,8 +4173,20 @@ varDecl(isExternC())
 
-Matcher<VarDecl>isStaticStorageClass -
Matches variablefunction declarations that have "static" storage
+Matcher<VarDecl>isStaticLocal
+
Matches a static variable with local scope.
+
+Example matches y (matcher = varDecl(isStaticLocal()))
+void f() {
+  int x;
+  static int y;
+}
+static int z;
+
+ + +Matcher<VarDecl>isStaticStorageClass +
Matches variable/function declarations that have "static" storage
 class specifier ("static" keyword) written in the source.
 
 Given:
@@ -3991,7 +4201,7 @@ varDecl(isStaticStorageClass())
 
-Matcher<VarDecl>isTemplateInstantiation +Matcher<VarDecl>isTemplateInstantiation
Matches template instantiations of function, class, or static
 member variable template instantiations.
 
@@ -4010,11 +4220,11 @@ But given
 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
   does not match, as X<A> is an explicit template specialization.
 
-Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
+Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>
 
-Matcher<internal::Matcher<Decl>>isInstantiated +Matcher<internal::Matcher<Decl>>isInstantiated
Matches declarations that are template instantiations or are inside
 template instantiations.
 
@@ -4027,14 +4237,14 @@ functionDecl(isInstantiated())
 
-Matcher<internal::Matcher<Expr>>nullPointerConstant +Matcher<internal::Matcher<Expr>>nullPointerConstant
Matches expressions that resolve to a null pointer constant, such as
 GNU's __null, C++11's nullptr, or C's NULL macro.
 
 Given:
   void *v1 = NULL;
   void *v2 = nullptr;
-  void *v3 = __null; GNU extension
+  void *v3 = __null; // GNU extension
   char *cp = (char *)0;
   int *ip = 0;
   int i = 0;
@@ -4044,7 +4254,7 @@ expr(nullPointerConstant())
 
-Matcher<internal::Matcher<NamedDecl>>hasAnyNameStringRef, ..., StringRef +Matcher<internal::Matcher<NamedDecl>>hasAnyNameStringRef, ..., StringRef
Matches NamedDecl nodes that have any of the specified names.
 
 This matcher is only provided as a performance optimization of hasName.
@@ -4054,7 +4264,7 @@ This matcher is only provided as a performance optimization of hasName.
 
-Matcher<internal::Matcher<ObjCMessageExpr>>hasAnySelectorStringRef, ..., StringRef +Matcher<internal::Matcher<ObjCMessageExpr>>hasAnySelectorStringRef, ..., StringRef
Matches when at least one of the supplied string equals to the
 Selector.getAsString()
 
@@ -4065,7 +4275,7 @@ Selector.getAsString()
 
-Matcher<internal::Matcher<Stmt>>isInTemplateInstantiation +Matcher<internal::Matcher<Stmt>>isInTemplateInstantiation
Matches statements inside of a template instantiation.
 
 Given
@@ -4124,8 +4334,8 @@ provided matcher.
 Example matches X, A, A::X, B, B::C, B::C::X
   (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
   class X {};
-  class A { class X {}; };  Matches A, because A::X is a class of name
-                            X inside A.
+  class A { class X {}; };  // Matches A, because A::X is a class of name
+                            // X inside A.
   class B { class C { class X {}; }; };
 
 DescendantT must be an AST base type.
@@ -4151,9 +4361,9 @@ provided matcher.
 Example matches X, Y, Y::X, Z::Y, Z::Y::X
   (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
   class X {};
-  class Y { class X {}; };  Matches Y, because Y::X is a class of name X
-                            inside Y.
-  class Z { class Y { class X {}; }; };  Does not match Z.
+  class Y { class X {}; };  // Matches Y, because Y::X is a class of name X
+                            // inside Y.
+  class Z { class Y { class X {}; }; };  // Does not match Z.
 
 ChildT must be an AST base type.
 
@@ -4183,7 +4393,7 @@ provided matcher.
 
 Example matches X, Y, Z
     (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
-  class X {};  Matches X, because X::X is a class of name X inside X.
+  class X {};  // Matches X, because X::X is a class of name X inside X.
   class Y { class X {}; };
   class Z { class Y { class X {}; }; };
 
@@ -4199,9 +4409,9 @@ provided matcher.
 
 Example matches X, Y
   (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
-  class X {};  Matches X, because X::X is a class of name X inside X.
+  class X {};  // Matches X, because X::X is a class of name X inside X.
   class Y { class X {}; };
-  class Z { class Y { class X {}; }; };  Does not match Z.
+  class Z { class Y { class X {}; }; };  // Does not match Z.
 
 ChildT must be an AST base type.
 
@@ -4225,7 +4435,7 @@ Usable as: Any Matcher
 
-Matcher<AbstractConditionalOperator>hasConditionMatcher<Expr> InnerMatcher +Matcher<AbstractConditionalOperator>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
 switch statement or conditional operator.
 
@@ -4234,7 +4444,7 @@ Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
 
-Matcher<AbstractConditionalOperator>hasFalseExpressionMatcher<Expr> InnerMatcher +Matcher<AbstractConditionalOperator>hasFalseExpressionMatcher<Expr> InnerMatcher
Matches the false branch expression of a conditional operator
 (binary or ternary).
 
@@ -4244,7 +4454,7 @@ Example matches b
 
-Matcher<AbstractConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher +Matcher<AbstractConditionalOperator>hasTrueExpressionMatcher<Expr> InnerMatcher
Matches the true branch expression of a conditional operator.
 
 Example 1 (conditional ternary operator): matches a
@@ -4255,7 +4465,7 @@ Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
 
-Matcher<AddrLabelExpr>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<AddrLabelExpr>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -4279,17 +4489,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<ArraySubscriptExpr>hasBaseMatcher<Expr> InnerMatcher +Matcher<ArraySubscriptExpr>hasBaseMatcher<Expr> InnerMatcher
Matches the base expression of an array subscript expression.
 
 Given
@@ -4301,7 +4511,7 @@ arraySubscriptExpression(hasBase(implicitCastExpr(
 
-Matcher<ArraySubscriptExpr>hasIndexMatcher<Expr> InnerMatcher +Matcher<ArraySubscriptExpr>hasIndexMatcher<Expr> InnerMatcher
Matches the index expression of an array subscript expression.
 
 Given
@@ -4312,7 +4522,7 @@ arraySubscriptExpression(hasIndex(integerLiteral()))
 
-Matcher<ArraySubscriptExpr>hasLHSMatcher<Expr> InnerMatcher +Matcher<ArraySubscriptExpr>hasLHSMatcher<Expr> InnerMatcher
Matches the left hand side of binary operator expressions.
 
 Example matches a (matcher = binaryOperator(hasLHS()))
@@ -4320,7 +4530,7 @@ Example matches a (matcher = binaryOperator(hasLHS()))
 
-Matcher<ArraySubscriptExpr>hasRHSMatcher<Expr> InnerMatcher +Matcher<ArraySubscriptExpr>hasRHSMatcher<Expr> InnerMatcher
Matches the right hand side of binary operator expressions.
 
 Example matches b (matcher = binaryOperator(hasRHS()))
@@ -4328,22 +4538,7 @@ Example matches b (matcher = binaryOperator(hasRHS()))
 
-Matcher<ArrayTypeLoc>hasElementTypeLocMatcher<TypeLoc> -
Matches arrays and C99 complex types that have a specific element
-type.
-
-Given
-  struct A {};
-  A a[7];
-  int b[7];
-arrayType(hasElementType(builtinType()))
-  matches "int b[7]"
-
-Usable as: Matcher<ArrayType>, Matcher<ComplexType>
-
- - -Matcher<ArrayType>hasElementTypeMatcher<Type> +Matcher<ArrayType>hasElementTypeMatcher<Type>
Matches arrays and C99 complex types that have a specific element
 type.
 
@@ -4354,24 +4549,11 @@ Given
 arrayType(hasElementType(builtinType()))
   matches "int b[7]"
 
-Usable as: Matcher<ArrayType>, Matcher<ComplexType>
+Usable as: Matcher<ArrayType>, Matcher<ComplexType>
 
-Matcher<AtomicTypeLoc>hasValueTypeLocMatcher<TypeLoc> -
Matches atomic types with a specific value type.
-
-Given
-  _Atomic(int) i;
-  _Atomic(float) f;
-atomicType(hasValueType(isInteger()))
- matches "_Atomic(int) i"
-
-Usable as: Matcher<AtomicType>
-
- - -Matcher<AtomicType>hasValueTypeMatcher<Type> +Matcher<AtomicType>hasValueTypeMatcher<Type>
Matches atomic types with a specific value type.
 
 Given
@@ -4380,11 +4562,11 @@ Given
 atomicType(hasValueType(isInteger()))
  matches "_Atomic(int) i"
 
-Usable as: Matcher<AtomicType>
+Usable as: Matcher<AtomicType>
 
-Matcher<AutoType>hasDeducedTypeMatcher<Type> +Matcher<AutoType>hasDeducedTypeMatcher<Type>
Matches AutoType nodes where the deduced type is a specific type.
 
 Note: There is no TypeLoc for the deduced type and thus no
@@ -4396,17 +4578,17 @@ Given
 autoType(hasDeducedType(isInteger()))
   matches "auto a"
 
-Usable as: Matcher<AutoType>
+Usable as: Matcher<AutoType>
 
-Matcher<BinaryOperator>hasEitherOperandconst Matcher<Expr> InnerMatcher +Matcher<BinaryOperator>hasEitherOperandconst Matcher<Expr> InnerMatcher
Matches if either the left hand side or the right hand side of a
 binary operator matches.
 
-Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher +Matcher<BinaryOperator>hasLHSMatcher<Expr> InnerMatcher
Matches the left hand side of binary operator expressions.
 
 Example matches a (matcher = binaryOperator(hasLHS()))
@@ -4414,7 +4596,7 @@ Example matches a (matcher = binaryOperator(hasLHS()))
 
-Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher +Matcher<BinaryOperator>hasRHSMatcher<Expr> InnerMatcher
Matches the right hand side of binary operator expressions.
 
 Example matches b (matcher = binaryOperator(hasRHS()))
@@ -4422,7 +4604,7 @@ Example matches b (matcher = binaryOperator(hasRHS()))
 
-Matcher<BlockDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher +Matcher<BlockDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
 block.
 
@@ -4451,7 +4633,7 @@ matching y.
 
-Matcher<BlockDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher +Matcher<BlockDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
 declaration or a block.
 
@@ -4471,23 +4653,7 @@ matching y.
 
-Matcher<BlockPointerTypeLoc>pointeeLocMatcher<TypeLoc> -
Narrows PointerType (and similar) matchers to those where the
-pointee matches a given matcher.
-
-Given
-  int *a;
-  int const *b;
-  float const *f;
-pointerType(pointee(isConstQualified(), isInteger()))
-  matches "int const *b"
-
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
-
- - -Matcher<BlockPointerType>pointeeMatcher<Type> +Matcher<BlockPointerType>pointeeMatcher<Type>
Narrows PointerType (and similar) matchers to those where the
 pointee matches a given matcher.
 
@@ -4498,12 +4664,12 @@ Given
 pointerType(pointee(isConstQualified(), isInteger()))
   matches "int const *b"
 
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
+Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
+  Matcher<PointerType>, Matcher<ReferenceType>
 
-Matcher<CXXConstructExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher +Matcher<CXXConstructExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher
Matches all arguments and their respective ParmVarDecl.
 
 Given
@@ -4523,7 +4689,7 @@ and parmVarDecl(...)
 
-Matcher<CXXConstructExpr>hasAnyArgumentMatcher<Expr> InnerMatcher +Matcher<CXXConstructExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
 expression, or an ObjC-message-send expression.
 
@@ -4542,7 +4708,7 @@ objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
 
-Matcher<CXXConstructExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher +Matcher<CXXConstructExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
Matches the n'th argument of a call expression or a constructor
 call expression.
 
@@ -4552,7 +4718,7 @@ Example matches y in x(y)
 
-Matcher<CXXConstructExpr>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<CXXConstructExpr>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -4576,17 +4742,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<CXXConstructorDecl>forEachConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher +Matcher<CXXConstructorDecl>forEachConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher
Matches each constructor initializer in a constructor definition.
 
 Given
@@ -4598,7 +4764,7 @@ cxxConstructorDecl(forEachConstructorInitializer(
 
-Matcher<CXXConstructorDecl>hasAnyConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher +Matcher<CXXConstructorDecl>hasAnyConstructorInitializerMatcher<CXXCtorInitializer> InnerMatcher
Matches a constructor initializer.
 
 Given
@@ -4613,7 +4779,7 @@ cxxRecordDecl(has(cxxConstructorDecl(
 
-Matcher<CXXCtorInitializer>forFieldMatcher<FieldDecl> InnerMatcher +Matcher<CXXCtorInitializer>forFieldMatcher<FieldDecl> InnerMatcher
Matches the field declaration of a constructor initializer.
 
 Given
@@ -4628,7 +4794,7 @@ with forField matching foo_
 
-Matcher<CXXCtorInitializer>withInitializerMatcher<Expr> InnerMatcher +Matcher<CXXCtorInitializer>withInitializerMatcher<Expr> InnerMatcher
Matches the initializer expression of a constructor initializer.
 
 Given
@@ -4643,7 +4809,21 @@ with withInitializer matching (1)
 
-Matcher<CXXForRangeStmt>hasBodyMatcher<Stmt> InnerMatcher +Matcher<CXXDependentScopeMemberExpr>hasObjectExpressionMatcher<Expr> InnerMatcher +
Matches a member expression where the object expression is
+matched by a given matcher.
+
+Given
+  struct X { int m; };
+  void f(X x) { x.m; m; }
+memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
+  matches "x.m" and "m"
+with hasObjectExpression(...)
+  matching "x" and the implicit object expression of "m" which has type X*.
+
+ + +Matcher<CXXForRangeStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
 
@@ -4656,7 +4836,7 @@ with compoundStmt()
 
-Matcher<CXXForRangeStmt>hasLoopVariableMatcher<VarDecl> InnerMatcher +Matcher<CXXForRangeStmt>hasLoopVariableMatcher<VarDecl> InnerMatcher
Matches the initialization statement of a for loop.
 
 Example:
@@ -4666,7 +4846,7 @@ matches 'int x' in
 
-Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher +Matcher<CXXForRangeStmt>hasRangeInitMatcher<Expr> InnerMatcher
Matches the range initialization statement of a for loop.
 
 Example:
@@ -4676,11 +4856,11 @@ matches 'a' in
 
-Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher +Matcher<CXXMemberCallExpr>onImplicitObjectArgumentMatcher<Expr> InnerMatcher

 
 
-Matcher<CXXMemberCallExpr>onMatcher<Expr> InnerMatcher
+Matcher<CXXMemberCallExpr>onMatcher<Expr> InnerMatcher
 
Matches on the implicit object argument of a member call expression.
 
 Example matches y.x()
@@ -4692,18 +4872,18 @@ FIXME: Overload to allow directly matching types?
 
-Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<Decl> InnerMatcher +Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<Decl> InnerMatcher
Overloaded to match the type's declaration.
 
-Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<QualType> InnerMatcher +Matcher<CXXMemberCallExpr>thisPointerTypeMatcher<QualType> InnerMatcher
Matches if the expression's type either matches the specified
 matcher, or is a pointer to a type that matches the InnerMatcher.
 
-Matcher<CXXMethodDecl>forEachOverriddenMatcher<CXXMethodDecl> InnerMatcher +Matcher<CXXMethodDecl>forEachOverriddenMatcher<CXXMethodDecl> InnerMatcher
Matches each method overridden by the given method. This matcher may
 produce multiple matches.
 
@@ -4727,7 +4907,7 @@ cxxMethodDecl(ofClass(hasName("C")),
 
-Matcher<CXXMethodDecl>ofClassMatcher<CXXRecordDecl> InnerMatcher +Matcher<CXXMethodDecl>ofClassMatcher<CXXRecordDecl> InnerMatcher
Matches the class declaration that the given method declaration
 belongs to.
 
@@ -4746,7 +4926,7 @@ Example matches A() in the last line
 
-Matcher<CXXNewExpr>hasArraySizeMatcher<Expr> InnerMatcher +Matcher<CXXNewExpr>hasArraySizeMatcher<Expr> InnerMatcher
Matches array new expressions with a given array size.
 
 Given:
@@ -4756,7 +4936,7 @@ cxxNewExpr(hasArraySize(intgerLiteral(equals(10))))
 
-Matcher<CXXNewExpr>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<CXXNewExpr>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -4780,17 +4960,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<CXXRecordDecl>hasMethodMatcher<CXXMethodDecl> InnerMatcher +Matcher<CXXRecordDecl>hasMethodMatcher<CXXMethodDecl> InnerMatcher
Matches the first method of a class or struct that satisfies InnerMatcher.
 
 Given:
@@ -4802,7 +4982,7 @@ A but not B.
 
-Matcher<CXXRecordDecl>isDerivedFromMatcher<NamedDecl> Base +Matcher<CXXRecordDecl>isDerivedFromMatcher<NamedDecl> Base
Matches C++ classes that are directly or indirectly derived from
 a class matching Base.
 
@@ -4810,26 +4990,45 @@ Note that a class is not considered to be derived from itself.
 
 Example matches Y, Z, C (Base == hasName("X"))
   class X;
-  class Y : public X {};  directly derived
-  class Z : public Y {};  indirectly derived
+  class Y : public X {};  // directly derived
+  class Z : public Y {};  // indirectly derived
   typedef X A;
   typedef A B;
-  class C : public B {};  derived from a typedef of X
+  class C : public B {};  // derived from a typedef of X
 
 In the following example, Bar matches isDerivedFrom(hasName("X")):
   class Foo;
   typedef Foo X;
-  class Bar : public Foo {};  derived from a type that X is a typedef of
+  class Bar : public Foo {};  // derived from a type that X is a typedef of
 
-Matcher<CXXRecordDecl>isSameOrDerivedFromMatcher<NamedDecl> Base +Matcher<CXXRecordDecl>isSameOrDerivedFromMatcher<NamedDecl> Base
Similar to isDerivedFrom(), but also matches classes that directly
 match Base.
 
-Matcher<CallExpr>calleeMatcher<Decl> InnerMatcher +Matcher<CXXUnresolvedConstructExpr>hasAnyArgumentMatcher<Expr> InnerMatcher +
Matches any argument of a call expression or a constructor call
+expression, or an ObjC-message-send expression.
+
+Given
+  void x(int, int, int) { int y; x(1, y, 42); }
+callExpr(hasAnyArgument(declRefExpr()))
+  matches x(1, y, 42)
+with hasAnyArgument(...)
+  matching y
+
+For ObjectiveC, given
+  @interface I - (void) f:(int) y; @end
+  void foo(I *i) { [i f:12]; }
+objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
+  matches [i f:12]
+
+ + +Matcher<CallExpr>calleeMatcher<Decl> InnerMatcher
Matches if the call expression's callee's declaration matches the
 given matcher.
 
@@ -4840,7 +5039,7 @@ Example matches y.x() (matcher = callExpr(callee(
 
-Matcher<CallExpr>calleeMatcher<Stmt> InnerMatcher +Matcher<CallExpr>calleeMatcher<Stmt> InnerMatcher
Matches if the call expression's callee expression matches.
 
 Given
@@ -4851,14 +5050,14 @@ callExpr(callee(expr()))
 with callee(...)
   matching this->x, x, y.x, f respectively
 
-Note: Callee cannot take the more general internal::Matcher<Expr>
+Note: Callee cannot take the more general internal::Matcher<Expr>
 because this introduces ambiguous overloads with calls to Callee taking a
-internal::Matcher<Decl>, as the matcher hierarchy is purely
+internal::Matcher<Decl>, as the matcher hierarchy is purely
 implemented in terms of implicit casts.
 
-Matcher<CallExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher +Matcher<CallExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher
Matches all arguments and their respective ParmVarDecl.
 
 Given
@@ -4878,7 +5077,7 @@ and parmVarDecl(...)
 
-Matcher<CallExpr>hasAnyArgumentMatcher<Expr> InnerMatcher +Matcher<CallExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
 expression, or an ObjC-message-send expression.
 
@@ -4897,7 +5096,7 @@ objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
 
-Matcher<CallExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher +Matcher<CallExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
Matches the n'th argument of a call expression or a constructor
 call expression.
 
@@ -4907,7 +5106,7 @@ Example matches y in x(y)
 
-Matcher<CallExpr>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<CallExpr>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -4931,17 +5130,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<CaseStmt>hasCaseConstantMatcher<Expr> InnerMatcher +Matcher<CaseStmt>hasCaseConstantMatcher<Expr> InnerMatcher
If the given case statement does not use the GNU case range
 extension, matches the constant given in the statement.
 
@@ -4952,7 +5151,7 @@ caseStmt(hasCaseConstant(integerLiteral()))
 
-Matcher<CastExpr>hasSourceExpressionMatcher<Expr> InnerMatcher +Matcher<CastExpr>hasSourceExpressionMatcher<Expr> InnerMatcher
Matches if the cast's source expression
 or opaque value's source expression matches the given matcher.
 
@@ -4967,7 +5166,7 @@ int a = b ?: 1;
 
-Matcher<ClassTemplateSpecializationDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher +Matcher<ClassTemplateSpecializationDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
 functionDecl that have at least one TemplateArgument matching the given
 InnerMatcher.
@@ -4989,19 +5188,19 @@ functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
 
-Matcher<ClassTemplateSpecializationDecl>hasSpecializedTemplateMatcher<ClassTemplateDecl> InnerMatcher +Matcher<ClassTemplateSpecializationDecl>hasSpecializedTemplateMatcher<ClassTemplateDecl> InnerMatcher
Matches the specialized template of a specialization declaration.
 
 Given
-  tempalate<typename T> class A {};
-  typedef A<int> B;
+  template<typename T> class A {}; #1
+  template<> class A<int> {}; #2
 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
-  matches 'B' with classTemplateDecl() matching the class template
-  declaration of 'A'.
+  matches '#2' with classTemplateDecl() matching the class template
+  declaration of 'A' at #1.
 
-Matcher<ClassTemplateSpecializationDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher +Matcher<ClassTemplateSpecializationDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
 
@@ -5021,22 +5220,7 @@ functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
 
-Matcher<ComplexTypeLoc>hasElementTypeLocMatcher<TypeLoc> -
Matches arrays and C99 complex types that have a specific element
-type.
-
-Given
-  struct A {};
-  A a[7];
-  int b[7];
-arrayType(hasElementType(builtinType()))
-  matches "int b[7]"
-
-Usable as: Matcher<ArrayType>, Matcher<ComplexType>
-
- - -Matcher<ComplexType>hasElementTypeMatcher<Type> +Matcher<ComplexType>hasElementTypeMatcher<Type>
Matches arrays and C99 complex types that have a specific element
 type.
 
@@ -5047,11 +5231,11 @@ Given
 arrayType(hasElementType(builtinType()))
   matches "int b[7]"
 
-Usable as: Matcher<ArrayType>, Matcher<ComplexType>
+Usable as: Matcher<ArrayType>, Matcher<ComplexType>
 
-Matcher<CompoundStmt>hasAnySubstatementMatcher<Stmt> InnerMatcher +Matcher<CompoundStmt>hasAnySubstatementMatcher<Stmt> InnerMatcher
Matches compound statements where at least one substatement matches
 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
 
@@ -5064,12 +5248,12 @@ with compoundStmt()
 
-Matcher<DecayedType>hasDecayedTypeMatcher<QualType> InnerType +Matcher<DecayedType>hasDecayedTypeMatcher<QualType> InnerType
Matches the decayed type, whos decayed type matches InnerMatcher
 
-Matcher<DeclRefExpr>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<DeclRefExpr>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -5093,17 +5277,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<DeclRefExpr>throughUsingDeclMatcher<UsingShadowDecl> InnerMatcher +Matcher<DeclRefExpr>throughUsingDeclMatcher<UsingShadowDecl> InnerMatcher
Matches a DeclRefExpr that refers to a declaration through a
 specific using shadow declaration.
 
@@ -5111,15 +5295,15 @@ Given
   namespace a { void f() {} }
   using a::f;
   void g() {
-    f();     Matches this ..
-    a::f();  .. but not this.
+    f();     // Matches this ..
+    a::f();  // .. but not this.
   }
 declRefExpr(throughUsingDecl(anything()))
   matches f()
 
-Matcher<DeclRefExpr>toMatcher<Decl> InnerMatcher +Matcher<DeclRefExpr>toMatcher<Decl> InnerMatcher
Matches a DeclRefExpr that refers to a declaration that matches the
 specified matcher.
 
@@ -5130,7 +5314,7 @@ Example matches x in if(x)
 
-Matcher<DeclStmt>containsDeclarationunsigned N, Matcher<Decl> InnerMatcher +Matcher<DeclStmt>containsDeclarationunsigned N, Matcher<Decl> InnerMatcher
Matches the n'th declaration of a declaration statement.
 
 Note that this does not work for global declarations because the AST
@@ -5149,7 +5333,7 @@ declStmt(containsDeclaration(1, varDecl()))
 
-Matcher<DeclStmt>hasSingleDeclMatcher<Decl> InnerMatcher +Matcher<DeclStmt>hasSingleDeclMatcher<Decl> InnerMatcher
Matches the Decl of a DeclStmt which has a single declaration.
 
 Given
@@ -5160,7 +5344,7 @@ declStmt(hasSingleDecl(anything()))
 
-Matcher<DeclaratorDecl>hasTypeLocMatcher<TypeLoc> Inner +Matcher<DeclaratorDecl>hasTypeLocMatcher<TypeLoc> Inner
Matches if the type location of the declarator decl's type matches
 the inner matcher.
 
@@ -5171,7 +5355,7 @@ declaratorDecl(hasTypeLoc(loc(asString("int"))))
 
-Matcher<Decl>hasDeclContextMatcher<Decl> InnerMatcher +Matcher<Decl>hasDeclContextMatcher<Decl> InnerMatcher
Matches declarations whose declaration context, interpreted as a
 Decl, matches InnerMatcher.
 
@@ -5187,20 +5371,20 @@ declaration of class D.
 
-Matcher<DecltypeType>hasUnderlyingTypeMatcher<Type> +Matcher<DecltypeType>hasUnderlyingTypeMatcher<Type>
Matches DecltypeType nodes to find out the underlying type.
 
 Given
   decltype(1) a = 1;
   decltype(2.0) b = 2.0;
 decltypeType(hasUnderlyingType(isInteger()))
-  matches "auto a"
+  matches the type of "a"
 
-Usable as: Matcher<DecltypeType>
+Usable as: Matcher<DecltypeType>
 
-Matcher<DoStmt>hasBodyMatcher<Stmt> InnerMatcher +Matcher<DoStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
 
@@ -5213,7 +5397,7 @@ with compoundStmt()
 
-Matcher<DoStmt>hasConditionMatcher<Expr> InnerMatcher +Matcher<DoStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
 switch statement or conditional operator.
 
@@ -5222,7 +5406,7 @@ Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
 
-Matcher<ElaboratedType>hasQualifierMatcher<NestedNameSpecifier> InnerMatcher +Matcher<ElaboratedType>hasQualifierMatcher<NestedNameSpecifier> InnerMatcher
Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
 matches InnerMatcher if the qualifier exists.
 
@@ -5239,7 +5423,7 @@ matches the type of the variable declaration of d.
 
-Matcher<ElaboratedType>namesTypeMatcher<QualType> InnerMatcher +Matcher<ElaboratedType>namesTypeMatcher<QualType> InnerMatcher
Matches ElaboratedTypes whose named type matches InnerMatcher.
 
 Given
@@ -5256,7 +5440,7 @@ declaration of d.
 
-Matcher<EnumType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<EnumType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -5280,17 +5464,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<ExplicitCastExpr>hasDestinationTypeMatcher<QualType> InnerMatcher +Matcher<ExplicitCastExpr>hasDestinationTypeMatcher<QualType> InnerMatcher
Matches casts whose destination type matches a given matcher.
 
 (Note: Clang's AST refers to other conversions as "casts" too, and calls
@@ -5298,7 +5482,7 @@ actual casts "explicit" casts.)
 
-Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher +Matcher<Expr>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
 declaration's type.
 
@@ -5315,11 +5499,11 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
  void y(X &x) { x; X z; }
  class Y { friend class X; };
 
-Usable as: Matcher<Expr>, Matcher<ValueDecl>
+Usable as: Matcher<Expr>, Matcher<ValueDecl>
 
-Matcher<Expr>hasTypeMatcher<QualType> InnerMatcher +Matcher<Expr>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
 matcher.
 
@@ -5334,7 +5518,7 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
 
-Matcher<Expr>ignoringImpCastsMatcher<Expr> InnerMatcher +Matcher<Expr>ignoringImpCastsMatcher<Expr> InnerMatcher
Matches expressions that match InnerMatcher after any implicit casts
 are stripped off.
 
@@ -5357,7 +5541,7 @@ only match the declarations for b, c, and d.
 
-Matcher<Expr>ignoringImplicitMatcher<Expr> InnerMatcher +Matcher<Expr>ignoringImplicitMatcher<Expr> InnerMatcher
Matches expressions that match InnerMatcher after any implicit AST
 nodes are stripped off.
 
@@ -5376,7 +5560,7 @@ only match the declarations for b and c.
 
-Matcher<Expr>ignoringParenCastsMatcher<Expr> InnerMatcher +Matcher<Expr>ignoringParenCastsMatcher<Expr> InnerMatcher
Matches expressions that match InnerMatcher after parentheses and
 casts are stripped off.
 
@@ -5395,7 +5579,7 @@ only match the declaration for a.
 
-Matcher<Expr>ignoringParenImpCastsMatcher<Expr> InnerMatcher +Matcher<Expr>ignoringParenImpCastsMatcher<Expr> InnerMatcher
Matches expressions that match InnerMatcher after implicit casts and
 parentheses are stripped off.
 
@@ -5418,7 +5602,18 @@ would only match the declaration for a.
 
-Matcher<FieldDecl>hasInClassInitializerMatcher<Expr> InnerMatcher +Matcher<Expr>ignoringParensMatcher<Expr> InnerMatcher +
Overload ignoringParens for Expr.
+
+Given
+  const char* str = ("my-string");
+The matcher
+  implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
+would match the implicit cast resulting from the assignment.
+
+ + +Matcher<FieldDecl>hasInClassInitializerMatcher<Expr> InnerMatcher
Matches non-static data members that have an in-class initializer.
 
 Given
@@ -5434,7 +5629,7 @@ fieldDecl(hasInClassInitializer(anything()))
 
-Matcher<ForStmt>hasBodyMatcher<Stmt> InnerMatcher +Matcher<ForStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
 
@@ -5447,7 +5642,7 @@ with compoundStmt()
 
-Matcher<ForStmt>hasConditionMatcher<Expr> InnerMatcher +Matcher<ForStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
 switch statement or conditional operator.
 
@@ -5456,7 +5651,7 @@ Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
 
-Matcher<ForStmt>hasIncrementMatcher<Stmt> InnerMatcher +Matcher<ForStmt>hasIncrementMatcher<Stmt> InnerMatcher
Matches the increment statement of a for loop.
 
 Example:
@@ -5466,7 +5661,7 @@ matches '++x' in
 
-Matcher<ForStmt>hasLoopInitMatcher<Stmt> InnerMatcher +Matcher<ForStmt>hasLoopInitMatcher<Stmt> InnerMatcher
Matches the initialization statement of a for loop.
 
 Example:
@@ -5476,7 +5671,7 @@ matches 'int x = 0' in
 
-Matcher<FriendDecl>hasTypeMatcher<Decl> InnerMatcher +Matcher<FriendDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
 declaration's type.
 
@@ -5493,11 +5688,11 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
  void y(X &x) { x; X z; }
  class Y { friend class X; };
 
-Usable as: Matcher<Expr>, Matcher<ValueDecl>
+Usable as: Matcher<Expr>, Matcher<ValueDecl>
 
-Matcher<FriendDecl>hasTypeMatcher<QualType> InnerMatcher +Matcher<FriendDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
 matcher.
 
@@ -5512,7 +5707,7 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
 
-Matcher<FunctionDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher +Matcher<FunctionDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
 block.
 
@@ -5541,7 +5736,7 @@ matching y.
 
-Matcher<FunctionDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher +Matcher<FunctionDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
 functionDecl that have at least one TemplateArgument matching the given
 InnerMatcher.
@@ -5563,7 +5758,7 @@ functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
 
-Matcher<FunctionDecl>hasBodyMatcher<Stmt> InnerMatcher +Matcher<FunctionDecl>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
 
@@ -5576,7 +5771,7 @@ with compoundStmt()
 
-Matcher<FunctionDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher +Matcher<FunctionDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
 declaration or a block.
 
@@ -5596,7 +5791,7 @@ matching y.
 
-Matcher<FunctionDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher +Matcher<FunctionDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
 
@@ -5616,7 +5811,7 @@ functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
 
-Matcher<FunctionDecl>returnsMatcher<QualType> InnerMatcher +Matcher<FunctionDecl>returnsMatcher<QualType> InnerMatcher
Matches the return type of a function declaration.
 
 Given:
@@ -5626,7 +5821,7 @@ cxxMethodDecl(returns(asString("int")))
 
-Matcher<IfStmt>hasConditionMatcher<Expr> InnerMatcher +Matcher<IfStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
 switch statement or conditional operator.
 
@@ -5635,7 +5830,7 @@ Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
 
-Matcher<IfStmt>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher +Matcher<IfStmt>hasConditionVariableStatementMatcher<DeclStmt> InnerMatcher
Matches the condition variable statement in an if statement.
 
 Given
@@ -5645,7 +5840,7 @@ hasConditionVariableStatement(...)
 
-Matcher<IfStmt>hasElseMatcher<Stmt> InnerMatcher +Matcher<IfStmt>hasElseMatcher<Stmt> InnerMatcher
Matches the else-statement of an if statement.
 
 Examples matches the if statement
@@ -5654,7 +5849,7 @@ Examples matches the if statement
 
-Matcher<IfStmt>hasThenMatcher<Stmt> InnerMatcher +Matcher<IfStmt>hasThenMatcher<Stmt> InnerMatcher
Matches the then-statement of an if statement.
 
 Examples matches the if statement
@@ -5663,7 +5858,7 @@ Examples matches the if statement
 
-Matcher<ImplicitCastExpr>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher +Matcher<ImplicitCastExpr>hasImplicitDestinationTypeMatcher<QualType> InnerMatcher
Matches implicit casts whose destination type matches a given
 matcher.
 
@@ -5671,13 +5866,22 @@ FIXME: Unit test this matcher
 
-Matcher<InitListExpr>hasSyntacticFormMatcher<Expr> InnerMatcher +Matcher<InitListExpr>hasInitunsigned N, ast_matchers::Matcher<Expr> InnerMatcher +
Matches the n'th item of an initializer list expression.
+
+Example matches y.
+    (matcher = initListExpr(hasInit(0, expr())))
+  int x{y}.
+
+ + +Matcher<InitListExpr>hasSyntacticFormMatcher<Expr> InnerMatcher
Matches the syntactic form of init list expressions
 (if expression have it).
 
-Matcher<InjectedClassNameType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<InjectedClassNameType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -5701,17 +5905,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<LabelStmt>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<LabelStmt>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -5735,17 +5939,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<MemberExpr>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<MemberExpr>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -5769,17 +5973,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<MemberExpr>hasObjectExpressionMatcher<Expr> InnerMatcher +Matcher<MemberExpr>hasObjectExpressionMatcher<Expr> InnerMatcher
Matches a member expression where the object expression is
 matched by a given matcher.
 
@@ -5793,7 +5997,7 @@ with hasObjectExpression(...)
 
-Matcher<MemberExpr>memberMatcher<ValueDecl> InnerMatcher +Matcher<MemberExpr>memberMatcher<ValueDecl> InnerMatcher
Matches a member expression where the member is matched by a
 given matcher.
 
@@ -5807,23 +6011,7 @@ memberExpr(member(hasName("first")))
 
-Matcher<MemberPointerTypeLoc>pointeeLocMatcher<TypeLoc> -
Narrows PointerType (and similar) matchers to those where the
-pointee matches a given matcher.
-
-Given
-  int *a;
-  int const *b;
-  float const *f;
-pointerType(pointee(isConstQualified(), isInteger()))
-  matches "int const *b"
-
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
-
- - -Matcher<MemberPointerType>pointeeMatcher<Type> +Matcher<MemberPointerType>pointeeMatcher<Type>
Narrows PointerType (and similar) matchers to those where the
 pointee matches a given matcher.
 
@@ -5834,12 +6022,12 @@ Given
 pointerType(pointee(isConstQualified(), isInteger()))
   matches "int const *b"
 
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
+Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
+  Matcher<PointerType>, Matcher<ReferenceType>
 
-Matcher<NamedDecl>hasUnderlyingDeclMatcher<NamedDecl> InnerMatcher +Matcher<NamedDecl>hasUnderlyingDeclMatcher<NamedDecl> InnerMatcher
Matches a NamedDecl whose underlying declaration matches the given
 matcher.
 
@@ -5852,7 +6040,7 @@ unresolvedLookupExpr(hasAnyDeclaration(
 
-Matcher<NestedNameSpecifierLoc>hasPrefixMatcher<NestedNameSpecifierLoc> InnerMatcher +Matcher<NestedNameSpecifierLoc>hasPrefixMatcher<NestedNameSpecifierLoc> InnerMatcher
Matches on the prefix of a NestedNameSpecifierLoc.
 
 Given
@@ -5863,7 +6051,7 @@ nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
 
-Matcher<NestedNameSpecifierLoc>specifiesTypeLocMatcher<TypeLoc> InnerMatcher +Matcher<NestedNameSpecifierLoc>specifiesTypeLocMatcher<TypeLoc> InnerMatcher
Matches nested name specifier locs that specify a type matching the
 given TypeLoc.
 
@@ -5876,7 +6064,7 @@ nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
 
-Matcher<NestedNameSpecifier>hasPrefixMatcher<NestedNameSpecifier> InnerMatcher +Matcher<NestedNameSpecifier>hasPrefixMatcher<NestedNameSpecifier> InnerMatcher
Matches on the prefix of a NestedNameSpecifier.
 
 Given
@@ -5887,7 +6075,7 @@ nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
 
-Matcher<NestedNameSpecifier>specifiesNamespaceMatcher<NamespaceDecl> InnerMatcher +Matcher<NestedNameSpecifier>specifiesNamespaceMatcher<NamespaceDecl> InnerMatcher
Matches nested name specifiers that specify a namespace matching the
 given namespace matcher.
 
@@ -5899,7 +6087,7 @@ nestedNameSpecifier(specifiesNamespace(hasName("ns")))
 
-Matcher<NestedNameSpecifier>specifiesTypeMatcher<QualType> InnerMatcher +Matcher<NestedNameSpecifier>specifiesTypeMatcher<QualType> InnerMatcher
Matches nested name specifiers that specify a type matching the
 given QualType matcher without qualifiers.
 
@@ -5913,8 +6101,8 @@ nestedNameSpecifier(specifiesType(
 
-Matcher<ObjCMessageExpr>hasAnyArgumentMatcher<Expr> InnerMatcher -
Matches any argument of a call expression or a constructor call
+Matcher<ObjCMessageExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
+
Matches any argument of a call expression or a constructor call
 expression, or an ObjC-message-send expression.
 
 Given
@@ -5932,7 +6120,7 @@ objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
 
-Matcher<ObjCMessageExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher +Matcher<ObjCMessageExpr>hasArgumentunsigned N, Matcher<Expr> InnerMatcher
Matches the n'th argument of a call expression or a constructor
 call expression.
 
@@ -5942,7 +6130,7 @@ Example matches y in x(y)
 
-Matcher<ObjCMessageExpr>hasReceiverMatcher<Expr> InnerMatcher +Matcher<ObjCMessageExpr>hasReceiverMatcher<Expr> InnerMatcher
Matches if the Objective-C message is sent to an instance,
 and the inner matcher matches on that instance.
 
@@ -5954,7 +6142,7 @@ objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
 
-Matcher<ObjCMessageExpr>hasReceiverTypeMatcher<QualType> InnerMatcher +Matcher<ObjCMessageExpr>hasReceiverTypeMatcher<QualType> InnerMatcher
Matches on the receiver of an ObjectiveC Message expression.
 
 Example
@@ -5966,7 +6154,7 @@ matches the [webView ...] message invocation.
 
-Matcher<ObjCMethodDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher +Matcher<ObjCMethodDecl>hasAnyParameterMatcher<ParmVarDecl> InnerMatcher
Matches any parameter of a function or an ObjC method declaration or a
 block.
 
@@ -5995,7 +6183,7 @@ matching y.
 
-Matcher<ObjCMethodDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher +Matcher<ObjCMethodDecl>hasParameterunsigned N, Matcher<ParmVarDecl> InnerMatcher
Matches the n'th parameter of a function or an ObjC method
 declaration or a block.
 
@@ -6015,7 +6203,7 @@ matching y.
 
-Matcher<OpaqueValueExpr>hasSourceExpressionMatcher<Expr> InnerMatcher +Matcher<OpaqueValueExpr>hasSourceExpressionMatcher<Expr> InnerMatcher
Matches if the cast's source expression
 or opaque value's source expression matches the given matcher.
 
@@ -6030,7 +6218,7 @@ int a = b ?: 1;
 
-Matcher<OverloadExpr>hasAnyDeclarationMatcher<Decl> InnerMatcher +Matcher<OverloadExpr>hasAnyDeclarationMatcher<Decl> InnerMatcher
Matches an OverloadExpr if any of the declarations in the set of
 overloads matches the given matcher.
 
@@ -6047,7 +6235,7 @@ unresolvedLookupExpr(hasAnyDeclaration(
 
-Matcher<ParenType>innerTypeMatcher<Type> +Matcher<ParenType>innerTypeMatcher<Type>
Matches ParenType nodes where the inner type is a specific type.
 
 Given
@@ -6057,27 +6245,11 @@ Given
 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
 ptr_to_func but not ptr_to_array.
 
-Usable as: Matcher<ParenType>
+Usable as: Matcher<ParenType>
 
-Matcher<PointerTypeLoc>pointeeLocMatcher<TypeLoc> -
Narrows PointerType (and similar) matchers to those where the
-pointee matches a given matcher.
-
-Given
-  int *a;
-  int const *b;
-  float const *f;
-pointerType(pointee(isConstQualified(), isInteger()))
-  matches "int const *b"
-
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
-
- - -Matcher<PointerType>pointeeMatcher<Type> +Matcher<PointerType>pointeeMatcher<Type>
Narrows PointerType (and similar) matchers to those where the
 pointee matches a given matcher.
 
@@ -6088,12 +6260,12 @@ Given
 pointerType(pointee(isConstQualified(), isInteger()))
   matches "int const *b"
 
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
+Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
+  Matcher<PointerType>, Matcher<ReferenceType>
 
-Matcher<QualType>hasCanonicalTypeMatcher<QualType> InnerMatcher +Matcher<QualType>hasCanonicalTypeMatcher<QualType> InnerMatcher
Matches QualTypes whose canonical type matches InnerMatcher.
 
 Given:
@@ -6106,7 +6278,7 @@ declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType()))
 
-Matcher<QualType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<QualType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6130,17 +6302,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<QualType>ignoringParensMatcher<QualType> InnerMatcher +Matcher<QualType>ignoringParensMatcher<QualType> InnerMatcher
Matches types that match InnerMatcher after any parens are stripped.
 
 Given
@@ -6151,12 +6323,12 @@ would match the declaration for fp.
 
-Matcher<QualType>pointsToMatcher<Decl> InnerMatcher +Matcher<QualType>pointsToMatcher<Decl> InnerMatcher
Overloaded to match the pointee type's declaration.
 
-Matcher<QualType>pointsToMatcher<QualType> InnerMatcher +Matcher<QualType>pointsToMatcher<QualType> InnerMatcher
Matches if the matched type is a pointer type and the pointee type
 matches the specified matcher.
 
@@ -6168,12 +6340,12 @@ Example matches y->x()
 
-Matcher<QualType>referencesMatcher<Decl> InnerMatcher +Matcher<QualType>referencesMatcher<Decl> InnerMatcher
Overloaded to match the referenced type's declaration.
 
-Matcher<QualType>referencesMatcher<QualType> InnerMatcher +Matcher<QualType>referencesMatcher<QualType> InnerMatcher
Matches if the matched type is a reference type and the referenced
 type matches the specified matcher.
 
@@ -6188,7 +6360,7 @@ Example matches X &x and const X &y
 
-Matcher<RecordType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<RecordType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6212,33 +6384,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<ReferenceTypeLoc>pointeeLocMatcher<TypeLoc> -
Narrows PointerType (and similar) matchers to those where the
-pointee matches a given matcher.
-
-Given
-  int *a;
-  int const *b;
-  float const *f;
-pointerType(pointee(isConstQualified(), isInteger()))
-  matches "int const *b"
-
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
-
- - -Matcher<ReferenceType>pointeeMatcher<Type> +Matcher<ReferenceType>pointeeMatcher<Type>
Narrows PointerType (and similar) matchers to those where the
 pointee matches a given matcher.
 
@@ -6249,12 +6405,12 @@ Given
 pointerType(pointee(isConstQualified(), isInteger()))
   matches "int const *b"
 
-Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
-  Matcher<PointerType>, Matcher<ReferenceType>
+Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>,
+  Matcher<PointerType>, Matcher<ReferenceType>
 
-Matcher<ReturnStmt>hasReturnValueMatcher<Expr> InnerMatcher +Matcher<ReturnStmt>hasReturnValueMatcher<Expr> InnerMatcher
Matches the return value expression of a return statement
 
 Given
@@ -6266,7 +6422,7 @@ with binaryOperator()
 
-Matcher<StmtExpr>hasAnySubstatementMatcher<Stmt> InnerMatcher +Matcher<StmtExpr>hasAnySubstatementMatcher<Stmt> InnerMatcher
Matches compound statements where at least one substatement matches
 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
 
@@ -6279,13 +6435,13 @@ with compoundStmt()
 
-Matcher<Stmt>alignOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher +Matcher<Stmt>alignOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
 alignof.
 
-Matcher<Stmt>forFunctionMatcher<FunctionDecl> InnerMatcher +Matcher<Stmt>forFunctionMatcher<FunctionDecl> InnerMatcher
Matches declaration of the function the statement belongs to
 
 Given:
@@ -6299,13 +6455,13 @@ returnStmt(forFunction(hasName("operator=")))
 
-Matcher<Stmt>sizeOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher +Matcher<Stmt>sizeOfExprconst Matcher<UnaryExprOrTypeTraitExpr> InnerMatcher
Same as unaryExprOrTypeTraitExpr, but only matching
 sizeof.
 
-Matcher<SubstTemplateTypeParmType>hasReplacementTypeMatcher<Type> +Matcher<SubstTemplateTypeParmType>hasReplacementTypeMatcher<Type>
Matches template type parameter substitutions that have a replacement
 type that matches the provided matcher.
 
@@ -6319,7 +6475,7 @@ substTemplateTypeParmType(hasReplacementType(type())) matches int
 
-Matcher<SwitchStmt>forEachSwitchCaseMatcher<SwitchCase> InnerMatcher +Matcher<SwitchStmt>forEachSwitchCaseMatcher<SwitchCase> InnerMatcher
Matches each case or default statement belonging to the given switch
 statement. This matcher may produce multiple matches.
 
@@ -6332,7 +6488,7 @@ switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
 
-Matcher<SwitchStmt>hasConditionMatcher<Expr> InnerMatcher +Matcher<SwitchStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
 switch statement or conditional operator.
 
@@ -6341,7 +6497,7 @@ Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
 
-Matcher<TagType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<TagType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6365,17 +6521,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<TemplateArgument>isExprMatcher<Expr> InnerMatcher +Matcher<TemplateArgument>isExprMatcher<Expr> InnerMatcher
Matches a sugar TemplateArgument that refers to a certain expression.
 
 Given
@@ -6389,7 +6545,7 @@ templateSpecializationType(hasAnyTemplateArgument(
 
-Matcher<TemplateArgument>refersToDeclarationMatcher<Decl> InnerMatcher +Matcher<TemplateArgument>refersToDeclarationMatcher<Decl> InnerMatcher
Matches a canonical TemplateArgument that refers to a certain
 declaration.
 
@@ -6404,7 +6560,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(
 
-Matcher<TemplateArgument>refersToIntegralTypeMatcher<QualType> InnerMatcher +Matcher<TemplateArgument>refersToIntegralTypeMatcher<QualType> InnerMatcher
Matches a TemplateArgument that referes to an integral type.
 
 Given
@@ -6416,12 +6572,12 @@ classTemplateSpecializationDecl(
 
-Matcher<TemplateArgument>refersToTemplateMatcher<TemplateName> InnerMatcher +Matcher<TemplateArgument>refersToTemplateMatcher<TemplateName> InnerMatcher
Matches a TemplateArgument that refers to a certain template.
 
 Given
   template<template <typename> class S> class X {};
-  template<typename T> class Y {};"
+  template<typename T> class Y {};
   X<Y> xi;
 classTemplateSpecializationDecl(hasAnyTemplateArgument(
     refersToTemplate(templateName())))
@@ -6429,7 +6585,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(
 
-Matcher<TemplateArgument>refersToTypeMatcher<QualType> InnerMatcher +Matcher<TemplateArgument>refersToTypeMatcher<QualType> InnerMatcher
Matches a TemplateArgument that refers to a certain type.
 
 Given
@@ -6442,7 +6598,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(
 
-Matcher<TemplateSpecializationType>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher +Matcher<TemplateSpecializationType>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
 functionDecl that have at least one TemplateArgument matching the given
 InnerMatcher.
@@ -6464,7 +6620,7 @@ functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
 
-Matcher<TemplateSpecializationType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<TemplateSpecializationType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6488,17 +6644,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<TemplateSpecializationType>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher +Matcher<TemplateSpecializationType>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher
Matches classTemplateSpecializations, templateSpecializationType and
 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
 
@@ -6518,7 +6674,7 @@ functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
 
-Matcher<TemplateTypeParmType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<TemplateTypeParmType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6542,13 +6698,13 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
@@ -6568,7 +6724,7 @@ Usable as: Any Matcher
-Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher +Matcher<TypedefNameDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
 matcher.
 
@@ -6583,7 +6739,7 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
 
-Matcher<TypedefType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<TypedefType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6607,17 +6763,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<Type>hasUnqualifiedDesugaredTypeMatcher<Type> InnerMatcher +Matcher<Type>hasUnqualifiedDesugaredTypeMatcher<Type> InnerMatcher
Matches if the matched type matches the unqualified desugared
 type of the matched node.
 
@@ -6629,7 +6785,7 @@ both B and A.
 
-Matcher<UnaryExprOrTypeTraitExpr>hasArgumentOfTypeMatcher<QualType> InnerMatcher +Matcher<UnaryExprOrTypeTraitExpr>hasArgumentOfTypeMatcher<QualType> InnerMatcher
Matches unary expressions that have a specific type of argument.
 
 Given
@@ -6639,7 +6795,7 @@ unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
 
-Matcher<UnaryOperator>hasUnaryOperandMatcher<Expr> InnerMatcher +Matcher<UnaryOperator>hasUnaryOperandMatcher<Expr> InnerMatcher
Matches if the operand of a unary operator matches.
 
 Example matches true (matcher = hasUnaryOperand(
@@ -6648,7 +6804,21 @@ Example matches true (matcher = hasUnaryOperand(
 
-Matcher<UnresolvedUsingType>hasDeclarationconst Matcher<Decl> InnerMatcher +Matcher<UnresolvedMemberExpr>hasObjectExpressionMatcher<Expr> InnerMatcher +
Matches a member expression where the object expression is
+matched by a given matcher.
+
+Given
+  struct X { int m; };
+  void f(X x) { x.m; m; }
+memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
+  matches "x.m" and "m"
+with hasObjectExpression(...)
+  matching "x" and the implicit object expression of "m" which has type X*.
+
+ + +Matcher<UnresolvedUsingType>hasDeclarationconst Matcher<Decl> InnerMatcher
Matches a node if the declaration associated with that node
 matches the given matcher.
 
@@ -6672,17 +6842,17 @@ This can be achieved by using the hasUnqualifiedDesugaredType matcher:
       recordType(hasDeclaration(decl())))))
 In this matcher, the decl will match the CXXRecordDecl of class X.
 
-Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
-  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
-  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
-  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
-  Matcher<TagType>, Matcher<TemplateSpecializationType>,
-  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
-  Matcher<UnresolvedUsingType>
+Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>,
+  Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>,
+  Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>,
+  Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>,
+  Matcher<TagType>, Matcher<TemplateSpecializationType>,
+  Matcher<TemplateTypeParmType>, Matcher<TypedefType>,
+  Matcher<UnresolvedUsingType>
 
-Matcher<UsingDecl>hasAnyUsingShadowDeclMatcher<UsingShadowDecl> InnerMatcher +Matcher<UsingDecl>hasAnyUsingShadowDeclMatcher<UsingShadowDecl> InnerMatcher
Matches any using shadow declaration.
 
 Given
@@ -6692,7 +6862,7 @@ usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
   matches using X::b 
-Matcher<UsingShadowDecl>hasTargetDeclMatcher<NamedDecl> InnerMatcher +Matcher<UsingShadowDecl>hasTargetDeclMatcher<NamedDecl> InnerMatcher
Matches a using shadow declaration where the target declaration is
 matched by the given matcher.
 
@@ -6704,7 +6874,7 @@ usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
   matches using X::b but not using X::a 
-Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher +Matcher<ValueDecl>hasTypeMatcher<Decl> InnerMatcher
Overloaded to match the declaration of the expression's or value
 declaration's type.
 
@@ -6721,11 +6891,11 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
  void y(X &x) { x; X z; }
  class Y { friend class X; };
 
-Usable as: Matcher<Expr>, Matcher<ValueDecl>
+Usable as: Matcher<Expr>, Matcher<ValueDecl>
 
-Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher +Matcher<ValueDecl>hasTypeMatcher<QualType> InnerMatcher
Matches if the expression's or declaration's type matches a type
 matcher.
 
@@ -6740,7 +6910,7 @@ Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
 
-Matcher<VarDecl>hasInitializerMatcher<Expr> InnerMatcher +Matcher<VarDecl>hasInitializerMatcher<Expr> InnerMatcher
Matches a variable declaration that has an initializer expression
 that matches the given matcher.
 
@@ -6750,7 +6920,7 @@ Example matches x (matcher = varDecl(hasInitializer(callExpr())))
 
-Matcher<VariableArrayType>hasSizeExprMatcher<Expr> InnerMatcher +Matcher<VariableArrayType>hasSizeExprMatcher<Expr> InnerMatcher
Matches VariableArrayType nodes that have a specific size
 expression.
 
@@ -6764,7 +6934,7 @@ variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
 
-Matcher<WhileStmt>hasBodyMatcher<Stmt> InnerMatcher +Matcher<WhileStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
 
@@ -6777,7 +6947,7 @@ with compoundStmt()
 
-Matcher<WhileStmt>hasConditionMatcher<Expr> InnerMatcher +Matcher<WhileStmt>hasConditionMatcher<Expr> InnerMatcher
Matches the condition expression of an if statement, for loop,
 switch statement or conditional operator.
 
@@ -6786,13 +6956,13 @@ Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
 
-Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>>locMatcher<NestedNameSpecifier> InnerMatcher +Matcher<internal::BindableMatcher<NestedNameSpecifierLoc>>locMatcher<NestedNameSpecifier> InnerMatcher
Matches NestedNameSpecifierLocs for which the given inner
 NestedNameSpecifier-matcher matches.
 
-Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher +Matcher<internal::BindableMatcher<TypeLoc>>locMatcher<QualType> InnerMatcher
Matches TypeLocs for which the given inner
 QualType-matcher matches.
 
diff --git a/docs/LibASTMatchersTutorial.rst b/docs/LibASTMatchersTutorial.rst index 832b47efd1b8..8b7ee7f98fa2 100644 --- a/docs/LibASTMatchersTutorial.rst +++ b/docs/LibASTMatchersTutorial.rst @@ -19,16 +19,16 @@ As Clang is part of the LLVM project, you'll need to download LLVM's source code first. Both Clang and LLVM are maintained as Subversion repositories, but we'll be accessing them through the git mirror. For further information, see the `getting started -guide `_. +guide `_. .. code-block:: console mkdir ~/clang-llvm && cd ~/clang-llvm - git clone http://llvm.org/git/llvm.git + git clone https://llvm.org/git/llvm.git cd llvm/tools - git clone http://llvm.org/git/clang.git + git clone https://llvm.org/git/clang.git cd clang/tools - git clone http://llvm.org/git/clang-tools-extra.git extra + git clone https://llvm.org/git/clang-tools-extra.git extra Next you need to obtain the CMake build system and Ninja build tool. You may already have CMake installed, but current binary versions of CMake @@ -113,6 +113,7 @@ CMakeLists.txt should have the following contents: LoopConvert.cpp ) target_link_libraries(loop-convert + PRIVATE clangTooling clangBasic clangASTMatchers diff --git a/docs/LibFormat.rst b/docs/LibFormat.rst index 2863a076edf4..889fbbac8c7a 100644 --- a/docs/LibFormat.rst +++ b/docs/LibFormat.rst @@ -45,7 +45,7 @@ two style guides are hard-coded: .. code-block:: c++ /// Returns a format style complying with the LLVM coding standards: - /// http://llvm.org/docs/CodingStandards.html. + /// https://llvm.org/docs/CodingStandards.html. FormatStyle getLLVMStyle(); /// Returns a format style complying with Google's C++ style guide: diff --git a/docs/LibTooling.rst b/docs/LibTooling.rst index a422a1d5665a..41110f5d3149 100644 --- a/docs/LibTooling.rst +++ b/docs/LibTooling.rst @@ -198,4 +198,4 @@ Linking For a list of libraries to link, look at one of the tools' Makefiles (for example `clang-check/Makefile -`_). +`_). diff --git a/docs/MSVCCompatibility.rst b/docs/MSVCCompatibility.rst index b82869b267cd..cd2acae97029 100644 --- a/docs/MSVCCompatibility.rst +++ b/docs/MSVCCompatibility.rst @@ -70,7 +70,7 @@ The status of major ABI-impacting C++ features: .. _#pragma pointers_to_members: http://msdn.microsoft.com/en-us/library/83cch5a6.aspx .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx -.. _pointer to a member of a virtual base class: http://llvm.org/PR15713 +.. _pointer to a member of a virtual base class: https://llvm.org/PR15713 * Debug info: :good:`Mostly complete`. Clang emits relatively complete CodeView debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will @@ -137,7 +137,7 @@ following program, Clang will recover as if the user had written the commented-out code: .. _frequently asked question: - http://clang.llvm.org/compatibility.html#dep_lookup + https://clang.llvm.org/compatibility.html#dep_lookup .. code-block:: c++ diff --git a/docs/MemorySanitizer.rst b/docs/MemorySanitizer.rst index 4e033fa1941d..f513b009a32f 100644 --- a/docs/MemorySanitizer.rst +++ b/docs/MemorySanitizer.rst @@ -16,7 +16,7 @@ Typical slowdown introduced by MemorySanitizer is **3x**. How to build ============ -Build LLVM/Clang with `CMake `_. +Build LLVM/Clang with `CMake `_. Usage ===== diff --git a/docs/Modules.rst b/docs/Modules.rst index 493c54d3913a..7aee4ffee2df 100644 --- a/docs/Modules.rst +++ b/docs/Modules.rst @@ -411,7 +411,7 @@ A *requires-declaration* specifies the requirements that an importing translatio *feature*: ``!``:sub:`opt` *identifier* -The requirements clause allows specific modules or submodules to specify that they are only accessible with certain language dialects or on certain platforms. The feature list is a set of identifiers, defined below. If any of the features is not available in a given translation unit, that translation unit shall not import the module. When building a module for use by a compilation, submodules requiring unavailable features are ignored. The optional ``!`` indicates that a feature is incompatible with the module. +The requirements clause allows specific modules or submodules to specify that they are only accessible with certain language dialects, platforms, environments and target specific features. The feature list is a set of identifiers, defined below. If any of the features is not available in a given translation unit, that translation unit shall not import the module. When building a module for use by a compilation, submodules requiring unavailable features are ignored. The optional ``!`` indicates that a feature is incompatible with the module. The following features are defined: @@ -466,6 +466,11 @@ tls *target feature* A specific target feature (e.g., ``sse4``, ``avx``, ``neon``) is available. +*platform/os* + A os/platform variant (e.g. ``freebsd``, ``win32``, ``windows``, ``linux``, ``ios``, ``macos``, ``iossimulator``) is available. + +*environment* + A environment variant (e.g. ``gnu``, ``gnueabi``, ``android``, ``msvc``) is available. **Example:** The ``std`` module can be extended to also include C++ and C++11 headers using a *requires-declaration*: diff --git a/docs/OpenMPSupport.rst b/docs/OpenMPSupport.rst index e8ec1e371b04..04a9648ca294 100644 --- a/docs/OpenMPSupport.rst +++ b/docs/OpenMPSupport.rst @@ -66,12 +66,11 @@ Combined directives * #pragma omp target teams distribute parallel for [simd]: :good:`Complete`. -Clang does not support any constructs/updates from upcoming OpenMP 5.0 except +Clang does not support any constructs/updates from OpenMP 5.0 except for `reduction`-based clauses in the `task` and `target`-based directives. In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS. -ows, and mac OS. .. _basic support for Cuda devices: @@ -109,11 +108,19 @@ are stored in the global memory. In `Cuda` mode local variables are not shared between the threads and it is user responsibility to share the required data between the threads in the parallel regions. +Collapsed loop nest counter +--------------------------- + +When using the collapse clause on a loop nest the default behaviour is to +automatically extend the representation of the loop counter to 64 bits for +the cases where the sizes of the collapsed loops are not known at compile +time. To prevent this conservative choice and use at most 32 bits, +compile your program with the `-fopenmp-optimistic-collapse`. + + Features not supported or with limited support for Cuda devices --------------------------------------------------------------- -- Reductions across the teams are not supported yet. - - Cancellation constructs are not supported. - Doacross loop nest is not supported. diff --git a/docs/PCHInternals.rst b/docs/PCHInternals.rst index b0372cb931ad..109260da9050 100644 --- a/docs/PCHInternals.rst +++ b/docs/PCHInternals.rst @@ -70,7 +70,7 @@ minimizes both creation time and the time required to initially load the AST file. The AST file itself contains a serialized representation of Clang's abstract syntax trees and supporting data structures, stored using the same compressed bitstream as `LLVM's bitcode file format -`_. +`_. Clang's AST files are loaded "lazily" from disk. When an AST file is initially loaded, Clang reads only a small amount of data from the AST file to establish @@ -134,7 +134,7 @@ only contain the serialized AST. The ``clangast`` section is organized into several different blocks, each of which contains the serialized representation of a part of Clang's internal representation. Each of the blocks corresponds to either a block or a record -within `LLVM's bitstream format `_. +within `LLVM's bitstream format `_. The contents of each of these logical blocks are described below. .. image:: PCHLayout.png @@ -142,7 +142,7 @@ The contents of each of these logical blocks are described below. The ``llvm-objdump`` utility provides a ``-raw-clang-ast`` option to extract the binary contents of the AST section from an object file container. -The `llvm-bcanalyzer `_ +The `llvm-bcanalyzer `_ utility can be used to examine the actual structure of the bitstream for the AST section. This information can be used both to help understand the structure of the AST section and to isolate areas where the AST representation can still be diff --git a/docs/PTHInternals.rst b/docs/PTHInternals.rst deleted file mode 100644 index 7401cf9b4d4b..000000000000 --- a/docs/PTHInternals.rst +++ /dev/null @@ -1,163 +0,0 @@ -========================== -Pretokenized Headers (PTH) -========================== - -This document first describes the low-level interface for using PTH and -then briefly elaborates on its design and implementation. If you are -interested in the end-user view, please see the :ref:`User's Manual -`. - -Using Pretokenized Headers with ``clang`` (Low-level Interface) -=============================================================== - -The Clang compiler frontend, ``clang -cc1``, supports three command line -options for generating and using PTH files. - -To generate PTH files using ``clang -cc1``, use the option ``-emit-pth``: - -.. code-block:: console - - $ clang -cc1 test.h -emit-pth -o test.h.pth - -This option is transparently used by ``clang`` when generating PTH -files. Similarly, PTH files can be used as prefix headers using the -``-include-pth`` option: - -.. code-block:: console - - $ clang -cc1 -include-pth test.h.pth test.c -o test.s - -Alternatively, Clang's PTH files can be used as a raw "token-cache" (or -"content" cache) of the source included by the original header file. -This means that the contents of the PTH file are searched as substitutes -for *any* source files that are used by ``clang -cc1`` to process a -source file. This is done by specifying the ``-token-cache`` option: - -.. code-block:: console - - $ cat test.h - #include - $ clang -cc1 -emit-pth test.h -o test.h.pth - $ cat test.c - #include "test.h" - $ clang -cc1 test.c -o test -token-cache test.h.pth - -In this example the contents of ``stdio.h`` (and the files it includes) -will be retrieved from ``test.h.pth``, as the PTH file is being used in -this case as a raw cache of the contents of ``test.h``. This is a -low-level interface used to both implement the high-level PTH interface -as well as to provide alternative means to use PTH-style caching. - -PTH Design and Implementation -============================= - -Unlike GCC's precompiled headers, which cache the full ASTs and -preprocessor state of a header file, Clang's pretokenized header files -mainly cache the raw lexer *tokens* that are needed to segment the -stream of characters in a source file into keywords, identifiers, and -operators. Consequently, PTH serves to mainly directly speed up the -lexing and preprocessing of a source file, while parsing and -type-checking must be completely redone every time a PTH file is used. - -Basic Design Tradeoffs ----------------------- - -In the long term there are plans to provide an alternate PCH -implementation for Clang that also caches the work for parsing and type -checking the contents of header files. The current implementation of PCH -in Clang as pretokenized header files was motivated by the following -factors: - -**Language independence** - PTH files work with any language that - Clang's lexer can handle, including C, Objective-C, and (in the early - stages) C++. This means development on language features at the - parsing level or above (which is basically almost all interesting - pieces) does not require PTH to be modified. - -**Simple design** - Relatively speaking, PTH has a simple design and - implementation, making it easy to test. Further, because the - machinery for PTH resides at the lower-levels of the Clang library - stack it is fairly straightforward to profile and optimize. - -Further, compared to GCC's PCH implementation (which is the dominate -precompiled header file implementation that Clang can be directly -compared against) the PTH design in Clang yields several attractive -features: - -**Architecture independence** - In contrast to GCC's PCH files (and - those of several other compilers), Clang's PTH files are architecture - independent, requiring only a single PTH file when building a - program for multiple architectures. - - For example, on Mac OS X one may wish to compile a "universal binary" - that runs on PowerPC, 32-bit Intel (i386), and 64-bit Intel - architectures. In contrast, GCC requires a PCH file for each - architecture, as the definitions of types in the AST are - architecture-specific. Since a Clang PTH file essentially represents - a lexical cache of header files, a single PTH file can be safely used - when compiling for multiple architectures. This can also reduce - compile times because only a single PTH file needs to be generated - during a build instead of several. - -**Reduced memory pressure** - Similar to GCC, Clang reads PTH files - via the use of memory mapping (i.e., ``mmap``). Clang, however, - memory maps PTH files as read-only, meaning that multiple invocations - of ``clang -cc1`` can share the same pages in memory from a - memory-mapped PTH file. In comparison, GCC also memory maps its PCH - files but also modifies those pages in memory, incurring the - copy-on-write costs. The read-only nature of PTH can greatly reduce - memory pressure for builds involving multiple cores, thus improving - overall scalability. - -**Fast generation** - PTH files can be generated in a small fraction - of the time needed to generate GCC's PCH files. Since PTH/PCH - generation is a serial operation that typically blocks progress - during a build, faster generation time leads to improved processor - utilization with parallel builds on multicore machines. - -Despite these strengths, PTH's simple design suffers some algorithmic -handicaps compared to other PCH strategies such as those used by GCC. -While PTH can greatly speed up the processing time of a header file, the -amount of work required to process a header file is still roughly linear -in the size of the header file. In contrast, the amount of work done by -GCC to process a precompiled header is (theoretically) constant (the -ASTs for the header are literally memory mapped into the compiler). This -means that only the pieces of the header file that are referenced by the -source file including the header are the only ones the compiler needs to -process during actual compilation. While GCC's particular implementation -of PCH mitigates some of these algorithmic strengths via the use of -copy-on-write pages, the approach itself can fundamentally dominate at -an algorithmic level, especially when one considers header files of -arbitrary size. - -There is also a PCH implementation for Clang based on the lazy -deserialization of ASTs. This approach theoretically has the same -constant-time algorithmic advantages just mentioned but also retains some -of the strengths of PTH such as reduced memory pressure (ideal for -multi-core builds). - -Internal PTH Optimizations --------------------------- - -While the main optimization employed by PTH is to reduce lexing time of -header files by caching pre-lexed tokens, PTH also employs several other -optimizations to speed up the processing of header files: - -- ``stat`` caching: PTH files cache information obtained via calls to - ``stat`` that ``clang -cc1`` uses to resolve which files are included - by ``#include`` directives. This greatly reduces the overhead - involved in context-switching to the kernel to resolve included - files. - -- Fast skipping of ``#ifdef`` ... ``#endif`` chains: PTH files - record the basic structure of nested preprocessor blocks. When the - condition of the preprocessor block is false, all of its tokens are - immediately skipped instead of requiring them to be handled by - Clang's preprocessor. - - diff --git a/docs/RAVFrontendAction.rst b/docs/RAVFrontendAction.rst index c37d3c0e812e..dea23733bc48 100644 --- a/docs/RAVFrontendAction.rst +++ b/docs/RAVFrontendAction.rst @@ -128,7 +128,7 @@ locations: if (Declaration->getQualifiedNameAsString() == "n::m::C") { // getFullLoc uses the ASTContext's SourceManager to resolve the source // location and break it up into its line and column parts. - FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart()); + FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getBeginLoc()); if (FullLocation.isValid()) llvm::outs() << "Found declaration at " << FullLocation.getSpellingLineNumber() << ":" @@ -160,7 +160,7 @@ Now we can combine all of the above into a small example program: bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) { if (Declaration->getQualifiedNameAsString() == "n::m::C") { - FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart()); + FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getBeginLoc()); if (FullLocation.isValid()) llvm::outs() << "Found declaration at " << FullLocation.getSpellingLineNumber() << ":" diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 1e45a13ef916..b6a405dbc78b 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -1,41 +1,41 @@ ======================================= -Clang 7.0.0 (In-Progress) Release Notes +Clang 8.0.0 (In-Progress) Release Notes ======================================= .. contents:: :local: :depth: 2 -Written by the `LLVM Team `_ +Written by the `LLVM Team `_ .. warning:: - These are in-progress notes for the upcoming Clang 7 release. + These are in-progress notes for the upcoming Clang 8 release. Release notes for previous releases can be found on - `the Download Page `_. + `the Download Page `_. Introduction ============ This document contains the release notes for the Clang C/C++/Objective-C -frontend, part of the LLVM Compiler Infrastructure, release 7.0.0. Here we +frontend, part of the LLVM Compiler Infrastructure, release 8.0.0. Here we describe the status of Clang in some detail, including major improvements from the previous release and new feature work. For the general LLVM release notes, see `the LLVM -documentation `_. All LLVM +documentation `_. All LLVM releases may be downloaded from the `LLVM releases web -site `_. +site `_. For more information about Clang or LLVM, including information about the -latest release, please see the `Clang Web Site `_ or the -`LLVM Web Site `_. +latest release, please see the `Clang Web Site `_ or the +`LLVM Web Site `_. Note that if you are reading this file from a Subversion checkout or the main Clang web page, this document applies to the *next* release, not the current one. To see the release notes for a specific release, please -see the `releases page `_. +see the `releases page `_. -What's New in Clang 7.0.0? +What's New in Clang 8.0.0? ========================== Some of the major new features and improvements to Clang are listed @@ -46,86 +46,95 @@ sections with improvements to Clang's support for those languages. Major New Features ------------------ -- A new Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group - was added. Please refer to the :ref:`release-notes-ubsan` section of the - release notes for the details. +- Clang supports use of a profile remapping file, which permits + profile data captured for one version of a program to be applied + when building another version where symbols have changed (for + example, due to renaming a class or namespace). + See the :doc:`UsersManual` for details. Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- ``-Wc++98-compat-extra-semi`` is a new flag, which was previously inseparable - from ``-Wc++98-compat-pedantic``. The latter still controls the new flag. +- ``-Wextra-semi-stmt`` is a new diagnostic that diagnoses extra semicolons, + much like ``-Wextra-semi``. This new diagnostic diagnoses all *unnecessary* + null statements (expression statements without an expression), unless: the + semicolon directly follows a macro that was expanded to nothing or if the + semicolon is within the macro itself. This applies to macros defined in system + headers as well as user-defined macros. -- ``-Wextra-semi`` now also controls ``-Wc++98-compat-extra-semi``. - Please do note that if you pass ``-Wno-c++98-compat-pedantic``, it implies - ``-Wno-c++98-compat-extra-semi``, so if you want that diagnostic, you need - to explicitly re-enable it (e.g. by appending ``-Wextra-semi``). + .. code-block:: c++ + + #define MACRO(x) int x; + #define NULLMACRO(varname) + + void test() { + ; // <- warning: ';' with no preceding expression is a null statement + + while (true) + ; // OK, it is needed. + + switch (my_enum) { + case E1: + // stuff + break; + case E2: + ; // OK, it is needed. + } + + MACRO(v0;) // Extra semicolon, but within macro, so ignored. + + MACRO(v1); // <- warning: ';' with no preceding expression is a null statement + + NULLMACRO(v2); // ignored, NULLMACRO expanded to nothing. + } + +- ``-Wempty-init-stmt`` is a new diagnostic that diagnoses empty init-statements + of ``if``, ``switch``, ``range-based for``, unless: the semicolon directly + follows a macro that was expanded to nothing or if the semicolon is within the + macro itself (both macros from system headers, and normal macros). This + diagnostic is in the ``-Wextra-semi-stmt`` group and is enabled in + ``-Wextra``. + + .. code-block:: c++ + + void test() { + if(; // <- warning: init-statement of 'if' is a null statement + true) + ; + + switch (; // <- warning: init-statement of 'switch' is a null statement + x) { + ... + } + + for (; // <- warning: init-statement of 'range-based for' is a null statement + int y : S()) + ; + } -- ``-Wself-assign`` and ``-Wself-assign-field`` were extended to diagnose - self-assignment operations using overloaded operators (i.e. classes). - If you are doing such an assignment intentionally, e.g. in a unit test for - a data structure, the first warning can be disabled by passing - ``-Wno-self-assign-overloaded``, also the warning can be suppressed by adding - ``*&`` to the right-hand side or casting it to the appropriate reference type. Non-comprehensive list of changes in this release ------------------------------------------------- -- Clang binary and libraries have been renamed from 7.0 to 7. - For example, the ``clang`` binary will be called ``clang-7`` - instead of ``clang-7.0``. +- The experimental feature Pretokenized Headers (PTH) was removed in its + entirely from Clang. The feature did not properly work with about 1/3 of the + possible tokens available and was unmaintained. -- Clang implements a collection of recent fixes to the C++ standard's definition - of "standard-layout". In particular, a class is only considered to be - standard-layout if all base classes and the first data member (or bit-field) - can be laid out at offset zero. - -- Clang's handling of the GCC ``packed`` class attribute in C++ has been fixed - to apply only to non-static data members and not to base classes. This fixes - an ABI difference between Clang and GCC, but creates an ABI difference between - Clang 7 and earlier versions. The old behavior can be restored by setting - ``-fclang-abi-compat`` to ``6`` or earlier. - -- Clang implements the proposed resolution of LWG issue 2358, along with the - `corresponding change to the Itanium C++ ABI - `_, which make classes - containing only unnamed non-zero-length bit-fields be considered non-empty. - This is an ABI break compared to prior Clang releases, but makes Clang - generate code that is ABI-compatible with other compilers. The old - behavior can be restored by setting ``-fclang-abi-compat`` to ``6`` or - lower. - -- An existing tool named ``diagtool`` has been added to the release. As the - name suggests, it helps with dealing with diagnostics in ``clang``, such as - finding out the warning hierarchy, and which of them are enabled by default - or for a particular compiler invocation. - -- By default, Clang emits an address-significance table into - every ELF object file when using the integrated assembler. - Address-significance tables allow linkers to implement `safe ICF - `_ without the false - positives that can result from other implementation techniques such as - relocation scanning. The ``-faddrsig`` and ``-fno-addrsig`` flags can be - used to control whether to emit the address-significance table. - -- ... +- The internals of libc++ include directory detection on MacOS have changed. + Instead of running a search based on the ``-resource-dir`` flag, the search + is now based on the path of the compiler in the filesystem. The default + behaviour should not change. However, if you override ``-resource-dir`` + manually and rely on the old behaviour you will need to add appropriate + compiler flags for finding the corresponding libc++ include directory. New Compiler Flags ------------------ -- ``-fstrict-float-cast-overflow`` and ``-fno-strict-float-cast-overflow``. +- ``-fprofile-filter-files=[regexes]`` and ``-fprofile-exclude-files=[regexes]``. - When a floating-point value is not representable in a destination integer - type, the code has undefined behavior according to the language standard. By - default, Clang will not guarantee any particular result in that case. With the - 'no-strict' option, Clang attempts to match the overflowing behavior of the - target's native float-to-int conversion instructions. - -- ``-fforce-emit-vtables`` and ``-fno-force-emit-vtables``. - - In order to improve devirtualization, forces emitting of vtables even in - modules where it isn't necessary. It causes more inline virtual functions - to be emitted. + Clang has now options to filter or exclude some files when + instrumenting for gcov-based profiling. + See the :doc:`UsersManual` for details. - ... @@ -140,46 +149,36 @@ future versions of Clang. Modified Compiler Flags ----------------------- -- Before Clang 7, we prepended the `#` character to the `--autocomplete` - argument to enable cc1 flags. For example, when the `-cc1` or `-Xclang` flag - is in the :program:`clang` invocation, the shell executed - `clang --autocomplete=#-`. Clang 7 now requires the - whole invocation including all flags to be passed to the `--autocomplete` like - this: `clang --autocomplete=-cc1,-xc++,-fsyn`. +- As of clang 8, `alignof` and `_Alignof` return the ABI alignment of a type, + as opposed to the preferred alignment. `__alignof` still returns the + preferred alignment. `-fclang-abi-compat=7` (and previous) will make + `alignof` and `_Alignof` return preferred alignment again. + New Pragmas in Clang -------------------- -Clang now supports the ... - +- Clang now supports adding multiple `#pragma clang attribute` attributes into + a scope of pushed attributes. Attribute Changes in Clang -------------------------- -- Clang now supports function multiversioning with attribute 'target' on ELF - based x86/x86-64 environments by using indirect functions. This implementation - has a few minor limitations over the GCC implementation for the sake of AST - sanity, however it is otherwise compatible with existing code using this - feature for GCC. Consult the documentation for the target attribute for more - information. - - ... Windows Support --------------- -- clang-cl's support for precompiled headers has been much improved: - - - When using a pch file, clang-cl now no longer redundantly emits inline - methods that are already stored in the obj that was built together with - the pch file (matching cl.exe). This speeds up builds using pch files - by around 30%. - - - The /Ycfoo.h and /Yufoo.h flags can now be used without /FIfoo.h when - foo.h is instead included by an explicit `#include` directive. This means - Visual Studio's default stdafx.h setup now uses precompiled headers with - clang-cl. +- clang-cl now supports the use of the precompiled header options /Yc and /Yu + without the filename argument. When these options are used without the + filename, a `#pragma hdrstop` inside the source marks the end of the + precompiled code. +- clang-cl has a new command-line option, ``/Zc:dllexportInlines-``, similar to + ``-fvisibility-inlines-hidden`` on non-Windows, that makes class-level + `dllexport` and `dllimport` attributes not apply to inline member functions. + This can significantly reduce compile and link times. See the `User's Manual + `_ for more info. - ... @@ -215,41 +214,52 @@ OpenCL C Language Changes in Clang ... +ABI Changes in Clang +-------------------- + +- `_Alignof` and `alignof` now return the ABI alignment of a type, as opposed + to the preferred alignment. + + - This is more in keeping with the language of the standards, as well as + being compatible with gcc + - `__alignof` and `__alignof__` still return the preferred alignment of + a type + - This shouldn't break any ABI except for things that explicitly ask for + `alignas(alignof(T))`. + - If you have interfaces that break with this change, you may wish to switch + to `alignas(__alignof(T))`, instead of using the `-fclang-abi-compat` + switch. + OpenMP Support in Clang ---------------------------------- -- Clang gained basic support for OpenMP 4.5 offloading for NVPTX target. - To compile your program for NVPTX target use the following options: - `-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda` for 64 bit platforms or - `-fopenmp -fopenmp-targets=nvptx-nvidia-cuda` for 32 bit platform. +- Support relational-op != (not-equal) as one of the canonical forms of random + access iterator. -- Passing options to the OpenMP device offloading toolchain can be done using - the `-Xopenmp-target= -opt=val` flag. In this way the `-opt=val` - option will be forwarded to the respective OpenMP device offloading toolchain - described by the triple. For example passing the compute capability to - the OpenMP NVPTX offloading toolchain can be done as follows: - `-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_60`. For the case when only one - target offload toolchain is specified under the `-fopenmp-targets=` - option, then the triple can be skipped: `-Xopenmp-target -march=sm_60`. +- Added support for mapping of the lambdas in target regions. -- Other bugfixes. +- Added parsing/sema analysis for OpenMP 5.0 requires directive. + +- Various bugfixes and improvements. + +New features supported for Cuda devices: + +- Added support for the reductions across the teams. + +- Extended number of constructs that can be executed in SPMD mode. + +- Fixed support for lastprivate/reduction variables in SPMD constructs. + +- General performance improvement. CUDA Support in Clang --------------------- -- Clang will now try to locate the CUDA installation next to :program:`ptxas` - in the `PATH` environment variable. This behavior can be turned off by passing - the new flag `--cuda-path-ignore-env`. - -- Clang now supports generating object files with relocatable device code. This - feature needs to be enabled with `-fcuda-rdc` and my result in performance - penalties compared to whole program compilation. Please note that NVIDIA's - :program:`nvcc` must be used for linking. Internal API Changes -------------------- -These are major API changes that have happened since the 6.0.0 release of +These are major API changes that have happened since the 7.0.0 release of Clang. If upgrading an external codebase that uses Clang as a library, this section should help get you past the largest hurdles of upgrading. @@ -263,9 +273,6 @@ AST Matchers clang-format ------------ -- Clang-format will now support detecting and formatting code snippets in raw - string literals. This is configured through the `RawStringFormats` style - option. - ... @@ -287,31 +294,75 @@ Static Analyzer Undefined Behavior Sanitizer (UBSan) ------------------------------------ -* A new Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group - was added. - - Currently, only one type of issues is caught - implicit integer truncation - (``-fsanitize=implicit-integer-truncation``), also known as integer demotion. - While there is a ``-Wconversion`` diagnostic group that catches this kind of - issues, it is both noisy, and does not catch **all** the cases. +* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group + was extended. One more type of issues is caught - implicit integer sign change. + (``-fsanitize=implicit-integer-sign-change``). + This makes the Implicit Conversion Sanitizer feature-complete, + with only missing piece being bitfield handling. + While there is a ``-Wsign-conversion`` diagnostic group that catches this kind + of issues, it is both noisy, and does not catch **all** the cases. .. code-block:: c++ - unsigned char store = 0; - bool consume(unsigned int val); - void test(unsigned long val) { - if (consume(val)) // the value may have been silently truncated. - store = store + 768; // before addition, 'store' was promoted to int. - (void)consume((unsigned int)val); // OK, the truncation is explicit. + void test(int val) { + (void)consume(val); // If the value was negative, it is now large positive. + (void)consume((unsigned int)val); // OK, the conversion is explicit. } - Just like other ``-fsanitize=integer`` checks, these issues are **not** + Like some other ``-fsanitize=integer`` checks, these issues are **not** undefined behaviour. But they are not *always* intentional, and are somewhat hard to track down. This group is **not** enabled by ``-fsanitize=undefined``, - but the ``-fsanitize=implicit-integer-truncation`` check + but the ``-fsanitize=implicit-integer-sign-change`` check is enabled by ``-fsanitize=integer``. + (as is ``-fsanitize=implicit-integer-truncation`` check) + +* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has + learned to sanitize compound assignment operators. + +* ``alignment`` check has learned to sanitize the assume_aligned-like attributes: + + .. code-block:: c++ + + typedef char **__attribute__((align_value(1024))) aligned_char; + struct ac_struct { + aligned_char a; + }; + char **load_from_ac_struct(struct ac_struct *x) { + return x->a; // <- check that loaded 'a' is aligned + } + + char **passthrough(__attribute__((align_value(1024))) char **x) { + return x; // <- check the pointer passed as function argument + } + + char **__attribute__((alloc_align(2))) + alloc_align(int size, unsigned long alignment); + + char **caller(int size) { + return alloc_align(size, 1024); // <- check returned pointer + } + + char **__attribute__((assume_aligned(1024))) get_ptr(); + + char **caller2() { + return get_ptr(); // <- check returned pointer + } + + void *caller3(char **x) { + return __builtin_assume_aligned(x, 1024); // <- check returned pointer + } + + void *caller4(char **x, unsigned long offset) { + return __builtin_assume_aligned(x, 1024, offset); // <- check returned pointer accounting for the offest + } + + void process(char *data, int width) { + #pragma omp for simd aligned(data : 1024) // <- aligned clause will be checked. + for (int x = 0; x < width; x++) + data[x] *= data[x]; + } Core Analysis Improvements ========================== @@ -337,7 +388,7 @@ Additional Information ====================== A wide variety of additional information is available on the `Clang web -page `_. The web page contains versions of the +page `_. The web page contains versions of the API documentation which are up-to-date with the Subversion version of the source code. You can access versions of these documents specific to this release by going into the "``clang/docs/``" directory in the Clang @@ -345,4 +396,4 @@ tree. If you have any questions or comments about Clang, please feel free to contact us via the `mailing -list `_. +list `_. diff --git a/docs/SanitizerCoverage.rst b/docs/SanitizerCoverage.rst index e1c3fc91d32c..f3f13c831760 100644 --- a/docs/SanitizerCoverage.rst +++ b/docs/SanitizerCoverage.rst @@ -245,7 +245,7 @@ around comparison instructions and switch statements. Similarly, with ``-fsanitize-coverage=trace-div`` the compiler will instrument integer division instructions (to capture the right argument of division) and with ``-fsanitize-coverage=trace-gep`` -- -the `LLVM GEP instructions `_ +the `LLVM GEP instructions `_ (to capture array indices). .. code-block:: c++ diff --git a/docs/SourceBasedCodeCoverage.rst b/docs/SourceBasedCodeCoverage.rst index 805c98794804..27a1950a1602 100644 --- a/docs/SourceBasedCodeCoverage.rst +++ b/docs/SourceBasedCodeCoverage.rst @@ -156,7 +156,7 @@ line-oriented report, try: The ``llvm-cov`` tool supports specifying a custom demangler, writing out reports in a directory structure, and generating html reports. For the full list of options, please refer to the `command guide -`_. +`_. A few final notes: diff --git a/docs/ThinLTO.rst b/docs/ThinLTO.rst index 38873f464c29..6e6cb801f522 100644 --- a/docs/ThinLTO.rst +++ b/docs/ThinLTO.rst @@ -47,7 +47,7 @@ The 3.9 release of clang includes ThinLTO support. However, ThinLTO is under active development, and new features, improvements and bugfixes are being added for the next release. For the latest ThinLTO support, `build a recent version of clang and LLVM -`_. +`_. Linkers ------- @@ -59,7 +59,7 @@ ThinLTO is currently supported for the following linkers: - **gold (via the gold-plugin)**: Similar to monolithic LTO, this requires using a `gold linker configured with plugins enabled - `_. + `_. - **ld64**: Starting with `Xcode 8 `_. - **lld**: @@ -99,13 +99,15 @@ With gold, if you see an error during the link of the form: Then either gold was not configured with plugins enabled, or clang was not built with ``-DLLVM_BINUTILS_INCDIR`` set properly. See the instructions for the -`LLVM gold plugin `_. +`LLVM gold plugin `_. Controlling Backend Parallelism ------------------------------- .. _parallelism: -By default, the ThinLTO link step will launch up to +By default, the ThinLTO link step will launch as many +threads in parallel as there are cores. If the number of +cores can't be computed for the architecture, then it will launch ``std::thread::hardware_concurrency`` number of threads in parallel. For machines with hyper-threading, this is the total number of virtual cores. For some applications and machine configurations this @@ -196,9 +198,9 @@ To bootstrap clang/LLVM with ThinLTO, follow these steps: 1. The host compiler_ must be a version of clang that supports ThinLTO. #. The host linker_ must support ThinLTO (and in the case of gold, must be - `configured with plugins enabled `_. + `configured with plugins enabled `_. #. Use the following additional `CMake variables - `_ + `_ when configuring the bootstrap compiler build: * ``-DLLVM_ENABLE_LTO=Thin`` diff --git a/docs/ThreadSanitizer.rst b/docs/ThreadSanitizer.rst index d1e2c65ec5f1..0d039bd5b25a 100644 --- a/docs/ThreadSanitizer.rst +++ b/docs/ThreadSanitizer.rst @@ -12,7 +12,7 @@ ThreadSanitizer is about **5x-10x**. How to build ------------ -Build LLVM/Clang with `CMake `_. +Build LLVM/Clang with `CMake `_. Supported Platforms ------------------- diff --git a/docs/Toolchain.rst b/docs/Toolchain.rst index 06bde35c3da6..3540708a382c 100644 --- a/docs/Toolchain.rst +++ b/docs/Toolchain.rst @@ -100,14 +100,14 @@ currently-supported languages are: In each case, GCC will be invoked to compile the input. -Assember --------- +Assembler +--------- Clang can either use LLVM's integrated assembler or an external system-specific tool (for instance, the GNU Assembler on GNU OSes) to produce machine code from assembly. By default, Clang uses LLVM's integrated assembler on all targets where it is -supported. If you wish to use the system assember instead, use the +supported. If you wish to use the system assembler instead, use the ``-fno-integrated-as`` option. Linker @@ -121,7 +121,7 @@ Clang can be configured to use one of several different linkers: * MSVC's link.exe Link-time optimization is natively supported by lld, and supported via -a `linker plugin `_ when using gold. +a `linker plugin `_ when using gold. The default linker varies between targets, and can be overridden via the ``-fuse-ld=`` flag. @@ -233,7 +233,7 @@ LLVM's unwinder library can be obtained from subversion: .. code-block:: console - llvm-src$ svn co http://llvm.org/svn/llvm-project/libunwind/trunk projects/libunwind + llvm-src$ svn co https://llvm.org/svn/llvm-project/libunwind/trunk projects/libunwind When checked out into projects/libunwind within an LLVM checkout, it should be automatically picked up by the LLVM build system. diff --git a/docs/Tooling.rst b/docs/Tooling.rst index 25ee21589022..141d4d8d8959 100644 --- a/docs/Tooling.rst +++ b/docs/Tooling.rst @@ -9,7 +9,7 @@ the different ways to write clang tools, and their pros and cons. LibClang -------- -`LibClang `_ is a stable high +`LibClang `_ is a stable high level C interface to clang. When in doubt LibClang is probably the interface you want to use. Consider the other interfaces only when you have a good reason not to use LibClang. diff --git a/docs/UndefinedBehaviorSanitizer.rst b/docs/UndefinedBehaviorSanitizer.rst index 86d0193a23c2..3700d4962d36 100644 --- a/docs/UndefinedBehaviorSanitizer.rst +++ b/docs/UndefinedBehaviorSanitizer.rst @@ -25,7 +25,7 @@ The checks have small runtime cost and no impact on address space layout or ABI. How to build ============ -Build LLVM/Clang with `CMake `_. +Build LLVM/Clang with `CMake `_. Usage ===== @@ -72,7 +72,7 @@ Available checks Available checks are: - ``-fsanitize=alignment``: Use of a misaligned pointer or creation - of a misaligned reference. + of a misaligned reference. Also sanitizes assume_aligned-like attributes. - ``-fsanitize=bool``: Load of a ``bool`` value which is neither ``true`` nor ``false``. - ``-fsanitize=builtin``: Passing invalid values to compiler builtins. @@ -89,10 +89,21 @@ Available checks are: - ``-fsanitize=function``: Indirect call of a function through a function pointer of the wrong type (Darwin/Linux, C++ and x86/x86_64 only). - - ``-fsanitize=implicit-integer-truncation``: Implicit conversion from + - ``-fsanitize=implicit-unsigned-integer-truncation``, + ``-fsanitize=implicit-signed-integer-truncation``: Implicit conversion from integer of larger bit width to smaller bit width, if that results in data loss. That is, if the demoted value, after casting back to the original width, is not equal to the original value before the downcast. + The ``-fsanitize=implicit-unsigned-integer-truncation`` handles conversions + between two ``unsigned`` types, while + ``-fsanitize=implicit-signed-integer-truncation`` handles the rest of the + conversions - when either one, or both of the types are signed. + Issues caught by these sanitizers are not undefined behavior, + but are often unintentional. + - ``-fsanitize=implicit-integer-sign-change``: Implicit conversion between + integer types, if that changes the sign of the value. That is, if the the + original value was negative and the new value is positive (or zero), + or the original value was positive, and the new value is negative. Issues caught by this sanitizer are not undefined behavior, but are often unintentional. - ``-fsanitize=integer-divide-by-zero``: Integer division by zero. @@ -156,13 +167,24 @@ You can also use the following check groups: ``nullability-*`` group of checks. - ``-fsanitize=undefined-trap``: Deprecated alias of ``-fsanitize=undefined``. + - ``-fsanitize=implicit-integer-truncation``: Catches lossy integral + conversions. Enables ``implicit-signed-integer-truncation`` and + ``implicit-unsigned-integer-truncation``. + - ``-fsanitize=implicit-integer-arithmetic-value-change``: Catches implicit + conversions that change the arithmetic value of the integer. Enables + ``implicit-signed-integer-truncation`` and ``implicit-integer-sign-change``. + - ``-fsanitize=implicit-conversion``: Checks for suspicious + behaviour of implicit conversions. Enables + ``implicit-unsigned-integer-truncation``, + ``implicit-signed-integer-truncation`` and + ``implicit-integer-sign-change``. - ``-fsanitize=integer``: Checks for undefined or suspicious integer behavior (e.g. unsigned integer overflow). Enables ``signed-integer-overflow``, ``unsigned-integer-overflow``, - ``shift``, ``integer-divide-by-zero``, and ``implicit-integer-truncation``. - - ``-fsanitize=implicit-conversion``: Checks for suspicious behaviours of - implicit conversions. - Currently, only ``-fsanitize=implicit-integer-truncation`` is implemented. + ``shift``, ``integer-divide-by-zero``, + ``implicit-unsigned-integer-truncation``, + ``implicit-signed-integer-truncation`` and + ``implicit-integer-sign-change``. - ``-fsanitize=nullability``: Enables ``nullability-arg``, ``nullability-assign``, and ``nullability-return``. While violating nullability does not have undefined behavior, it is often unintentional, @@ -266,7 +288,7 @@ There are several limitations: Supported Platforms =================== -UndefinedBehaviorSanitizer is supported on the following OS: +UndefinedBehaviorSanitizer is supported on the following operating systems: * Android * Linux @@ -274,6 +296,11 @@ UndefinedBehaviorSanitizer is supported on the following OS: * FreeBSD * OpenBSD * OS X 10.6 onwards +* Windows + +The runtime library is relatively portable and platform independent. If the OS +you need is not listed above, UndefinedBehaviorSanitizer may already work for +it, or could be made to work with a minor porting effort. Current Status ============== @@ -296,6 +323,7 @@ Example ------- For a file called ``/code/library/file.cpp``, here is what would be emitted: + * Default (No flag, or ``-fsanitize-undefined-strip-path-components=0``): ``/code/library/file.cpp`` * ``-fsanitize-undefined-strip-path-components=1``: ``code/library/file.cpp`` * ``-fsanitize-undefined-strip-path-components=2``: ``library/file.cpp`` diff --git a/docs/UsersManual.rst b/docs/UsersManual.rst index 363bb4e461a6..7634d24eb5a6 100644 --- a/docs/UsersManual.rst +++ b/docs/UsersManual.rst @@ -22,7 +22,7 @@ This document describes important notes about using Clang as a compiler for an end-user, documenting the supported features, command line options, etc. If you are interested in using Clang to build a tool that processes code, please see :doc:`InternalsManual`. If you are interested in the -`Clang Static Analyzer `_, please see its web +`Clang Static Analyzer `_, please see its web page. Clang is one component in a complete toolchain for C family languages. @@ -587,7 +587,7 @@ Options to Control Clang Crash Diagnostics As unbelievable as it may sound, Clang does crash from time to time. Generally, this only occurs to those living on the `bleeding -edge `_. Clang goes to great +edge `_. Clang goes to great lengths to assist you in filing a bug report. Specifically, Clang generates preprocessed source file(s) and associated run script(s) upon a crash. These files should be attached to a bug report to ease @@ -982,11 +982,11 @@ Controlling Static Analyzer Diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ While not strictly part of the compiler, the diagnostics from Clang's -`static analyzer `_ can also be +`static analyzer `_ can also be influenced by the user via changes to the source code. See the available -`annotations `_ and the +`annotations `_ and the analyzer's `FAQ -page `_ for more +page `_ for more information. .. _usersmanual-precompiled-headers: @@ -1799,6 +1799,127 @@ In these cases, you can use the flag ``-fno-profile-instr-generate`` (or Note that these flags should appear after the corresponding profile flags to have an effect. +Profile remapping +^^^^^^^^^^^^^^^^^ + +When the program is compiled after a change that affects many symbol names, +pre-existing profile data may no longer match the program. For example: + + * switching from libstdc++ to libc++ will result in the mangled names of all + functions taking standard library types to change + * renaming a widely-used type in C++ will result in the mangled names of all + functions that have parameters involving that type to change + * moving from a 32-bit compilation to a 64-bit compilation may change the + underlying type of ``size_t`` and similar types, resulting in changes to + manglings + +Clang allows use of a profile remapping file to specify that such differences +in mangled names should be ignored when matching the profile data against the +program. + +.. option:: -fprofile-remapping-file= + + Specifies a file containing profile remapping information, that will be + used to match mangled names in the profile data to mangled names in the + program. + +The profile remapping file is a text file containing lines of the form + +.. code-block:: text + + fragmentkind fragment1 fragment2 + +where ``fragmentkind`` is one of ``name``, ``type``, or ``encoding``, +indicating whether the following mangled name fragments are +<`name `_>s, +<`type `_>s, or +<`encoding `_>s, +respectively. +Blank lines and lines starting with ``#`` are ignored. + +For convenience, built-in s such as ``St`` and ``Ss`` +are accepted as s (even though they technically are not s). + +For example, to specify that ``absl::string_view`` and ``std::string_view`` +should be treated as equivalent when matching profile data, the following +remapping file could be used: + +.. code-block:: text + + # absl::string_view is considered equivalent to std::string_view + type N4absl11string_viewE St17basic_string_viewIcSt11char_traitsIcEE + + # std:: might be std::__1:: in libc++ or std::__cxx11:: in libstdc++ + name 3std St3__1 + name 3std St7__cxx11 + +Matching profile data using a profile remapping file is supported on a +best-effort basis. For example, information regarding indirect call targets is +currently not remapped. For best results, you are encouraged to generate new +profile data matching the updated program, or to remap the profile data +using the ``llvm-cxxmap`` and ``llvm-profdata merge`` tools. + +.. note:: + + Profile data remapping support is currently only implemented for LLVM's + new pass manager, which can be enabled with + ``-fexperimental-new-pass-manager``. + +.. note:: + + Profile data remapping is currently only supported for C++ mangled names + following the Itanium C++ ABI mangling scheme. This covers all C++ targets + supported by Clang other than Windows. + +GCOV-based Profiling +-------------------- + +GCOV is a test coverage program, it helps to know how often a line of code +is executed. When instrumenting the code with ``--coverage`` option, some +counters are added for each edge linking basic blocks. + +At compile time, gcno files are generated containing information about +blocks and edges between them. At runtime the counters are incremented and at +exit the counters are dumped in gcda files. + +The tool ``llvm-cov gcov`` will parse gcno, gcda and source files to generate +a report ``.c.gcov``. + +.. option:: -fprofile-filter-files=[regexes] + + Define a list of regexes separated by a semi-colon. + If a file name matches any of the regexes then the file is instrumented. + + .. code-block:: console + + $ clang --coverage -fprofile-filter-files=".*\.c$" foo.c + + For example, this will only instrument files finishing with ``.c``, skipping ``.h`` files. + +.. option:: -fprofile-exclude-files=[regexes] + + Define a list of regexes separated by a semi-colon. + If a file name doesn't match all the regexes then the file is instrumented. + + .. code-block:: console + + $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" foo.c + + For example, this will instrument all the files except the ones in ``/usr/include``. + +If both options are used then a file is instrumented if its name matches any +of the regexes from ``-fprofile-filter-list`` and doesn't match all the regexes +from ``-fprofile-exclude-list``. + +.. code-block:: console + + $ clang --coverage -fprofile-exclude-files="^/usr/include/.*$" \ + -fprofile-filter-files="^/usr/.*$" + +In that case ``/usr/foo/oof.h`` is instrumented since it matches the filter regex and +doesn't match the exclude regex, but ``/usr/include/foo.h`` doesn't since it matches +the exclude regex. + Controlling Debug Information ----------------------------- @@ -2086,7 +2207,7 @@ comment(lib)`` are well supported. clang has a ``-fms-compatibility`` flag that makes clang accept enough invalid C++ to be able to parse most Microsoft headers. For example, it allows `unqualified lookup of dependent base class members -`_, which is +`_, which is a common compatibility issue with clang. This flag is enabled by default for Windows targets. @@ -2711,16 +2832,17 @@ Command Prompt or a regular Command Prompt where the environment has been set up using e.g. `vcvarsall.bat `_. clang-cl can also be used from inside Visual Studio by selecting the LLVM -Platform Toolset. The toolset is installed by the LLVM installer, which can be -downloaded from the `LLVM release `_ or -`snapshot build `_ web pages. To use the toolset, -select a project in Solution Explorer, open its Property Page (Alt+F7), and in -the "General" section of "Configuration Properties" change "Platform Toolset" -to e.g. LLVM-vs2014. +Platform Toolset. The toolset is not part of the installer, but may be installed +separately from the +`Visual Studio Marketplace `_. +To use the toolset, select a project in Solution Explorer, open its Property +Page (Alt+F7), and in the "General" section of "Configuration Properties" +change "Platform Toolset" to LLVM. Doing so enables an additional Property +Page for selecting the clang-cl executable to use for builds. To use the toolset with MSBuild directly, invoke it with e.g. -``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl -toolchain without modifying your project files. +``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain +without modifying your project files. It's also possible to point MSBuild at clang-cl without changing toolset by passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``. @@ -2729,7 +2851,7 @@ When using CMake and the Visual Studio generators, the toolset can be set with t :: - cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 .. + cmake -G"Visual Studio 15 2017" -T LLVM .. When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and ``CMAKE_CXX_COMPILER`` variables to clang-cl: @@ -2776,6 +2898,7 @@ Execute ``clang-cl /?`` to see a list of supported options: /arch: Set architecture for code generation /Brepro- Emit an object file which cannot be reproduced over time /Brepro Emit an object file which can be reproduced over time + /clang: Pass to the clang driver /C Don't discard comments when preprocessing /c Compile only /d1PP Retain macro definitions in /E mode @@ -2805,20 +2928,23 @@ Execute ``clang-cl /?`` to see a list of supported options: /GA Assume thread-local variables are defined in the executable /Gd Set __cdecl as a default calling convention /GF- Disable string pooling + /GF Enable string pooling (default) /GR- Disable emission of RTTI data /Gregcall Set __regcall as a default calling convention /GR Enable emission of RTTI data /Gr Set __fastcall as a default calling convention /GS- Disable buffer security check - /GS Enable buffer security check - /Gs Set stack probe size - /guard: Enable Control Flow Guard with /guard:cf + /GS Enable buffer security check (default) + /Gs Use stack probes (default) + /Gs Set stack probe size (default 4096) + /guard: Enable Control Flow Guard with /guard:cf, + or only the table with /guard:cf,nochecks /Gv Set __vectorcall as a default calling convention /Gw- Don't put each data item in its own section /Gw Put each data item in its own section /GX- Disable exception handling /GX Enable exception handling - /Gy- Don't put each function in its own section + /Gy- Don't put each function in its own section (default) /Gy Put each function in its own section /Gz Set __stdcall as a default calling convention /help Display available options @@ -2832,16 +2958,28 @@ Execute ``clang-cl /?`` to see a list of supported options: /MD Use DLL run-time /MTd Use static debug run-time /MT Use static run-time + /O0 Disable optimization + /O1 Optimize for size (same as /Og /Os /Oy /Ob2 /GF /Gy) + /O2 Optimize for speed (same as /Og /Oi /Ot /Oy /Ob2 /GF /Gy) + /Ob0 Disable function inlining + /Ob1 Only inline functions which are (explicitly or implicitly) marked inline + /Ob2 Inline functions as deemed beneficial by the compiler /Od Disable optimization + /Og No effect /Oi- Disable use of builtin functions /Oi Enable use of builtin functions /Os Optimize for size /Ot Optimize for speed - /O Optimization level + /Ox Deprecated (same as /Og /Oi /Ot /Oy /Ob2); use /O2 instead + /Oy- Disable frame pointer omission (x86 only, default) + /Oy Enable frame pointer omission (x86 only) + /O Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-' /o Set output file or directory (ends in / or \) /P Preprocess to file /Qvec- Disable the loop vectorization passes /Qvec Enable the loop vectorization passes + /showFilenames- Don't print the name of each compiled file (default) + /showFilenames Print the name of each compiled file /showIncludes Print info about included files to stderr /source-charset: Source encoding, supports only UTF-8 /std: Language standard to compile for @@ -2873,6 +3011,8 @@ Execute ``clang-cl /?`` to see a list of supported options: /Yc Generate a pch file for all code up to and including /Yu Load a pch file and use it instead of all code up to and including /Z7 Enable CodeView debug information in object files + /Zc:dllexportInlines- Don't dllexport/dllimport inline member functions of dllexport/import classes + /Zc:dllexportInlines dllexport/dllimport inline member functions of dllexport/import classes (default) /Zc:sizedDealloc- Disable C++14 sized global deallocation functions /Zc:sizedDealloc Enable C++14 sized global deallocation functions /Zc:strictStrings Treat string literals as const @@ -2924,13 +3064,16 @@ Execute ``clang-cl /?`` to see a list of supported options: -fno-complete-member-pointers Do not require member pointer base types to be complete if they would be significant under the Microsoft ABI -fno-coverage-mapping Disable code coverage analysis + -fno-crash-diagnostics Disable auto-generation of preprocessed source files and a script for reproduction during a clang crash -fno-debug-macro Do not emit macro debug information -fno-delayed-template-parsing Disable delayed template parsing - -fno-sanitize-address-poison-class-member-array-new-cookie - Disable poisoning array cookies when using class member operator new[] in AddressSanitizer + -fno-sanitize-address-poison-custom-array-cookie + Disable poisoning array cookies when using custom operator new[] in AddressSanitizer -fno-sanitize-address-use-after-scope Disable use-after-scope detection in AddressSanitizer + -fno-sanitize-address-use-odr-indicator + Disable ODR indicator globals -fno-sanitize-blacklist Don't use blacklist file for sanitizers -fno-sanitize-cfi-cross-dso Disable control flow integrity (CFI) checks for cross-DSO calls. @@ -2952,6 +3095,11 @@ Execute ``clang-cl /?`` to see a list of supported options: -fno-sanitize-trap= Disable trapping for specified sanitizers -fno-standalone-debug Limit debug information produced to reduce size of debug binary + -fobjc-runtime= Specify the target Objective-C runtime kind and version + -fprofile-exclude-files= + Instrument only functions from files where names don't match all the regexes separated by a semi-colon + -fprofile-filter-files= + Instrument only functions from files where names match any regex separated by a semi-colon -fprofile-instr-generate= Generate instrumented code to collect execution counts into (overridden by LLVM_PROFILE_FILE env var) @@ -2960,14 +3108,18 @@ Execute ``clang-cl /?`` to see a list of supported options: (overridden by '=' form of option or LLVM_PROFILE_FILE env var) -fprofile-instr-use= Use instrumentation data for profile-guided optimization + -fprofile-remapping-file= + Use the remappings described in to match the profile data against names in the program -fsanitize-address-field-padding= Level of field padding for AddressSanitizer -fsanitize-address-globals-dead-stripping Enable linker dead stripping of globals in AddressSanitizer - -fsanitize-address-poison-class-member-array-new-cookie - Enable poisoning array cookies when using class member operator new[] in AddressSanitizer + -fsanitize-address-poison-custom-array-cookie + Enable poisoning array cookies when using custom operator new[] in AddressSanitizer -fsanitize-address-use-after-scope Enable use-after-scope detection in AddressSanitizer + -fsanitize-address-use-odr-indicator + Enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size -fsanitize-blacklist= Path to blacklist file for sanitizers -fsanitize-cfi-cross-dso @@ -2976,6 +3128,8 @@ Execute ``clang-cl /?`` to see a list of supported options: Generalize pointers in CFI indirect call type signature checks -fsanitize-coverage= Specify the type of coverage instrumentation for Sanitizers + -fsanitize-hwaddress-abi= + Select the HWAddressSanitizer ABI to target (interceptor or platform, default interceptor) -fsanitize-memory-track-origins= Enable origins tracking in MemorySanitizer -fsanitize-memory-track-origins @@ -2996,9 +3150,12 @@ Execute ``clang-cl /?`` to see a list of supported options: Strip (or keep only, if negative) a given number of path components when emitting check metadata. -fsanitize= Turn on runtime checks for various forms of undefined or suspicious behavior. See user manual for available checks + -fsplit-lto-unit Enables splitting of the LTO unit. -fstandalone-debug Emit full debug info for all types used by the program -fwhole-program-vtables Enables whole-program vtable optimization. Requires -flto + -gcodeview-ghash Emit type record hashes in a .debug$H section -gcodeview Generate CodeView debug information + -gline-directives-only Emit debug line info directives only -gline-tables-only Emit debug line number tables only -miamcu Use Intel MCU ABI -mllvm Additional arguments to forward to LLVM's option processing @@ -3011,6 +3168,92 @@ Execute ``clang-cl /?`` to see a list of supported options: -W Enable the specified warning -Xclang Pass to the clang compiler +The /clang: Option +^^^^^^^^^^^^^^^^^^ + +When clang-cl is run with a set of ``/clang:`` options, it will gather all +of the ```` arguments and process them as if they were passed to the clang +driver. This mechanism allows you to pass flags that are not exposed in the +clang-cl options or flags that have a different meaning when passed to the clang +driver. Regardless of where they appear in the command line, the ``/clang:`` +arguments are treated as if they were passed at the end of the clang-cl command +line. + +The /Zc:dllexportInlines- Option +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This causes the class-level `dllexport` and `dllimport` attributes to not apply +to inline member functions, as they otherwise would. For example, in the code +below `S::foo()` would normally be defined and exported by the DLL, but when +using the ``/Zc:dllexportInlines-`` flag it is not: + +.. code-block:: c + + struct __declspec(dllexport) S { + void foo() {} + } + +This has the benefit that the compiler doesn't need to emit a definition of +`S::foo()` in every translation unit where the declaration is included, as it +would otherwise do to ensure there's a definition in the DLL even if it's not +used there. If the declaration occurs in a header file that's widely used, this +can save significant compilation time and output size. It also reduces the +number of functions exported by the DLL similarly to what +``-fvisibility-inlines-hidden`` does for shared objects on ELF and Mach-O. +Since the function declaration comes with an inline definition, users of the +library can use that definition directly instead of importing it from the DLL. + +Note that the Microsoft Visual C++ compiler does not support this option, and +if code in a DLL is compiled with ``/Zc:dllexportInlines-``, the code using the +DLL must be compiled in the same way so that it doesn't attempt to dllimport +the inline member functions. The reverse scenario should generally work though: +a DLL compiled without this flag (such as a system library compiled with Visual +C++) can be referenced from code compiled using the flag, meaning that the +referencing code will use the inline definitions instead of importing them from +the DLL. + +Also note that like when using ``-fvisibility-inlines-hidden``, the address of +`S::foo()` will be different inside and outside the DLL, breaking the C/C++ +standard requirement that functions have a unique address. + +The flag does not apply to explicit class template instantiation definitions or +declarations, as those are typically used to explicitly provide a single +definition in a DLL, (dllexported instantiation definition) or to signal that +the definition is available elsewhere (dllimport instantiation declaration). It +also doesn't apply to inline members with static local variables, to ensure +that the same instance of the variable is used inside and outside the DLL. + +Using this flag can cause problems when inline functions that would otherwise +be dllexported refer to internal symbols of a DLL. For example: + +.. code-block:: c + + void internal(); + + struct __declspec(dllimport) S { + void foo() { internal(); } + } + +Normally, references to `S::foo()` would use the definition in the DLL from +which it was exported, and which presumably also has the definition of +`internal()`. However, when using ``/Zc:dllexportInlines-``, the inline +definition of `S::foo()` is used directly, resulting in a link error since +`internal()` is not available. Even worse, if there is an inline definition of +`internal()` containing a static local variable, we will now refer to a +different instance of that variable than in the DLL: + +.. code-block:: c + + inline int internal() { static int x; return x++; } + + struct __declspec(dllimport) S { + int foo() { return internal(); } + } + +This could lead to very subtle bugs. Using ``-fvisibility-inlines-hidden`` can +lead to the same issue. To avoid it in this case, make `S::foo()` or +`internal()` non-inline, or mark them `dllimport/dllexport` explicitly. + The /fallback Option ^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/analyzer/DebugChecks.rst b/docs/analyzer/DebugChecks.rst index 67521b82cabc..bb2f37f33955 100644 --- a/docs/analyzer/DebugChecks.rst +++ b/docs/analyzer/DebugChecks.rst @@ -30,9 +30,12 @@ using a 'dot' format viewer (such as Graphviz on OS X) instead. - debug.DumpLiveVars: Show the results of live variable analysis for each top-level function being analyzed. +- debug.DumpLiveStmts: Show the results of live statement analysis for each + top-level function being analyzed. + - debug.ViewExplodedGraph: Show the Exploded Graphs generated for the analysis of different functions in the input translation unit. When there - are several functions analyzed, display one graph per function. Beware + are several functions analyzed, display one graph per function. Beware that these graphs may grow very large, even for small functions. Path Tracking @@ -255,6 +258,23 @@ ExprInspection checks clang_analyzer_hashDump(x); // expected-warning{{hashed string for x}} } +- ``void clang_analyzer_denote(int, const char *);`` + + Denotes symbols with strings. A subsequent call to clang_analyzer_express() + will expresses another symbol in terms of these string. Useful for testing + relationships between different symbols. + + Example usage:: + + void foo(int x) { + clang_analyzer_denote(x, "$x"); + clang_analyzer_express(x + 1); // expected-warning{{$x + 1}} + } + +- ``void clang_analyzer_express(int);`` + + See clang_analyzer_denote(). + Statistics ========== diff --git a/docs/analyzer/RegionStore.txt b/docs/analyzer/RegionStore.txt index 5d37cf7bed99..ef994b6401e2 100644 --- a/docs/analyzer/RegionStore.txt +++ b/docs/analyzer/RegionStore.txt @@ -118,7 +118,7 @@ sometimes zero, for static data, or "uninitialized", for stack variables). int manyInts[10]; manyInts[1] = 42; // Creates a Direct binding for manyInts[1]. print(manyInts[1]); // Retrieves the Direct binding for manyInts[1]; - print(manyInts[0]); // There is no Direct binding for manyInts[1]. + print(manyInts[0]); // There is no Direct binding for manyInts[0]. // Is there a Default binding for the entire array? // There is not, but it is a stack variable, so we use // "uninitialized" as the default value (and emit a @@ -166,6 +166,6 @@ Here's a concrete example: return p2.x; // The binding for FieldRegion 'p2.x' is requested. // There is no Direct binding, so we look for a Default // binding to 'p2' and find the LCV. - // Because it's an LCV, we look at our requested region + // Because it's a LCV, we look at our requested region // and see that it's the '.x' field. We ask for the value // of 'p.x' within the snapshot, and get back 42. diff --git a/docs/conf.py b/docs/conf.py index b38c93af23c2..19113d0d5a70 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,6 +11,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +from __future__ import absolute_import, division, print_function import sys, os from datetime import date @@ -49,9 +50,9 @@ copyright = u'2007-%d, The Clang Team' % date.today().year # built documents. # # The short version. -version = '7' +version = '8' # The full version, including alpha/beta/rc tags. -release = '7' +release = '8' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -233,14 +234,14 @@ for name in os.listdir(command_guide_path): header = f.readline().rstrip('\n') if len(header) != len(title): - print >>sys.stderr, ( + print(( "error: invalid header in %r (does not match title)" % ( - file_subpath,)) + file_subpath,)), file=sys.stderr) if ' - ' not in title: - print >>sys.stderr, ( + print(( ("error: invalid title in %r " "(expected ' - ')") % ( - file_subpath,)) + file_subpath,)), file=sys.stderr) # Split the name out of the title. name,description = title.split(' - ', 1) diff --git a/docs/index.rst b/docs/index.rst index be7a371cd711..3eb1d160c756 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -83,7 +83,6 @@ Design Documents InternalsManual DriverInternals - PTHInternals PCHInternals ItaniumMangleAbiTags HardwareAssistedAddressSanitizerDesign.rst diff --git a/docs/tools/dump_ast_matchers.py b/docs/tools/dump_ast_matchers.py index d38977548fd9..c96c1ca27acb 100644 --- a/docs/tools/dump_ast_matchers.py +++ b/docs/tools/dump_ast_matchers.py @@ -5,7 +5,10 @@ import collections import re -import urllib2 +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen MATCHERS_FILE = '../../include/clang/ASTMatchers/ASTMatchers.h' @@ -38,11 +41,11 @@ def esc(text): text = re.sub(r'>', '>', text) def link_if_exists(m): name = m.group(1) - url = 'http://clang.llvm.org/doxygen/classclang_1_1%s.html' % name + url = 'https://clang.llvm.org/doxygen/classclang_1_1%s.html' % name if url not in doxygen_probes: try: - print 'Probing %s...' % url - urllib2.urlopen(url) + print('Probing %s...' % url) + urlopen(url) doxygen_probes[url] = True except: doxygen_probes[url] = False @@ -181,9 +184,9 @@ def act_on_decl(declaration, comment, allowed_types): raise Exception('Inconsistent documentation for: %s' % name) for result_type in result_types: add_matcher(result_type, name, 'Matcher', comment) - if loc: - add_matcher('%sLoc' % result_type, '%sLoc' % name, 'Matcher', - comment) + # if loc: + # add_matcher('%sLoc' % result_type, '%sLoc' % name, 'Matcher', + # comment) return m = re.match(r"""^\s*AST_POLYMORPHIC_MATCHER(_P)?(.?)(?:_OVERLOAD)?\( @@ -307,14 +310,14 @@ def act_on_decl(declaration, comment, allowed_types): if not result_types: if not comment: # Only overloads don't have their own doxygen comments; ignore those. - print 'Ignoring "%s"' % name + print('Ignoring "%s"' % name) else: - print 'Cannot determine result type for "%s"' % name + print('Cannot determine result type for "%s"' % name) else: for result_type in result_types: add_matcher(result_type, name, args, comment) else: - print '*** Unparsable: "' + declaration + '" ***' + print('*** Unparsable: "' + declaration + '" ***') def sort_table(matcher_type, matcher_map): """Returns the sorted html table for the given row map.""" @@ -354,7 +357,7 @@ for line in open(MATCHERS_FILE).read().splitlines(): allowed_types += [m.group(1)] continue if line.strip() and line.lstrip()[0] == '/': - comment += re.sub(r'/+\s?', '', line) + '\n' + comment += re.sub(r'^/+\s?', '', line) + '\n' else: declaration += ' ' + line if ((not line.strip()) or diff --git a/docs/tools/dump_format_style.py b/docs/tools/dump_format_style.py index 3d61227f7361..5feb793a4d70 100644 --- a/docs/tools/dump_format_style.py +++ b/docs/tools/dump_format_style.py @@ -6,7 +6,6 @@ import collections import os import re -import urllib2 CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..') FORMAT_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Format/Format.h') @@ -32,7 +31,7 @@ def indent(text, columns, indent_first_line=True): return s return indent + s -class Option: +class Option(object): def __init__(self, name, type, comment): self.name = name self.type = type @@ -50,7 +49,7 @@ class Option: 2) return s -class NestedStruct: +class NestedStruct(object): def __init__(self, name, comment): self.name = name self.comment = comment.strip() @@ -59,7 +58,7 @@ class NestedStruct: def __str__(self): return '\n'.join(map(str, self.values)) -class NestedField: +class NestedField(object): def __init__(self, name, comment): self.name = name self.comment = comment.strip() @@ -69,7 +68,7 @@ class NestedField: self.name, doxygen2rst(indent(self.comment, 2, indent_first_line=False))) -class Enum: +class Enum(object): def __init__(self, name, comment): self.name = name self.comment = comment.strip() @@ -78,7 +77,7 @@ class Enum: def __str__(self): return '\n'.join(map(str, self.values)) -class EnumValue: +class EnumValue(object): def __init__(self, name, comment): self.name = name self.comment = comment @@ -101,7 +100,7 @@ def clean_comment_line(line): return line[4:] + '\n' def read_options(header): - class State: + class State(object): BeforeStruct, Finished, InStruct, InNestedStruct, InNestedFieldComent, \ InFieldComment, InEnum, InEnumMemberComment = range(8) state = State.BeforeStruct @@ -180,9 +179,9 @@ def read_options(header): 'std::vector', 'std::vector', 'std::vector']: - if enums.has_key(option.type): + if option.type in enums: option.enum = enums[option.type] - elif nested_structs.has_key(option.type): + elif option.type in nested_structs: option.nested_struct = nested_structs[option.type] else: raise Exception('Unknown type: %s' % option.type) diff --git a/examples/AnnotateFunctions/CMakeLists.txt b/examples/AnnotateFunctions/CMakeLists.txt index 5684abf2380d..44b6317e72af 100644 --- a/examples/AnnotateFunctions/CMakeLists.txt +++ b/examples/AnnotateFunctions/CMakeLists.txt @@ -1,4 +1,4 @@ -add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp PLUGIN_TOOL clang) +add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) target_link_libraries(AnnotateFunctions PRIVATE diff --git a/examples/PrintFunctionNames/CMakeLists.txt b/examples/PrintFunctionNames/CMakeLists.txt index e582b2c45a86..68c6f76dff05 100644 --- a/examples/PrintFunctionNames/CMakeLists.txt +++ b/examples/PrintFunctionNames/CMakeLists.txt @@ -9,7 +9,7 @@ if( NOT MSVC ) # MSVC mangles symbols differently, and endif() endif() -add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL clang) +add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) target_link_libraries(PrintFunctionNames PRIVATE diff --git a/examples/analyzer-plugin/CMakeLists.txt b/examples/analyzer-plugin/CMakeLists.txt index 0d5b2754cafe..7c7b2aec1988 100644 --- a/examples/analyzer-plugin/CMakeLists.txt +++ b/examples/analyzer-plugin/CMakeLists.txt @@ -1,5 +1,5 @@ set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/SampleAnalyzerPlugin.exports) -add_llvm_loadable_module(SampleAnalyzerPlugin MainCallChecker.cpp PLUGIN_TOOL clang) +add_llvm_library(SampleAnalyzerPlugin MODULE MainCallChecker.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) target_link_libraries(SampleAnalyzerPlugin PRIVATE diff --git a/examples/analyzer-plugin/MainCallChecker.cpp b/examples/analyzer-plugin/MainCallChecker.cpp index 74fe663e981f..77316d696de3 100644 --- a/examples/analyzer-plugin/MainCallChecker.cpp +++ b/examples/analyzer-plugin/MainCallChecker.cpp @@ -1,6 +1,6 @@ #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" -#include "clang/StaticAnalyzer/Core/CheckerRegistry.h" +#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" using namespace clang; @@ -45,7 +45,9 @@ void MainCallChecker::checkPreStmt(const CallExpr *CE, CheckerContext &C) const // Register plugin! extern "C" void clang_registerCheckers (CheckerRegistry ®istry) { - registry.addChecker("example.MainCallChecker", "Disallows calls to functions called main"); + registry.addChecker( + "example.MainCallChecker", "Disallows calls to functions called main", + ""); } extern "C" diff --git a/examples/clang-interpreter/CMakeLists.txt b/examples/clang-interpreter/CMakeLists.txt index 7b9657ec1abf..b69a82e0541b 100644 --- a/examples/clang-interpreter/CMakeLists.txt +++ b/examples/clang-interpreter/CMakeLists.txt @@ -25,6 +25,7 @@ target_link_libraries(clang-interpreter clangCodeGen clangDriver clangFrontend + clangSerialization ) export_executable_symbols(clang-interpreter) diff --git a/examples/clang-interpreter/Test.cxx b/examples/clang-interpreter/Test.cxx index d2cbb0baac5c..d39249214dc5 100644 --- a/examples/clang-interpreter/Test.cxx +++ b/examples/clang-interpreter/Test.cxx @@ -21,7 +21,7 @@ static void ThrowerAnError(const char* Name) { int main(int argc, const char** argv) { for (int I = 0; I < argc; ++I) printf("arg[%d]='%s'\n", I, argv[I]); - + try { ThrowerAnError("In JIT"); } catch (const std::exception& E) { diff --git a/examples/clang-interpreter/main.cpp b/examples/clang-interpreter/main.cpp index 3f87be29a979..1c83b1d3e75f 100644 --- a/examples/clang-interpreter/main.cpp +++ b/examples/clang-interpreter/main.cpp @@ -54,8 +54,8 @@ private: std::shared_ptr Resolver; std::unique_ptr TM; const DataLayout DL; - RTDyldObjectLinkingLayer ObjectLayer; - IRCompileLayer CompileLayer; + LegacyRTDyldObjectLinkingLayer ObjectLayer; + LegacyIRCompileLayer CompileLayer; public: SimpleJIT() @@ -75,7 +75,7 @@ public: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), ObjectLayer(ES, [this](VModuleKey) { - return RTDyldObjectLinkingLayer::Resources{ + return LegacyRTDyldObjectLinkingLayer::Resources{ std::make_shared(), Resolver}; }), CompileLayer(ObjectLayer, SimpleCompiler(*TM)) { @@ -164,7 +164,7 @@ int main(int argc, const char **argv) { } // Initialize a compiler invocation object from the clang (-cc1) arguments. - const driver::ArgStringList &CCArgs = Cmd.getArguments(); + const llvm::opt::ArgStringList &CCArgs = Cmd.getArguments(); std::unique_ptr CI(new CompilerInvocation); CompilerInvocation::CreateFromArgs(*CI, const_cast(CCArgs.data()), diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 65dada38b050..c51dfb1598b9 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 49 +#define CINDEX_VERSION_MINOR 50 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -178,7 +178,6 @@ typedef struct CXVersion { * A negative value indicates that the cursor is not a function declaration. */ enum CXCursor_ExceptionSpecificationKind { - /** * The cursor has no exception specification. */ @@ -1332,7 +1331,17 @@ enum CXTranslationUnit_Flags { * * The function bodies of the main file are not skipped. */ - CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800 + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, + + /** + * Used to indicate that attributed types should be included in CXType. + */ + CXTranslationUnit_IncludeAttributedTypes = 0x1000, + + /** + * Used to indicate that implicit attributes should be visited. + */ + CXTranslationUnit_VisitImplicitAttributes = 0x2000 }; /** @@ -2559,7 +2568,25 @@ enum CXCursorKind { CXCursor_VisibilityAttr = 417, CXCursor_DLLExport = 418, CXCursor_DLLImport = 419, - CXCursor_LastAttr = CXCursor_DLLImport, + CXCursor_NSReturnsRetained = 420, + CXCursor_NSReturnsNotRetained = 421, + CXCursor_NSReturnsAutoreleased = 422, + CXCursor_NSConsumesSelf = 423, + CXCursor_NSConsumed = 424, + CXCursor_ObjCException = 425, + CXCursor_ObjCNSObject = 426, + CXCursor_ObjCIndependentClass = 427, + CXCursor_ObjCPreciseLifetime = 428, + CXCursor_ObjCReturnsInnerPointer = 429, + CXCursor_ObjCRequiresSuper = 430, + CXCursor_ObjCRootClass = 431, + CXCursor_ObjCSubclassingRestricted = 432, + CXCursor_ObjCExplicitProtocolImpl = 433, + CXCursor_ObjCDesignatedInitializer = 434, + CXCursor_ObjCRuntimeVisible = 435, + CXCursor_ObjCBoxable = 436, + CXCursor_FlagEnum = 437, + CXCursor_LastAttr = CXCursor_FlagEnum, /* Preprocessing */ CXCursor_PreprocessingDirective = 500, @@ -3266,7 +3293,25 @@ enum CXTypeKind { CXType_OCLSampler = 157, CXType_OCLEvent = 158, CXType_OCLQueue = 159, - CXType_OCLReserveID = 160 + CXType_OCLReserveID = 160, + + CXType_ObjCObject = 161, + CXType_ObjCTypeParam = 162, + CXType_Attributed = 163, + + CXType_OCLIntelSubgroupAVCMcePayload = 164, + CXType_OCLIntelSubgroupAVCImePayload = 165, + CXType_OCLIntelSubgroupAVCRefPayload = 166, + CXType_OCLIntelSubgroupAVCSicPayload = 167, + CXType_OCLIntelSubgroupAVCMceResult = 168, + CXType_OCLIntelSubgroupAVCImeResult = 169, + CXType_OCLIntelSubgroupAVCRefResult = 170, + CXType_OCLIntelSubgroupAVCSicResult = 171, + CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172, + CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173, + CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174, + + CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175 }; /** @@ -3291,6 +3336,7 @@ enum CXCallingConv { CXCallingConv_Swift = 13, CXCallingConv_PreserveMost = 14, CXCallingConv_PreserveAll = 15, + CXCallingConv_AArch64VectorCall = 16, CXCallingConv_Invalid = 100, CXCallingConv_Unexposed = 200 @@ -3627,6 +3673,43 @@ CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); */ CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); +/** + * Retrieves the base type of the ObjCObjectType. + * + * If the type is not an ObjC object, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T); + +/** + * Retrieve the number of protocol references associated with an ObjC object/id. + * + * If the type is not an ObjC object, 0 is returned. + */ +CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T); + +/** + * Retrieve the decl for a protocol reference for an ObjC object/id. + * + * If the type is not an ObjC object or there are not enough protocol + * references, an invalid cursor is returned. + */ +CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i); + +/** + * Retreive the number of type arguments associated with an ObjC object. + * + * If the type is not an ObjC object, 0 is returned. + */ +CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T); + +/** + * Retrieve a type argument associated with an ObjC object. + * + * If the type is not an ObjC or the index is not valid, + * an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i); + /** * Return 1 if the CXType is a variadic function type, and 0 otherwise. */ @@ -3700,6 +3783,33 @@ CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T); */ CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T); +enum CXTypeNullabilityKind { + /** + * Values of this type can never be null. + */ + CXTypeNullability_NonNull = 0, + /** + * Values of this type can be null. + */ + CXTypeNullability_Nullable = 1, + /** + * Whether values of this type can be null is (explicitly) + * unspecified. This captures a (fairly rare) case where we + * can't conclude anything about the nullability of the type even + * though it has been considered. + */ + CXTypeNullability_Unspecified = 2, + /** + * Nullability is not applicable to this type. + */ + CXTypeNullability_Invalid = 3 +}; + +/** + * Retrieve the nullability kind of a pointer type. + */ +CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T); + /** * List the possible error codes for \c clang_Type_getSizeOf, * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and @@ -3778,6 +3888,13 @@ CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); */ CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); +/** + * Return the type that was modified by this attributed type. + * + * If the type is not an attributed type, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T); + /** * Return the offset of the field represented by the Cursor. * @@ -4347,6 +4464,18 @@ typedef enum { CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved); +/** + * Given a cursor that represents a property declaration, return the + * name of the method that implements the getter. + */ +CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C); + +/** + * Given a cursor that represents a property declaration, return the + * name of the method that implements the setter, if any. + */ +CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C); + /** * 'Qualifiers' written next to the return and parameter types in * Objective-C method declarations. @@ -5491,10 +5620,15 @@ enum CXCompletionContext { */ CXCompletionContext_NaturalLanguage = 1 << 21, + /** + * #include file completions should be included in the results. + */ + CXCompletionContext_IncludedFile = 1 << 22, + /** * The current context is unknown, so set all contexts. */ - CXCompletionContext_Unknown = ((1 << 22) - 1) + CXCompletionContext_Unknown = ((1 << 23) - 1) }; /** diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index a9ab687a8de9..13870116c7fd 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -15,6 +15,7 @@ #ifndef LLVM_CLANG_AST_ASTCONTEXT_H #define LLVM_CLANG_AST_ASTCONTEXT_H +#include "clang/AST/ASTContextAllocate.h" #include "clang/AST/ASTTypeTraits.h" #include "clang/AST/CanonicalType.h" #include "clang/AST/CommentCommandTraits.h" @@ -22,6 +23,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclBase.h" #include "clang/AST/DeclarationName.h" +#include "clang/AST/Expr.h" #include "clang/AST/ExternalASTSource.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/PrettyPrinter.h" @@ -30,6 +32,7 @@ #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include "clang/Basic/AddressSpaces.h" +#include "clang/Basic/AttrKinds.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" @@ -79,6 +82,7 @@ struct fltSemantics; namespace clang { +class APFixedPoint; class APValue; class ASTMutationListener; class ASTRecordLayout; @@ -92,6 +96,7 @@ class CXXMethodDecl; class CXXRecordDecl; class DiagnosticsEngine; class Expr; +class FixedPointSemantics; class MangleContext; class MangleNumberingContext; class MaterializeTemporaryExpr; @@ -148,6 +153,22 @@ struct TypeInfo { /// Holds long-lived AST nodes (such as types and decls) that can be /// referred to throughout the semantic analysis of a file. class ASTContext : public RefCountedBase { +public: + /// Copy initialization expr of a __block variable and a boolean flag that + /// indicates whether the expression can throw. + struct BlockVarCopyInit { + BlockVarCopyInit() = default; + BlockVarCopyInit(Expr *CopyExpr, bool CanThrow) + : ExprAndFlag(CopyExpr, CanThrow) {} + void setExprAndFlag(Expr *CopyExpr, bool CanThrow) { + ExprAndFlag.setPointerAndInt(CopyExpr, CanThrow); + } + Expr *getCopyExpr() const { return ExprAndFlag.getPointer(); } + bool canThrow() const { return ExprAndFlag.getInt(); } + llvm::PointerIntPair ExprAndFlag; + }; + +private: friend class NestedNameSpecifier; mutable SmallVector Types; @@ -242,8 +263,8 @@ class ASTContext : public RefCountedBase { /// interface. llvm::DenseMap ObjCMethodRedecls; - /// Mapping from __block VarDecls to their copy initialization expr. - llvm::DenseMap BlockVarCopyInits; + /// Mapping from __block VarDecls to BlockVarCopyInit. + llvm::DenseMap BlockVarCopyInits; /// Mapping from class scope functions specialization to their /// template patterns. @@ -316,7 +337,7 @@ class ASTContext : public RefCountedBase { mutable IdentifierInfo *BoolName = nullptr; /// The identifier 'NSObject'. - IdentifierInfo *NSObjectName = nullptr; + mutable IdentifierInfo *NSObjectName = nullptr; /// The identifier 'NSCopying'. IdentifierInfo *NSCopyingName = nullptr; @@ -549,26 +570,6 @@ public: IntrusiveRefCntPtr ExternalSource; ASTMutationListener *Listener = nullptr; - /// Contains parents of a node. - using ParentVector = llvm::SmallVector; - - /// Maps from a node to its parents. This is used for nodes that have - /// pointer identity only, which are more common and we can save space by - /// only storing a unique pointer to them. - using ParentMapPointers = - llvm::DenseMap>; - - /// Parent map for nodes without pointer identity. We store a full - /// DynTypedNode for all keys. - using ParentMapOtherNodes = - llvm::DenseMap>; - /// Container for either a single DynTypedNode or for an ArrayRef to /// DynTypedNode. For use with ParentMap. class DynTypedNodeList { @@ -610,7 +611,17 @@ public: } }; - /// Returns the parents of the given node. + // A traversal scope limits the parts of the AST visible to certain analyses. + // RecursiveASTVisitor::TraverseAST will only visit reachable nodes, and + // getParents() will only observe reachable parent edges. + // + // The scope is defined by a set of "top-level" declarations. + // Initially, it is the entire TU: {getTranslationUnitDecl()}. + // Changing the scope clears the parent cache, which is expensive to rebuild. + std::vector getTraversalScope() const { return TraversalScope; } + void setTraversalScope(const std::vector &); + + /// Returns the parents of the given node (within the traversal scope). /// /// Note that this will lazily compute the parents of all nodes /// and store them for later retrieval. Thus, the first call is O(n) @@ -977,7 +988,8 @@ public: /// Get the additional modules in which the definition \p Def has /// been merged. ArrayRef getModulesWithMergedDefinition(const NamedDecl *Def) { - auto MergedIt = MergedDefModules.find(Def); + auto MergedIt = + MergedDefModules.find(cast(Def->getCanonicalDecl())); if (MergedIt == MergedDefModules.end()) return None; return MergedIt->second; @@ -1041,6 +1053,9 @@ public: CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLReserveIDTy; CanQualType OMPArraySectionTy; +#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ + CanQualType Id##Ty; +#include "clang/Basic/OpenCLExtensionTypes.def" // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. mutable QualType AutoDeductTy; // Deduction against 'auto'. @@ -1403,7 +1418,7 @@ public: QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; - QualType getAttributedType(AttributedType::Kind attrKind, + QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType); @@ -1656,7 +1671,7 @@ public: } /// Retrieve the identifier 'NSObject'. - IdentifierInfo *getNSObjectName() { + IdentifierInfo *getNSObjectName() const { if (!NSObjectName) { NSObjectName = &Idents.get("NSObject"); } @@ -1961,6 +1976,9 @@ public: unsigned char getFixedPointScale(QualType Ty) const; unsigned char getFixedPointIBits(QualType Ty) const; + FixedPointSemantics getFixedPointSemantics(QualType Ty) const; + APFixedPoint getFixedPointMax(QualType Ty) const; + APFixedPoint getFixedPointMin(QualType Ty) const; DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const; @@ -2488,6 +2506,8 @@ public: unsigned getTargetAddressSpace(LangAS AS) const; + LangAS getLangASForBuiltinAddressSpace(unsigned AS) const; + /// Get target-dependent integer value for null pointer which is used for /// constant folding. uint64_t getTargetNullPointerValue(QualType QT) const; @@ -2657,12 +2677,13 @@ public: /// otherwise returns null. const ObjCInterfaceDecl *getObjContainingInterface(const NamedDecl *ND) const; - /// Set the copy inialization expression of a block var decl. - void setBlockVarCopyInits(VarDecl*VD, Expr* Init); + /// Set the copy inialization expression of a block var decl. \p CanThrow + /// indicates whether the copy expression can throw or not. + void setBlockVarCopyInit(const VarDecl* VD, Expr *CopyExpr, bool CanThrow); /// Get the copy initialization expression of the VarDecl \p VD, or /// nullptr if none exists. - Expr *getBlockVarCopyInits(const VarDecl* VD); + BlockVarCopyInit getBlockVarCopyInit(const VarDecl* VD) const; /// Allocate an uninitialized TypeSourceInfo. /// @@ -2718,7 +2739,7 @@ public: /// predicate. void forEachMultiversionedFunctionVersion( const FunctionDecl *FD, - llvm::function_ref Pred) const; + llvm::function_ref Pred) const; const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD); @@ -2894,13 +2915,13 @@ private: // but we include it here so that ASTContext can quickly deallocate them. llvm::PointerIntPair LastSDM; - std::unique_ptr PointerParents; - std::unique_ptr OtherParents; + std::vector TraversalScope; + class ParentMap; + std::unique_ptr Parents; std::unique_ptr VTContext; void ReleaseDeclContextMaps(); - void ReleaseParentMapEntries(); public: enum PragmaSectionFlag : unsigned { @@ -2949,8 +2970,8 @@ inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) { /// This placement form of operator new uses the ASTContext's allocator for /// obtaining memory. /// -/// IMPORTANT: These are also declared in clang/AST/AttrIterator.h! Any changes -/// here need to also be made there. +/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h! +/// Any changes here need to also be made there. /// /// We intentionally avoid using a nothrow specification here so that the calls /// to this operator will not perform a null check on the result -- the @@ -2973,7 +2994,7 @@ inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) { /// allocator supports it). /// @return The allocated memory. Could be nullptr. inline void *operator new(size_t Bytes, const clang::ASTContext &C, - size_t Alignment) { + size_t Alignment /* = 8 */) { return C.Allocate(Bytes, Alignment); } @@ -3011,7 +3032,7 @@ inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) { /// allocator supports it). /// @return The allocated memory. Could be nullptr. inline void *operator new[](size_t Bytes, const clang::ASTContext& C, - size_t Alignment = 8) { + size_t Alignment /* = 8 */) { return C.Allocate(Bytes, Alignment); } diff --git a/include/clang/AST/ASTContextAllocate.h b/include/clang/AST/ASTContextAllocate.h new file mode 100644 index 000000000000..5b9eed208a4d --- /dev/null +++ b/include/clang/AST/ASTContextAllocate.h @@ -0,0 +1,38 @@ +//===- ASTContextAllocate.h - ASTContext allocate functions -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares ASTContext allocation functions separate from the main +// code in ASTContext.h. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H +#define LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H + +#include + +namespace clang { + +class ASTContext; + +} // namespace clang + +// Defined in ASTContext.h +void *operator new(size_t Bytes, const clang::ASTContext &C, + size_t Alignment = 8); +void *operator new[](size_t Bytes, const clang::ASTContext &C, + size_t Alignment = 8); + +// It is good practice to pair new/delete operators. Also, MSVC gives many +// warnings if a matching delete overload is not declared, even though the +// throw() spec guarantees it will not be implicitly called. +void operator delete(void *Ptr, const clang::ASTContext &C, size_t); +void operator delete[](void *Ptr, const clang::ASTContext &C, size_t); + +#endif // LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h index 2534272da3a3..fe92604587ef 100644 --- a/include/clang/AST/ASTDiagnostic.h +++ b/include/clang/AST/ASTDiagnostic.h @@ -11,19 +11,9 @@ #define LLVM_CLANG_AST_ASTDIAGNOSTIC_H #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticAST.h" namespace clang { - namespace diag { - enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\ - SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM, -#define ASTSTART -#include "clang/Basic/DiagnosticASTKinds.inc" -#undef DIAG - NUM_BUILTIN_AST_DIAGNOSTICS - }; - } // end namespace diag - /// DiagnosticsEngine argument formatting function for diagnostics that /// involve AST nodes. /// diff --git a/include/clang/AST/ASTDumperUtils.h b/include/clang/AST/ASTDumperUtils.h new file mode 100644 index 000000000000..5e62e902b423 --- /dev/null +++ b/include/clang/AST/ASTDumperUtils.h @@ -0,0 +1,97 @@ +//===--- ASTDumperUtils.h - Printing of AST nodes -------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements AST utilities for traversal down the tree. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H +#define LLVM_CLANG_AST_ASTDUMPERUTILS_H + +#include "llvm/Support/raw_ostream.h" + +namespace clang { + +// Colors used for various parts of the AST dump +// Do not use bold yellow for any text. It is hard to read on white screens. + +struct TerminalColor { + llvm::raw_ostream::Colors Color; + bool Bold; +}; + +// Red - CastColor +// Green - TypeColor +// Bold Green - DeclKindNameColor, UndeserializedColor +// Yellow - AddressColor, LocationColor +// Blue - CommentColor, NullColor, IndentColor +// Bold Blue - AttrColor +// Bold Magenta - StmtColor +// Cyan - ValueKindColor, ObjectKindColor +// Bold Cyan - ValueColor, DeclNameColor + +// Decl kind names (VarDecl, FunctionDecl, etc) +static const TerminalColor DeclKindNameColor = {llvm::raw_ostream::GREEN, true}; +// Attr names (CleanupAttr, GuardedByAttr, etc) +static const TerminalColor AttrColor = {llvm::raw_ostream::BLUE, true}; +// Statement names (DeclStmt, ImplicitCastExpr, etc) +static const TerminalColor StmtColor = {llvm::raw_ostream::MAGENTA, true}; +// Comment names (FullComment, ParagraphComment, TextComment, etc) +static const TerminalColor CommentColor = {llvm::raw_ostream::BLUE, false}; + +// Type names (int, float, etc, plus user defined types) +static const TerminalColor TypeColor = {llvm::raw_ostream::GREEN, false}; + +// Pointer address +static const TerminalColor AddressColor = {llvm::raw_ostream::YELLOW, false}; +// Source locations +static const TerminalColor LocationColor = {llvm::raw_ostream::YELLOW, false}; + +// lvalue/xvalue +static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false}; +// bitfield/objcproperty/objcsubscript/vectorcomponent +static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false}; + +// Null statements +static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false}; + +// Undeserialized entities +static const TerminalColor UndeserializedColor = {llvm::raw_ostream::GREEN, + true}; + +// CastKind from CastExpr's +static const TerminalColor CastColor = {llvm::raw_ostream::RED, false}; + +// Value of the statement +static const TerminalColor ValueColor = {llvm::raw_ostream::CYAN, true}; +// Decl names +static const TerminalColor DeclNameColor = {llvm::raw_ostream::CYAN, true}; + +// Indents ( `, -. | ) +static const TerminalColor IndentColor = {llvm::raw_ostream::BLUE, false}; + +class ColorScope { + llvm::raw_ostream &OS; + const bool ShowColors; + +public: + ColorScope(llvm::raw_ostream &OS, bool ShowColors, TerminalColor Color) + : OS(OS), ShowColors(ShowColors) { + if (ShowColors) + OS.changeColor(Color.Color, Color.Bold); + } + ~ColorScope() { + if (ShowColors) + OS.resetColor(); + } +}; + +} // namespace clang + +#endif // LLVM_CLANG_AST_ASTDUMPERUTILS_H diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index 2e9a8775a8a2..dbb9cf35ddea 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -25,12 +25,15 @@ #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Error.h" #include namespace clang { class ASTContext; +class ASTImporterLookupTable; class CXXBaseSpecifier; class CXXCtorInitializer; class Decl; @@ -43,6 +46,29 @@ class TagDecl; class TypeSourceInfo; class Attr; + class ImportError : public llvm::ErrorInfo { + public: + /// \brief Kind of error when importing an AST component. + enum ErrorKind { + NameConflict, /// Naming ambiguity (likely ODR violation). + UnsupportedConstruct, /// Not supported node or case. + Unknown /// Other error. + }; + + ErrorKind Error; + + static char ID; + + ImportError() : Error(Unknown) { } + ImportError(const ImportError &Other) : Error(Other.Error) { } + ImportError(ErrorKind Error) : Error(Error) { } + + std::string toString() const; + + void log(raw_ostream &OS) const override; + std::error_code convertToErrorCode() const override; + }; + // \brief Returns with a list of declarations started from the canonical decl // then followed by subsequent decls in the translation unit. // This gives a canonical list for each entry in the redecl chain. @@ -55,12 +81,21 @@ class Attr; /// Imports selected nodes from one AST context into another context, /// merging AST nodes where appropriate. class ASTImporter { + friend class ASTNodeImporter; public: using NonEquivalentDeclSet = llvm::DenseSet>; using ImportedCXXBaseSpecifierMap = llvm::DenseMap; private: + + /// Pointer to the import specific lookup table, which may be shared + /// amongst several ASTImporter objects. + /// This is an externally managed resource (and should exist during the + /// lifetime of the ASTImporter object) + /// If not set then the original C/C++ lookup is used. + ASTImporterLookupTable *LookupTable = nullptr; + /// The contexts we're importing to and from. ASTContext &ToContext, &FromContext; @@ -98,9 +133,13 @@ class Attr; /// (which we have already complained about). NonEquivalentDeclSet NonEquivalentDecls; + using FoundDeclsTy = SmallVector; + FoundDeclsTy findDeclsInToCtx(DeclContext *DC, DeclarationName Name); + + void AddToLookupTable(Decl *ToD); + public: - /// Create a new AST importer. - /// + /// \param ToContext The context we'll be importing into. /// /// \param ToFileManager The file manager we'll be importing into. @@ -112,9 +151,14 @@ class Attr; /// \param MinimalImport If true, the importer will attempt to import /// as little as it can, e.g., by importing declarations as forward /// declarations that can be completed at a later point. + /// + /// \param LookupTable The importer specific lookup table which may be + /// shared amongst several ASTImporter objects. + /// If not set then the original C/C++ lookup is used. ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, - bool MinimalImport); + bool MinimalImport, + ASTImporterLookupTable *LookupTable = nullptr); virtual ~ASTImporter(); @@ -122,31 +166,60 @@ class Attr; /// to-be-completed forward declarations when possible. bool isMinimalImport() const { return Minimal; } - /// Import the given type from the "from" context into the "to" - /// context. + /// \brief Import the given object, returns the result. /// - /// \returns the equivalent type in the "to" context, or a NULL type if - /// an error occurred. + /// \param To Import the object into this variable. + /// \param From Object to import. + /// \return Error information (success or error). + template + LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From) { + To = Import(From); + if (From && !To) + return llvm::make_error(); + return llvm::Error::success(); + // FIXME: this should be the final code + //auto ToOrErr = Import(From); + //if (ToOrErr) + // To = *ToOrErr; + //return ToOrErr.takeError(); + } + + /// Import the given type from the "from" context into the "to" + /// context. A null type is imported as a null type (no error). + /// + /// \returns The equivalent type in the "to" context, or the import error. + llvm::Expected Import_New(QualType FromT); + // FIXME: Remove this version. QualType Import(QualType FromT); /// Import the given type source information from the /// "from" context into the "to" context. /// - /// \returns the equivalent type source information in the "to" - /// context, or NULL if an error occurred. + /// \returns The equivalent type source information in the "to" + /// context, or the import error. + llvm::Expected Import_New(TypeSourceInfo *FromTSI); + // FIXME: Remove this version. TypeSourceInfo *Import(TypeSourceInfo *FromTSI); /// Import the given attribute from the "from" context into the /// "to" context. /// - /// \returns the equivalent attribute in the "to" context. + /// \returns The equivalent attribute in the "to" context, or the import + /// error. + llvm::Expected Import_New(const Attr *FromAttr); + // FIXME: Remove this version. Attr *Import(const Attr *FromAttr); /// Import the given declaration from the "from" context into the /// "to" context. /// - /// \returns the equivalent declaration in the "to" context, or a NULL type - /// if an error occurred. + /// \returns The equivalent declaration in the "to" context, or the import + /// error. + llvm::Expected Import_New(Decl *FromD); + llvm::Expected Import_New(const Decl *FromD) { + return Import_New(const_cast(FromD)); + } + // FIXME: Remove this version. Decl *Import(Decl *FromD); Decl *Import(const Decl *FromD) { return Import(const_cast(FromD)); @@ -155,104 +228,137 @@ class Attr; /// Return the copy of the given declaration in the "to" context if /// it has already been imported from the "from" context. Otherwise return /// NULL. - Decl *GetAlreadyImportedOrNull(Decl *FromD); + Decl *GetAlreadyImportedOrNull(const Decl *FromD) const; /// Import the given declaration context from the "from" /// AST context into the "to" AST context. /// /// \returns the equivalent declaration context in the "to" - /// context, or a NULL type if an error occurred. - DeclContext *ImportContext(DeclContext *FromDC); + /// context, or error value. + llvm::Expected ImportContext(DeclContext *FromDC); /// Import the given expression from the "from" context into the /// "to" context. /// - /// \returns the equivalent expression in the "to" context, or NULL if - /// an error occurred. + /// \returns The equivalent expression in the "to" context, or the import + /// error. + llvm::Expected Import_New(Expr *FromE); + // FIXME: Remove this version. Expr *Import(Expr *FromE); /// Import the given statement from the "from" context into the /// "to" context. /// - /// \returns the equivalent statement in the "to" context, or NULL if - /// an error occurred. + /// \returns The equivalent statement in the "to" context, or the import + /// error. + llvm::Expected Import_New(Stmt *FromS); + // FIXME: Remove this version. Stmt *Import(Stmt *FromS); /// Import the given nested-name-specifier from the "from" /// context into the "to" context. /// - /// \returns the equivalent nested-name-specifier in the "to" - /// context, or NULL if an error occurred. + /// \returns The equivalent nested-name-specifier in the "to" + /// context, or the import error. + llvm::Expected + Import_New(NestedNameSpecifier *FromNNS); + // FIXME: Remove this version. NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS); - /// Import the given nested-name-specifier from the "from" + /// Import the given nested-name-specifier-loc from the "from" /// context into the "to" context. /// - /// \returns the equivalent nested-name-specifier in the "to" - /// context. + /// \returns The equivalent nested-name-specifier-loc in the "to" + /// context, or the import error. + llvm::Expected + Import_New(NestedNameSpecifierLoc FromNNS); + // FIXME: Remove this version. NestedNameSpecifierLoc Import(NestedNameSpecifierLoc FromNNS); - /// Import the goven template name from the "from" context into the - /// "to" context. + /// Import the given template name from the "from" context into the + /// "to" context, or the import error. + llvm::Expected Import_New(TemplateName From); + // FIXME: Remove this version. TemplateName Import(TemplateName From); /// Import the given source location from the "from" context into /// the "to" context. /// - /// \returns the equivalent source location in the "to" context, or an - /// invalid source location if an error occurred. + /// \returns The equivalent source location in the "to" context, or the + /// import error. + llvm::Expected Import_New(SourceLocation FromLoc); + // FIXME: Remove this version. SourceLocation Import(SourceLocation FromLoc); /// Import the given source range from the "from" context into /// the "to" context. /// - /// \returns the equivalent source range in the "to" context, or an - /// invalid source location if an error occurred. + /// \returns The equivalent source range in the "to" context, or the import + /// error. + llvm::Expected Import_New(SourceRange FromRange); + // FIXME: Remove this version. SourceRange Import(SourceRange FromRange); /// Import the given declaration name from the "from" /// context into the "to" context. /// - /// \returns the equivalent declaration name in the "to" context, - /// or an empty declaration name if an error occurred. + /// \returns The equivalent declaration name in the "to" context, or the + /// import error. + llvm::Expected Import_New(DeclarationName FromName); + // FIXME: Remove this version. DeclarationName Import(DeclarationName FromName); /// Import the given identifier from the "from" context /// into the "to" context. /// - /// \returns the equivalent identifier in the "to" context. + /// \returns The equivalent identifier in the "to" context. Note: It + /// returns nullptr only if the FromId was nullptr. IdentifierInfo *Import(const IdentifierInfo *FromId); /// Import the given Objective-C selector from the "from" /// context into the "to" context. /// - /// \returns the equivalent selector in the "to" context. + /// \returns The equivalent selector in the "to" context, or the import + /// error. + llvm::Expected Import_New(Selector FromSel); + // FIXME: Remove this version. Selector Import(Selector FromSel); /// Import the given file ID from the "from" context into the /// "to" context. /// - /// \returns the equivalent file ID in the source manager of the "to" - /// context. + /// \returns The equivalent file ID in the source manager of the "to" + /// context, or the import error. + llvm::Expected Import_New(FileID); + // FIXME: Remove this version. FileID Import(FileID); /// Import the given C++ constructor initializer from the "from" /// context into the "to" context. /// - /// \returns the equivalent initializer in the "to" context. + /// \returns The equivalent initializer in the "to" context, or the import + /// error. + llvm::Expected + Import_New(CXXCtorInitializer *FromInit); + // FIXME: Remove this version. CXXCtorInitializer *Import(CXXCtorInitializer *FromInit); /// Import the given CXXBaseSpecifier from the "from" context into /// the "to" context. /// - /// \returns the equivalent CXXBaseSpecifier in the source manager of the - /// "to" context. + /// \returns The equivalent CXXBaseSpecifier in the source manager of the + /// "to" context, or the import error. + llvm::Expected + Import_New(const CXXBaseSpecifier *FromSpec); + // FIXME: Remove this version. CXXBaseSpecifier *Import(const CXXBaseSpecifier *FromSpec); /// Import the definition of the given declaration, including all of /// the declarations it contains. - /// - /// This routine is intended to be used + LLVM_NODISCARD llvm::Error ImportDefinition_New(Decl *From); + + // FIXME: Compatibility function. + // Usages of this should be changed to ImportDefinition_New. void ImportDefinition(Decl *From); /// Cope with a name conflict when importing a declaration into the @@ -333,6 +439,13 @@ class Attr; /// equivalent. bool IsStructurallyEquivalent(QualType From, QualType To, bool Complain = true); + + /// Determine the index of a field in its parent record. + /// F should be a field (or indirect field) declaration. + /// \returns The index of the field in its parent context (starting from 0). + /// On error `None` is returned (parent context is non-record). + static llvm::Optional getFieldIndex(Decl *F); + }; } // namespace clang diff --git a/include/clang/AST/ASTImporterLookupTable.h b/include/clang/AST/ASTImporterLookupTable.h new file mode 100644 index 000000000000..14cafe817ddc --- /dev/null +++ b/include/clang/AST/ASTImporterLookupTable.h @@ -0,0 +1,75 @@ +//===- ASTImporterLookupTable.h - ASTImporter specific lookup--*- C++ -*---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the ASTImporterLookupTable class which implements a +// lookup procedure for the import mechanism. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H +#define LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H + +#include "clang/AST/DeclBase.h" // lookup_result +#include "clang/AST/DeclarationName.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SetVector.h" + +namespace clang { + +class ASTContext; +class NamedDecl; +class DeclContext; + +// There are certain cases when normal C/C++ lookup (localUncachedLookup) +// does not find AST nodes. E.g.: +// Example 1: +// template +// struct X { +// friend void foo(); // this is never found in the DC of the TU. +// }; +// Example 2: +// // The fwd decl to Foo is not found in the lookupPtr of the DC of the +// // translation unit decl. +// // Here we could find the node by doing a traverse throught the list of +// // the Decls in the DC, but that would not scale. +// struct A { struct Foo *p; }; +// This is a severe problem because the importer decides if it has to create a +// new Decl or not based on the lookup results. +// To overcome these cases we need an importer specific lookup table which +// holds every node and we are not interested in any C/C++ specific visibility +// considerations. Simply, we must know if there is an existing Decl in a +// given DC. Once we found it then we can handle any visibility related tasks. +class ASTImporterLookupTable { + + // We store a list of declarations for each name. + // And we collect these lists for each DeclContext. + // We could have a flat map with (DeclContext, Name) tuple as key, but a two + // level map seems easier to handle. + using DeclList = llvm::SmallSetVector; + using NameMap = llvm::SmallDenseMap; + using DCMap = llvm::DenseMap; + + void add(DeclContext *DC, NamedDecl *ND); + void remove(DeclContext *DC, NamedDecl *ND); + + DCMap LookupTable; + +public: + ASTImporterLookupTable(TranslationUnitDecl &TU); + void add(NamedDecl *ND); + void remove(NamedDecl *ND); + using LookupResult = DeclList; + LookupResult lookup(DeclContext *DC, DeclarationName Name) const; + void dump(DeclContext *DC) const; + void dump() const; +}; + +} // namespace clang + +#endif // LLVM_CLANG_AST_ASTIMPORTERLOOKUPTABLE_H diff --git a/include/clang/AST/ASTStructuralEquivalence.h b/include/clang/AST/ASTStructuralEquivalence.h index d32f87d43e04..f8847505bc72 100644 --- a/include/clang/AST/ASTStructuralEquivalence.h +++ b/include/clang/AST/ASTStructuralEquivalence.h @@ -15,6 +15,7 @@ #ifndef LLVM_CLANG_AST_ASTSTRUCTURALEQUIVALENCE_H #define LLVM_CLANG_AST_ASTSTRUCTURALEQUIVALENCE_H +#include "clang/AST/DeclBase.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" @@ -114,8 +115,19 @@ struct StructuralEquivalenceContext { private: /// Finish checking all of the structural equivalences. /// - /// \returns true if an error occurred, false otherwise. + /// \returns true if the equivalence check failed (non-equivalence detected), + /// false if equivalence was detected. bool Finish(); + + /// Check for common properties at Finish. + /// \returns true if D1 and D2 may be equivalent, + /// false if they are for sure not. + bool CheckCommonEquivalence(Decl *D1, Decl *D2); + + /// Check for class dependent properties at Finish. + /// \returns true if D1 and D2 may be equivalent, + /// false if they are for sure not. + bool CheckKindSpecificEquivalence(Decl *D1, Decl *D2); }; } // namespace clang diff --git a/include/clang/AST/ASTVector.h b/include/clang/AST/ASTVector.h index 80cd6b7007a6..51de119f080e 100644 --- a/include/clang/AST/ASTVector.h +++ b/include/clang/AST/ASTVector.h @@ -18,6 +18,7 @@ #ifndef LLVM_CLANG_AST_ASTVECTOR_H #define LLVM_CLANG_AST_ASTVECTOR_H +#include "clang/AST/ASTContextAllocate.h" #include "llvm/ADT/PointerIntPair.h" #include #include diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 20922742f687..3a319326d269 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_AST_ATTR_H #define LLVM_CLANG_AST_ATTR_H +#include "clang/AST/ASTContextAllocate.h" // For Attrs.inc #include "clang/AST/AttrIterator.h" #include "clang/AST/Decl.h" #include "clang/AST/Expr.h" @@ -113,6 +114,19 @@ public: void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const; }; +class TypeAttr : public Attr { +protected: + TypeAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, + bool IsLateParsed) + : Attr(AK, R, SpellingListIndex, IsLateParsed) {} + +public: + static bool classof(const Attr *A) { + return A->getKind() >= attr::FirstTypeAttr && + A->getKind() <= attr::LastTypeAttr; + } +}; + class StmtAttr : public Attr { protected: StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, diff --git a/include/clang/AST/AttrIterator.h b/include/clang/AST/AttrIterator.h index 2087ecc0e70c..43ad1c931967 100644 --- a/include/clang/AST/AttrIterator.h +++ b/include/clang/AST/AttrIterator.h @@ -26,25 +26,6 @@ namespace clang { class ASTContext; class Attr; -} // namespace clang - -// Defined in ASTContext.h -void *operator new(size_t Bytes, const clang::ASTContext &C, - size_t Alignment = 8); - -// FIXME: Being forced to not have a default argument here due to redeclaration -// rules on default arguments sucks -void *operator new[](size_t Bytes, const clang::ASTContext &C, - size_t Alignment); - -// It is good practice to pair new/delete operators. Also, MSVC gives many -// warnings if a matching delete overload is not declared, even though the -// throw() spec guarantees it will not be implicitly called. -void operator delete(void *Ptr, const clang::ASTContext &C, size_t); -void operator delete[](void *Ptr, const clang::ASTContext &C, size_t); - -namespace clang { - /// AttrVec - A vector of Attr, which is how they are stored on the AST. using AttrVec = SmallVector; diff --git a/include/clang/AST/AttrVisitor.h b/include/clang/AST/AttrVisitor.h new file mode 100644 index 000000000000..867f9e7ad18d --- /dev/null +++ b/include/clang/AST/AttrVisitor.h @@ -0,0 +1,76 @@ +//===- AttrVisitor.h - Visitor for Attr subclasses --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the AttrVisitor interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_ATTRVISITOR_H +#define LLVM_CLANG_AST_ATTRVISITOR_H + +#include "clang/AST/Attr.h" + +namespace clang { + +namespace attrvisitor { + +/// A simple visitor class that helps create attribute visitors. +template