diff --git a/CMakeLists.txt b/CMakeLists.txt index cfcd2212cfa..c56707e7fb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) "--libdir" "--includedir" "--prefix" - "--src-root") + "--src-root" + "--cmakedir") execute_process( COMMAND ${CONFIG_COMMAND} RESULT_VARIABLE HAD_ERROR @@ -41,6 +42,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_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_CMAKE_PATH) if(NOT MSVC_IDE) set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} @@ -58,7 +60,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH) - set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake") if(EXISTS ${LLVMCONFIG_FILE}) list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") @@ -124,6 +125,7 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") endif() if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) + # Note: path not really used, except for checking if lit was found set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) if(NOT LLVM_UTILS_PROVIDED) add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck) @@ -140,8 +142,10 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") endif() else() # Seek installed Lit. - find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit - DOC "Path to lit.py") + find_program(LLVM_LIT + NAMES llvm-lit lit.py lit + PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit" + DOC "Path to lit.py") endif() if(LLVM_LIT) @@ -177,6 +181,9 @@ if (LIBXML2_FOUND) set(CLANG_HAVE_LIBXML 1) endif() +include(CheckIncludeFile) +check_include_file(sys/resource.h CLANG_HAVE_RLIMITS) + set(CLANG_RESOURCE_DIR "" CACHE STRING "Relative directory from the Clang binary to its resource files.") @@ -192,13 +199,27 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL "enable x86 relax relocations by default") +set(CLANG_DEFAULT_LINKER "" CACHE STRING + "Default linker to use (linker name or absolute path, empty for platform default)") + set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING - "Default C++ stdlib to use (empty for architecture default, \"libstdc++\" or \"libc++\"") + "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default") if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR CLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++")) - message(WARNING "Resetting default C++ stdlib to use architecture default") - set(CLANG_DEFAULT_CXX_STDLIB "") + message(WARNING "Resetting default C++ stdlib to use platform default") + set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING + "Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default" FORCE) +endif() + +set(CLANG_DEFAULT_RTLIB "" CACHE STRING + "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)") +if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR + CLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR + CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")) + message(WARNING "Resetting default rtlib to use platform default") + set(CLANG_DEFAULT_RTLIB "" CACHE STRING + "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE) endif() set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING @@ -247,22 +268,19 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) endif() endif() -# Compute the Clang version from the LLVM version. -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION - ${PACKAGE_VERSION}) -message(STATUS "Clang version: ${CLANG_VERSION}") - -string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" CLANG_VERSION_MAJOR - ${CLANG_VERSION}) -string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" CLANG_VERSION_MINOR - ${CLANG_VERSION}) -if (${CLANG_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - set(CLANG_HAS_VERSION_PATCHLEVEL 1) - string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" CLANG_VERSION_PATCHLEVEL - ${CLANG_VERSION}) -else() - set(CLANG_HAS_VERSION_PATCHLEVEL 0) +# 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}) +endif() +if(NOT DEFINED CLANG_VERSION_MINOR) + set(CLANG_VERSION_MINOR ${LLVM_VERSION_MINOR}) endif() +if(NOT DEFINED CLANG_VERSION_PATCHLEVEL) + set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH}) +endif() +# Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX. +set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}") +message(STATUS "Clang version: ${CLANG_VERSION}") # Configure the Version.inc file. configure_file( @@ -404,6 +422,29 @@ else() endif() add_subdirectory(examples) +if(APPLE) + # this line is needed as a cleanup to ensure that any CMakeCaches with the old + # default value get updated to the new default. + if(CLANG_ORDER_FILE STREQUAL "") + unset(CLANG_ORDER_FILE CACHE) + unset(CLANG_ORDER_FILE) + endif() + + + set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH + "Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).") + + if(NOT EXISTS ${CLANG_ORDER_FILE}) + string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START) + if(PATH_START EQUAL 0) + file(WRITE ${CLANG_ORDER_FILE} "\n") + else() + message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.") + endif() + endif() +endif() + + if( CLANG_INCLUDE_TESTS ) if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) add_subdirectory(unittests) @@ -438,37 +479,19 @@ if( CLANG_INCLUDE_DOCS ) add_subdirectory(docs) endif() +add_subdirectory(cmake/modules) -if(APPLE) - # this line is needed as a cleanup to ensure that any CMakeCaches with the old - # default value get updated to the new default. - if(CLANG_ORDER_FILE STREQUAL "") - unset(CLANG_ORDER_FILE CACHE) - unset(CLANG_ORDER_FILE) - endif() - - - set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH - "Order file to use when compiling clang in order to improve startup time (Darwin Only - requires ld64).") - - if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE}) - string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START) - if(PATH_START EQUAL 0) - file(WRITE ${CLANG_ORDER_FILE} "\n") - else() - message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not exist.") - endif() - endif() +if(CLANG_STAGE) + message(STATUS "Setting current clang stage to: ${CLANG_STAGE}") endif() -add_subdirectory(cmake/modules) - if (CLANG_ENABLE_BOOTSTRAP) include(ExternalProject) + add_custom_target(clang-bootstrap-deps DEPENDS clang) + if(NOT CLANG_STAGE) set(CLANG_STAGE stage1) - message(STATUS "Setting current clang stage to: ${CLANG_STAGE}") endif() string(REGEX MATCH "stage([0-9]*)" MATCHED_STAGE "${CLANG_STAGE}") @@ -491,19 +514,28 @@ if (CLANG_ENABLE_BOOTSTRAP) set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/) set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/) - set(cmake_command ${CMAKE_COMMAND}) - # If the next stage is LTO we need to depend on LTO and possibly LLVMgold - if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO) - set(LTO_DEP LTO) + # If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold + if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED) if(APPLE) + add_dependencies(clang-bootstrap-deps LTO) # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work # using the just-built compiler, and we need to override DYLD_LIBRARY_PATH # so that the host object file tools will use the just-built libLTO. - set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib) - set(cmake_command ${CMAKE_COMMAND} -E env DYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR} ${CMAKE_COMMAND}) + # However if System Integrity Protection is enabled the DYLD variables + # will be scrubbed from the environment of any base system commands. This + # includes /bin/sh, which ninja uses when executing build commands. To + # work around the envar being filtered away we pass it in as a CMake + # variable, and have LLVM's CMake append the envar to the archiver calls. + set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib + -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR}) elseif(NOT WIN32) - list(APPEND LTO_DEP LLVMgold llvm-ar llvm-ranlib) + add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib) + if(BOOTSTRAP_LLVM_ENABLE_LLD) + add_dependencies(clang-bootstrap-deps lld) + elseif(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) endif() @@ -514,7 +546,7 @@ if (CLANG_ENABLE_BOOTSTRAP) ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-cleared - DEPENDS clang ${LTO_DEP} + DEPENDS clang-bootstrap-deps COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR} @@ -526,18 +558,25 @@ if (CLANG_ENABLE_BOOTSTRAP) set(verbose -DCMAKE_VERBOSE_MAKEFILE=On) endif() - set(BOOTSTRAP_DEFAULT_PASSTHROUGH + set(_BOOTSTRAP_DEFAULT_PASSTHROUGH PACKAGE_VERSION + PACKAGE_VENDOR LLVM_VERSION_MAJOR LLVM_VERSION_MINOR LLVM_VERSION_PATCH + CLANG_VERSION_MAJOR + CLANG_VERSION_MINOR + CLANG_VERSION_PATCHLEVEL LLVM_VERSION_SUFFIX LLVM_BINUTILS_INCDIR CLANG_REPOSITORY_STRING - CMAKE_MAKE_PROGRAM) + CMAKE_MAKE_PROGRAM + CMAKE_OSX_ARCHITECTURES) - if(TARGET compiler-rt) - set(RUNTIME_DEP compiler-rt) + # We don't need to depend on compiler-rt if we're building instrumented + # because the next stage will use the same compiler used to build this stage. + if(TARGET compiler-rt AND NOT LLVM_BUILD_INSTRUMENTED) + add_dependencies(clang-bootstrap-deps compiler-rt) endif() set(COMPILER_OPTIONS @@ -546,18 +585,27 @@ if (CLANG_ENABLE_BOOTSTRAP) -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) if(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED) - set(PGO_DEP llvm-profdata) + add_dependencies(clang-bootstrap-deps llvm-profdata) set(PGO_OPT -DLLVM_PROFDATA=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-profdata) endif() if(LLVM_BUILD_INSTRUMENTED) - set(PGO_DEP generate-profdata) + add_dependencies(clang-bootstrap-deps generate-profdata) set(PGO_OPT -DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata) - set(COMPILER_OPTIONS - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER}) - set(RUNTIME_DEP) # Don't set runtime dependencies + # Use the current tools for LTO instead of the instrumented ones + list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH + CMAKE_CXX_COMPILER + CMAKE_C_COMPILER + CMAKE_ASM_COMPILER + CMAKE_AR + CMAKE_RANLIB + DARWIN_LTO_LIBRARY + DYLD_LIBRARY_PATH) + + set(COMPILER_OPTIONS) + set(LTO_LIBRARY) + set(LTO_AR) + set(LTO_RANLIB) endif() # Find all variables that start with BOOTSTRAP_ and populate a variable with @@ -577,16 +625,20 @@ if (CLANG_ENABLE_BOOTSTRAP) endforeach() # Populate the passthrough variables - foreach(variableName ${CLANG_BOOTSTRAP_PASSTHROUGH} ${BOOTSTRAP_DEFAULT_PASSTHROUGH}) - if(${variableName}) - string(REPLACE ";" "\;" value ${${variableName}}) + foreach(variableName ${CLANG_BOOTSTRAP_PASSTHROUGH} ${_BOOTSTRAP_DEFAULT_PASSTHROUGH}) + if(DEFINED ${variableName}) + if("${${variableName}}" STREQUAL "") + set(value "") + else() + string(REPLACE ";" "\;" value ${${variableName}}) + endif() list(APPEND PASSTHROUGH_VARIABLES -D${variableName}=${value}) endif() endforeach() ExternalProject_Add(${NEXT_CLANG_STAGE} - DEPENDS clang ${LTO_DEP} ${RUNTIME_DEP} ${PGO_DEP} + DEPENDS clang-bootstrap-deps PREFIX ${NEXT_CLANG_STAGE} SOURCE_DIR ${CMAKE_SOURCE_DIR} STAMP_DIR ${STAMP_DIR} @@ -601,7 +653,6 @@ if (CLANG_ENABLE_BOOTSTRAP) -DCLANG_STAGE=${NEXT_CLANG_STAGE} ${COMPILER_OPTIONS} ${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${PGO_OPT} - CMAKE_COMMAND ${cmake_command} INSTALL_COMMAND "" STEP_TARGETS configure build USES_TERMINAL_CONFIGURE 1 @@ -612,7 +663,7 @@ if (CLANG_ENABLE_BOOTSTRAP) # exclude really-install from main target set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_really-install_EXCLUDE_FROM_MAIN On) ExternalProject_Add_Step(${NEXT_CLANG_STAGE} really-install - COMMAND ${cmake_command} --build --target install + COMMAND ${CMAKE_COMMAND} --build --target install COMMENT "Performing install step for '${NEXT_CLANG_STAGE}'" DEPENDEES build USES_TERMINAL 1 @@ -628,7 +679,7 @@ if (CLANG_ENABLE_BOOTSTRAP) set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_${target}_EXCLUDE_FROM_MAIN On) ExternalProject_Add_Step(${NEXT_CLANG_STAGE} ${target} - COMMAND ${cmake_command} --build --target ${target} + COMMAND ${CMAKE_COMMAND} --build --target ${target} COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'" DEPENDEES configure USES_TERMINAL 1 diff --git a/bindings/python/clang/__init__.py b/bindings/python/clang/__init__.py index 88f30812383..fba49e38c9b 100644 --- a/bindings/python/clang/__init__.py +++ b/bindings/python/clang/__init__.py @@ -20,5 +20,13 @@ Bindings for the Clang indexing library. """ + +# Python 3 uses unicode for strings. The bindings, in particular the interaction +# with ctypes, need modifying to handle conversions between unicode and +# c-strings. +import sys +if sys.version_info[0] != 2: + raise Exception("Only Python 2 is supported.") + __all__ = ['cindex'] diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index aeb34f8cb23..cf867bbf7d0 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -305,6 +305,14 @@ class Diagnostic(object): Error = 3 Fatal = 4 + DisplaySourceLocation = 0x01 + DisplayColumn = 0x02 + DisplaySourceRanges = 0x04 + DisplayOption = 0x08 + DisplayCategoryId = 0x10 + DisplayCategoryName = 0x20 + _FormatOptionsMask = 0x3f + def __init__(self, ptr): self.ptr = ptr @@ -399,10 +407,27 @@ def disable_option(self): return conf.lib.clang_getCString(disable) + def format(self, options=None): + """ + Format this diagnostic for display. The options argument takes + Diagnostic.Display* flags, which can be combined using bitwise OR. If + the options argument is not provided, the default display options will + be used. + """ + if options is None: + options = conf.lib.clang_defaultDiagnosticDisplayOptions() + if options & ~Diagnostic._FormatOptionsMask: + raise ValueError('Invalid format options') + formatted = conf.lib.clang_formatDiagnostic(self, options) + return conf.lib.clang_getCString(formatted) + def __repr__(self): return "" % ( self.severity, self.location, self.spelling) + def __str__(self): + return self.format() + def from_param(self): return self.ptr @@ -529,8 +554,8 @@ def __init__(self, value): if value >= len(self.__class__._kinds): self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1) if self.__class__._kinds[value] is not None: - raise ValueError,'{0} value {1} already loaded'.format( - str(self.__class__), value) + raise ValueError('{0} value {1} already loaded'.format( + str(self.__class__), value)) self.value = value self.__class__._kinds[value] = self self.__class__._name_map = None @@ -552,7 +577,7 @@ def name(self): @classmethod def from_id(cls, id): if id >= len(cls._kinds) or cls._kinds[id] is None: - raise ValueError,'Unknown template argument kind %d' % id + raise ValueError('Unknown template argument kind %d' % id) return cls._kinds[id] def __repr__(self): @@ -983,6 +1008,12 @@ def __repr__(self): # Represents the "self" expression in a ObjC method. CursorKind.OBJ_SELF_EXPR = CursorKind(146) +# OpenMP 4.0 [2.4, Array Section]. +CursorKind.OMP_ARRAY_SECTION_EXPR = CursorKind(147) + +# Represents an @available(...) check. +CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148) + # A statement whose specific kind is not exposed via this interface. # @@ -1084,6 +1115,126 @@ def __repr__(self): # Adaptor class for mixing declarations with statements and expressions. CursorKind.DECL_STMT = CursorKind(231) +# OpenMP parallel directive. +CursorKind.OMP_PARALLEL_DIRECTIVE = CursorKind(232) + +# OpenMP SIMD directive. +CursorKind.OMP_SIMD_DIRECTIVE = CursorKind(233) + +# OpenMP for directive. +CursorKind.OMP_FOR_DIRECTIVE = CursorKind(234) + +# OpenMP sections directive. +CursorKind.OMP_SECTIONS_DIRECTIVE = CursorKind(235) + +# OpenMP section directive. +CursorKind.OMP_SECTION_DIRECTIVE = CursorKind(236) + +# OpenMP single directive. +CursorKind.OMP_SINGLE_DIRECTIVE = CursorKind(237) + +# OpenMP parallel for directive. +CursorKind.OMP_PARALLEL_FOR_DIRECTIVE = CursorKind(238) + +# OpenMP parallel sections directive. +CursorKind.OMP_PARALLEL_SECTIONS_DIRECTIVE = CursorKind(239) + +# OpenMP task directive. +CursorKind.OMP_TASK_DIRECTIVE = CursorKind(240) + +# OpenMP master directive. +CursorKind.OMP_MASTER_DIRECTIVE = CursorKind(241) + +# OpenMP critical directive. +CursorKind.OMP_CRITICAL_DIRECTIVE = CursorKind(242) + +# OpenMP taskyield directive. +CursorKind.OMP_TASKYIELD_DIRECTIVE = CursorKind(243) + +# OpenMP barrier directive. +CursorKind.OMP_BARRIER_DIRECTIVE = CursorKind(244) + +# OpenMP taskwait directive. +CursorKind.OMP_TASKWAIT_DIRECTIVE = CursorKind(245) + +# OpenMP flush directive. +CursorKind.OMP_FLUSH_DIRECTIVE = CursorKind(246) + +# Windows Structured Exception Handling's leave statement. +CursorKind.SEH_LEAVE_STMT = CursorKind(247) + +# OpenMP ordered directive. +CursorKind.OMP_ORDERED_DIRECTIVE = CursorKind(248) + +# OpenMP atomic directive. +CursorKind.OMP_ATOMIC_DIRECTIVE = CursorKind(249) + +# OpenMP for SIMD directive. +CursorKind.OMP_FOR_SIMD_DIRECTIVE = CursorKind(250) + +# OpenMP parallel for SIMD directive. +CursorKind.OMP_PARALLELFORSIMD_DIRECTIVE = CursorKind(251) + +# OpenMP target directive. +CursorKind.OMP_TARGET_DIRECTIVE = CursorKind(252) + +# OpenMP teams directive. +CursorKind.OMP_TEAMS_DIRECTIVE = CursorKind(253) + +# OpenMP taskgroup directive. +CursorKind.OMP_TASKGROUP_DIRECTIVE = CursorKind(254) + +# OpenMP cancellation point directive. +CursorKind.OMP_CANCELLATION_POINT_DIRECTIVE = CursorKind(255) + +# OpenMP cancel directive. +CursorKind.OMP_CANCEL_DIRECTIVE = CursorKind(256) + +# OpenMP target data directive. +CursorKind.OMP_TARGET_DATA_DIRECTIVE = CursorKind(257) + +# OpenMP taskloop directive. +CursorKind.OMP_TASK_LOOP_DIRECTIVE = CursorKind(258) + +# OpenMP taskloop simd directive. +CursorKind.OMP_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(259) + +# OpenMP distribute directive. +CursorKind.OMP_DISTRIBUTE_DIRECTIVE = CursorKind(260) + +# OpenMP target enter data directive. +CursorKind.OMP_TARGET_ENTER_DATA_DIRECTIVE = CursorKind(261) + +# OpenMP target exit data directive. +CursorKind.OMP_TARGET_EXIT_DATA_DIRECTIVE = CursorKind(262) + +# OpenMP target parallel directive. +CursorKind.OMP_TARGET_PARALLEL_DIRECTIVE = CursorKind(263) + +# OpenMP target parallel for directive. +CursorKind.OMP_TARGET_PARALLELFOR_DIRECTIVE = CursorKind(264) + +# OpenMP target update directive. +CursorKind.OMP_TARGET_UPDATE_DIRECTIVE = CursorKind(265) + +# OpenMP distribute parallel for directive. +CursorKind.OMP_DISTRIBUTE_PARALLELFOR_DIRECTIVE = CursorKind(266) + +# OpenMP distribute parallel for simd directive. +CursorKind.OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(267) + +# OpenMP distribute simd directive. +CursorKind.OMP_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(268) + +# OpenMP target parallel for simd directive. +CursorKind.OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(269) + +# OpenMP target simd directive. +CursorKind.OMP_TARGET_SIMD_DIRECTIVE = CursorKind(270) + +# OpenMP teams distribute directive. +CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) + ### # Other Kinds @@ -1136,6 +1287,10 @@ def __repr__(self): CursorKind.MODULE_IMPORT_DECL = CursorKind(600) # A type alias template declaration CursorKind.TYPE_ALIAS_TEMPLATE_DECL = CursorKind(601) +# A static_assert or _Static_assert node +CursorKind.STATIC_ASSERT = CursorKind(602) +# A friend declaration +CursorKind.FRIEND_DECL = CursorKind(603) # A code completion overload candidate. CursorKind.OVERLOAD_CANDIDATE = CursorKind(700) @@ -1622,7 +1777,7 @@ def __init__(self, value): if value >= len(StorageClass._kinds): StorageClass._kinds += [None] * (value - len(StorageClass._kinds) + 1) if StorageClass._kinds[value] is not None: - raise ValueError,'StorageClass already loaded' + raise ValueError('StorageClass already loaded') self.value = value StorageClass._kinds[value] = self StorageClass._name_map = None @@ -1643,7 +1798,7 @@ def name(self): @staticmethod def from_id(id): if id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: - raise ValueError,'Unknown storage class %d' % id + raise ValueError('Unknown storage class %d' % id) return StorageClass._kinds[id] def __repr__(self): @@ -2574,9 +2729,9 @@ def reparse(self, unsaved_files=None, options=0): # FIXME: It would be great to support an efficient version # of this, one day. value = value.read() - print value + print(value) if not isinstance(value, str): - raise TypeError,'Unexpected unsaved file contents.' + raise TypeError('Unexpected unsaved file contents.') unsaved_files_array[i].name = name unsaved_files_array[i].contents = value unsaved_files_array[i].length = len(value) @@ -2638,9 +2793,9 @@ def codeComplete(self, path, line, column, unsaved_files=None, # FIXME: It would be great to support an efficient version # of this, one day. value = value.read() - print value + print(value) if not isinstance(value, str): - raise TypeError,'Unexpected unsaved file contents.' + raise TypeError('Unexpected unsaved file contents.') unsaved_files_array[i].name = name unsaved_files_array[i].contents = value unsaved_files_array[i].length = len(value) @@ -3012,6 +3167,10 @@ def cursor(self): [Cursor], bool), + ("clang_defaultDiagnosticDisplayOptions", + [], + c_uint), + ("clang_defaultSaveOptions", [TranslationUnit], c_uint), @@ -3053,6 +3212,10 @@ def cursor(self): [Type, Type], bool), + ("clang_formatDiagnostic", + [Diagnostic, c_uint], + _CXString), + ("clang_getArgType", [Type, c_uint], Type, diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py index 6c8230d4283..8103e96df4f 100644 --- a/bindings/python/tests/cindex/test_cursor.py +++ b/bindings/python/tests/cindex/test_cursor.py @@ -375,7 +375,7 @@ def test_get_tokens(): foo = get_cursor(tu, 'foo') tokens = list(foo.get_tokens()) - assert len(tokens) == 7 + assert len(tokens) == 6 assert tokens[0].spelling == 'int' assert tokens[1].spelling == 'foo' diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py index 5bac289625b..4d8d88b9213 100644 --- a/bindings/python/tests/cindex/test_cursor_kind.py +++ b/bindings/python/tests/cindex/test_cursor_kind.py @@ -42,7 +42,8 @@ def test_kind_groups(): CursorKind.MACRO_DEFINITION, CursorKind.MACRO_INSTANTIATION, CursorKind.INCLUSION_DIRECTIVE, - CursorKind.PREPROCESSING_DIRECTIVE): + CursorKind.PREPROCESSING_DIRECTIVE, + CursorKind.OVERLOAD_CANDIDATE): assert len(group) == 0 else: assert len(group) == 1 diff --git a/bindings/python/tests/cindex/test_tokens.py b/bindings/python/tests/cindex/test_tokens.py index 70748429094..688b5c1c900 100644 --- a/bindings/python/tests/cindex/test_tokens.py +++ b/bindings/python/tests/cindex/test_tokens.py @@ -14,7 +14,7 @@ def test_token_to_cursor(): r = tu.get_extent('t.c', (0, 9)) tokens = list(tu.get_tokens(extent=r)) - assert len(tokens) == 5 + assert len(tokens) == 4 assert tokens[1].spelling == 'i' assert tokens[1].kind == TokenKind.IDENTIFIER diff --git a/cmake/caches/Apple-stage1.cmake b/cmake/caches/Apple-stage1.cmake index 814cfdf4860..32159811a88 100644 --- a/cmake/caches/Apple-stage1.cmake +++ b/cmake/caches/Apple-stage1.cmake @@ -27,11 +27,6 @@ set(CLANG_BOOTSTRAP_PASSTHROUGH set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") -# LIBCXX Settings -set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "") -set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "") -set(LIBCXX_OVERRIDE_DARWIN_INSTALL ON CACHE BOOL "") - set(CLANG_BOOTSTRAP_TARGETS generate-order-file check-all diff --git a/cmake/caches/Apple-stage2.cmake b/cmake/caches/Apple-stage2.cmake index 9076868fd6d..11c595c1530 100644 --- a/cmake/caches/Apple-stage2.cmake +++ b/cmake/caches/Apple-stage2.cmake @@ -3,6 +3,7 @@ set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") set(PACKAGE_VENDOR Apple CACHE STRING "") +set(CLANG_VENDOR_UTI com.apple.clang CACHE STRING "") set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "") @@ -19,6 +20,8 @@ set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/" CACHE STRING "") set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "Build Compiler-RT with just-built clang") set(COMPILER_RT_ENABLE_IOS ON CACHE BOOL "Build iOS Compiler-RT libraries") +set(LLVM_CREATE_XCODE_TOOLCHAIN ON CACHE BOOL "Generate targets to create and install an Xcode compatable toolchain") + # Make unit tests (if present) part of the ALL target set(LLVM_BUILD_TESTS ON CACHE BOOL "") diff --git a/cmake/caches/DistributionExample-stage2.cmake b/cmake/caches/DistributionExample-stage2.cmake new file mode 100644 index 00000000000..894ea6af6c3 --- /dev/null +++ b/cmake/caches/DistributionExample-stage2.cmake @@ -0,0 +1,30 @@ +# This file sets up a CMakeCache for the second stage of a simple distribution +# bootstrap build. + +set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "") + +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 "") + +# setup toolchain +set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") +set(LLVM_TOOLCHAIN_TOOLS + llvm-dsymutil + llvm-cov + llvm-dwarfdump + llvm-profdata + llvm-objdump + llvm-nm + llvm-size + CACHE STRING "") + +set(LLVM_DISTRIBUTION_COMPONENTS + clang + LTO + clang-format + clang-headers + builtins + runtimes + ${LLVM_TOOLCHAIN_TOOLS} + CACHE STRING "") diff --git a/cmake/caches/DistributionExample.cmake b/cmake/caches/DistributionExample.cmake new file mode 100644 index 00000000000..862f547c165 --- /dev/null +++ b/cmake/caches/DistributionExample.cmake @@ -0,0 +1,34 @@ +# This file sets up a CMakeCache for a simple distribution bootstrap build. + +# Only build the native target in stage1 since it is a throwaway build. +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") + +# Optimize the stage1 compiler, but don't LTO it because that wastes time. +set(CMAKE_BUILD_TYPE Release CACHE STRING "") + +# Setup vendor-specific settings. +set(PACKAGE_VENDOR LLVM.org CACHE STRING "") + +# Setting up the stage2 LTO option needs to be done on the stage1 build so that +# the proper LTO library dependencies can be connected. +set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "") + +# Expose stage2 targets through the stage1 build configuration. +set(CLANG_BOOTSTRAP_TARGETS + check-all + check-llvm + check-clang + llvm-config + test-suite + test-depends + llvm-test-depends + clang-test-depends + distribution + install-distribution + clang CACHE STRING "") + +# Setup the bootstrap build. +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS + -C ${CMAKE_CURRENT_LIST_DIR}/DistributionExample-stage2.cmake + CACHE STRING "") diff --git a/cmake/caches/PGO-stage2-instrumented.cmake b/cmake/caches/PGO-stage2-instrumented.cmake index fe5e83d28a2..858c07f5626 100644 --- a/cmake/caches/PGO-stage2-instrumented.cmake +++ b/cmake/caches/PGO-stage2-instrumented.cmake @@ -1,9 +1,22 @@ -set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "") set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") -set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_TARGETS + distribution + install-distribution + install-distribution-toolchain + check-all + check-llvm + check-clang + test-suite CACHE STRING "") -set(CLANG_BOOTSTRAP_TARGETS check-all check-llvm check-clang test-suite CACHE STRING "") +if(PGO_BUILD_CONFIGURATION) + include(${PGO_BUILD_CONFIGURATION}) + set(CLANG_BOOTSTRAP_CMAKE_ARGS + -C ${PGO_BUILD_CONFIGURATION} + CACHE STRING "") +else() + include(${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake) -set(CLANG_BOOTSTRAP_CMAKE_ARGS - -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake - CACHE STRING "") + set(CLANG_BOOTSTRAP_CMAKE_ARGS + -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake + CACHE STRING "") +endif() diff --git a/cmake/caches/PGO.cmake b/cmake/caches/PGO.cmake index dc11173fae3..7e4a001129c 100644 --- a/cmake/caches/PGO.cmake +++ b/cmake/caches/PGO.cmake @@ -7,11 +7,24 @@ set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON CACHE BOOL "") set(CLANG_BOOTSTRAP_TARGETS generate-profdata stage2 + stage2-distribution + stage2-install-distribution + stage2-install-distribution-toolchain stage2-check-all stage2-check-llvm stage2-check-clang stage2-test-suite CACHE STRING "") +if(PGO_INSTRUMENT_LTO) + set(BOOTSTRAP_LLVM_ENABLE_LTO ${PGO_INSTRUMENT_LTO} CACHE BOOL "") + set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LTO ${PGO_INSTRUMENT_LTO} CACHE BOOL "") +endif() + +if(PGO_BUILD_CONFIGURATION) + set(EXTRA_ARGS -DPGO_BUILD_CONFIGURATION=${PGO_BUILD_CONFIGURATION}) +endif() + set(CLANG_BOOTSTRAP_CMAKE_ARGS + ${EXTRA_ARGS} -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2-instrumented.cmake CACHE STRING "") diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake index 6e063a706bf..e657059744a 100644 --- a/cmake/modules/AddClang.cmake +++ b/cmake/modules/AddClang.cmake @@ -89,9 +89,16 @@ macro(add_clang_library name) target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS}) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang") + + if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR + NOT LLVM_DISTRIBUTION_COMPONENTS) + set(export_to_clangtargets EXPORT ClangTargets) + set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True) + endif() + install(TARGETS ${name} COMPONENT ${name} - EXPORT ClangTargets + ${export_to_clangtargets} LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} RUNTIME DESTINATION bin) @@ -128,7 +135,14 @@ macro(add_clang_tool name) add_clang_executable(${name} ${ARGN}) if (CLANG_BUILD_TOOLS) + if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR + NOT LLVM_DISTRIBUTION_COMPONENTS) + set(export_to_clangtargets EXPORT ClangTargets) + set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True) + endif() + install(TARGETS ${name} + ${export_to_clangtargets} RUNTIME DESTINATION bin COMPONENT ${name}) @@ -139,6 +153,7 @@ macro(add_clang_tool name) -DCMAKE_INSTALL_COMPONENT=${name} -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") endif() + set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name}) endif() endmacro() diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 3cc808a46b9..b784c0d215e 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -39,7 +39,10 @@ set(CLANG_CONFIG_CMAKE_DIR) set(CLANG_CONFIG_EXPORTS_FILE) if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}) + get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS) + if(clang_has_exports) + install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}) + endif() install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake diff --git a/docs/AddressSanitizer.rst b/docs/AddressSanitizer.rst index a42a1ff6237..ed28ad4de6e 100644 --- a/docs/AddressSanitizer.rst +++ b/docs/AddressSanitizer.rst @@ -14,7 +14,8 @@ following types of bugs: * Out-of-bounds accesses to heap, stack and globals * Use-after-free -* Use-after-return (to some extent) +* Use-after-return (runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1`) +* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`) * Double-free, invalid free * Memory leaks (experimental) @@ -48,16 +49,16 @@ you may need to disable inlining (just use ``-O1``) and tail call elimination } # Compile and link - % clang -O1 -g -fsanitize=address -fno-omit-frame-pointer example_UseAfterFree.cc + % clang++ -O1 -g -fsanitize=address -fno-omit-frame-pointer example_UseAfterFree.cc or: .. code-block:: console # Compile - % clang -O1 -g -fsanitize=address -fno-omit-frame-pointer -c example_UseAfterFree.cc + % clang++ -O1 -g -fsanitize=address -fno-omit-frame-pointer -c example_UseAfterFree.cc # Link - % clang -g -fsanitize=address example_UseAfterFree.o + % clang++ -g -fsanitize=address example_UseAfterFree.o If a bug is detected, the program will print an error message to stderr and exit with a non-zero exit code. AddressSanitizer exits on the first detected error. diff --git a/docs/AttributeReference.rst b/docs/AttributeReference.rst index 054d706fb28..db4812afdaa 100644 --- a/docs/AttributeReference.rst +++ b/docs/AttributeReference.rst @@ -90,6 +90,47 @@ acquire_capability (acquire_shared_capability, clang::acquire_capability, clang: Marks a function as acquiring a capability. +alloc_size (gnu::alloc_size) +---------------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","X","","", "" + +The ``alloc_size`` attribute can be placed on functions that return pointers in +order to hint to the compiler how many bytes of memory will be available at the +returned poiner. ``alloc_size`` takes one or two arguments. + +- ``alloc_size(N)`` implies that argument number N equals the number of + available bytes at the returned pointer. +- ``alloc_size(N, M)`` implies that the product of argument number N and + argument number M equals the number of available bytes at the returned + pointer. + +Argument numbers are 1-based. + +An example of how to use ``alloc_size`` + +.. code-block:: c + + void *my_malloc(int a) __attribute__((alloc_size(1))); + void *my_calloc(int a, int b) __attribute__((alloc_size(1, 2))); + + int main() { + void *const p = my_malloc(100); + assert(__builtin_object_size(p, 0) == 100); + void *const a = my_calloc(20, 5); + assert(__builtin_object_size(a, 0) == 100); + } + +.. Note:: This attribute works differently in clang than it does in GCC. + Specifically, clang will only trace ``const`` pointers (as above); we give up + on pointers that are not marked as ``const``. In the vast majority of cases, + this is unimportant, because LLVM has support for the ``alloc_size`` + attribute. However, this may cause mildly unintuitive behavior when used with + other attributes, such as ``enable_if``. + + interrupt --------- .. csv-table:: Supported Syntaxes @@ -340,7 +381,7 @@ The ``carries_dependency`` attribute specifies dependency propagation into and out of functions. When specified on a function or Objective-C method, the ``carries_dependency`` -attribute means that the return value carries a dependency out of the function, +attribute means that the return value carries a dependency out of the function, so that the implementation need not constrain ordering upon return from that function. Implementations of the function and its caller may choose to preserve dependencies instead of emitting memory ordering instructions such as fences. @@ -349,6 +390,35 @@ Note, this attribute does not change the meaning of the program, but may result in generation of more efficient code. +convergent (clang::convergent) +------------------------------ +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","X","","", "" + +The ``convergent`` attribute can be placed on a function declaration. It is +translated into the LLVM ``convergent`` attribute, which indicates that the call +instructions of a function with this attribute cannot be made control-dependent +on any additional values. + +In languages designed for SPMD/SIMT programming model, e.g. OpenCL or CUDA, +the call instructions of a function with this attribute must be executed by +all work items or threads in a work group or sub group. + +This attribute is different from ``noduplicate`` because it allows duplicating +function calls if it can be proved that the duplicated function calls are +not made control-dependent on any additional values, e.g., unrolling a loop +executed by all work items. + +Sample usage: +.. code-block:: c + + void convfunc(void) __attribute__((convergent)); + // Setting it as a C++11 attribute is also valid in a C++ program. + // void convfunc(void) [[clang::convergent]]; + + deprecated (gnu::deprecated) ---------------------------- .. csv-table:: Supported Syntaxes @@ -374,6 +444,69 @@ to replace the deprecated name with a new name. Otherwise, when spelled as string argument which is the message to display when emitting the warning. +diagnose_if +----------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" + +The ``diagnose_if`` attribute can be placed on function declarations to emit +warnings or errors at compile-time if calls to the attributed function meet +certain user-defined criteria. For example: + +.. code-block:: c + + void abs(int a) + __attribute__((diagnose_if(a >= 0, "Redundant abs call", "warning"))); + void must_abs(int a) + __attribute__((diagnose_if(a >= 0, "Redundant abs call", "error"))); + + int val = abs(1); // warning: Redundant abs call + int val2 = must_abs(1); // error: Redundant abs call + int val3 = abs(val); + int val4 = must_abs(val); // Because run-time checks are not emitted for + // diagnose_if attributes, this executes without + // issue. + + +``diagnose_if`` is closely related to ``enable_if``, with a few key differences: + +* Overload resolution is not aware of ``diagnose_if`` attributes: they're + considered only after we select the best candidate from a given candidate set. +* Function declarations that differ only in their ``diagnose_if`` attributes are + considered to be redeclarations of the same function (not overloads). +* If the condition provided to ``diagnose_if`` cannot be evaluated, no + diagnostic will be emitted. + +Otherwise, ``diagnose_if`` is essentially the logical negation of ``enable_if``. + +As a result of bullet number two, ``diagnose_if`` attributes will stack on the +same function. For example: + +.. code-block:: c + + int foo() __attribute__((diagnose_if(1, "diag1", "warning"))); + int foo() __attribute__((diagnose_if(1, "diag2", "warning"))); + + int bar = foo(); // warning: diag1 + // warning: diag2 + int (*fooptr)(void) = foo; // warning: diag1 + // warning: diag2 + + constexpr int supportsAPILevel(int N) { return N < 5; } + int baz(int a) + __attribute__((diagnose_if(!supportsAPILevel(10), + "Upgrade to API level 10 to use baz", "error"))); + int baz(int a) + __attribute__((diagnose_if(!a, "0 is not recommended.", "warning"))); + + int (*bazptr)(int) = baz; // error: Upgrade to API level 10 to use baz + int v = baz(0); // error: Upgrade to API level 10 to use baz + +Query for this feature with ``__has_attribute(diagnose_if)``. + + disable_tail_calls (clang::disable_tail_calls) ---------------------------------------------- .. csv-table:: Supported Syntaxes @@ -816,7 +949,7 @@ no_sanitize_memory .. _langext-memory_sanitizer: Use ``__attribute__((no_sanitize_memory))`` on a function declaration to -specify that checks for uninitialized memory should not be inserted +specify that checks for uninitialized memory should not be inserted (e.g. by MemorySanitizer). The function may still be instrumented by the tool to avoid false positives in other places. @@ -952,10 +1085,10 @@ objc_boxable "X","","","", "" -Structs and unions marked with the ``objc_boxable`` attribute can be used +Structs and unions marked with the ``objc_boxable`` attribute can be used with the Objective-C boxed expression syntax, ``@(...)``. -**Usage**: ``__attribute__((objc_boxable))``. This attribute +**Usage**: ``__attribute__((objc_boxable))``. This attribute can only be placed on a declaration of a trivially-copyable struct or union: .. code-block:: objc @@ -1142,6 +1275,12 @@ semantics: * A conversion from type ``T`` to a value of type ``U`` is permitted if ``T`` and ``U`` are compatible types. This conversion is given "conversion" rank. +* If no viable candidates are otherwise available, we allow a conversion from a + pointer of type ``T*`` to a pointer of type ``U*``, where ``T`` and ``U`` are + incompatible. This conversion is ranked below all other types of conversions. + Please note: ``U`` lacking qualifiers that are present on ``T`` is sufficient + for ``T`` and ``U`` to be incompatible. + The declaration of ``overloadable`` functions is restricted to function declarations and definitions. Most importantly, if any function with a given name is given the ``overloadable`` attribute, then all function declarations @@ -1270,15 +1409,15 @@ potentially-evaluated discarded-value expression that is not explicitly cast to `void`. .. code-block: c++ - struct [[nodiscard]] error_info { /*...*/ }; - error_info enable_missile_safety_mode(); - - void launch_missiles(); - void test_missiles() { - enable_missile_safety_mode(); // diagnoses - launch_missiles(); - } - error_info &foo(); + struct [[nodiscard]] error_info { /*...*/ }; + error_info enable_missile_safety_mode(); + + void launch_missiles(); + void test_missiles() { + enable_missile_safety_mode(); // diagnoses + launch_missiles(); + } + error_info &foo(); void f() { foo(); } // Does not diagnose, error_info is a reference. @@ -1480,6 +1619,46 @@ Currently, ``pass_object_size`` is a bit restricted in terms of its usage: applied to must be marked ``const`` at its function's definition. +require_constant_initialization (clang::require_constant_initialization) +------------------------------------------------------------------------ +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","X","","", "" + +This attribute specifies that the variable to which it is attached is intended +to have a `constant initializer `_ +according to the rules of [basic.start.static]. The variable is required to +have static or thread storage duration. If the initialization of the variable +is not a constant initializer an error will be produced. This attribute may +only be used in C++. + +Note that in C++03 strict constant expression checking is not done. Instead +the attribute reports if Clang can emit the variable as a constant, even if it's +not technically a 'constant initializer'. This behavior is non-portable. + +Static storage duration variables with constant initializers avoid hard-to-find +bugs caused by the indeterminate order of dynamic initialization. They can also +be safely used during dynamic initialization across translation units. + +This attribute acts as a compile time assertion that the requirements +for constant initialization have been met. Since these requirements change +between dialects and have subtle pitfalls it's important to fail fast instead +of silently falling back on dynamic initialization. + +.. code-block:: c++ + + // -std=c++14 + #define SAFE_STATIC [[clang::require_constant_initialization]] + struct T { + constexpr T(int) {} + ~T(); // non-trivial + }; + SAFE_STATIC T x = {42}; // Initialization OK. Doesn't check destructor. + SAFE_STATIC T y = 42; // error: variable does not have a constant initializer + // copy initialization is not a constant expression on a non-literal type. + + section (gnu::section, __declspec(allocate)) -------------------------------------------- .. csv-table:: Supported Syntaxes @@ -1624,7 +1803,7 @@ swift_indirect_result (gnu::swift_indirect_result) "X","X","","", "" The ``swift_indirect_result`` attribute marks a parameter of a ``swiftcall`` -function as having the special indirect-result ABI treatmenet. +function as having the special indirect-result ABI treatment. This treatment gives the parameter the target's normal indirect-result ABI treatment, which may involve passing it differently from an ordinary @@ -1704,12 +1883,12 @@ variable, a function or method, a function parameter, an enumeration, an enumerator, a non-static data member, or a label. .. code-block: c++ - #include - - [[maybe_unused]] void f([[maybe_unused]] bool thing1, - [[maybe_unused]] bool thing2) { - [[maybe_unused]] bool b = thing1 && thing2; - assert(b); + #include + + [[maybe_unused]] void f([[maybe_unused]] bool thing1, + [[maybe_unused]] bool thing2) { + [[maybe_unused]] bool b = thing1 && thing2; + assert(b); } @@ -1850,6 +2029,38 @@ the compiler that constructors and destructors will not reference the virtual function table. It is only supported when using the Microsoft C++ ABI. +objc_subclassing_restricted +--------------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" + +This attribute can be added to an Objective-C ``@interface`` declaration to +ensure that this class cannot be subclassed. + + +transparent_union (gnu::transparent_union) +------------------------------------------ +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","X","","", "" + +This attribute can be applied to a union to change the behaviour of calls to +functions that have an argument with a transparent union type. The compiler +behaviour is changed in the following manner: + +- A value whose type is any member of the transparent union can be passed as an + argument without the need to cast that value. + +- The argument is passed to the function using the calling convention of the + first member of the transparent union. Consequently, all the members of the + transparent union should have the same calling convention as its first member. + +Transparent unions are not supported in C++. + + Statement Attributes ==================== @@ -2025,31 +2236,260 @@ This is a compiler hint and the compiler may ignore this directive. See s6.11.5 for details. -AMD GPU Register Attributes -=========================== -Clang supports attributes for controlling register usage on AMD GPU -targets. These attributes may be attached to a kernel function -definition and is an optimization hint to the backend for the maximum -number of registers to use. This is useful in cases where register -limited occupancy is known to be an important factor for the -performance for the kernel. +Type Safety Checking +==================== +Clang supports additional attributes to enable checking type safety properties +that can't be enforced by the C type system. To see warnings produced by these +checks, ensure that -Wtype-safety is enabled. Use cases include: -The semantics are as follows: +* MPI library implementations, where these attributes enable checking that + the buffer type matches the passed ``MPI_Datatype``; +* for HDF5 library there is a similar use case to MPI; +* checking types of variadic functions' arguments for functions like + ``fcntl()`` and ``ioctl()``. + +You can detect support for these attributes with ``__has_attribute()``. For +example: + +.. code-block:: c++ + + #if defined(__has_attribute) + # if __has_attribute(argument_with_type_tag) && \ + __has_attribute(pointer_with_type_tag) && \ + __has_attribute(type_tag_for_datatype) + # define ATTR_MPI_PWT(buffer_idx, type_idx) __attribute__((pointer_with_type_tag(mpi,buffer_idx,type_idx))) + /* ... other macros ... */ + # endif + #endif + + #if !defined(ATTR_MPI_PWT) + # define ATTR_MPI_PWT(buffer_idx, type_idx) + #endif + + int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */) + ATTR_MPI_PWT(1,3); + +argument_with_type_tag +---------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" + +Use ``__attribute__((argument_with_type_tag(arg_kind, arg_idx, +type_tag_idx)))`` on a function declaration to specify that the function +accepts a type tag that determines the type of some other argument. + +This attribute is primarily useful for checking arguments of variadic functions +(``pointer_with_type_tag`` can be used in most non-variadic cases). + +In the attribute prototype above: + * ``arg_kind`` is an identifier that should be used when annotating all + applicable type tags. + * ``arg_idx`` provides the position of a function argument. The expected type of + this function argument will be determined by the function argument specified + by ``type_tag_idx``. In the code example below, "3" means that the type of the + function's third argument will be determined by ``type_tag_idx``. + * ``type_tag_idx`` provides the position of a function argument. This function + argument will be a type tag. The type tag will determine the expected type of + the argument specified by ``arg_idx``. In the code example below, "2" means + that the type tag associated with the function's second argument should agree + with the type of the argument specified by ``arg_idx``. + +For example: + +.. code-block:: c++ + + int fcntl(int fd, int cmd, ...) + __attribute__(( argument_with_type_tag(fcntl,3,2) )); + // The function's second argument will be a type tag; this type tag will + // determine the expected type of the function's third argument. + + +pointer_with_type_tag +--------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" -- The backend will attempt to limit the number of used registers to - the specified value, but the exact number used is not - guaranteed. The number used may be rounded up to satisfy the - allocation requirements or ABI constraints of the subtarget. For - example, on Southern Islands VGPRs may only be allocated in - increments of 4, so requesting a limit of 39 VGPRs will really - attempt to use up to 40. Requesting more registers than the - subtarget supports will truncate to the maximum allowed. The backend - may also use fewer registers than requested whenever possible. +Use ``__attribute__((pointer_with_type_tag(ptr_kind, ptr_idx, type_tag_idx)))`` +on a function declaration to specify that the function accepts a type tag that +determines the pointee type of some other pointer argument. + +In the attribute prototype above: + * ``ptr_kind`` is an identifier that should be used when annotating all + applicable type tags. + * ``ptr_idx`` provides the position of a function argument; this function + argument will have a pointer type. The expected pointee type of this pointer + type will be determined by the function argument specified by + ``type_tag_idx``. In the code example below, "1" means that the pointee type + of the function's first argument will be determined by ``type_tag_idx``. + * ``type_tag_idx`` provides the position of a function argument; this function + argument will be a type tag. The type tag will determine the expected pointee + type of the pointer argument specified by ``ptr_idx``. In the code example + below, "3" means that the type tag associated with the function's third + argument should agree with the pointee type of the pointer argument specified + by ``ptr_idx``. + +For example: + +.. code-block:: c++ -- 0 implies the default no limit on register usage. + typedef int MPI_Datatype; + int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */) + __attribute__(( pointer_with_type_tag(mpi,1,3) )); + // The function's 3rd argument will be a type tag; this type tag will + // determine the expected pointee type of the function's 1st argument. + + +type_tag_for_datatype +--------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" + +When declaring a variable, use +``__attribute__((type_tag_for_datatype(kind, type)))`` to create a type tag that +is tied to the ``type`` argument given to the attribute. + +In the attribute prototype above: + * ``kind`` is an identifier that should be used when annotating all applicable + type tags. + * ``type`` indicates the name of the type. + +Clang supports annotating type tags of two forms. + + * **Type tag that is a reference to a declared identifier.** + Use ``__attribute__((type_tag_for_datatype(kind, type)))`` when declaring that + identifier: + + .. code-block:: c++ + + typedef int MPI_Datatype; + extern struct mpi_datatype mpi_datatype_int + __attribute__(( type_tag_for_datatype(mpi,int) )); + #define MPI_INT ((MPI_Datatype) &mpi_datatype_int) + // &mpi_datatype_int is a type tag. It is tied to type "int". + + * **Type tag that is an integral literal.** + Declare a ``static const`` variable with an initializer value and attach + ``__attribute__((type_tag_for_datatype(kind, type)))`` on that declaration: + + .. code-block:: c++ + + typedef int MPI_Datatype; + static const MPI_Datatype mpi_datatype_int + __attribute__(( type_tag_for_datatype(mpi,int) )) = 42; + #define MPI_INT ((MPI_Datatype) 42) + // The number 42 is a type tag. It is tied to type "int". + + +The ``type_tag_for_datatype`` attribute also accepts an optional third argument +that determines how the type of the function argument specified by either +``arg_idx`` or ``ptr_idx`` is compared against the type associated with the type +tag. (Recall that for the ``argument_with_type_tag`` attribute, the type of the +function argument specified by ``arg_idx`` is compared against the type +associated with the type tag. Also recall that for the ``pointer_with_type_tag`` +attribute, the pointee type of the function argument specified by ``ptr_idx`` is +compared against the type associated with the type tag.) There are two supported +values for this optional third argument: + + * ``layout_compatible`` will cause types to be compared according to + layout-compatibility rules (In C++11 [class.mem] p 17, 18, see the + layout-compatibility rules for two standard-layout struct types and for two + standard-layout union types). This is useful when creating a type tag + associated with a struct or union type. For example: + + .. code-block:: c++ + + /* In mpi.h */ + typedef int MPI_Datatype; + struct internal_mpi_double_int { double d; int i; }; + extern struct mpi_datatype mpi_datatype_double_int + __attribute__(( type_tag_for_datatype(mpi, + struct internal_mpi_double_int, layout_compatible) )); + + #define MPI_DOUBLE_INT ((MPI_Datatype) &mpi_datatype_double_int) + + int MPI_Send(void *buf, int count, MPI_Datatype datatype, ...) + __attribute__(( pointer_with_type_tag(mpi,1,3) )); + + /* In user code */ + struct my_pair { double a; int b; }; + struct my_pair *buffer; + MPI_Send(buffer, 1, MPI_DOUBLE_INT /*, ... */); // no warning because the + // layout of my_pair is + // compatible with that of + // internal_mpi_double_int + + struct my_int_pair { int a; int b; } + struct my_int_pair *buffer2; + MPI_Send(buffer2, 1, MPI_DOUBLE_INT /*, ... */); // warning because the + // layout of my_int_pair + // does not match that of + // internal_mpi_double_int + + * ``must_be_null`` specifies that the function argument specified by either + ``arg_idx`` (for the ``argument_with_type_tag`` attribute) or ``ptr_idx`` (for + the ``pointer_with_type_tag`` attribute) should be a null pointer constant. + The second argument to the ``type_tag_for_datatype`` attribute is ignored. For + example: + + .. code-block:: c++ + + /* In mpi.h */ + typedef int MPI_Datatype; + extern struct mpi_datatype mpi_datatype_null + __attribute__(( type_tag_for_datatype(mpi, void, must_be_null) )); + + #define MPI_DATATYPE_NULL ((MPI_Datatype) &mpi_datatype_null) + int MPI_Send(void *buf, int count, MPI_Datatype datatype, ...) + __attribute__(( pointer_with_type_tag(mpi,1,3) )); + + /* In user code */ + struct my_pair { double a; int b; }; + struct my_pair *buffer; + MPI_Send(buffer, 1, MPI_DATATYPE_NULL /*, ... */); // warning: MPI_DATATYPE_NULL + // was specified but buffer + // is not a null pointer + + +AMD GPU Attributes +================== + + +amdgpu_flat_work_group_size +--------------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" + +The flat work-group size is the number of work-items in the work-group size +specified when the kernel is dispatched. It is the product of the sizes of the +x, y, and z dimension of the work-group. + +Clang supports the +``__attribute__((amdgpu_flat_work_group_size(, )))`` attribute for the +AMDGPU target. This attribute may be attached to a kernel function definition +and is an optimization hint. + +```` parameter specifies the minimum flat work-group size, and ```` +parameter specifies the maximum flat work-group size (must be greater than +````) to which all dispatches of the kernel will conform. Passing ``0, 0`` +as ``, `` implies the default behavior (``128, 256``). + +If specified, the AMDGPU target backend might be able to produce better machine +code for barriers and perform scratch promotion by estimating available group +segment size. + +An error will be given if: + - Specified values violate subtarget specifications; + - Specified values are not compatible with values provided through other + attributes. -- Ignored on older VLIW subtargets which did not have separate scalar - and vector registers, R600 through Northern Islands. amdgpu_num_sgpr --------------- @@ -2058,17 +2498,28 @@ amdgpu_num_sgpr "X","","","", "" -Clang supports the -``__attribute__((amdgpu_num_sgpr()))`` attribute on AMD -Southern Islands GPUs and later for controlling the number of scalar -registers. A typical value would be between 8 and 104 in increments of -8. +Clang supports the ``__attribute__((amdgpu_num_sgpr()))`` and +``__attribute__((amdgpu_num_vgpr()))`` attributes for the AMDGPU +target. These attributes may be attached to a kernel function definition and are +an optimization hint. + +If these attributes are specified, then the AMDGPU target backend will attempt +to limit the number of SGPRs and/or VGPRs used to the specified value(s). The +number of used SGPRs and/or VGPRs may further be rounded up to satisfy the +allocation requirements or constraints of the subtarget. Passing ``0`` as +``num_sgpr`` and/or ``num_vgpr`` implies the default behavior (no limits). -Due to common instruction constraints, an additional 2-4 SGPRs are -typically required for internal use depending on features used. This -value is a hint for the total number of SGPRs to use, and not the -number of user SGPRs, so no special consideration needs to be given -for these. +These attributes can be used to test the AMDGPU target backend. It is +recommended that the ``amdgpu_waves_per_eu`` attribute be used to control +resources such as SGPRs and VGPRs since it is aware of the limits for different +subtargets. + +An error will be given if: + - Specified values violate subtarget specifications; + - Specified values are not compatible with values provided through other + attributes; + - The AMDGPU target backend is unable to create machine code that can meet the + request. amdgpu_num_vgpr @@ -2078,11 +2529,79 @@ amdgpu_num_vgpr "X","","","", "" -Clang supports the -``__attribute__((amdgpu_num_vgpr()))`` attribute on AMD -Southern Islands GPUs and later for controlling the number of vector -registers. A typical value would be between 4 and 256 in increments -of 4. +Clang supports the ``__attribute__((amdgpu_num_sgpr()))`` and +``__attribute__((amdgpu_num_vgpr()))`` attributes for the AMDGPU +target. These attributes may be attached to a kernel function definition and are +an optimization hint. + +If these attributes are specified, then the AMDGPU target backend will attempt +to limit the number of SGPRs and/or VGPRs used to the specified value(s). The +number of used SGPRs and/or VGPRs may further be rounded up to satisfy the +allocation requirements or constraints of the subtarget. Passing ``0`` as +``num_sgpr`` and/or ``num_vgpr`` implies the default behavior (no limits). + +These attributes can be used to test the AMDGPU target backend. It is +recommended that the ``amdgpu_waves_per_eu`` attribute be used to control +resources such as SGPRs and VGPRs since it is aware of the limits for different +subtargets. + +An error will be given if: + - Specified values violate subtarget specifications; + - Specified values are not compatible with values provided through other + attributes; + - The AMDGPU target backend is unable to create machine code that can meet the + request. + + +amdgpu_waves_per_eu +------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","","","", "" + +A compute unit (CU) is responsible for executing the wavefronts of a work-group. +It is composed of one or more execution units (EU), which are responsible for +executing the wavefronts. An EU can have enough resources to maintain the state +of more than one executing wavefront. This allows an EU to hide latency by +switching between wavefronts in a similar way to symmetric multithreading on a +CPU. In order to allow the state for multiple wavefronts to fit on an EU, the +resources used by a single wavefront have to be limited. For example, the number +of SGPRs and VGPRs. Limiting such resources can allow greater latency hiding, +but can result in having to spill some register state to memory. + +Clang supports the ``__attribute__((amdgpu_waves_per_eu([, ])))`` +attribute for the AMDGPU target. This attribute may be attached to a kernel +function definition and is an optimization hint. + +```` parameter specifies the requested minimum number of waves per EU, and +*optional* ```` parameter specifies the requested maximum number of waves +per EU (must be greater than ```` if specified). If ```` is omitted, +then there is no restriction on the maximum number of waves per EU other than +the one dictated by the hardware for which the kernel is compiled. Passing +``0, 0`` as ``, `` implies the default behavior (no limits). + +If specified, this attribute allows an advanced developer to tune the number of +wavefronts that are capable of fitting within the resources of an EU. The AMDGPU +target backend can use this information to limit resources, such as number of +SGPRs, number of VGPRs, size of available group and private memory segments, in +such a way that guarantees that at least ```` wavefronts and at most +```` wavefronts are able to fit within the resources of an EU. Requesting +more wavefronts can hide memory latency but limits available registers which +can result in spilling. Requesting fewer wavefronts can help reduce cache +thrashing, but can reduce memory latency hiding. + +This attribute controls the machine code generated by the AMDGPU target backend +to ensure it is capable of meeting the requested values. However, when the +kernel is executed, there may be other reasons that prevent meeting the request, +for example, there may be wavefronts from other kernels executing on the EU. + +An error will be given if: + - Specified values violate subtarget specifications; + - Specified values are not compatible with values provided through other + attributes; + - The AMDGPU target backend is unable to create machine code that can meet the + request. Calling Conventions @@ -2206,6 +2725,21 @@ supports X86-64 and AArch64, but the intention is to support more architectures in the future. +regcall (gnu::regcall, __regcall) +--------------------------------- +.. csv-table:: Supported Syntaxes + :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" + + "X","X","","X", "" + +On x86 targets, this attribute changes the calling convention to +`__regcall`_ convention. This convention aims to pass as many arguments +as possible in registers. It also tries to utilize registers for the +return value whenever it is possible. + +.. _`__regcall`: https://software.intel.com/en-us/node/693069 + + regparm (gnu::regparm) ---------------------- .. csv-table:: Supported Syntaxes @@ -2270,7 +2804,7 @@ passed in RCX, RDX, R8, and R9 as is done for the default Windows x64 calling convention. On both 32-bit x86 and x86_64 targets, vector and floating point arguments are -passed in XMM0-XMM5. Homogenous vector aggregates of up to four elements are +passed in XMM0-XMM5. Homogeneous vector aggregates of up to four elements are passed in sequential SSE registers if enough are available. If AVX is enabled, 256 bit vectors are passed in YMM0-YMM5. Any vector or aggregate type that cannot be passed in registers for any reason is passed by reference, which @@ -2370,157 +2904,6 @@ Use ``__attribute__((test_typestate(tested_state)))`` to indicate that a method returns true if the object is in the specified state.. -Type Safety Checking -==================== -Clang supports additional attributes to enable checking type safety properties -that can't be enforced by the C type system. Use cases include: - -* MPI library implementations, where these attributes enable checking that - the buffer type matches the passed ``MPI_Datatype``; -* for HDF5 library there is a similar use case to MPI; -* checking types of variadic functions' arguments for functions like - ``fcntl()`` and ``ioctl()``. - -You can detect support for these attributes with ``__has_attribute()``. For -example: - -.. code-block:: c++ - - #if defined(__has_attribute) - # if __has_attribute(argument_with_type_tag) && \ - __has_attribute(pointer_with_type_tag) && \ - __has_attribute(type_tag_for_datatype) - # define ATTR_MPI_PWT(buffer_idx, type_idx) __attribute__((pointer_with_type_tag(mpi,buffer_idx,type_idx))) - /* ... other macros ... */ - # endif - #endif - - #if !defined(ATTR_MPI_PWT) - # define ATTR_MPI_PWT(buffer_idx, type_idx) - #endif - - int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */) - ATTR_MPI_PWT(1,3); - -argument_with_type_tag ----------------------- -.. csv-table:: Supported Syntaxes - :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" - - "X","","","", "" - -Use ``__attribute__((argument_with_type_tag(arg_kind, arg_idx, -type_tag_idx)))`` on a function declaration to specify that the function -accepts a type tag that determines the type of some other argument. -``arg_kind`` is an identifier that should be used when annotating all -applicable type tags. - -This attribute is primarily useful for checking arguments of variadic functions -(``pointer_with_type_tag`` can be used in most non-variadic cases). - -For example: - -.. code-block:: c++ - - int fcntl(int fd, int cmd, ...) - __attribute__(( argument_with_type_tag(fcntl,3,2) )); - - -pointer_with_type_tag ---------------------- -.. csv-table:: Supported Syntaxes - :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" - - "X","","","", "" - -Use ``__attribute__((pointer_with_type_tag(ptr_kind, ptr_idx, type_tag_idx)))`` -on a function declaration to specify that the function accepts a type tag that -determines the pointee type of some other pointer argument. - -For example: - -.. code-block:: c++ - - int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */) - __attribute__(( pointer_with_type_tag(mpi,1,3) )); - - -type_tag_for_datatype ---------------------- -.. csv-table:: Supported Syntaxes - :header: "GNU", "C++11", "__declspec", "Keyword", "Pragma" - - "X","","","", "" - -Clang supports annotating type tags of two forms. - -* **Type tag that is an expression containing a reference to some declared - identifier.** Use ``__attribute__((type_tag_for_datatype(kind, type)))`` on a - declaration with that identifier: - - .. code-block:: c++ - - extern struct mpi_datatype mpi_datatype_int - __attribute__(( type_tag_for_datatype(mpi,int) )); - #define MPI_INT ((MPI_Datatype) &mpi_datatype_int) - -* **Type tag that is an integral literal.** Introduce a ``static const`` - variable with a corresponding initializer value and attach - ``__attribute__((type_tag_for_datatype(kind, type)))`` on that declaration, - for example: - - .. code-block:: c++ - - #define MPI_INT ((MPI_Datatype) 42) - static const MPI_Datatype mpi_datatype_int - __attribute__(( type_tag_for_datatype(mpi,int) )) = 42 - -The attribute also accepts an optional third argument that determines how the -expression is compared to the type tag. There are two supported flags: - -* ``layout_compatible`` will cause types to be compared according to - layout-compatibility rules (C++11 [class.mem] p 17, 18). This is - implemented to support annotating types like ``MPI_DOUBLE_INT``. - - For example: - - .. code-block:: c++ - - /* In mpi.h */ - struct internal_mpi_double_int { double d; int i; }; - extern struct mpi_datatype mpi_datatype_double_int - __attribute__(( type_tag_for_datatype(mpi, struct internal_mpi_double_int, layout_compatible) )); - - #define MPI_DOUBLE_INT ((MPI_Datatype) &mpi_datatype_double_int) - - /* In user code */ - struct my_pair { double a; int b; }; - struct my_pair *buffer; - MPI_Send(buffer, 1, MPI_DOUBLE_INT /*, ... */); // no warning - - struct my_int_pair { int a; int b; } - struct my_int_pair *buffer2; - MPI_Send(buffer2, 1, MPI_DOUBLE_INT /*, ... */); // warning: actual buffer element - // type 'struct my_int_pair' - // doesn't match specified MPI_Datatype - -* ``must_be_null`` specifies that the expression should be a null pointer - constant, for example: - - .. code-block:: c++ - - /* In mpi.h */ - extern struct mpi_datatype mpi_datatype_null - __attribute__(( type_tag_for_datatype(mpi, void, must_be_null) )); - - #define MPI_DATATYPE_NULL ((MPI_Datatype) &mpi_datatype_null) - - /* In user code */ - MPI_Send(buffer, 1, MPI_DATATYPE_NULL /*, ... */); // warning: MPI_DATATYPE_NULL - // was specified but buffer - // is not a null pointer - - OpenCL Address Spaces ===================== The address space qualifier may be used to specify the region of memory that is @@ -2617,7 +3000,7 @@ cannot point to the private address space. Nullability Attributes ====================== -Whether a particular pointer may be "null" is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the ``nonnull`` and ``returns_nonnull`` attributes indicate which function or method parameters and result types can never be null, while nullability type qualifiers indicate which pointer types can be null (``_Nullable``) or cannot be null (``_Nonnull``). +Whether a particular pointer may be "null" is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the ``nonnull`` and ``returns_nonnull`` attributes indicate which function or method parameters and result types can never be null, while nullability type qualifiers indicate which pointer types can be null (``_Nullable``) or cannot be null (``_Nonnull``). The nullability (type) qualifiers express whether a value of a given pointer type can be null (the ``_Nullable`` qualifier), doesn't have a defined meaning for null (the ``_Nonnull`` qualifier), or for which the purpose of null is unclear (the ``_Null_unspecified`` qualifier). Because nullability qualifiers are expressed within the type system, they are more general than the ``nonnull`` and ``returns_nonnull`` attributes, allowing one to express (for example) a nullable pointer to an array of nonnull pointers. Nullability qualifiers are written to the right of the pointer to which they apply. For example: diff --git a/docs/AutomaticReferenceCounting.rst b/docs/AutomaticReferenceCounting.rst index 2faed237916..aa2a28399d1 100644 --- a/docs/AutomaticReferenceCounting.rst +++ b/docs/AutomaticReferenceCounting.rst @@ -910,10 +910,10 @@ not support ``__weak`` references. binary compatibility. A class may indicate that it does not support weak references by providing the -``objc_arc_weak_unavailable`` attribute on the class's interface declaration. A +``objc_arc_weak_reference_unavailable`` attribute on the class's interface declaration. A retainable object pointer type is **weak-unavailable** if is a pointer to an (optionally protocol-qualified) Objective-C class ``T`` where -``T`` or one of its superclasses has the ``objc_arc_weak_unavailable`` +``T`` or one of its superclasses has the ``objc_arc_weak_reference_unavailable`` attribute. A program is ill-formed if it applies the ``__weak`` ownership qualifier to a weak-unavailable type or if the value operand of a weak assignment operation has a weak-unavailable type. diff --git a/docs/Block-ABI-Apple.rst b/docs/Block-ABI-Apple.rst index 08f346447e0..628e6f3d90b 100644 --- a/docs/Block-ABI-Apple.rst +++ b/docs/Block-ABI-Apple.rst @@ -530,13 +530,13 @@ and: .. code-block:: c - struct _block_byref_i i = {( .forwarding=&i, .flags=0, .size=sizeof(struct _block_byref_i) )}; + struct _block_byref_i i = {( .isa=NULL, .forwarding=&i, .flags=0, .size=sizeof(struct _block_byref_i), .captured_i=2 )}; struct __block_literal_5 _block_literal = { &_NSConcreteStackBlock, (1<<25)|(1<<29), , __block_invoke_5, &__block_descriptor_5, - 2, + &i, }; Importing ``__attribute__((NSObject))`` ``__block`` variables diff --git a/docs/ClangCheck.rst b/docs/ClangCheck.rst index 4650049b1fb..c249c126770 100644 --- a/docs/ClangCheck.rst +++ b/docs/ClangCheck.rst @@ -31,6 +31,6 @@ do basic error checking and AST dumping. 1 error generated. Error while processing snippet.cc. -The '--' at the end is important as it prevents `clang-check` from search for a -compilation database. For more information on how to setup and use `clang-check` -in a project, see :doc:`HowToSetupToolingForLLVM`. +The '--' at the end is important as it prevents :program:`clang-check` from +searching for a compilation database. For more information on how to setup and +use :program:`clang-check` in a project, see :doc:`HowToSetupToolingForLLVM`. diff --git a/docs/ClangFormat.rst b/docs/ClangFormat.rst index 3f52b767e3a..dc1e2b9a763 100644 --- a/docs/ClangFormat.rst +++ b/docs/ClangFormat.rst @@ -184,7 +184,7 @@ So to reformat all the lines in the latest :program:`git` commit, just do: .. code-block:: console - git diff -U0 HEAD^ | clang-format-diff.py -i -p1 + git diff -U0 --no-color HEAD^ | clang-format-diff.py -i -p1 In an SVN client, you can do: diff --git a/docs/ClangFormatStyleOptions.rst b/docs/ClangFormatStyleOptions.rst index a548e835a56..3f76da6dca3 100644 --- a/docs/ClangFormatStyleOptions.rst +++ b/docs/ClangFormatStyleOptions.rst @@ -670,6 +670,9 @@ the configuration (without a prefix: ``Auto``). **SpaceAfterCStyleCast** (``bool``) If ``true``, a space may be inserted after C style casts. +**SpaceAfterTemplateKeyword** (``bool``) + If ``true``, a space will be inserted after the 'template' keyword. + **SpaceBeforeAssignmentOperators** (``bool``) If ``false``, spaces will be removed before assignment operators. diff --git a/docs/CommandGuide/clang.rst b/docs/CommandGuide/clang.rst index 0546304e710..16bb09f3c74 100644 --- a/docs/CommandGuide/clang.rst +++ b/docs/CommandGuide/clang.rst @@ -105,7 +105,12 @@ Language Selection and Mode Options .. option:: -stdlib= Specify the C++ standard library to use; supported options are libstdc++ and - libc++. + libc++. If not specified, platform default will be used. + +.. option:: -rtlib= + + Specify the compiler runtime library to use; supported options are libgcc and + compiler-rt. If not specified, platform default will be used. .. option:: -ansi @@ -162,16 +167,6 @@ Language Selection and Mode Options Enable the "Blocks" language feature. -.. option:: -fobjc-gc-only - - Indicate that Objective-C code should be compiled in GC-only mode, which only - works when Objective-C Garbage Collection is enabled. - -.. option:: -fobjc-gc - - Indicate that Objective-C code should be compiled in hybrid-GC mode, which - works with both GC and non-GC mode. - .. option:: -fobjc-abi-version=version Select the Objective-C ABI version to use. Available versions are 1 (legacy @@ -221,7 +216,7 @@ number of cross compilers, or may only support a native target. Code Generation Options ~~~~~~~~~~~~~~~~~~~~~~~ -.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4 +.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4 Specify which optimization level to use: @@ -247,6 +242,9 @@ 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 + disable different optimizations in order to improve debuggability. + :option:`-O` Equivalent to :option:`-O2`. :option:`-O4` and higher @@ -323,13 +321,19 @@ Code Generation Options model can be overridden with the tls_model attribute. The compiler will try to choose a more efficient model if possible. -.. option:: -flto, -emit-llvm +.. option:: -flto, -flto=full, -flto=thin, -emit-llvm Generate output files in LLVM formats, suitable for link time optimization. When used with :option:`-S` this generates LLVM intermediate language assembly files, otherwise this generates LLVM bitcode format object files (which may be passed to the linker depending on the stage selection options). + The default for :option:`-flto` is "full", in which the + LLVM bitcode is suitable for monolithic Link Time Optimization (LTO), where + the linker merges all such modules into a single combined module for + optimization. With "thin", :doc:`ThinLTO <../ThinLTO>` + compilation is invoked instead. + Driver Options ~~~~~~~~~~~~~~ @@ -383,7 +387,8 @@ Driver Options .. option:: -print-libgcc-file-name - Print the library path for "libgcc.a". + Print the library path for the currently used compiler runtime library + ("libgcc.a" or "libclang_rt.builtins.*.a"). .. option:: -print-prog-name= @@ -397,6 +402,12 @@ Driver Options Save intermediate compilation results. +.. option:: -save-stats, -save-stats=cwd, -save-stats=obj + + Save internal code generation (LLVM) statistics to a file in the current + directory (:option:`-save-stats`/"-save-stats=cwd") or the directory + of the output file ("-save-state=obj"). + .. option:: -integrated-as, -no-integrated-as Used to enable and disable, respectively, the use of the integrated diff --git a/docs/ControlFlowIntegrityDesign.rst b/docs/ControlFlowIntegrityDesign.rst index 38c5e5b99e3..a9f0b28a95f 100644 --- a/docs/ControlFlowIntegrityDesign.rst +++ b/docs/ControlFlowIntegrityDesign.rst @@ -497,3 +497,57 @@ Cross-DSO CFI mode requires that the main executable is built as PIE. In non-PIE executables the address of an external function (taken from the main executable) is the address of that function’s PLT record in the main executable. This would break the CFI checks. + + +Hardware support +================ + +We believe that the above design can be efficiently implemented in hardware. +A single new instruction added to an ISA would allow to perform the CFI check +with fewer bytes per check (smaller code size overhead) and potentially more +efficiently. The current software-only instrumentation requires at least +32-bytes per check (on x86_64). +A hardware instruction may probably be less than ~ 12 bytes. +Such instruction would check that the argument pointer is in-bounds, +and is properly aligned, and if the checks fail it will either trap (in monolithic scheme) +or call the slow path function (cross-DSO scheme). +The bit vector lookup is probably too complex for a hardware implementation. + +.. code-block:: none + + // This instruction checks that 'Ptr' + // * is aligned by (1 << kAlignment) and + // * is inside [kRangeBeg, kRangeBeg+(kRangeSize<= kRangeBeg + (kRangeSize << kAlignment) || + Ptr & ((1 << kAlignment) - 1)) + Jump(kFailedCheckTarget); + } + +An alternative and more compact enconding would not use `kFailedCheckTarget`, +and will trap on check failure instead. +This will allow us to fit the instruction into **8-9 bytes**. +The cross-DSO checks will be performed by a trap handler and +performance-critical ones will have to be black-listed and checked using the +software-only scheme. + +Note that such hardware extension would be complementary to checks +at the callee side, such as e.g. **Intel ENDBRANCH**. +Moreover, CFI would have two benefits over ENDBRANCH: a) precision and b) +ability to protect against invalid casts between polymorphic types. diff --git a/docs/CrossCompilation.rst b/docs/CrossCompilation.rst index c07bc21a430..5e1253ddf85 100644 --- a/docs/CrossCompilation.rst +++ b/docs/CrossCompilation.rst @@ -78,14 +78,14 @@ go ahead, creating code for the host platform, which will break later on when assembling or linking. The triple has the general format ``---``, where: - * ``arch`` = ``x86``, ``arm``, ``thumb``, ``mips``, etc. + * ``arch`` = ``x86_64``, ``i386``, ``arm``, ``thumb``, ``mips``, etc. * ``sub`` = for ex. on ARM: ``v5``, ``v6m``, ``v7a``, ``v7m``, etc. * ``vendor`` = ``pc``, ``apple``, ``nvidia``, ``ibm``, etc. * ``sys`` = ``none``, ``linux``, ``win32``, ``darwin``, ``cuda``, etc. * ``abi`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc. The sub-architecture options are available for their own architectures, -of course, so "x86v7a" doesn't make sense. The vendor needs to be +of course, so "x86v7a" doesn't make sense. The vendor needs to be specified only if there's a relevant change, for instance between PC and Apple. Most of the time it can be omitted (and Unknown) will be assumed, which sets the defaults for the specified architecture. diff --git a/docs/DiagnosticsReference.rst b/docs/DiagnosticsReference.rst new file mode 100644 index 00000000000..7294c366202 --- /dev/null +++ b/docs/DiagnosticsReference.rst @@ -0,0 +1,10560 @@ +.. + ------------------------------------------------------------------- + NOTE: This file is automatically generated by running clang-tblgen + -gen-diag-docs. Do not edit this file by hand!! + ------------------------------------------------------------------- + +.. Add custom CSS to output. FIXME: This should be put into rather + than the start of . +.. raw:: html + + + +.. FIXME: rST doesn't support formatting this, so we format all elements + as monospace font face instead. +.. |nbsp| unicode:: 0xA0 + :trim: + +.. Roles generated by clang-tblgen. +.. role:: error +.. role:: warning +.. role:: remark +.. role:: diagtext +.. role:: placeholder(emphasis) + +========================= +Diagnostic flags in Clang +========================= +.. contents:: + :local: + +Introduction +============ + +This page lists the diagnostic flags currently supported by Clang. + +Diagnostic flags +================ + +-W +-- +Synonym for `-Wextra`_. + + +-W#pragma-messages +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-W#warnings +----------- +This diagnostic is enabled by default. + +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-WCFString-literal +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`input conversion stopped due to an input byte that does not belong to the input codeset UTF-8`| ++------------------------------------------------------------------------------------------------------------------------------------+ + + +-WCL4 +----- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wall`_, `-Wextra`_. + + +-WIndependentClass-attribute +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'objc\_independent\_class' attribute may be put on a typedef only; attribute is ignored`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'objc\_independent\_class' attribute may be put on Objective-C object pointer type only; attribute is ignored`| ++----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-WNSObject-attribute +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'NSObject' attribute may be put on a typedef only; attribute is ignored`| ++--------------------------------------------------------------------------------------------------------------+ + + +-Wabi +----- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wabsolute-value +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`absolute value function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`given an argument of type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`but has parameter of type` |nbsp| :placeholder:`C` |nbsp| :diagtext:`which may cause truncation of value`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------+----------------------+---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`taking the absolute value of` |nbsp| |+--------------------+| |nbsp| :diagtext:`type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`is suspicious`| +| ||:diagtext:`pointer` || | +| |+--------------------+| | +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`array` || | +| |+--------------------+| | ++---------------------------------------------------------------------------+----------------------+---------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`taking the absolute value of unsigned type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has no effect`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------+----------------------------+------------------------------------------------------------------------------------------------------------------+----------------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using` |nbsp| |+--------------------------+| |nbsp| :diagtext:`absolute value function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`when argument is of` |nbsp| |+--------------------------+| |nbsp| :diagtext:`type`| +| ||:diagtext:`integer` || ||:diagtext:`integer` || | +| |+--------------------------+| |+--------------------------+| | +| ||:diagtext:`floating point`|| ||:diagtext:`floating point`|| | +| |+--------------------------+| |+--------------------------+| | +| ||:diagtext:`complex` || ||:diagtext:`complex` || | +| |+--------------------------+| |+--------------------------+| | ++----------------------------------------------------+----------------------------+------------------------------------------------------------------------------------------------------------------+----------------------------+------------------------+ + + +-Wabstract-final-class +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------+--------------------+-------------+ +|:warning:`warning:` |nbsp| :diagtext:`abstract class is marked '`|+------------------+|:diagtext:`'`| +| ||:diagtext:`final` || | +| |+------------------+| | +| ||:diagtext:`sealed`|| | +| |+------------------+| | ++-----------------------------------------------------------------+--------------------+-------------+ + + +-Wabstract-vbase-init +--------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initializer for virtual base class` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of abstract class` |nbsp| :placeholder:`B` |nbsp| :diagtext:`will never be used`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Waddress +--------- +This diagnostic is enabled by default. + +Controls `-Wpointer-bool-conversion`_, `-Wstring-compare`_, `-Wtautological-pointer-compare`_. + + +-Waddress-of-array-temporary +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pointer is initialized by a temporary array, which will be destroyed at the end of the full-expression`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Waddress-of-packed-member +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`taking address of packed member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of class or structure` |nbsp| :placeholder:`B` |nbsp| :diagtext:`may result in an unaligned pointer value`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Waddress-of-temporary +---------------------- +This diagnostic is an error by default, but the flag ``-Wno-address-of-temporary`` can be used to disable the error. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`taking the address of a temporary object of type` |nbsp| :placeholder:`A`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Waggregate-return +------------------ +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wall +----- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wmost`_, `-Wparentheses`_, `-Wswitch`_, `-Wswitch-bool`_. + + +-Wambiguous-ellipsis +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+---------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'...' in this location creates a C-style varargs function`|+-------------------------------------------+| +| ||:diagtext:`, not a function parameter pack`|| +| |+-------------------------------------------+| +| || || +| |+-------------------------------------------+| ++------------------------------------------------------------------------------------------------+---------------------------------------------+ + + +-Wambiguous-macro +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ambiguous expansion of macro` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------+ + + +-Wambiguous-member-template +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`lookup of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in member access expression is ambiguous; using member of` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wanalyzer-incompatible-plugin +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`checker plugin '`:placeholder:`A`:diagtext:`' is not compatible with this version of the analyzer`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wanonymous-pack-parens +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C++11 requires a parenthesized pack declaration to have a name`| ++---------------------------------------------------------------------------------------------------------+ + + +-Warc +----- +This diagnostic is enabled by default. + +Controls `-Warc-non-pod-memaccess`_, `-Warc-retain-cycles`_, `-Warc-unsafe-retained-assign`_. + + +-Warc-bridge-casts-disallowed-in-nonarc +--------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' casts have no effect when not using ARC`| ++-------------------------------------------------------------------------------------------------------------+ + + +-Warc-maybe-repeated-use-of-weak +-------------------------------- +**Diagnostic text:** + ++---------------------------------------------------+-------------------------------+------------------------------------------------------------------------------------------+----------------------+-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`weak` |nbsp| |+-----------------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`may be accessed multiple times in this` |nbsp| |+--------------------+| |nbsp| :diagtext:`and may be unpredictably set to nil; assign to a strong variable to keep the object alive`| +| ||:diagtext:`variable` || ||:diagtext:`function`|| | +| |+-----------------------------+| |+--------------------+| | +| ||:diagtext:`property` || ||:diagtext:`method` || | +| |+-----------------------------+| |+--------------------+| | +| ||:diagtext:`implicit property`|| ||:diagtext:`block` || | +| |+-----------------------------+| |+--------------------+| | +| ||:diagtext:`instance variable`|| ||:diagtext:`lambda` || | +| |+-----------------------------+| |+--------------------+| | ++---------------------------------------------------+-------------------------------+------------------------------------------------------------------------------------------+----------------------+-------------------------------------------------------------------------------------------------------------+ + + +-Warc-non-pod-memaccess +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------------+| |nbsp| :diagtext:`this` |nbsp| :placeholder:`B` |nbsp| :diagtext:`call is a pointer to ownership-qualified type` |nbsp| :placeholder:`C`| +| ||:diagtext:`destination for`|| | +| |+---------------------------+| | +| ||:diagtext:`source of` || | +| |+---------------------------+| | ++---------------------------+-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+ + + +-Warc-performSelector-leaks +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`performSelector may cause a leak because its selector is unknown`| ++-------------------------------------------------------------------------------------------------------+ + + +-Warc-repeated-use-of-weak +-------------------------- +Also controls `-Warc-maybe-repeated-use-of-weak`_. + +**Diagnostic text:** + ++---------------------------------------------------+-------------------------------+--------------------------------------------------------------------------------------+----------------------+-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`weak` |nbsp| |+-----------------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`is accessed multiple times in this` |nbsp| |+--------------------+| |nbsp| :diagtext:`but may be unpredictably set to nil; assign to a strong variable to keep the object alive`| +| ||:diagtext:`variable` || ||:diagtext:`function`|| | +| |+-----------------------------+| |+--------------------+| | +| ||:diagtext:`property` || ||:diagtext:`method` || | +| |+-----------------------------+| |+--------------------+| | +| ||:diagtext:`implicit property`|| ||:diagtext:`block` || | +| |+-----------------------------+| |+--------------------+| | +| ||:diagtext:`instance variable`|| ||:diagtext:`lambda` || | +| |+-----------------------------+| |+--------------------+| | ++---------------------------------------------------+-------------------------------+--------------------------------------------------------------------------------------+----------------------+-------------------------------------------------------------------------------------------------------------+ + + +-Warc-retain-cycles +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`capturing` |nbsp| :placeholder:`A` |nbsp| :diagtext:`strongly in this block is likely to lead to a retain cycle`| ++------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Warc-unsafe-retained-assign +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------+---------------------------------+-------------------------------------+----------------------+------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`assigning` |nbsp| |+-------------------------------+| |nbsp| :diagtext:`to a weak` |nbsp| |+--------------------+|:diagtext:`; object will be released after assignment`| +| ||:diagtext:`array literal` || ||:diagtext:`property`|| | +| |+-------------------------------+| |+--------------------+| | +| ||:diagtext:`dictionary literal` || ||:diagtext:`variable`|| | +| |+-------------------------------+| |+--------------------+| | +| ||:diagtext:`numeric literal` || | | | +| |+-------------------------------+| | | | +| ||:diagtext:`boxed expression` || | | | +| |+-------------------------------+| | | | +| ||:diagtext:``|| | | | +| |+-------------------------------+| | | | +| ||:diagtext:`block literal` || | | | +| |+-------------------------------+| | | | ++--------------------------------------------------------+---------------------------------+-------------------------------------+----------------------+------------------------------------------------------+ + ++---------------------------------------------------------------------------+--------------------------------+--------+----------------------+------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`assigning retained object to` |nbsp| |+------------------------------+| |nbsp| |+--------------------+|:diagtext:`; object will be released after assignment`| +| ||:diagtext:`weak` || ||:diagtext:`property`|| | +| |+------------------------------+| |+--------------------+| | +| ||:diagtext:`unsafe\_unretained`|| ||:diagtext:`variable`|| | +| |+------------------------------+| |+--------------------+| | ++---------------------------------------------------------------------------+--------------------------------+--------+----------------------+------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`assigning retained object to unsafe property; object will be released after assignment`| ++-----------------------------------------------------------------------------------------------------------------------------+ + + +-Warray-bounds +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+-------------+ +|:warning:`warning:` |nbsp| :diagtext:`array index` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is past the end of the array (which contains` |nbsp| :placeholder:`B` |nbsp| :diagtext:`element`|+-------------+|:diagtext:`)`| +| || || | +| |+-------------+| | +| ||:diagtext:`s`|| | +| |+-------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+-------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array index` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is before the beginning of the array`| ++----------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array argument is too small; contains` |nbsp| :placeholder:`A` |nbsp| :diagtext:`elements, callee requires at least` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'static' has no effect on zero-length arrays`| ++-----------------------------------------------------------------------------------+ + + +-Warray-bounds-pointer-arithmetic +--------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+-------------+ +|:warning:`warning:` |nbsp| :diagtext:`the pointer incremented by` |nbsp| :placeholder:`A` |nbsp| :diagtext:`refers past the end of the array (that contains` |nbsp| :placeholder:`B` |nbsp| :diagtext:`element`|+-------------+|:diagtext:`)`| +| || || | +| |+-------------+| | +| ||:diagtext:`s`|| | +| |+-------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+-------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`the pointer decremented by` |nbsp| :placeholder:`A` |nbsp| :diagtext:`refers before the beginning of the array`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wasm +----- +Synonym for `-Wasm-operand-widths`_. + + +-Wasm-operand-widths +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`value size does not match register size specified by the constraint and modifier`| ++-----------------------------------------------------------------------------------------------------------------------+ + + +-Wassign-enum +------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`integer constant not in range of enumerated type` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------------------------------------+ + + +-Wassume +-------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`the argument to` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has side effects that will be discarded`| ++-----------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wat-protocol +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`@protocol is using a forward protocol declaration of` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------+ + + +-Watomic-memory-ordering +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`memory order argument to atomic operation is invalid`| ++-------------------------------------------------------------------------------------------+ + + +-Watomic-properties +------------------- +Controls `-Wcustom-atomic-properties`_, `-Wimplicit-atomic-properties`_. + + +-Watomic-property-with-user-defined-accessor +-------------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------+--------------------+-----------------------------------------------+--------------------+ +|:warning:`warning:` |nbsp| :diagtext:`writable atomic property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot pair a synthesized` |nbsp| |+------------------+| |nbsp| :diagtext:`with a user defined` |nbsp| |+------------------+| +| ||:diagtext:`getter`|| ||:diagtext:`getter`|| +| |+------------------+| |+------------------+| +| ||:diagtext:`setter`|| ||:diagtext:`setter`|| +| |+------------------+| |+------------------+| ++--------------------------------------------------------------------------------------------------------------------------------------------+--------------------+-----------------------------------------------+--------------------+ + + +-Wattribute-packed-for-bitfield +------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'packed' attribute was ignored on bit-fields with single-byte alignment in older versions of GCC and Clang`| ++-------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wattributes +------------ +This diagnostic is enabled by default. + +Controls `-Wignored-attributes`_, `-Wunknown-attributes`_. + + +-Wauto-disable-vptr-sanitizer +----------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicitly disabling vptr sanitizer because rtti wasn't enabled`| ++------------------------------------------------------------------------------------------------------+ + + +-Wauto-import +------------- +**Diagnostic text:** + ++-------------------------------------------------+---------------------------------+-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`treating #`|+-------------------------------+| |nbsp| :diagtext:`as an import of module '`:placeholder:`B`:diagtext:`'`| +| ||:diagtext:`include` || | +| |+-------------------------------+| | +| ||:diagtext:`import` || | +| |+-------------------------------+| | +| ||:diagtext:`include\_next` || | +| |+-------------------------------+| | +| ||:diagtext:`\_\_include\_macros`|| | +| |+-------------------------------+| | ++-------------------------------------------------+---------------------------------+-------------------------------------------------------------------------+ + + +-Wauto-storage-class +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wauto-var-id +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'auto' deduced as 'id' in declaration of` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------+ + + +-Wavailability +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'unavailable' availability overrides all other availability information`| ++--------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown platform` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in availability macro`| ++------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------+------------------------+------------------------------------------------------------------------------------------------------------------------------------------+------------------------+-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`feature cannot be` |nbsp| |+----------------------+| |nbsp| :diagtext:`in` |nbsp| :placeholder:`B` |nbsp| :diagtext:`version` |nbsp| :placeholder:`C` |nbsp| :diagtext:`before it was` |nbsp| |+----------------------+| |nbsp| :diagtext:`in version` |nbsp| :placeholder:`E`:diagtext:`; attribute ignored`| +| ||:diagtext:`introduced`|| ||:diagtext:`introduced`|| | +| |+----------------------+| |+----------------------+| | +| ||:diagtext:`deprecated`|| ||:diagtext:`deprecated`|| | +| |+----------------------+| |+----------------------+| | +| ||:diagtext:`obsoleted` || ||:diagtext:`obsoleted` || | +| |+----------------------+| |+----------------------+| | ++----------------------------------------------------------------+------------------------+------------------------------------------------------------------------------------------------------------------------------------------+------------------------+-------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use same version number separators '\_' or '.'; as in 'major\[.minor\[.subminor\]\]'`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`availability does not match previous declaration`| ++---------------------------------------------------------------------------------------+ + ++---------------------------+--------------------------------+--------------------------+-------------------------------+--------+-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+------------------------------+|:diagtext:`method` |nbsp| |+-----------------------------+| |nbsp| |+---------------------------------------------+| |nbsp| :diagtext:`on` |nbsp| :placeholder:`B` |nbsp| :diagtext:`(`:placeholder:`C` |nbsp| :diagtext:`vs.` |nbsp| :placeholder:`D`:diagtext:`)`| +| || || ||:diagtext:`introduced after` || ||:diagtext:`the protocol method it implements`|| | +| |+------------------------------+| |+-----------------------------+| |+---------------------------------------------+| | +| ||:diagtext:`overriding` |nbsp| || ||:diagtext:`deprecated before`|| ||:diagtext:`overridden method` || | +| |+------------------------------+| |+-----------------------------+| |+---------------------------------------------+| | +| | | ||:diagtext:`obsoleted before` || | | | +| | | |+-----------------------------+| | | | ++---------------------------+--------------------------------+--------------------------+-------------------------------+--------+-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+--------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------+--------------------------------+ +|:warning:`warning:` |nbsp| |+------------------------------+|:diagtext:`method cannot be unavailable on` |nbsp| :placeholder:`A` |nbsp| :diagtext:`when` |nbsp| |+---------------------------------------------+| |nbsp| :diagtext:`is available`| +| || || ||:diagtext:`the protocol method it implements`|| | +| |+------------------------------+| |+---------------------------------------------+| | +| ||:diagtext:`overriding` |nbsp| || ||:diagtext:`its overridden method` || | +| |+------------------------------+| |+---------------------------------------------+| | ++---------------------------+--------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------+--------------------------------+ + + +-Wbackend-plugin +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-Wbackslash-newline-escape +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`backslash and newline separated by space`| ++-------------------------------------------------------------------------------+ + + +-Wbad-array-new-length +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array is too large (`:placeholder:`A` |nbsp| :diagtext:`elements)`| ++--------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array size is negative`| ++-------------------------------------------------------------+ + + +-Wbad-function-cast +------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast from function call of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to non-matching type` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wbind-to-temporary-copy +------------------------ +Also controls `-Wc++98-compat-bind-to-temporary-copy`_. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C++98 requires an accessible copy constructor for class` |nbsp| :placeholder:`C` |nbsp| :diagtext:`when binding a reference to a temporary; was` |nbsp| |+---------------------+| +| ||:diagtext:`private` || +| |+---------------------+| +| ||:diagtext:`protected`|| +| |+---------------------+| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+ + ++--------------------------------------------------------------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no viable constructor` |nbsp| |+---------------------------------------+| |nbsp| :diagtext:`of type` |nbsp| :placeholder:`B`:diagtext:`; C++98 requires a copy constructor when binding a reference to a temporary`| +| ||:diagtext:`copying variable` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying parameter` || | +| |+---------------------------------------+| | +| ||:diagtext:`returning object` || | +| |+---------------------------------------+| | +| ||:diagtext:`throwing object` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying member subobject` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying array element` || | +| |+---------------------------------------+| | +| ||:diagtext:`allocating object` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying temporary` || | +| |+---------------------------------------+| | +| ||:diagtext:`initializing base subobject`|| | +| |+---------------------------------------+| | +| ||:diagtext:`initializing vector element`|| | +| |+---------------------------------------+| | +| ||:diagtext:`capturing value` || | +| |+---------------------------------------+| | ++--------------------------------------------------------------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wbitfield-constant-conversion +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit truncation from` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to bitfield changes value from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wbitfield-width +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+ +|:warning:`warning:` |nbsp| :diagtext:`width of anonymous bit-field (`:placeholder:`A` |nbsp| :diagtext:`bits) exceeds width of its type; value will be truncated to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`bit`|+-------------+| +| || || +| |+-------------+| +| ||:diagtext:`s`|| +| |+-------------+| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+ +|:warning:`warning:` |nbsp| :diagtext:`width of bit-field` |nbsp| :placeholder:`A` |nbsp| :diagtext:`(`:placeholder:`B` |nbsp| :diagtext:`bits) exceeds the width of its type; value will be truncated to` |nbsp| :placeholder:`C` |nbsp| :diagtext:`bit`|+-------------+| +| || || +| |+-------------+| +| ||:diagtext:`s`|| +| |+-------------+| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+ + + +-Wbitwise-op-parentheses +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' within '`:placeholder:`B`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wbool-conversion +----------------- +This diagnostic is enabled by default. + +Also controls `-Wpointer-bool-conversion`_, `-Wundefined-bool-conversion`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initialization of pointer of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to null from a constant boolean expression`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wbool-conversions +------------------ +Synonym for `-Wbool-conversion`_. + + +-Wbraced-scalar-init +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`braces around scalar initializer`| ++-----------------------------------------------------------------------+ + + +-Wbridge-cast +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`bridges to` |nbsp| :placeholder:`B`:diagtext:`, not` |nbsp| :placeholder:`C`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot bridge to` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------+ + + +-Wbuiltin-macro-redefined +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redefining builtin macro`| ++---------------------------------------------------------------+ + ++---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`undefining builtin macro`| ++---------------------------------------------------------------+ + + +-Wbuiltin-memcpy-chk-size +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will always overflow destination buffer`| ++------------------------------------------------------------------------------------------------------+ + + +-Wbuiltin-requires-header +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration of built-in function '`:placeholder:`B`:diagtext:`' requires inclusion of the header <`:placeholder:`A`:diagtext:`>`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wc++-compat +------------ +**Diagnostic text:** + ++---------------------------+---------------------------+--------------------+--------------------------------------------+---------------------------+--------------------------+ +|:warning:`warning:` |nbsp| |+-------------------------+|+------------------+| |nbsp| :diagtext:`has size 0 in C,` |nbsp| |+-------------------------+| |nbsp| :diagtext:`in C++`| +| || |||:diagtext:`struct`|| ||:diagtext:`size 1` || | +| |+-------------------------+|+------------------+| |+-------------------------+| | +| ||:diagtext:`empty` |nbsp| |||:diagtext:`union` || ||:diagtext:`non-zero size`|| | +| |+-------------------------+|+------------------+| |+-------------------------+| | ++---------------------------+---------------------------+--------------------+--------------------------------------------+---------------------------+--------------------------+ + + +-Wc++0x-compat +-------------- +Synonym for `-Wc++11-compat`_. + + +-Wc++0x-extensions +------------------ +Synonym for `-Wc++11-extensions`_. + + +-Wc++0x-narrowing +----------------- +Synonym for `-Wc++11-narrowing`_. + + +-Wc++11-compat +-------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wc++11-compat-deprecated-writable-strings`_, `-Wc++11-compat-reserved-user-defined-literal`_, `-Wc++11-narrowing`_, `-Wc++98-c++11-c++14-compat`_, `-Wc++98-c++11-compat`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`integer literal is too large to be represented in type 'long' and is subject to undefined behavior under C++98, interpreting as 'unsigned long'; this literal will` |nbsp| |+---------------------------------+| |nbsp| :diagtext:`in C++11 onwards`| +| ||:diagtext:`have type 'long long'`|| | +| |+---------------------------------+| | +| ||:diagtext:`be ill-formed` || | +| |+---------------------------------+| | ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'auto' storage class specifier is redundant and incompatible with C++11`| ++--------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`identifier after literal will be treated as a user-defined literal suffix in C++11`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' is a keyword in C++11`| ++-------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of right-shift operator ('>>') in template argument will require parentheses in C++11`| ++--------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit instantiation cannot be 'inline'`| ++--------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit instantiation of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`must occur at global scope`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit instantiation of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not in a namespace enclosing` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit instantiation of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`must occur in namespace` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C++98; this literal will` |nbsp| |+---------------------------------+| |nbsp| :diagtext:`in C++11 onwards`| +| ||:diagtext:`have type 'long long'`|| | +| |+---------------------------------+| | +| ||:diagtext:`be ill-formed` || | +| |+---------------------------------+| | ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+------------------------------------+ + + +-Wc++11-compat-deprecated-writable-strings +------------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conversion from string literal to` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is deprecated`| ++---------------------------------------------------------------------------------------------------------------------------------+ + + +-Wc++11-compat-pedantic +----------------------- +Controls `-Wc++98-c++11-c++14-compat-pedantic`_, `-Wc++98-c++11-compat-pedantic`_. + + +-Wc++11-compat-reserved-user-defined-literal +-------------------------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`identifier after literal will be treated as a reserved user-defined literal suffix in C++11`| ++----------------------------------------------------------------------------------------------------------------------------------+ + + +-Wc++11-extensions +------------------ +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wc++11-extra-semi`_, `-Wc++11-inline-namespace`_, `-Wc++11-long-long`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`alias declarations are a C++11 extension`| ++-------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from array size expression of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| |+-----------------------+| |nbsp| :diagtext:`type` |nbsp| :placeholder:`C` |nbsp| :diagtext:`is a C++11 extension`| +| ||:diagtext:`integral` || | +| |+-----------------------+| | +| ||:diagtext:`enumeration`|| | +| |+-----------------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'auto' type specifier is a C++11 extension`| ++---------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration types with a fixed underlying type are a C++11 extension`| ++-----------------------------------------------------------------------------------------------------------+ + ++---------------------------+-----------------------+--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------+| |nbsp| :diagtext:`function definitions are a C++11 extension`| +| ||:diagtext:`defaulted`|| | +| |+---------------------+| | +| ||:diagtext:`deleted` || | +| |+---------------------+| | ++---------------------------+-----------------------+--------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`befriending enumeration type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a C++11 extension`| ++-----------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`commas at the end of enumerator lists are a C++11 extension`| ++--------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit conversion functions are a C++11 extension`| ++------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extern templates are a C++11 extension`| ++-----------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`range-based for loop is a C++11 extension`| ++--------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`generalized initializer lists are a C++11 extension`| ++------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of enumeration in a nested name specifier is a C++11 extension`| ++---------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-class friend type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a C++11 extension`| ++----------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`in-class initialization of non-static data member is a C++11 extension`| ++-------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' keyword is a C++11 extension`| ++--------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference qualifiers on functions are a C++11 extension`| ++----------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`rvalue references are a C++11 extension`| ++------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`scoped enumerations are a C++11 extension`| ++--------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static data member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in union is a C++11 extension`| ++----------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+----------------------+--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-type template argument referring to` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`with internal linkage is a C++11 extension`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`object` || | +| |+--------------------+| | ++--------------------------------------------------------------------------------------+----------------------+--------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'template' keyword outside of a template`| ++-------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default template arguments for a function template are a C++11 extension`| ++---------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------+---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`first declaration of` |nbsp| |+-------------------------------------+| |nbsp| :diagtext:`specialization of` |nbsp| :placeholder:`B` |nbsp| :diagtext:`outside namespace` |nbsp| :placeholder:`C` |nbsp| :diagtext:`is a C++11 extension`| +| ||:diagtext:`class template` || | +| |+-------------------------------------+| | +| ||:diagtext:`class template partial` || | +| |+-------------------------------------+| | +| ||:diagtext:`variable template` || | +| |+-------------------------------------+| | +| ||:diagtext:`variable template partial`|| | +| |+-------------------------------------+| | +| ||:diagtext:`function template` || | +| |+-------------------------------------+| | +| ||:diagtext:`member function` || | +| |+-------------------------------------+| | +| ||:diagtext:`static data member` || | +| |+-------------------------------------+| | +| ||:diagtext:`member class` || | +| |+-------------------------------------+| | +| ||:diagtext:`member enumeration` || | +| |+-------------------------------------+| | ++-------------------------------------------------------------------+---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'typename' occurs outside of a template`| ++------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unelaborated friend declaration is a C++11 extension; specify '`|+---------------------+|:diagtext:`' to befriend` |nbsp| :placeholder:`B`| +| ||:diagtext:`struct` || | +| |+---------------------+| | +| ||:diagtext:`interface`|| | +| |+---------------------+| | +| ||:diagtext:`union` || | +| |+---------------------+| | +| ||:diagtext:`class` || | +| |+---------------------+| | +| ||:diagtext:`enum` || | +| |+---------------------+| | ++------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variadic templates are a C++11 extension`| ++-------------------------------------------------------------------------------+ + + +-Wc++11-extra-semi +------------------ +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra ';' outside of a function is a C++11 extension`| ++-------------------------------------------------------------------------------------------+ + + +-Wc++11-inline-namespace +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inline namespaces are a C++11 feature`| ++----------------------------------------------------------------------------+ + + +-Wc++11-long-long +----------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'long long' is a C++11 extension`| ++-----------------------------------------------------------------------+ + + +-Wc++11-narrowing +----------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-----------------------+----------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| |+--------------------------------------+| |nbsp| |+------------------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`case value` || ||+--------------------------------------------------------------------------------------------------------------+ || +| |+--------------------------------------+| |||:diagtext:`cannot be narrowed from type` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to` |nbsp| :placeholder:`D`| || +| ||:diagtext:`enumerator value` || ||+--------------------------------------------------------------------------------------------------------------+ || +| |+--------------------------------------+| |+------------------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`non-type template argument`|| ||+----------------------------------------------------------------------------------------------------------------------+|| +| |+--------------------------------------+| |||:diagtext:`evaluates to` |nbsp| :placeholder:`C`:diagtext:`, which cannot be narrowed to type` |nbsp| :placeholder:`D`||| +| ||:diagtext:`array size` || ||+----------------------------------------------------------------------------------------------------------------------+|| +| |+--------------------------------------+| |+------------------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`constexpr if condition` || | | +| |+--------------------------------------+| | | ++-----------------------+----------------------------------------+--------+--------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`constant expression evaluates to` |nbsp| :placeholder:`A` |nbsp| :diagtext:`which cannot be narrowed to type` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot be narrowed to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`in initializer list`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`non-constant-expression cannot be narrowed from type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`in initializer list`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constant expression evaluates to` |nbsp| :placeholder:`A` |nbsp| :diagtext:`which cannot be narrowed to type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`in C++11`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot be narrowed to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`in initializer list in C++11`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-constant-expression cannot be narrowed from type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`in initializer list in C++11`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wc++14-binary-literal +---------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`binary integer literals are a C++14 extension`| ++------------------------------------------------------------------------------------+ + + +-Wc++14-compat +-------------- +Synonym for `-Wc++98-c++11-c++14-compat`_. + + +-Wc++14-compat-pedantic +----------------------- +Synonym for `-Wc++98-c++11-c++14-compat-pedantic`_. + + +-Wc++14-extensions +------------------ +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wc++14-binary-literal`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------+-------------------------+----------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of this statement in a constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is a C++14 extension`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++-----------------------------------------------------------------------------------+-------------------------+----------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multiple return statements in constexpr function is a C++14 extension`| ++------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------+-------------------------+----------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable declaration in a constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is a C++14 extension`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++----------------------------------------------------------------------------------+-------------------------+----------------------------------------+ + ++-----------------------------------------------------------------------------+-------------------------+----------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type definition in a constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is a C++14 extension`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++-----------------------------------------------------------------------------+-------------------------+----------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of the` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute is a C++14 extension`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'decltype(auto)' type specifier is a C++14 extension`| ++-------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initialized lambda captures are a C++14 extension`| ++----------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable templates are a C++14 extension`| ++-------------------------------------------------------------------------------+ + + +-Wc++1y-extensions +------------------ +Synonym for `-Wc++14-extensions`_. + + +-Wc++1z-compat +-------------- +This diagnostic is enabled by default. + +Controls `-Wdeprecated-increment-bool`_, `-Wdeprecated-register`_. + + +-Wc++1z-extensions +------------------ +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constexpr if is a C++1z extension`| ++------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'constexpr' on lambda expressions is a C++1z extension`| ++---------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of the` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute is a C++1z extension`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`decomposition declarations are a C++1z extension`| ++---------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pack fold expression is a C++1z extension`| ++--------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'begin' and 'end' returning different types (`:placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B`:diagtext:`) is a C++1z extension`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`hexadecimal floating literals are a C++1z feature`| ++----------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inline variables are a C++1z extension`| ++-----------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`nested namespace definition is a C++1z extension; define each namespace separately`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`capture of '\*this' by copy is a C++1z extension`| ++---------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static\_assert with no message is a C++1z extension`| ++------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template template parameter using 'typename' is a C++1z extension`| ++--------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default scope specifier for attributes is a C++1z extension`| ++--------------------------------------------------------------------------------------------------+ + + +-Wc++98-c++11-c++14-compat +-------------------------- +**Diagnostic text:** + ++------------------------------------------------------------+---------------------------+--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attributes on` |nbsp| |+-------------------------+| |nbsp| :diagtext:`declaration are incompatible with C++ standards before C++1z`| +| ||:diagtext:`a namespace` || | +| |+-------------------------+| | +| ||:diagtext:`an enumerator`|| | +| |+-------------------------+| | ++------------------------------------------------------------+---------------------------+--------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constexpr if is incompatible with C++ standards before C++1z`| ++---------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constexpr on lambda expressions is incompatible with C++ standards before C++1z`| ++----------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`decomposition declarations are incompatible with C++ standards before C++1z`| ++------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pack fold expression is incompatible with C++ standards before C++1z`| ++-----------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inline variables are incompatible with C++ standards before C++1z`| ++--------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`nested namespace definition is incompatible with C++ standards before C++1z`| ++------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`by value capture of '\*this' is incompatible with C++ standards before C++1z`| ++-------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static\_assert with no message is incompatible with C++ standards before C++1z`| ++---------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template template parameter using 'typename' is incompatible with C++ standards before C++1z`| ++-----------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unicode literals are incompatible with C++ standards before C++1z`| ++--------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default scope specifier for attributes is incompatible with C++ standards before C++1z`| ++-----------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'begin' and 'end' returning different types (`:placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B`:diagtext:`) is incompatible with C++ standards before C++1z`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wc++98-c++11-c++14-compat-pedantic +----------------------------------- +Also controls `-Wc++98-c++11-c++14-compat`_. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`hexidecimal floating literals are incompatible with C++ standards before C++1z`| ++---------------------------------------------------------------------------------------------------------------------+ + + +-Wc++98-c++11-compat +-------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------+-------------------------+-------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of this statement in a constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is incompatible with C++ standards before C++14`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++-----------------------------------------------------------------------------------+-------------------------+-------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multiple return statements in constexpr function is incompatible with C++ standards before C++14`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constexpr function with no return statements is incompatible with C++ standards before C++14`| ++-----------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------+-------------------------+-------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable declaration in a constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is incompatible with C++ standards before C++14`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++----------------------------------------------------------------------------------+-------------------------+-------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+-------------------------+-------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type definition in a constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is incompatible with C++ standards before C++14`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++-----------------------------------------------------------------------------+-------------------------+-------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'decltype(auto)' type specifier is incompatible with C++ standards before C++14`| ++----------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`digit separators are incompatible with C++ standards before C++14`| ++--------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initialized lambda captures are incompatible with C++ standards before C++14`| ++-------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable templates are incompatible with C++ standards before C++14`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wc++98-c++11-compat-pedantic +----------------------------- +Also controls `-Wc++98-c++11-compat`_. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`binary integer literals are incompatible with C++ standards before C++14`| ++---------------------------------------------------------------------------------------------------------------+ + + +-Wc++98-compat +-------------- +Also controls `-Wc++98-c++11-c++14-compat`_, `-Wc++98-c++11-compat`_, `-Wc++98-compat-local-type-template-args`_, `-Wc++98-compat-unnamed-type-template-args`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`alias declarations are incompatible with C++98`| ++-------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'alignas' is incompatible with C++98`| ++---------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`alignof expressions are incompatible with C++98`| ++--------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C++11 attribute syntax is incompatible with C++98`| ++----------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'auto' type specifier is incompatible with C++98`| ++---------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'constexpr' specifier is incompatible with C++98`| ++---------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constructor call from initializer list is incompatible with C++98`| ++--------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'decltype' type specifier is incompatible with C++98`| ++-------------------------------------------------------------------------------------------+ + ++---------------------------+-----------------------+--------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------+| |nbsp| :diagtext:`function definitions are incompatible with C++98`| +| ||:diagtext:`defaulted`|| | +| |+---------------------+| | +| ||:diagtext:`deleted` || | +| |+---------------------+| | ++---------------------------+-----------------------+--------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`delegating constructors are incompatible with C++98`| ++------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`scalar initialized from empty initializer list is incompatible with C++98`| ++----------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration types with a fixed underlying type are incompatible with C++98`| ++-----------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`befriending enumeration type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is incompatible with C++98`| ++-----------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration type in nested name specifier is incompatible with C++98`| ++-----------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit conversion functions are incompatible with C++98`| ++------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`range-based for loop is incompatible with C++98`| ++--------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`friend declaration naming a member of the declaring class is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`generalized initializer lists are incompatible with C++98`| ++------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`jump from this goto statement to its label is incompatible with C++98`| ++------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`jump from this indirect goto statement to one of its possible targets is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initialization of initializer\_list object is incompatible with C++98`| ++------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inline namespaces are incompatible with C++98`| ++------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`lambda expressions are incompatible with C++98`| ++-------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'<::' is treated as digraph '<:' (aka '\[') followed by ':' in C++98`| ++-----------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`literal operators are incompatible with C++98`| ++------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`universal character name referring to a control character is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`specifying character '`:placeholder:`A`:diagtext:`' with a universal character name is incompatible with C++98`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`noexcept specifications are incompatible with C++98`| ++------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`noexcept expressions are incompatible with C++98`| ++---------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of non-static data member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in an unevaluated context is incompatible with C++98`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-class friend type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is incompatible with C++98`| ++----------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`in-class initialization of non-static data members is incompatible with C++98`| ++--------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+------------------------------+------------------------------------------------------------------------------------------------+--------------------------------------+----------------------------------------------+ +|:warning:`warning:` |nbsp| |+----------------------------+| |nbsp| :diagtext:`member` |nbsp| :placeholder:`B` |nbsp| :diagtext:`with a non-trivial` |nbsp| |+------------------------------------+| |nbsp| :diagtext:`is incompatible with C++98`| +| ||:diagtext:`anonymous struct`|| ||:diagtext:`constructor` || | +| |+----------------------------+| |+------------------------------------+| | +| ||:diagtext:`union` || ||:diagtext:`copy constructor` || | +| |+----------------------------+| |+------------------------------------+| | +| | | ||:diagtext:`move constructor` || | +| | | |+------------------------------------+| | +| | | ||:diagtext:`copy assignment operator`|| | +| | | |+------------------------------------+| | +| | | ||:diagtext:`move assignment operator`|| | +| | | |+------------------------------------+| | +| | | ||:diagtext:`destructor` || | +| | | |+------------------------------------+| | ++---------------------------+------------------------------+------------------------------------------------------------------------------------------------+--------------------------------------+----------------------------------------------+ + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'nullptr' is incompatible with C++98`| ++---------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' keyword is incompatible with C++98`| ++--------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`passing object of trivial but non-POD type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`through variadic` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is incompatible with C++98`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`block` || | +| |+-----------------------+| | +| ||:diagtext:`method` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++-----------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`raw string literals are incompatible with C++98`| ++--------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference qualifiers on functions are incompatible with C++98`| ++----------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference initialized from initializer list is incompatible with C++98`| ++-------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`rvalue references are incompatible with C++98`| ++------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`scoped enumerations are incompatible with C++98`| ++--------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`substitution failure due to access control is incompatible with C++98`| ++------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static\_assert declarations are incompatible with C++98`| ++----------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static data member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in union is incompatible with C++98`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`jump from switch statement to this case label is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redundant parentheses surrounding address non-type template argument are incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of null pointer as non-type template argument is incompatible with C++98`| ++-------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+----------------------+--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-type template argument referring to` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`with internal linkage is incompatible with C++98`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`object` || | +| |+--------------------+| | ++--------------------------------------------------------------------------------------+----------------------+--------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of 'template' keyword outside of a template is incompatible with C++98`| ++-----------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default template arguments for a function template are incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------------------------+| |nbsp| :diagtext:`specialization of` |nbsp| :placeholder:`B` |nbsp| :diagtext:`outside namespace` |nbsp| :placeholder:`C` |nbsp| :diagtext:`is incompatible with C++98`| +| ||:diagtext:`class template` || | +| |+-------------------------------------+| | +| ||:diagtext:`class template partial` || | +| |+-------------------------------------+| | +| ||:diagtext:`variable template` || | +| |+-------------------------------------+| | +| ||:diagtext:`variable template partial`|| | +| |+-------------------------------------+| | +| ||:diagtext:`function template` || | +| |+-------------------------------------+| | +| ||:diagtext:`member function` || | +| |+-------------------------------------+| | +| ||:diagtext:`static data member` || | +| |+-------------------------------------+| | +| ||:diagtext:`member class` || | +| |+-------------------------------------+| | +| ||:diagtext:`member enumeration` || | +| |+-------------------------------------+| | ++---------------------------+---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`trailing return types are incompatible with C++98`| ++----------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`consecutive right angle brackets are incompatible with C++98 (use '> >')`| ++---------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of 'typename' outside of a template is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+-----------------------+------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`befriending` |nbsp| :placeholder:`B` |nbsp| :diagtext:`without '`|+---------------------+|:diagtext:`' keyword is incompatible with C++98`| +| ||:diagtext:`struct` || | +| |+---------------------+| | +| ||:diagtext:`interface`|| | +| |+---------------------+| | +| ||:diagtext:`union` || | +| |+---------------------+| | +| ||:diagtext:`class` || | +| |+---------------------+| | +| ||:diagtext:`enum` || | +| |+---------------------+| | ++-------------------------------------------------------------------------------------------------------+-----------------------+------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using this character in an identifier is incompatible with C++98`| ++-------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unicode literals are incompatible with C++98`| ++-----------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' type specifier is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inheriting constructors are incompatible with C++98`| ++------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variadic templates are incompatible with C++98`| ++-------------------------------------------------------------------------------------+ + + +-Wc++98-compat-bind-to-temporary-copy +------------------------------------- +**Diagnostic text:** + ++---------------------------+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------+----------------------------+ +|:warning:`warning:` |nbsp| |+---------------------------------------+| |nbsp| :diagtext:`of type` |nbsp| :placeholder:`C` |nbsp| :diagtext:`when binding a reference to a temporary would` |nbsp| |+----------------------------------------------+| |nbsp| :diagtext:`in C++98`| +| ||:diagtext:`copying variable` || ||:diagtext:`invoke an inaccessible constructor`|| | +| |+---------------------------------------+| |+----------------------------------------------+| | +| ||:diagtext:`copying parameter` || ||:diagtext:`find no viable constructor` || | +| |+---------------------------------------+| |+----------------------------------------------+| | +| ||:diagtext:`returning object` || ||:diagtext:`find ambiguous constructors` || | +| |+---------------------------------------+| |+----------------------------------------------+| | +| ||:diagtext:`throwing object` || ||:diagtext:`invoke a deleted constructor` || | +| |+---------------------------------------+| |+----------------------------------------------+| | +| ||:diagtext:`copying member subobject` || | | | +| |+---------------------------------------+| | | | +| ||:diagtext:`copying array element` || | | | +| |+---------------------------------------+| | | | +| ||:diagtext:`allocating object` || | | | +| |+---------------------------------------+| | | | +| ||:diagtext:`copying temporary` || | | | +| |+---------------------------------------+| | | | +| ||:diagtext:`initializing base subobject`|| | | | +| |+---------------------------------------+| | | | +| ||:diagtext:`initializing vector element`|| | | | +| |+---------------------------------------+| | | | ++---------------------------+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------+----------------------------+ + + +-Wc++98-compat-local-type-template-args +--------------------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`local type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`as template argument is incompatible with C++98`| ++--------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wc++98-compat-pedantic +----------------------- +Also controls `-Wc++98-c++11-c++14-compat-pedantic`_, `-Wc++98-c++11-compat-pedantic`_, `-Wc++98-compat`_, `-Wc++98-compat-bind-to-temporary-copy`_. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from array size expression of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| |+-----------------------+| |nbsp| :diagtext:`type` |nbsp| :placeholder:`C` |nbsp| :diagtext:`is incompatible with C++98`| +| ||:diagtext:`integral` || | +| |+-----------------------+| | +| ||:diagtext:`enumeration`|| | +| |+-----------------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast between pointer-to-function and pointer-to-object is incompatible with C++98`| ++------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty macro arguments are incompatible with C++98`| ++----------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`commas at the end of enumerator lists are incompatible with C++98`| ++--------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extern templates are incompatible with C++98`| ++-----------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'long long' is incompatible with C++98`| ++-----------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C++98 requires newline at end of file`| ++----------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#line number greater than 32767 is incompatible with C++98`| ++-------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra ';' outside of a function is incompatible with C++98`| ++-------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variadic macros are incompatible with C++98`| ++----------------------------------------------------------------------------------+ + + +-Wc++98-compat-unnamed-type-template-args +----------------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unnamed type as template argument is incompatible with C++98`| ++---------------------------------------------------------------------------------------------------+ + + +-Wc11-extensions +---------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`anonymous unions are a C11 extension`| ++---------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a C11-specific feature`| ++----------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`anonymous structs are a C11 extension`| ++----------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`generic selections are a C11-specific feature`| ++------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_Noreturn functions are a C11-specific feature`| ++--------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_Static\_assert is a C11-specific feature`| ++---------------------------------------------------------------------------------+ + + +-Wc99-compat +------------ +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++---------------------------+--------------------------------------------------------+--------------------------------------------+ +|:warning:`warning:` |nbsp| |+------------------------------------------------------+| |nbsp| :diagtext:`is incompatible with C99`| +| ||:diagtext:`using this character in an identifier` || | +| |+------------------------------------------------------+| | +| ||:diagtext:`starting an identifier with this character`|| | +| |+------------------------------------------------------+| | ++---------------------------+--------------------------------------------------------+--------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unicode literals are incompatible with C99`| ++---------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+----------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will` |nbsp| |+---------------------------------+| |nbsp| :diagtext:`in C99 onwards`| +| ||:diagtext:`have type 'long long'`|| | +| |+---------------------------------+| | +| ||:diagtext:`be ill-formed` || | +| |+---------------------------------+| | ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+----------------------------------+ + + +-Wc99-extensions +---------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initializer for aggregate is not a compile-time constant`| ++-----------------------------------------------------------------------------------------------+ + ++---------------------------+----------------------------------+------------------------------+-----------------------+----------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------+|:diagtext:`array size` |nbsp| |+---------------------+|:diagtext:`is a C99 feature`| +| ||:diagtext:`qualifier in` |nbsp| || || || | +| |+--------------------------------+| |+---------------------+| | +| ||:diagtext:`static` |nbsp| || || || | +| |+--------------------------------+| |+---------------------+| | +| || || ||:diagtext:`'\[\*\] '`|| | +| |+--------------------------------+| |+---------------------+| | ++---------------------------+----------------------------------+------------------------------+-----------------------+----------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`compound literals are a C99-specific feature`| ++-----------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array members are a C99 feature`| ++-------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable declaration in for loop is a C99-specific feature`| ++-------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C99 requires whitespace after the macro name`| ++---------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`designated initializers are a C99 feature`| ++--------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty macro arguments are a C99 feature`| ++------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`commas at the end of enumerator lists are a C99-specific feature`| ++-------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`hexadecimal floating constants are a C99 feature`| ++---------------------------------------------------------------------------------------+ + + +-Wcast-align +------------ +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`increases required alignment from` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to` |nbsp| :placeholder:`D`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wcast-calling-convention +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast between incompatible calling conventions '`:placeholder:`A`:diagtext:`' and '`:placeholder:`B`:diagtext:`'; calls through this pointer may abort at runtime`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wcast-of-sel-type +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`is deprecated; use sel\_getName instead`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wcast-qual +----------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`drops` |nbsp| |+-----------------------------------------+| +| ||:diagtext:`const and volatile qualifiers`|| +| |+-----------------------------------------+| +| ||:diagtext:`const qualifier` || +| |+-----------------------------------------+| +| ||:diagtext:`volatile qualifier` || +| |+-----------------------------------------+| ++-------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`must have all intermediate pointers const qualified to be safe`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wchar-align +------------ +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wchar-subscripts +----------------- +**Diagnostic text:** + ++------------------------------------------------------------+-------------------------+-------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array section` |nbsp| |+-----------------------+| |nbsp| :diagtext:`is of type 'char'`| +| ||:diagtext:`lower bound`|| | +| |+-----------------------+| | +| ||:diagtext:`length` || | +| |+-----------------------+| | ++------------------------------------------------------------+-------------------------+-------------------------------------+ + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array subscript is of type 'char'`| ++------------------------------------------------------------------------+ + + +-Wclang-cl-pch +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`support for '/Yc' with more than one source file not implemented yet; flag ignored`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`support for '/Yc' and '/Yu' with different filenames not implemented yet; flags ignored`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`support for '`:placeholder:`A`:diagtext:`' without a filename not implemented yet; flag ignored`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`support for '`:placeholder:`A`:diagtext:`' without a corresponding /FI flag not implemented yet; flag ignored`| ++----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wclass-varargs +--------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wnon-pod-varargs`_. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`passing object of class type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`through variadic` |nbsp| |+-----------------------+|+--------------------------------------------------------------------+| +| ||:diagtext:`function` ||| || +| |+-----------------------+|+--------------------------------------------------------------------+| +| ||:diagtext:`block` |||+------------------------------------------------------------------+|| +| |+-----------------------+|||:diagtext:`; did you mean to call '`:placeholder:`D`:diagtext:`'?`||| +| ||:diagtext:`method` |||+------------------------------------------------------------------+|| +| |+-----------------------+|+--------------------------------------------------------------------+| +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------+ + + +-Wcomma +------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`possible misuse of comma operator here`| ++-----------------------------------------------------------------------------+ + + +-Wcomment +--------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`escaped newline between \*/ characters at block comment end`| ++--------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`// comments are not allowed in this language`| ++-----------------------------------------------------------------------------------+ + ++------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multi-line // comment`| ++------------------------------------------------------------+ + ++-----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'/\*' within block comment`| ++-----------------------------------------------------------------+ + + +-Wcomments +---------- +Synonym for `-Wcomment`_. + + +-Wcompare-distinct-pointer-types +-------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of distinct pointer types`| ++---------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of distinct pointer types (`:placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B`:diagtext:`) uses non-standard composite pointer type` |nbsp| :placeholder:`C`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wcomplex-component-init +------------------------ +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`complex initialization specifying real and imaginary components is an extension`| ++----------------------------------------------------------------------------------------------------------------------+ + + +-Wconditional-type-mismatch +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pointer/integer type mismatch in conditional expression`| ++----------------------------------------------------------------------------------------------+ + + +-Wconditional-uninitialized +--------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------+-------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may be uninitialized when` |nbsp| |+-----------------------------+| +| ||:diagtext:`used here` || +| |+-----------------------------+| +| ||:diagtext:`captured by block`|| +| |+-----------------------------+| ++----------------------------------------------------------------------------------------------------------------------------+-------------------------------+ + + +-Wconfig-macros +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+---------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+----------------------+| |nbsp| :diagtext:`of configuration macro '`:placeholder:`B`:diagtext:`' has no effect on the import of '`:placeholder:`C`:diagtext:`'; pass '`|+------------------------------------------------+|:diagtext:`' on the command line to configure the module`| +| ||:diagtext:`definition`|| ||+----------------------------------------------+|| | +| |+----------------------+| |||:diagtext:`-D`:placeholder:`B`:diagtext:`=...`||| | +| ||:diagtext:`#undef` || ||+----------------------------------------------+|| | +| |+----------------------+| |+------------------------------------------------+| | +| | | ||+------------------------------+ || | +| | | |||:diagtext:`-U`:placeholder:`B`| || | +| | | ||+------------------------------+ || | +| | | |+------------------------------------------------+| | ++---------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------+---------------------------------------------------------+ + + +-Wconstant-conversion +--------------------- +This diagnostic is enabled by default. + +Also controls `-Wbitfield-constant-conversion`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to` |nbsp| :placeholder:`D` |nbsp| :diagtext:`changes value from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wconstant-logical-operand +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of logical '`:placeholder:`A`:diagtext:`' with constant operand`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wconstexpr-not-const +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wconsumed +---------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`consumed analysis attribute is attached to member of class '`:placeholder:`A`:diagtext:`' which isn't marked as consumable`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`state of variable '`:placeholder:`A`:diagtext:`' must match at the entry and exit of loop`| ++--------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`parameter '`:placeholder:`A`:diagtext:`' not in expected state when the function returns: expected '`:placeholder:`B`:diagtext:`', observed '`:placeholder:`C`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument not in expected state; expected '`:placeholder:`A`:diagtext:`', observed '`:placeholder:`B`:diagtext:`'`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`return state set for an unconsumable type '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`return value not in expected state; expected '`:placeholder:`A`:diagtext:`', observed '`:placeholder:`B`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid invocation of method '`:placeholder:`A`:diagtext:`' on object '`:placeholder:`B`:diagtext:`' while it is in the '`:placeholder:`C`:diagtext:`' state`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid invocation of method '`:placeholder:`A`:diagtext:`' on a temporary object while it is in the '`:placeholder:`B`:diagtext:`' state`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wconversion +------------ +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wbool-conversion`_, `-Wconstant-conversion`_, `-Wenum-conversion`_, `-Wfloat-conversion`_, `-Wint-conversion`_, `-Wliteral-conversion`_, `-Wnon-literal-null-conversion`_, `-Wnull-conversion`_, `-Wobjc-literal-conversion`_, `-Wshorten-64-to-32`_, `-Wsign-conversion`_, `-Wstring-conversion`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion discards imaginary component:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion loses floating-point precision:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion loses integer precision:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion turns vector to scalar:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-type template argument with value '`:placeholder:`A`:diagtext:`' converted to '`:placeholder:`B`:diagtext:`' for unsigned template parameter of type` |nbsp| :placeholder:`C`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-type template argument value '`:placeholder:`A`:diagtext:`' truncated to '`:placeholder:`B`:diagtext:`' for template parameter of type` |nbsp| :placeholder:`C`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wconversion-null +----------------- +Synonym for `-Wnull-conversion`_. + + +-Wcoreturn-without-coawait +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'co\_return' used in a function that uses neither 'co\_await' nor 'co\_yield'`| ++--------------------------------------------------------------------------------------------------------------------+ + + +-Wcovered-switch-default +------------------------ +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default label in switch which covers all enumeration values`| ++--------------------------------------------------------------------------------------------------+ + + +-Wcstring-format-directive +-------------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------+----------------------+--------------------------------------------------------------------------------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using` |nbsp| :placeholder:`A` |nbsp| :diagtext:`directive in` |nbsp| |+--------------------+| |nbsp| :diagtext:`which is being passed as a formatting argument to the formatting` |nbsp| |+----------------------+| +| ||:diagtext:`NSString`|| ||:diagtext:`method` || +| |+--------------------+| |+----------------------+| +| ||:diagtext:`CFString`|| ||:diagtext:`CFfunction`|| +| |+--------------------+| |+----------------------+| ++------------------------------------------------------------------------------------------------------------+----------------------+--------------------------------------------------------------------------------------------+------------------------+ + + +-Wctor-dtor-privacy +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wcuda-compat +------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute parameter` |nbsp| :placeholder:`B` |nbsp| :diagtext:`is negative and will be ignored`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignored 'inline' attribute on kernel function` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`kernel function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a member function; this may not be accepted by nvcc`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument to '#pragma unroll' should not be in parentheses in CUDA C/C++`| ++--------------------------------------------------------------------------------------------------------------+ + + +-Wcustom-atomic-properties +-------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`atomic by default property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has a user defined` |nbsp| |+------------------+| |nbsp| :diagtext:`(property should be marked 'atomic' if this is intended)`| +| ||:diagtext:`getter`|| | +| |+------------------+| | +| ||:diagtext:`setter`|| | +| |+------------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------------------------------------------------------------------------+ + + +-Wdangling-else +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`add explicit braces to avoid dangling else`| ++---------------------------------------------------------------------------------+ + + +-Wdangling-field +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`binding reference member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to stack allocated parameter` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`binding reference` |nbsp| |+--------------------------------+|:diagtext:`member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to a temporary value`| +| || || | +| |+--------------------------------+| | +| ||:diagtext:`subobject of` |nbsp| || | +| |+--------------------------------+| | ++----------------------------------------------------------------+----------------------------------+----------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initializing pointer member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`with the stack address of parameter` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdangling-initializer-list +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------+---------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`array backing the initializer list will be destroyed at the end of` |nbsp| |+-------------------------------+| +| ||:diagtext:`the full-expression`|| +| |+-------------------------------+| +| ||:diagtext:`the constructor` || +| |+-------------------------------+| ++-----------------------------------------------------------------------------------------------------------------+---------------------------------+ + + +-Wdate-time +----------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expansion of date or time macro is not reproducible`| ++------------------------------------------------------------------------------------------+ + + +-Wdealloc-in-category +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`-dealloc is being overridden in a category`| ++---------------------------------------------------------------------------------+ + + +-Wdebug-compression-unavailable +------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot compress debug sections (zlib not installed)`| ++------------------------------------------------------------------------------------------+ + + +-Wdeclaration-after-statement +----------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C90 forbids mixing declarations and code`| ++-----------------------------------------------------------------------------------+ + + +-Wdelegating-ctor-cycles +------------------------ +This diagnostic is an error by default, but the flag ``-Wno-delegating-ctor-cycles`` can be used to disable the error. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`constructor for` |nbsp| :placeholder:`A` |nbsp| :diagtext:`creates a delegation cycle`| ++------------------------------------------------------------------------------------------------------------------------+ + + +-Wdelete-incomplete +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot delete expression with pointer-to-'void' type` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`deleting pointer to incomplete type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may cause undefined behavior`| ++--------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdelete-non-virtual-dtor +------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++---------------------------+------------------------+------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+----------------------+| |nbsp| :diagtext:`called on` |nbsp| :placeholder:`B` |nbsp| :diagtext:`that is abstract but has non-virtual destructor`| +| ||:diagtext:`delete` || | +| |+----------------------+| | +| ||:diagtext:`destructor`|| | +| |+----------------------+| | ++---------------------------+------------------------+------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+----------------------+| |nbsp| :diagtext:`called on non-final` |nbsp| :placeholder:`B` |nbsp| :diagtext:`that has virtual functions but non-virtual destructor`| +| ||:diagtext:`delete` || | +| |+----------------------+| | +| ||:diagtext:`destructor`|| | +| |+----------------------+| | ++---------------------------+------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated +------------ +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wdeprecated-attributes`_, `-Wdeprecated-declarations`_, `-Wdeprecated-increment-bool`_, `-Wdeprecated-register`_, `-Wdeprecated-writable-strings`_. + +**Diagnostic text:** + ++---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`-O4 is equivalent to -O3`| ++---------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`access declarations are deprecated; use using declarations instead`| ++---------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------+---------------------------------+-----------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`definition of implicit copy` |nbsp| |+-------------------------------+| |nbsp| :diagtext:`for` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is deprecated because it has a user-declared` |nbsp| |+------------------------------------------------------------+| +| ||:diagtext:`constructor` || ||+------------------------+---------------------------------+|| +| |+-------------------------------+| |||:diagtext:`copy` |nbsp| |+-------------------------------+||| +| ||:diagtext:`assignment operator`|| ||| ||:diagtext:`assignment operator`|||| +| |+-------------------------------+| ||| |+-------------------------------+||| +| | | ||| ||:diagtext:`constructor` |||| +| | | ||| |+-------------------------------+||| +| | | ||+------------------------+---------------------------------+|| +| | | |+------------------------------------------------------------+| +| | | ||:diagtext:`destructor` || +| | | |+------------------------------------------------------------+| ++--------------------------------------------------------------------------+---------------------------------+-----------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument '`:placeholder:`A`:diagtext:`' is deprecated, use '`:placeholder:`B`:diagtext:`' instead`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`treating '`:placeholder:`A`:diagtext:`' input as '`:placeholder:`B`:diagtext:`' when in C++ mode, this behavior is deprecated`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`dynamic exception specifications are deprecated`| ++--------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`OpenCL version` |nbsp| :placeholder:`A` |nbsp| :diagtext:`does not support the option '`:placeholder:`B`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Use of 'long' with '\_\_vector' is deprecated`| ++------------------------------------------------------------------------------------+ + + +-Wdeprecated-attributes +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`specifying vector types with the 'mode' attribute is deprecated; use the 'vector\_size' attribute instead`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-declarations +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of C-style parameters in Objective-C method declarations is deprecated`| ++-----------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is deprecated`| ++----------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may be deprecated because the receiver type is unknown`| ++---------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is deprecated:` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property access is using` |nbsp| :placeholder:`A` |nbsp| :diagtext:`method which is deprecated`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-implementations +---------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------+----------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Implementing deprecated` |nbsp| |+--------------------+| +| ||:diagtext:`method` || +| |+--------------------+| +| ||:diagtext:`class` || +| |+--------------------+| +| ||:diagtext:`category`|| +| |+--------------------+| ++----------------------------------------------------------------------+----------------------+ + + +-Wdeprecated-increment-bool +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incrementing expression of type bool is deprecated and incompatible with C++1z`| ++---------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-objc-isa-usage +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`assignment to Objective-C's isa is deprecated in favor of object\_setClass()`| ++-------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`direct access to Objective-C's isa is deprecated in favor of object\_getClass()`| ++----------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-objc-pointer-introspection +--------------------------------------- +This diagnostic is enabled by default. + +Also controls `-Wdeprecated-objc-pointer-introspection-performSelector`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`bitmasking for introspection of Objective-C object pointers is strongly discouraged`| ++--------------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-objc-pointer-introspection-performSelector +------------------------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`bitmasking for introspection of Objective-C object pointers is strongly discouraged`| ++--------------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-register +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'register' storage class specifier is deprecated and incompatible with C++1z`| ++-------------------------------------------------------------------------------------------------------------------+ + + +-Wdeprecated-writable-strings +----------------------------- +Synonym for `-Wc++11-compat-deprecated-writable-strings`_. + + +-Wdirect-ivar-access +-------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instance variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is being directly accessed`| ++------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdisabled-macro-expansion +-------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`disabled expansion of recursive macro`| ++----------------------------------------------------------------------------+ + + +-Wdisabled-optimization +----------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wdiscard-qual +-------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wdistributed-object-modifiers +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting distributed object modifiers on parameter type in implementation of` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting distributed object modifiers on return type in implementation of` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdiv-by-zero +------------- +Synonym for `-Wdivision-by-zero`_. + + +-Wdivision-by-zero +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+-----------------------+----------------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------+| |nbsp| :diagtext:`by zero is undefined`| +| ||:diagtext:`remainder`|| | +| |+---------------------+| | +| ||:diagtext:`division` || | +| |+---------------------+| | ++---------------------------+-----------------------+----------------------------------------+ + + +-Wdll-attribute-on-redeclaration +-------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redeclaration of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`should not add` |nbsp| :placeholder:`B` |nbsp| :diagtext:`attribute`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdllexport-explicit-instantiation-decl +--------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit instantiation declaration should not be 'dllexport'`| ++---------------------------------------------------------------------------------------------------+ + + +-Wdllimport-static-field-def +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`definition of dllimport static field`| ++---------------------------------------------------------------------------+ + + +-Wdocumentation +--------------- +Also controls `-Wdocumentation-deprecated-sync`_, `-Wdocumentation-html`_. + +**Diagnostic text:** + ++----------------------------------------+----------------+-----------------------+------------------------------------------------------------------------+-----------------------+-------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|+---------------------+|:diagtext:`' command should not be used in a comment attached to a non-`|+---------------------+| |nbsp| :diagtext:`declaration`| +| ||:diagtext:`\\`|||:diagtext:`class` || ||:diagtext:`class` || | +| |+--------------+|+---------------------+| |+---------------------+| | +| ||:diagtext:`@` |||:diagtext:`interface`|| ||:diagtext:`interface`|| | +| |+--------------+|+---------------------+| |+---------------------+| | +| | ||:diagtext:`protocol` || ||:diagtext:`protocol` || | +| | |+---------------------+| |+---------------------+| | +| | ||:diagtext:`struct` || ||:diagtext:`struct` || | +| | |+---------------------+| |+---------------------+| | +| | ||:diagtext:`union` || ||:diagtext:`union` || | +| | |+---------------------+| |+---------------------+| | ++----------------------------------------+----------------+-----------------------+------------------------------------------------------------------------+-----------------------+-------------------------------+ + ++-----------------------------------------------------------+----------------+-----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`duplicated command '`|+--------------+|:placeholder:`B`:diagtext:`'`| +| ||:diagtext:`\\`|| | +| |+--------------+| | +| ||:diagtext:`@` || | +| |+--------------+| | ++-----------------------------------------------------------+----------------+-----------------------------+ + ++------------------------------------------------------------------+----------------+-------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty paragraph passed to '`|+--------------+|:placeholder:`B`:diagtext:`' command`| +| ||:diagtext:`\\`|| | +| |+--------------+| | +| ||:diagtext:`@` || | +| |+--------------+| | ++------------------------------------------------------------------+----------------+-------------------------------------+ + ++----------------------------------------+----------------+--------------------------+---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|+------------------------+|:diagtext:`' command should not be used in a comment attached to a non-container declaration`| +| ||:diagtext:`\\`|||:diagtext:`classdesign` || | +| |+--------------+|+------------------------+| | +| ||:diagtext:`@` |||:diagtext:`coclass` || | +| |+--------------+|+------------------------+| | +| | ||:diagtext:`dependency` || | +| | |+------------------------+| | +| | ||:diagtext:`helper` || | +| | |+------------------------+| | +| | ||:diagtext:`helperclass` || | +| | |+------------------------+| | +| | ||:diagtext:`helps` || | +| | |+------------------------+| | +| | ||:diagtext:`instancesize`|| | +| | |+------------------------+| | +| | ||:diagtext:`ownership` || | +| | |+------------------------+| | +| | ||:diagtext:`performance` || | +| | |+------------------------+| | +| | ||:diagtext:`security` || | +| | |+------------------------+| | +| | ||:diagtext:`superclass` || | +| | |+------------------------+| | ++----------------------------------------+----------------+--------------------------+---------------------------------------------------------------------------------------------+ + ++----------------------------------------+----------------+---------------------------+---------------------------------------------------------------------+-----------------------------------+-------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|+-------------------------+|:diagtext:`' command should be used in a comment attached to` |nbsp| |+---------------------------------+| |nbsp| :diagtext:`declaration`| +| ||:diagtext:`\\`|||:diagtext:`function` || ||:diagtext:`a function` || | +| |+--------------+|+-------------------------+| |+---------------------------------+| | +| ||:diagtext:`@` |||:diagtext:`functiongroup`|| ||:diagtext:`a function` || | +| |+--------------+|+-------------------------+| |+---------------------------------+| | +| | ||:diagtext:`method` || ||:diagtext:`an Objective-C method`|| | +| | |+-------------------------+| |+---------------------------------+| | +| | ||:diagtext:`methodgroup` || ||:diagtext:`an Objective-C method`|| | +| | |+-------------------------+| |+---------------------------------+| | +| | ||:diagtext:`callback` || ||:diagtext:`a pointer to function`|| | +| | |+-------------------------+| |+---------------------------------+| | ++----------------------------------------+----------------+---------------------------+---------------------------------------------------------------------+-----------------------------------+-------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`HTML start tag prematurely ended, expected attribute name or '>'`| ++-------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected quoted string after equals sign`| ++-------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`parameter '`:placeholder:`A`:diagtext:`' is already documented`| ++-----------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unrecognized parameter passing direction, valid directions are '\[in\]', '\[out\]' and '\[in,out\]'`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------+----------------+-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|:diagtext:`param' command used in a comment that is not attached to a function declaration`| +| ||:diagtext:`\\`|| | +| |+--------------+| | +| ||:diagtext:`@` || | +| |+--------------+| | ++----------------------------------------+----------------+-------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`parameter '`:placeholder:`A`:diagtext:`' not found in the function declaration`| ++---------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------+----------------+-------------------------------------------------------------------------------------+-------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|:placeholder:`B`:diagtext:`' command used in a comment that is attached to a` |nbsp| |+-----------------------------------+| +| ||:diagtext:`\\`|| ||:diagtext:`function returning void`|| +| |+--------------+| |+-----------------------------------+| +| ||:diagtext:`@` || ||:diagtext:`constructor` || +| |+--------------+| |+-----------------------------------+| +| | | ||:diagtext:`destructor` || +| | | |+-----------------------------------+| +| | | ||:diagtext:`method returning void` || +| | | |+-----------------------------------+| ++----------------------------------------+----------------+-------------------------------------------------------------------------------------+-------------------------------------+ + ++----------------------------------------+----------------+----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|:placeholder:`B`:diagtext:`' command used in a comment that is not attached to a function or method declaration`| +| ||:diagtext:`\\`|| | +| |+--------------+| | +| ||:diagtext:`@` || | +| |+--------------+| | ++----------------------------------------+----------------+----------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template parameter '`:placeholder:`A`:diagtext:`' is already documented`| ++--------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------+----------------+--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|:diagtext:`tparam' command used in a comment that is not attached to a template declaration`| +| ||:diagtext:`\\`|| | +| |+--------------+| | +| ||:diagtext:`@` || | +| |+--------------+| | ++----------------------------------------+----------------+--------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template parameter '`:placeholder:`A`:diagtext:`' not found in the template declaration`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`not a Doxygen trailing comment`| ++---------------------------------------------------------------------+ + ++----------------------------------------+----------------+------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+--------------+|:placeholder:`B`:diagtext:`' command does not terminate a verbatim text block`| +| ||:diagtext:`\\`|| | +| |+--------------+| | +| ||:diagtext:`@` || | +| |+--------------+| | ++----------------------------------------+----------------+------------------------------------------------------------------------------+ + + +-Wdocumentation-deprecated-sync +------------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration is marked with '\\deprecated' command but does not have a deprecation attribute`| ++----------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdocumentation-html +-------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`HTML end tag '`:placeholder:`A`:diagtext:`' is forbidden`| ++-----------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`HTML end tag does not match any start tag`| ++--------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`HTML tag '`:placeholder:`A`:diagtext:`' requires an end tag`| ++--------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`HTML start tag '`:placeholder:`A`:diagtext:`' closed by '`:placeholder:`B`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------------------------+ + + +-Wdocumentation-pedantic +------------------------ +Also controls `-Wdocumentation-unknown-command`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`whitespace is not allowed in parameter passing direction`| ++-----------------------------------------------------------------------------------------------+ + + +-Wdocumentation-unknown-command +------------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown command tag name '`:placeholder:`A`:diagtext:`'; did you mean '`:placeholder:`B`:diagtext:`'?`| ++--------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown command tag name`| ++---------------------------------------------------------------+ + + +-Wdollar-in-identifier-extension +-------------------------------- +**Diagnostic text:** + ++--------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'$' in identifier`| ++--------------------------------------------------------+ + + +-Wdouble-promotion +------------------ +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion increases floating-point precision:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wduplicate-decl-specifier +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`duplicate '`:placeholder:`A`:diagtext:`' declaration specifier`| ++-----------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`duplicate '`:placeholder:`A`:diagtext:`' declaration specifier`| ++-----------------------------------------------------------------------------------------------------+ + + +-Wduplicate-enum +---------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`element` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has been implicitly assigned` |nbsp| :placeholder:`B` |nbsp| :diagtext:`which another element has been assigned`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wduplicate-method-arg +---------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redeclaration of method parameter` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------------------------+ + + +-Wduplicate-method-match +------------------------ +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multiple declarations of method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`found and ignored`| ++-----------------------------------------------------------------------------------------------------------------------------------+ + + +-Wdynamic-class-memaccess +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+-------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------+---------------------------------------------------------------------------------------------+-------------------------+ +|:warning:`warning:` |nbsp| |+-----------------------------+| |nbsp| :diagtext:`this` |nbsp| :placeholder:`B` |nbsp| :diagtext:`call is a pointer to` |nbsp| |+--------------------------------------+|:diagtext:`dynamic class` |nbsp| :placeholder:`D`:diagtext:`; vtable pointer will be` |nbsp| |+-----------------------+| +| ||:diagtext:`destination for` || || || ||:diagtext:`overwritten`|| +| |+-----------------------------+| |+--------------------------------------+| |+-----------------------+| +| ||:diagtext:`source of` || ||:diagtext:`class containing a` |nbsp| || ||:diagtext:`copied` || +| |+-----------------------------+| |+--------------------------------------+| |+-----------------------+| +| ||:diagtext:`first operand of` || | | ||:diagtext:`moved` || +| |+-----------------------------+| | | |+-----------------------+| +| ||:diagtext:`second operand of`|| | | ||:diagtext:`compared` || +| |+-----------------------------+| | | |+-----------------------+| ++---------------------------+-------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------+---------------------------------------------------------------------------------------------+-------------------------+ + + +-Weffc++ +-------- +Synonym for `-Wnon-virtual-dtor`_. + + +-Wembedded-directive +-------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`embedding a directive within macro arguments has undefined behavior`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wempty-body +------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`for loop has empty body`| ++--------------------------------------------------------------+ + ++------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`if statement has empty body`| ++------------------------------------------------------------------+ + ++--------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`range-based for loop has empty body`| ++--------------------------------------------------------------------------+ + ++----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`switch statement has empty body`| ++----------------------------------------------------------------------+ + ++----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`while loop has empty body`| ++----------------------------------------------------------------+ + + +-Wempty-decomposition +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C++1z does not allow a decomposition group to be empty`| ++-------------------------------------------------------------------------------------------------+ + + +-Wempty-translation-unit +------------------------ +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C requires a translation unit to contain at least one declaration`| ++------------------------------------------------------------------------------------------------------------+ + + +-Wencode-type +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`encoding of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`type is incomplete because` |nbsp| :placeholder:`B` |nbsp| :diagtext:`component has unknown encoding`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wendif-labels +-------------- +Synonym for `-Wextra-tokens`_. + + +-Wenum-compare +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of two values with different enumeration types`| ++------------------------------------------------------------------------------------------------+ + + +-Wenum-conversion +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from enumeration type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to different enumeration type` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wenum-too-large +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration values exceed range of largest integer`| ++-----------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incremented enumerator value` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not representable in the largest integer type`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wexceptions +------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------+-------------------------+--------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot refer to a non-static member from the handler of a` |nbsp| |+-----------------------+| |nbsp| :diagtext:`function try block`| +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | +| ||:diagtext:`destructor` || | +| |+-----------------------+| | ++--------------------------------------------------------------------------------------------------------+-------------------------+--------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`exception of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will be caught by earlier handler`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wexit-time-destructors +----------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration requires an exit-time destructor`| ++-----------------------------------------------------------------------------------+ + + +-Wexpansion-to-defined +---------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`macro expansion producing 'defined' has undefined behavior`| ++-------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`macro expansion producing 'defined' has undefined behavior`| ++-------------------------------------------------------------------------------------------------+ + + +-Wexplicit-initialize-call +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit call to +initialize results in duplicate call to +initialize`| ++------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit call to \[super initialize\] should only be in implementation of +initialize`| ++----------------------------------------------------------------------------------------------------------------------------+ + + +-Wexplicit-ownership-type +------------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method parameter of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`with no explicit ownership`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wextended-offsetof +------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using extended field designator is an extension`| ++--------------------------------------------------------------------------------------+ + + +-Wextern-c-compat +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+---------------------------+--------------------+--------------------------------------------+---------------------------+--------------------------+ +|:warning:`warning:` |nbsp| |+-------------------------+|+------------------+| |nbsp| :diagtext:`has size 0 in C,` |nbsp| |+-------------------------+| |nbsp| :diagtext:`in C++`| +| || |||:diagtext:`struct`|| ||:diagtext:`size 1` || | +| |+-------------------------+|+------------------+| |+-------------------------+| | +| ||:diagtext:`empty` |nbsp| |||:diagtext:`union` || ||:diagtext:`non-zero size`|| | +| |+-------------------------+|+------------------+| |+-------------------------+| | ++---------------------------+---------------------------+--------------------+--------------------------------------------+---------------------------+--------------------------+ + + +-Wextern-initializer +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'extern' variable has an initializer`| ++---------------------------------------------------------------------------+ + + +-Wextra +------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wignored-qualifiers`_, `-Winitializer-overrides`_, `-Wmissing-field-initializers`_, `-Wmissing-method-return-type`_, `-Wsemicolon-before-method-body`_, `-Wsign-compare`_, `-Wunused-parameter`_. + + +-Wextra-qualification +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra qualification on member` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------+ + + +-Wextra-semi +------------ +Also controls `-Wc++11-extra-semi`_. + +**Diagnostic text:** + ++--------------------------------------------------------+------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra ';'` |nbsp| |+----------------------------------------------+| +| ||:diagtext:`outside of a function` || +| |+----------------------------------------------+| +| ||+--------------------------------------------+|| +| |||:diagtext:`inside a` |nbsp| :placeholder:`B`||| +| ||+--------------------------------------------+|| +| |+----------------------------------------------+| +| ||:diagtext:`inside instance variable list` || +| |+----------------------------------------------+| +| ||:diagtext:`after member function definition` || +| |+----------------------------------------------+| ++--------------------------------------------------------+------------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra ';' after member function definition`| ++---------------------------------------------------------------------------------+ + + +-Wextra-tokens +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra tokens at end of #`:placeholder:`A` |nbsp| :diagtext:`directive`| ++------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra tokens at the end of '#pragma omp` |nbsp| :placeholder:`A`:diagtext:`' are ignored`| ++-------------------------------------------------------------------------------------------------------------------------------+ + + +-Wfallback +---------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`falling back to` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------+ + + +-Wflag-enum +----------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration value` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is out of range of flags in enumeration type` |nbsp| :placeholder:`B`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wflexible-array-extensions +--------------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may not be used as an array element due to flexible array member`| ++-------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may not be nested in a struct due to flexible array member`| ++-------------------------------------------------------------------------------------------------------------------------+ + + +-Wfloat-conversion +------------------ +Also controls `-Wfloat-overflow-conversion`_, `-Wfloat-zero-conversion`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion turns floating-point number into integer:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wfloat-equal +------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparing floating point with == or != is unsafe`| ++---------------------------------------------------------------------------------------+ + + +-Wfloat-overflow-conversion +--------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion of out of range value from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`changes value from` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to` |nbsp| :placeholder:`D`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wfloat-zero-conversion +----------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`changes non-zero value from` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to` |nbsp| :placeholder:`D`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wfor-loop-analysis +------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is` |nbsp| |+-----------------------+| |nbsp| :diagtext:`both in the loop header and in the loop body`| +| ||:diagtext:`decremented`|| | +| |+-----------------------+| | +| ||:diagtext:`incremented`|| | +| |+-----------------------+| | ++-----------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------+ + ++-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable`|+----------------------------------------------------------------------------------------------------------------------------------------------------------+| |nbsp| :diagtext:`used in loop condition not modified in loop body`| +| ||:diagtext:`s` || | +| |+----------------------------------------------------------------------------------------------------------------------------------------------------------+| | +| ||+------------------------+ || | +| ||| |nbsp| :placeholder:`B`| || | +| ||+------------------------+ || | +| |+----------------------------------------------------------------------------------------------------------------------------------------------------------+| | +| ||+------------------------------------------------------------------------------------+ || | +| |||:diagtext:`s` |nbsp| :placeholder:`B` |nbsp| :diagtext:`and` |nbsp| :placeholder:`C`| || | +| ||+------------------------------------------------------------------------------------+ || | +| |+----------------------------------------------------------------------------------------------------------------------------------------------------------+| | +| ||+-------------------------------------------------------------------------------------------------------------------+ || | +| |||:diagtext:`s` |nbsp| :placeholder:`B`:diagtext:`,` |nbsp| :placeholder:`C`:diagtext:`, and` |nbsp| :placeholder:`D`| || | +| ||+-------------------------------------------------------------------------------------------------------------------+ || | +| |+----------------------------------------------------------------------------------------------------------------------------------------------------------+| | +| ||+--------------------------------------------------------------------------------------------------------------------------------------------------------+|| | +| |||:diagtext:`s` |nbsp| :placeholder:`B`:diagtext:`,` |nbsp| :placeholder:`C`:diagtext:`,` |nbsp| :placeholder:`D`:diagtext:`, and` |nbsp| :placeholder:`E`||| | +| ||+--------------------------------------------------------------------------------------------------------------------------------------------------------+|| | +| |+----------------------------------------------------------------------------------------------------------------------------------------------------------+| | ++-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+ + + +-Wformat +-------- +This diagnostic is enabled by default. + +Also controls `-Wformat-extra-args`_, `-Wformat-invalid-specifier`_, `-Wformat-security`_, `-Wformat-y2k`_, `-Wformat-zero-length`_, `-Wnonnull`_. + +**Diagnostic text:** + ++---------------------------+----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------------------+| |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' should not be used as format arguments; add an explicit cast to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`instead`| +| ||:diagtext:`values of type` || | +| |+--------------------------------------------+| | +| ||:diagtext:`enum values with underlying type`|| | +| |+--------------------------------------------+| | ++---------------------------+----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format specifies type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`but the argument has` |nbsp| |+---------------------------+| |nbsp| :placeholder:`B`| +| ||:diagtext:`type` || | +| |+---------------------------+| | +| ||:diagtext:`underlying type`|| | +| |+---------------------------+| | ++------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+------------------------+ + ++-----------------------------------------------------------------------------+-----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid position specified for` |nbsp| |+---------------------------+| +| ||:diagtext:`field width` || +| |+---------------------------+| +| ||:diagtext:`field precision`|| +| |+---------------------------+| ++-----------------------------------------------------------------------------+-----------------------------+ + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot mix positional and non-positional arguments in format string`| ++----------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`length modifier '`:placeholder:`A`:diagtext:`' results in undefined behavior or no effect with '`:placeholder:`B`:diagtext:`' conversion specifier`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string should not be a wide string`| ++--------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`position arguments in format strings start counting at 1 (not 0)`| ++-------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string missing`| ++------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`object format flags cannot be used with '`:placeholder:`A`:diagtext:`' conversion specifier`| ++----------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------+-----------------+-------------------------------------+-----------------------+--------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`|+---------------+|:diagtext:`' specified field` |nbsp| |+---------------------+| |nbsp| :diagtext:`is missing a matching 'int' argument`| +| ||:diagtext:`\*` || ||:diagtext:`width` || | +| |+---------------+| |+---------------------+| | +| ||:diagtext:`.\*`|| ||:diagtext:`precision`|| | +| |+---------------+| |+---------------------+| | ++----------------------------------------+-----------------+-------------------------------------+-----------------------+--------------------------------------------------------+ + ++----------------------------------------------------+-----------------------+-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`field` |nbsp| |+---------------------+| |nbsp| :diagtext:`should have type` |nbsp| :placeholder:`B`:diagtext:`, but argument has type` |nbsp| :placeholder:`C`| +| ||:diagtext:`width` || | +| |+---------------------+| | +| ||:diagtext:`precision`|| | +| |+---------------------+| | ++----------------------------------------------------+-----------------------+-----------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing object format flag`| ++-----------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string contains '\\0' within the string body`| ++------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string is not null-terminated`| ++---------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flag '`:placeholder:`A`:diagtext:`' is ignored when flag '`:placeholder:`B`:diagtext:`' is present`| ++-----------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incomplete format specifier`| ++------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`more '%%' conversions than data arguments`| ++--------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' is not a valid object format flag`| ++-------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flag '`:placeholder:`A`:diagtext:`' results in undefined behavior with '`:placeholder:`B`:diagtext:`' conversion specifier`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+-------------------------+------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-----------------------+| |nbsp| :diagtext:`used with '`:placeholder:`B`:diagtext:`' conversion specifier, resulting in undefined behavior`| +| ||:diagtext:`field width`|| | +| |+-----------------------+| | +| ||:diagtext:`precision` || | +| |+-----------------------+| | ++---------------------------+-------------------------+------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`data argument position '`:placeholder:`A`:diagtext:`' exceeds the number of data arguments (`:placeholder:`B`:diagtext:`)`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`zero field width in scanf format string is unused`| ++----------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no closing '\]' for '%%\[' in scanf format string`| ++----------------------------------------------------------------------------------------+ + + +-Wformat-extra-args +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`data argument not used by format string`| ++------------------------------------------------------------------------------+ + + +-Wformat-invalid-specifier +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid conversion specifier '`:placeholder:`A`:diagtext:`'`| ++--------------------------------------------------------------------------------------------------+ + + +-Wformat-non-iso +---------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------+----------------------------------+---------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`'` |nbsp| |+--------------------------------+| |nbsp| :diagtext:`is not supported by ISO C`| +| ||:diagtext:`length modifier` || | +| |+--------------------------------+| | +| ||:diagtext:`conversion specifier`|| | +| |+--------------------------------+| | ++-----------------------------------------------------------------------------+----------------------------------+---------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using length modifier '`:placeholder:`A`:diagtext:`' with conversion specifier '`:placeholder:`B`:diagtext:`' is not supported by ISO C`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`positional arguments are not supported by ISO C`| ++--------------------------------------------------------------------------------------+ + + +-Wformat-nonliteral +------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string is not a string literal`| ++----------------------------------------------------------------------------+ + + +-Wformat-pedantic +----------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format specifies type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`but the argument has` |nbsp| |+---------------------------+| |nbsp| :placeholder:`B`| +| ||:diagtext:`type` || | +| |+---------------------------+| | +| ||:diagtext:`underlying type`|| | +| |+---------------------------+| | ++------------------------------------------------------------------------------------------------------------------------------------+-----------------------------+------------------------+ + + +-Wformat-security +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string is not a string literal (potentially insecure)`| ++---------------------------------------------------------------------------------------------------+ + + +-Wformat-y2k +------------ +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wformat-zero-length +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`format string is empty`| ++-------------------------------------------------------------+ + + +-Wformat=2 +---------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wformat-nonliteral`_, `-Wformat-security`_, `-Wformat-y2k`_. + + +-Wfour-char-constants +--------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multi-character character constant`| ++-------------------------------------------------------------------------+ + + +-Wframe-larger-than= +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`stack frame size of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`bytes in` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wfunction-def-in-objc-container +-------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function definition inside an Objective-C container is deprecated`| ++--------------------------------------------------------------------------------------------------------+ + + +-Wfuture-compat +--------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wgcc-compat +------------ +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'enable\_if' is a clang extension`| ++------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_\_final is a GNU extension, consider using C++11 final`| ++-----------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`GCC does not allow` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute in this position on a function definition`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'break' is bound to loop, GCC binds it to switch`| ++---------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`GCC does not allow the 'cleanup' attribute argument to be anything other than a simple identifier`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`GCC does not allow an attribute in this position on a function declaration`| ++-----------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' is bound to current loop, GCC binds it to the enclosing loop`| ++----------------------------------------------------------------------------------------------------------------------------------+ + + +-Wglobal-constructors +--------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration requires a global constructor`| ++--------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration requires a global destructor`| ++-------------------------------------------------------------------------------+ + + +-Wgnu +----- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wgnu-alignof-expression`_, `-Wgnu-anonymous-struct`_, `-Wgnu-auto-type`_, `-Wgnu-binary-literal`_, `-Wgnu-case-range`_, `-Wgnu-complex-integer`_, `-Wgnu-compound-literal-initializer`_, `-Wgnu-conditional-omitted-operand`_, `-Wgnu-designator`_, `-Wgnu-empty-initializer`_, `-Wgnu-empty-struct`_, `-Wgnu-flexible-array-initializer`_, `-Wgnu-flexible-array-union-member`_, `-Wgnu-folding-constant`_, `-Wgnu-imaginary-constant`_, `-Wgnu-include-next`_, `-Wgnu-label-as-value`_, `-Wgnu-redeclared-enum`_, `-Wgnu-statement-expression`_, `-Wgnu-static-float-init`_, `-Wgnu-string-literal-operator-template`_, `-Wgnu-union-cast`_, `-Wgnu-variable-sized-type-not-at-end`_, `-Wgnu-zero-line-directive`_, `-Wgnu-zero-variadic-macro-arguments`_, `-Wredeclared-class-member`_, `-Wvla-extension`_, `-Wzero-length-array`_. + + +-Wgnu-alignof-expression +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`applied to an expression is a GNU extension`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wgnu-anonymous-struct +---------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`anonymous structs are a GNU extension`| ++----------------------------------------------------------------------------+ + + +-Wgnu-array-member-paren-init +----------------------------- +This diagnostic is an error by default, but the flag ``-Wno-gnu-array-member-paren-init`` can be used to disable the error. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`parenthesized initialization of a member array is a GNU extension`| ++----------------------------------------------------------------------------------------------------+ + + +-Wgnu-auto-type +--------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'\_\_auto\_type' is a GNU extension`| ++--------------------------------------------------------------------------+ + + +-Wgnu-binary-literal +-------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`binary integer literals are a GNU extension`| ++----------------------------------------------------------------------------------+ + + +-Wgnu-case-range +---------------- +**Diagnostic text:** + ++----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU case range extension`| ++----------------------------------------------------------------------+ + + +-Wgnu-complex-integer +--------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`complex integer types are a GNU extension`| ++--------------------------------------------------------------------------------+ + + +-Wgnu-compound-literal-initializer +---------------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initialization of an array` |nbsp| :diagtext:`from a compound literal` |nbsp| :diagtext:`is a GNU extension`| ++--------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wgnu-conditional-omitted-operand +--------------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU ?: conditional expression extension, omitting middle operand`| ++--------------------------------------------------------------------------------------------------------------+ + + +-Wgnu-designator +---------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU array range extension`| ++-----------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU 'missing =' extension in designator`| ++-------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU old-style field designator extension`| ++--------------------------------------------------------------------------------------+ + + +-Wgnu-empty-initializer +----------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU empty initializer extension`| ++-----------------------------------------------------------------------------+ + + +-Wgnu-empty-struct +------------------ +**Diagnostic text:** + ++----------------------------------------------------+--------------------+--------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty` |nbsp| |+------------------+| |nbsp| :diagtext:`is a GNU extension`| +| ||:diagtext:`struct`|| | +| |+------------------+| | +| ||:diagtext:`union` || | +| |+------------------+| | ++----------------------------------------------------+--------------------+--------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+-----------------------+--------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in otherwise empty` |nbsp| |+---------------------+| |nbsp| :diagtext:`is a GNU extension`| +| ||:diagtext:`struct` || | +| |+---------------------+| | +| ||:diagtext:`interface`|| | +| |+---------------------+| | +| ||:diagtext:`union` || | +| |+---------------------+| | +| ||:diagtext:`class` || | +| |+---------------------+| | +| ||:diagtext:`enum` || | +| |+---------------------+| | ++----------------------------------------------------------------------------------------------------------------------------------+-----------------------+--------------------------------------+ + ++---------------------------+--------------------+------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+------------------+| |nbsp| :diagtext:`without named members is a GNU extension`| +| ||:diagtext:`struct`|| | +| |+------------------+| | +| ||:diagtext:`union` || | +| |+------------------+| | ++---------------------------+--------------------+------------------------------------------------------------+ + + +-Wgnu-flexible-array-initializer +-------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array initialization is a GNU extension`| ++---------------------------------------------------------------------------------------+ + + +-Wgnu-flexible-array-union-member +--------------------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in a union is a GNU extension`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wgnu-folding-constant +---------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------+----------------------+------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression is not an` |nbsp| |+--------------------+| |nbsp| :diagtext:`constant expression; folding it to a constant is a GNU extension`| +| ||:diagtext:`integer` || | +| |+--------------------+| | +| ||:diagtext:`integral`|| | +| |+--------------------+| | ++-------------------------------------------------------------------+----------------------+------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable length array folded to constant array as an extension`| ++-----------------------------------------------------------------------------------------------------+ + + +-Wgnu-imaginary-constant +------------------------ +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`imaginary constants are a GNU extension`| ++------------------------------------------------------------------------------+ + + +-Wgnu-include-next +------------------ +**Diagnostic text:** + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#include\_next is a language extension`| ++-----------------------------------------------------------------------------+ + + +-Wgnu-label-as-value +-------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU address-of-label extension`| ++----------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU indirect-goto extension`| ++-------------------------------------------------------------------------+ + + +-Wgnu-redeclared-enum +--------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redeclaration of already-defined enum` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a GNU extension`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wgnu-statement-expression +-------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU statement expression extension`| ++--------------------------------------------------------------------------------+ + + +-Wgnu-static-float-init +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`in-class initializer for static data member of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a GNU extension`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wgnu-string-literal-operator-template +-------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`string literal operator templates are a GNU extension`| ++--------------------------------------------------------------------------------------------+ + + +-Wgnu-union-cast +---------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast to union type is a GNU extension`| ++----------------------------------------------------------------------------+ + + +-Wgnu-variable-sized-type-not-at-end +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`field` |nbsp| :placeholder:`A` |nbsp| :diagtext:`with variable sized type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`not at the end of a struct or class is a GNU extension`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wgnu-zero-line-directive +------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#line directive with zero argument is a GNU extension`| ++--------------------------------------------------------------------------------------------+ + + +-Wgnu-zero-variadic-macro-arguments +----------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`must specify at least one argument for '...' parameter of variadic macro`| ++---------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`token pasting of ',' and \_\_VA\_ARGS\_\_ is a GNU extension`| ++---------------------------------------------------------------------------------------------------+ + + +-Wheader-guard +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is used as a header guard here, followed by #define of a different macro`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wheader-hygiene +---------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using namespace directive in global context in header`| ++--------------------------------------------------------------------------------------------+ + + +-Widiomatic-parentheses +----------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using the result of an assignment as a condition without parentheses`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wignored-attributes +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-----------------+| |nbsp| :diagtext:`will always resolve to` |nbsp| :placeholder:`A` |nbsp| :diagtext:`even if weak definition of` |nbsp| :placeholder:`B` |nbsp| :diagtext:`is overridden`| +| ||:diagtext:`alias`|| | +| |+-----------------+| | +| ||:diagtext:`ifunc`|| | +| |+-----------------+| | ++---------------------------+-------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+-------------------+----------------------------------------------------------------------------------------------------------------+----------------------+ +|:warning:`warning:` |nbsp| |+-----------------+| |nbsp| :diagtext:`will not be in section '`:placeholder:`A`:diagtext:`' but in the same section as the` |nbsp| |+--------------------+| +| ||:diagtext:`alias`|| ||:diagtext:`aliasee` || +| |+-----------------+| |+--------------------+| +| ||:diagtext:`ifunc`|| ||:diagtext:`resolver`|| +| |+-----------------+| |+--------------------+| ++---------------------------+-------------------+----------------------------------------------------------------------------------------------------------------+----------------------+ + ++----------------------------------------------------------------------+------------------------+-------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'abi\_tag' attribute on` |nbsp| |+----------------------+| |nbsp| :diagtext:`namespace ignored`| +| ||:diagtext:`non-inline`|| | +| |+----------------------+| | +| ||:diagtext:`anonymous` || | +| |+----------------------+| | ++----------------------------------------------------------------------+------------------------+-------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`after definition is ignored`| ++-----------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute can only be applied to instance variables or properties`| ++--------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute ignored`| ++--------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute ignored on inline function`| ++---------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' attribute cannot be specified on a definition`| ++-------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`ignored, because it is not attached to a declaration`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'nonnull' attribute applied to function with no pointer arguments`| ++--------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'nonnull' attribute when used on parameters takes no arguments`| ++-----------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute ignored when parsing type`| ++--------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to a pointer or reference (`:placeholder:`B` |nbsp| :diagtext:`is invalid)`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+------------------------------+-------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to`|+----------------------------+| |nbsp| :diagtext:`pointer arguments`| +| || || | +| |+----------------------------+| | +| || |nbsp| :diagtext:`constant`|| | +| |+----------------------------+| | ++----------------------------------------------------------------------------------------+------------------------------+-------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute declaration must precede definition`| ++------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to return values that are pointers`| ++------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to return values that are pointers or references`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'sentinel' attribute requires named arguments`| ++------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+-----------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'sentinel' attribute only supported for variadic` |nbsp| |+---------------------+| +| ||:diagtext:`functions`|| +| |+---------------------+| +| ||:diagtext:`blocks` || +| |+---------------------+| ++-----------------------------------------------------------------------------------------------+-----------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute argument not supported:` |nbsp| :placeholder:`B`| ++------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown visibility` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+--------------------------------+----------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot be applied to` |nbsp| |+------------------------------+| |nbsp| :diagtext:`without return value`| +| ||:diagtext:`functions` || | +| |+------------------------------+| | +| ||:diagtext:`Objective-C method`|| | +| |+------------------------------+| | ++------------------------------------------------------------------------------------------------------------------------+--------------------------------+----------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_\_weak attribute cannot be specified on a field declaration`| ++----------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_\_weak attribute cannot be specified on an automatic variable when ARC is not enabled`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to` |nbsp| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`unions` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables and functions` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions, variables, and Objective-C interfaces` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions and methods` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`parameters` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions, methods and blocks` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions, methods, and classes` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions, methods, and parameters` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`classes` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`enums` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`methods` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`fields and global variables` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`structs` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`parameters and typedefs` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables and typedefs` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`thread-local variables` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables and fields` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables, data members and tag types` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`types and namespaces` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`Objective-C interfaces` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`methods and properties` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`struct or union` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`struct, union or class` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`types` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`Objective-C instance methods` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`init methods of interface or class extension declarations` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables, functions and classes` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions, variables, classes, and Objective-C interfaces` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`Objective-C protocols` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables with static or thread storage duration` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions and global variables` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`structs, unions, and typedefs` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`structs and typedefs` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`interface or protocol declarations` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`kernel functions` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`non-K&R-style functions` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables, enums, fields and typedefs` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`functions, methods, enums, and classes` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`structs, classes, variables, functions, and inline namespaces` || +| |+----------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members`|| +| |+----------------------------------------------------------------------------------------------------------------+| ++------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`ignored, because it cannot be applied to omitted return type`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`calling convention` |nbsp| :placeholder:`A` |nbsp| :diagtext:`ignored for this target`| ++----------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`calling convention ignored on constructor/destructor`| ++-------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`calling convention ignored on variadic function`| ++--------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`ignored, because it cannot be applied to a type`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+-----------------------+----------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is ignored, place it after "`|+---------------------+|:diagtext:`" to apply attribute to type declaration`| +| ||:diagtext:`class` || | +| |+---------------------+| | +| ||:diagtext:`struct` || | +| |+---------------------+| | +| ||:diagtext:`interface`|| | +| |+---------------------+| | +| ||:diagtext:`union` || | +| |+---------------------+| | +| ||:diagtext:`enum` || | +| |+---------------------+| | ++------------------------------------------------------------------------------------------------------------------------+-----------------------+----------------------------------------------------+ + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'deprecated' attribute on anonymous namespace ignored`| ++--------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`redeclared inline;` |nbsp| :placeholder:`B` |nbsp| :diagtext:`attribute ignored`| ++----------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is already applied with different parameters`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is already applied`| ++--------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Objective-C GC does not allow weak variables on the stack`| ++------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'gnu\_inline' attribute requires function to be marked 'inline', attribute ignored`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------+------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inheritance model ignored on` |nbsp| |+----------------------------------+| +| ||:diagtext:`primary template` || +| |+----------------------------------+| +| ||:diagtext:`partial specialization`|| +| |+----------------------------------+| ++---------------------------------------------------------------------------+------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'internal\_linkage' attribute on a non-static local variable is ignored`| ++--------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`qualifiers after comma in declarator list are ignored`| ++--------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------+----------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`MIPS 'interrupt' attribute only applies to functions that have` |nbsp| |+--------------------------------+| +| ||:diagtext:`no parameters` || +| |+--------------------------------+| +| ||:diagtext:`a 'void' return type`|| +| |+--------------------------------+| ++-------------------------------------------------------------------------------------------------------------+----------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown attribute '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+-----------------------------------+------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to` |nbsp| |+---------------------------------+| |nbsp| :diagtext:`parameters`| +| ||:diagtext:`Objective-C object` || | +| |+---------------------------------+| | +| ||:diagtext:`pointer` || | +| |+---------------------------------+| | +| ||:diagtext:`pointer-to-CF-pointer`|| | +| |+---------------------------------+| | ++------------------------------------------------------------------------------------------------+-----------------------------------+------------------------------+ + ++------------------------------------------------------------------------------------------------+------------------------+---------------------------------------+--------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute only applies to` |nbsp| |+----------------------+| |nbsp| :diagtext:`that return` |nbsp| |+------------------------------------+| +| ||:diagtext:`functions` || ||:diagtext:`an Objective-C object` || +| |+----------------------+| |+------------------------------------+| +| ||:diagtext:`methods` || ||:diagtext:`a pointer` || +| |+----------------------+| |+------------------------------------+| +| ||:diagtext:`properties`|| ||:diagtext:`a non-retainable pointer`|| +| |+----------------------+| |+------------------------------------+| ++------------------------------------------------------------------------------------------------+------------------------+---------------------------------------+--------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute is deprecated and ignored in OpenCL version` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------+| |nbsp| :diagtext:`of field` |nbsp| :placeholder:`B` |nbsp| :diagtext:`(`:placeholder:`C` |nbsp| :diagtext:`bits) does not match the` |nbsp| |+---------------------+| |nbsp| :diagtext:`of the first field in transparent union; transparent\_union attribute ignored`| +| ||:diagtext:`alignment`|| ||:diagtext:`alignment`|| | +| |+---------------------+| |+---------------------+| | +| ||:diagtext:`size` || ||:diagtext:`size` || | +| |+---------------------+| |+---------------------+| | ++---------------------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+-------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------+----------------------------+--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`first field of a transparent union cannot have` |nbsp| |+--------------------------+| |nbsp| :diagtext:`type` |nbsp| :placeholder:`B`:diagtext:`; transparent\_union attribute ignored`| +| ||:diagtext:`floating point`|| | +| |+--------------------------+| | +| ||:diagtext:`vector` || | +| |+--------------------------+| | ++---------------------------------------------------------------------------------------------+----------------------------+--------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`transparent\_union attribute can only be applied to a union definition; attribute ignored`| ++--------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`transparent union definition must contain at least one field; transparent\_union attribute ignored`| ++-----------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------+-------------------------------------------------+---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' only applies to` |nbsp| |+-----------------------------------------------+| |nbsp| :diagtext:`types; type here is` |nbsp| :placeholder:`C`| +| ||:diagtext:`function` || | +| |+-----------------------------------------------+| | +| ||:diagtext:`pointer` || | +| |+-----------------------------------------------+| | +| ||:diagtext:`Objective-C object or block pointer`|| | +| |+-----------------------------------------------+| | ++---------------------------------------------------------------------------------------------+-------------------------------------------------+---------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_\_declspec attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not supported`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Ignoring unsupported '`:placeholder:`A`:diagtext:`' in the target attribute string`| ++-------------------------------------------------------------------------------------------------------------------------+ + + +-Wignored-optimization-argument +------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`optimization flag '`:placeholder:`A`:diagtext:`' is not supported for target '`:placeholder:`B`:diagtext:`'`| ++--------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`optimization flag '`:placeholder:`A`:diagtext:`' is not supported`| ++--------------------------------------------------------------------------------------------------------+ + + +-Wignored-pragmas +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------+---------------------------+-----------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected '=' following '#pragma` |nbsp| |+-------------------------+|:diagtext:`' - ignored`| +| ||:diagtext:`align` || | +| |+-------------------------+| | +| ||:diagtext:`options align`|| | +| |+-------------------------+| | ++------------------------------------------------------------------------------+---------------------------+-----------------------+ + ++-----------------------------------------------------------------------------------+---------------------------+-----------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid alignment option in '#pragma` |nbsp| |+-------------------------+|:diagtext:`' - ignored`| +| ||:diagtext:`align` || | +| |+-------------------------+| | +| ||:diagtext:`options align`|| | +| |+-------------------------+| | ++-----------------------------------------------------------------------------------+---------------------------+-----------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'#pragma comment` |nbsp| :placeholder:`A`:diagtext:`' ignored`| ++----------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing argument to debug command '`:placeholder:`A`:diagtext:`'`| ++-------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unexpected debug command '`:placeholder:`A`:diagtext:`'`| ++----------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected action or ')' in '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing ':' after` |nbsp| :placeholder:`A` |nbsp| :diagtext:`- ignoring`| ++--------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing ':' or ')' after` |nbsp| :placeholder:`A` |nbsp| :diagtext:`- ignoring`| ++---------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected 'enable' or 'disable' - ignoring`| ++--------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected identifier in '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++---------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected 'compiler', 'lib', 'user', or a string literal for the section name in '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected integer between` |nbsp| :placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B` |nbsp| :diagtext:`inclusive in '#pragma` |nbsp| :placeholder:`C`:diagtext:`' - ignored`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing '(' after '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignoring`| ++-----------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected non-wide string literal in '#pragma` |nbsp| :placeholder:`A`:diagtext:`'`| ++------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected ')' or ',' in '#pragma` |nbsp| :placeholder:`A`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing ')' after '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignoring`| ++-----------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected a stack label or a string literal for the section name in '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected a string literal for the section name in '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected push, pop or a string literal for the section name in '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra tokens at end of '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++---------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'#pragma init\_seg' is only supported when targeting a Microsoft environment`| ++-------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not a recognized builtin`|+----------------------------------------------------------------------------+| +| || || +| |+----------------------------------------------------------------------------+| +| ||:diagtext:`; consider including to access non-builtin intrinsics`|| +| |+----------------------------------------------------------------------------+| ++------------------------------------------------------------------------------------------+------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown action for '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++-----------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown action '`:placeholder:`B`:diagtext:`' for '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incorrect use of '#pragma ms\_struct on\|off' - ignored`| ++----------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma options align=reset failed:` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected 'align' following '#pragma options' - ignored`| ++---------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected #pragma pack parameter to be '1', '2', '4', '8', or '16'`| ++--------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected integer or identifier in '#pragma pack' - ignored`| ++-------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma` |nbsp| :placeholder:`A`:diagtext:`(pop, ...) failed:` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma pop\_macro could not pop '`:placeholder:`A`:diagtext:`', no matching push\_macro`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown OpenCL extension` |nbsp| :placeholder:`A` |nbsp| :diagtext:`- ignoring`| ++---------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`known but unsupported action '`:placeholder:`B`:diagtext:`' for '#pragma` |nbsp| :placeholder:`A`:diagtext:`' - ignored`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unsupported OpenCL extension` |nbsp| :placeholder:`A` |nbsp| :diagtext:`- ignoring`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected '#pragma unused' argument to be a variable name`| ++-----------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`only variables can be arguments to '#pragma unused'`| ++------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`undeclared variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`used as an argument for '#pragma unused'`| ++----------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wignored-qualifiers +-------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------+------------------------------------+----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ARC` |nbsp| |+----------------------------------+| |nbsp| :diagtext:`lifetime qualifier on return type is ignored`| +| ||:diagtext:`unused` || | +| |+----------------------------------+| | +| ||:diagtext:`\_\_unsafe\_unretained`|| | +| |+----------------------------------+| | +| ||:diagtext:`\_\_strong` || | +| |+----------------------------------+| | +| ||:diagtext:`\_\_weak` || | +| |+----------------------------------+| | +| ||:diagtext:`\_\_autoreleasing` || | +| |+----------------------------------+| | ++--------------------------------------------------+------------------------------------+----------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' qualifier on omitted return type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`has no effect`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+---------------+------------------------------------------+-------------------+-----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' type qualifier`|+-------------+| |nbsp| :diagtext:`on return type` |nbsp| |+-----------------+| |nbsp| :diagtext:`no effect`| +| || || ||:diagtext:`:has` || | +| |+-------------+| |+-----------------+| | +| ||:diagtext:`s`|| ||:diagtext:`:have`|| | +| |+-------------+| |+-----------------+| | ++------------------------------------------------------------------------------------+---------------+------------------------------------------+-------------------+-----------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' qualifier on function type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`has no effect`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' qualifier on reference type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`has no effect`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wimplicit +---------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wimplicit-function-declaration`_, `-Wimplicit-int`_. + + +-Wimplicit-atomic-properties +---------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property is assumed atomic when auto-synthesizing the property`| ++-----------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property is assumed atomic by default`| ++----------------------------------------------------------------------------+ + + +-Wimplicit-conversion-floating-point-to-bool +-------------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion turns floating-point number into bool:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wimplicit-exception-spec-mismatch +---------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------+----------------------+----------------------------------------------------------------------+----------------------+-------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function previously declared with an` |nbsp| |+--------------------+| |nbsp| :diagtext:`exception specification redeclared with an` |nbsp| |+--------------------+| |nbsp| :diagtext:`exception specification`| +| ||:diagtext:`explicit`|| ||:diagtext:`implicit`|| | +| |+--------------------+| |+--------------------+| | +| ||:diagtext:`implicit`|| ||:diagtext:`explicit`|| | +| |+--------------------+| |+--------------------+| | ++-----------------------------------------------------------------------------------+----------------------+----------------------------------------------------------------------+----------------------+-------------------------------------------+ + + +-Wimplicit-fallthrough +---------------------- +Also controls `-Wimplicit-fallthrough-per-function`_. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`fallthrough annotation in unreachable code`| ++---------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unannotated fall-through between switch labels`| ++-------------------------------------------------------------------------------------+ + + +-Wimplicit-fallthrough-per-function +----------------------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unannotated fall-through between switch labels in partly-annotated function`| ++------------------------------------------------------------------------------------------------------------------+ + + +-Wimplicit-function-declaration +------------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit declaration of function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is invalid in C99`| ++------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicitly declaring library function '`:placeholder:`A`:diagtext:`' with type` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`use of unknown builtin` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit declaration of function` |nbsp| :placeholder:`A`| ++-----------------------------------------------------------------------------------------------+ + + +-Wimplicit-int +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type specifier missing, defaults to 'int'`| ++--------------------------------------------------------------------------------+ + + +-Wimplicit-retain-self +---------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`block implicitly retains 'self'; explicitly mention 'self' to indicate this is intended behavior`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wimplicitly-unsigned-literal +----------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`integer literal is too large to be represented in a signed integer type, interpreting as unsigned`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wimport +-------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wimport-preprocessor-directive-pedantic +---------------------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#import is a language extension`| ++----------------------------------------------------------------------+ + + +-Winaccessible-base +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`direct base` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is inaccessible due to ambiguity:`:placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winclude-next-absolute-path +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#include\_next with absolute path`| ++------------------------------------------------------------------------+ + + +-Winclude-next-outside-header +----------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#include\_next in primary source file`| ++----------------------------------------------------------------------------+ + + +-Wincompatible-function-pointer-types +------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incompatible function pointer types` |nbsp| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`assigning to different types` ||| || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`passing to parameter of different type` |||:diagtext:`; dereference with \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`returning from function with different return type`|||:diagtext:`; take the address with &`|| +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`converting between types` |||:diagtext:`; remove \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`initializing with expression of different type` |||:diagtext:`; remove &` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++----------------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ + + +-Wincompatible-library-redeclaration +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incompatible redeclaration of library function` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------+ + + +-Wincompatible-ms-struct +------------------------ +This diagnostic is an error by default, but the flag ``-Wno-incompatible-ms-struct`` can be used to disable the error. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`ms\_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wincompatible-pointer-types +---------------------------- +This diagnostic is enabled by default. + +Also controls `-Wincompatible-function-pointer-types`_, `-Wincompatible-pointer-types-discards-qualifiers`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incompatible pointer types` |nbsp| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`assigning to different types` ||| || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`passing to parameter of different type` |||:diagtext:`; dereference with \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`returning from function with different return type`|||:diagtext:`; take the address with &`|| +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`converting between types` |||:diagtext:`; remove \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`initializing with expression of different type` |||:diagtext:`; remove &` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++-------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ + + +-Wincompatible-pointer-types-discards-qualifiers +------------------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+----------------------------------------------------------------+---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------------------------------------+| |nbsp| :diagtext:`discards qualifiers in nested pointer types`| +| ||:diagtext:`assigning to different types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`passing to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`returning from function with different return type`|| | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`converting between types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`initializing with expression of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++---------------------------+----------------------------------------------------------------+---------------------------------------------------------------+ + ++---------------------------+----------------------------------------------------------------+---------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------------------------------------+| |nbsp| :diagtext:`discards qualifiers`| +| ||:diagtext:`assigning to different types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`passing to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`returning from function with different return type`|| | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`converting between types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`initializing with expression of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++---------------------------+----------------------------------------------------------------+---------------------------------------+ + + +-Wincompatible-property-type +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is incompatible with type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`inherited from` |nbsp| :placeholder:`C`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wincompatible-sysroot +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using sysroot for '`:placeholder:`A`:diagtext:`' but targeting '`:placeholder:`B`:diagtext:`'`| ++------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wincomplete-implementation +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method definition for` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found`| ++-----------------------------------------------------------------------------------------------------------------+ + + +-Wincomplete-module +------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wincomplete-umbrella`_, `-Wnon-modular-include-in-module`_. + + +-Wincomplete-umbrella +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing submodule '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`umbrella header for module '`:placeholder:`A`:diagtext:`' does not include header '`:placeholder:`B`:diagtext:`'`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winconsistent-dllimport +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`redeclared without` |nbsp| :placeholder:`B` |nbsp| :diagtext:`attribute: previous` |nbsp| :placeholder:`B` |nbsp| :diagtext:`ignored`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`redeclared without 'dllimport' attribute: 'dllexport' attribute added`| ++------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winconsistent-missing-override +------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`overrides a member function but is not marked 'override'`| ++-----------------------------------------------------------------------------------------------------------------------+ + + +-Wincrement-bool +---------------- +This diagnostic is enabled by default. + +Also controls `-Wdeprecated-increment-bool`_. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`ISO C++1z does not allow incrementing expression of type bool`| ++------------------------------------------------------------------------------------------------+ + + +-Winfinite-recursion +-------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`all paths through this function will call itself`| ++---------------------------------------------------------------------------------------+ + + +-Winit-self +----------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Winitializer-overrides +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initializer overrides prior initialization of this subobject`| ++---------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`subobject initialization overrides initialization of other fields within its enclosing subobject`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winline +-------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Winline-asm +------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-Winline-new-delete +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`replacement function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot be declared 'inline'`| ++----------------------------------------------------------------------------------------------------------------------------------+ + + +-Winstantiation-after-specialization +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit instantiation of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`that occurs after an explicit specialization has no effect`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wint-conversion +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incompatible integer to pointer conversion` |nbsp| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`assigning to different types` ||| || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`passing to parameter of different type` |||:diagtext:`; dereference with \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`returning from function with different return type`|||:diagtext:`; take the address with &`|| +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`converting between types` |||:diagtext:`; remove \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`initializing with expression of different type` |||:diagtext:`; remove &` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++-----------------------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ + ++-----------------------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incompatible pointer to integer conversion` |nbsp| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`assigning to different types` ||| || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`passing to parameter of different type` |||:diagtext:`; dereference with \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`returning from function with different return type`|||:diagtext:`; take the address with &`|| +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`converting between types` |||:diagtext:`; remove \*` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`initializing with expression of different type` |||:diagtext:`; remove &` || +| |+--------------------------------------------------------------+|+-------------------------------------+| +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++-----------------------------------------------------------------------------------------+----------------------------------------------------------------+---------------------------------------+ + + +-Wint-conversions +----------------- +Synonym for `-Wint-conversion`_. + + +-Wint-to-pointer-cast +--------------------- +This diagnostic is enabled by default. + +Also controls `-Wint-to-void-pointer-cast`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`from smaller integer type` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wint-to-void-pointer-cast +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`from smaller integer type` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winteger-overflow +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`overflow in expression; result is` |nbsp| :placeholder:`A` |nbsp| :diagtext:`with type` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winvalid-command-line-argument +------------------------------- +This diagnostic is enabled by default. + +Also controls `-Wignored-optimization-argument`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`optimization level '`:placeholder:`A`:diagtext:`' is not supported; using '`:placeholder:`B`:placeholder:`C`:diagtext:`' instead`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winvalid-constexpr +------------------- +This diagnostic is an error by default, but the flag ``-Wno-invalid-constexpr`` can be used to disable the error. + +**Diagnostic text:** + ++----------------------------------------------------+-------------------------+--------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`constexpr` |nbsp| |+-----------------------+| |nbsp| :diagtext:`never produces a constant expression`| +| ||:diagtext:`function` || | +| |+-----------------------+| | +| ||:diagtext:`constructor`|| | +| |+-----------------------+| | ++----------------------------------------------------+-------------------------+--------------------------------------------------------+ + + +-Winvalid-iboutlet +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-----------------------------+| |nbsp| :diagtext:`with` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute must be an object type (invalid` |nbsp| :placeholder:`B`:diagtext:`)`| +| ||:diagtext:`instance variable`|| | +| |+-----------------------------+| | +| ||:diagtext:`property` || | +| |+-----------------------------+| | ++---------------------------+-------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`IBOutletCollection properties should be copy/strong and not assign`| ++---------------------------------------------------------------------------------------------------------+ + + +-Winvalid-initializer-from-system-header +---------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid constructor form class in system header, should not be explicit`| ++--------------------------------------------------------------------------------------------------------------+ + + +-Winvalid-noreturn +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function declared 'noreturn' should not return`| ++-------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`declared 'noreturn' should not return`| ++--------------------------------------------------------------------------------------------------------------------------------+ + + +-Winvalid-offsetof +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`offset of on non-POD type` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`offset of on non-standard-layout type` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------------------+ + + +-Winvalid-or-nonexistent-directory +---------------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`environment variable SCE\_ORBIS\_SDK\_DIR is set, but points to invalid or nonexistent directory '`:placeholder:`A`:diagtext:`'`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unable to find` |nbsp| :placeholder:`A` |nbsp| :diagtext:`directory, expected to be in '`:placeholder:`B`:diagtext:`'`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Winvalid-pch +------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Winvalid-pp-token +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty character constant`| ++---------------------------------------------------------------+ + ++------------------------------------------------------------------+-----------------+-----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing terminating` |nbsp| |+---------------+| |nbsp| :diagtext:`character`| +| ||:diagtext:`'` || | +| |+---------------+| | +| ||:diagtext:`'"'`|| | +| |+---------------+| | ++------------------------------------------------------------------+-----------------+-----------------------------+ + + +-Winvalid-source-encoding +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`illegal character encoding in character literal`| ++--------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`illegal character encoding in string literal`| ++-----------------------------------------------------------------------------------+ + + +-Winvalid-token-paste +--------------------- +This diagnostic is an error by default, but the flag ``-Wno-invalid-token-paste`` can be used to disable the error. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`pasting formed '`:placeholder:`A`:diagtext:`', an invalid preprocessing token`| ++----------------------------------------------------------------------------------------------------------------+ + + +-Wjump-seh-finally +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`jump out of \_\_finally block has undefined behavior`| ++-------------------------------------------------------------------------------------------+ + + +-Wkeyword-compat +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`keyword '`:placeholder:`A`:diagtext:`' will be made available as an identifier` |nbsp| |+-----------------------------------------------------+| +| ||:diagtext:`here` || +| |+-----------------------------------------------------+| +| ||:diagtext:`for the remainder of the translation unit`|| +| |+-----------------------------------------------------+| ++-----------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------+ + + +-Wkeyword-macro +--------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`keyword is hidden by macro definition`| ++----------------------------------------------------------------------------+ + + +-Wknr-promoted-parameter +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`promoted type of K&R function parameter is not compatible with parameter type` |nbsp| :diagtext:`declared in a previous prototype`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wlanguage-extension-token +-------------------------- +**Diagnostic text:** + ++-----------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extension used`| ++-----------------------------------------------------+ + + +-Wlarge-by-value-copy +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a large (`:placeholder:`B` |nbsp| :diagtext:`bytes) pass-by-value argument; pass it by reference instead ?`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`return value of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a large (`:placeholder:`B` |nbsp| :diagtext:`bytes) pass-by-value object; pass it by reference instead ?`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wliblto +-------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wliteral-conversion +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`changes value from` |nbsp| :placeholder:`C` |nbsp| :diagtext:`to` |nbsp| :placeholder:`D`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wliteral-range +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`magnitude of floating-point constant too large for type` |nbsp| :placeholder:`A`:diagtext:`; maximum is` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`magnitude of floating-point constant too small for type` |nbsp| :placeholder:`A`:diagtext:`; minimum is` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wlocal-type-template-args +-------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wc++98-compat-local-type-template-args`_. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template argument uses local type` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------------------------+ + + +-Wlogical-not-parentheses +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`logical not is only applied to the left hand side of this comparison`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wlogical-op-parentheses +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'&&' within '\|\|'`| ++---------------------------------------------------------+ + + +-Wlong-long +----------- +Also controls `-Wc++11-long-long`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'long long' is an extension when C99 mode is not enabled`| ++-----------------------------------------------------------------------------------------------+ + + +-Wloop-analysis +--------------- +Controls `-Wfor-loop-analysis`_, `-Wrange-loop-analysis`_. + + +-Wmacro-redefined +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`macro redefined`| ++------------------------------------------------------------------------------+ + + +-Wmain +------ +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C++ does not allow 'main' to be used by a program`| ++--------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'main' is not allowed to be declared \_Noreturn`| ++--------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'main' is not allowed to be declared variadic`| ++------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`only one parameter on 'main' declaration`| ++-------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable named 'main' with external linkage has undefined behavior`| ++---------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'main' should not be declared static`| ++---------------------------------------------------------------------------+ + + +-Wmain-return-type +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`return type of 'main' is not 'int'`| ++-------------------------------------------------------------------------+ + + +-Wmalformed-warning-check +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_\_has\_warning expected option name (e.g. "-Wundef")`| ++---------------------------------------------------------------------------------------------+ + + +-Wmany-braces-around-scalar-init +-------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`too many braces around scalar initializer`| ++--------------------------------------------------------------------------------+ + + +-Wmemsize-comparison +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`size argument in` |nbsp| :placeholder:`A` |nbsp| :diagtext:`call is a comparison`| ++-----------------------------------------------------------------------------------------------------------------------+ + + +-Wmethod-signatures +------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting parameter types in implementation of` |nbsp| :placeholder:`A`:diagtext:`:` |nbsp| :placeholder:`B` |nbsp| :diagtext:`vs` |nbsp| :placeholder:`C`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting return type in implementation of` |nbsp| :placeholder:`A`:diagtext:`:` |nbsp| :placeholder:`B` |nbsp| :diagtext:`vs` |nbsp| :placeholder:`C`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft +----------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Winconsistent-dllimport`_, `-Wmicrosoft-anon-tag`_, `-Wmicrosoft-cast`_, `-Wmicrosoft-charize`_, `-Wmicrosoft-comment-paste`_, `-Wmicrosoft-const-init`_, `-Wmicrosoft-cpp-macro`_, `-Wmicrosoft-default-arg-redefinition`_, `-Wmicrosoft-end-of-file`_, `-Wmicrosoft-enum-forward-reference`_, `-Wmicrosoft-enum-value`_, `-Wmicrosoft-exception-spec`_, `-Wmicrosoft-explicit-constructor-call`_, `-Wmicrosoft-extra-qualification`_, `-Wmicrosoft-fixed-enum`_, `-Wmicrosoft-flexible-array`_, `-Wmicrosoft-goto`_, `-Wmicrosoft-include`_, `-Wmicrosoft-mutable-reference`_, `-Wmicrosoft-pure-definition`_, `-Wmicrosoft-redeclare-static`_, `-Wmicrosoft-sealed`_, `-Wmicrosoft-template`_, `-Wmicrosoft-union-member-reference`_, `-Wmicrosoft-unqualified-friend`_, `-Wmicrosoft-using-decl`_, `-Wmicrosoft-void-pseudo-dtor`_. + + +-Wmicrosoft-anon-tag +-------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------+--------------------+---------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`types declared in an anonymous` |nbsp| |+------------------+| |nbsp| :diagtext:`are a Microsoft extension`| +| ||:diagtext:`struct`|| | +| |+------------------+| | +| ||:diagtext:`union` || | +| |+------------------+| | ++-----------------------------------------------------------------------------+--------------------+---------------------------------------------+ + ++--------------------------------------------------------+---------------------+---------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`anonymous` |nbsp| |+-------------------+| |nbsp| :diagtext:`are a Microsoft extension`| +| ||:diagtext:`structs`|| | +| |+-------------------+| | +| ||:diagtext:`unions` || | +| |+-------------------+| | ++--------------------------------------------------------+---------------------+---------------------------------------------+ + + +-Wmicrosoft-cast +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static\_cast between pointer-to-function and pointer-to-object is a Microsoft extension`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-charize +------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`charizing operator #@ is a Microsoft extension`| ++-------------------------------------------------------------------------------------+ + + +-Wmicrosoft-comment-paste +------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pasting two '/' tokens into a '//' comment is a Microsoft extension`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-const-init +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+--------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default initialization of an object of const type` |nbsp| :placeholder:`A`|+---------------------------------------------------------------+| |nbsp| :diagtext:`is a Microsoft extension`| +| || || | +| |+---------------------------------------------------------------+| | +| || |nbsp| :diagtext:`without a user-provided default constructor`|| | +| |+---------------------------------------------------------------+| | ++----------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+--------------------------------------------+ + + +-Wmicrosoft-cpp-macro +--------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C++ operator` |nbsp| :placeholder:`A` |nbsp| :diagtext:`(aka` |nbsp| :placeholder:`B`:diagtext:`) used as a macro name`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-default-arg-redefinition +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redefinition of default argument`| ++-----------------------------------------------------------------------+ + + +-Wmicrosoft-end-of-file +----------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`treating Ctrl-Z as end-of-file is a Microsoft extension`| ++----------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-enum-forward-reference +---------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`forward references to 'enum' types are a Microsoft extension`| ++---------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-enum-value +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumerator value is not representable in the underlying type` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-exception-spec +-------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`exception specification of '...' is a Microsoft extension`| ++------------------------------------------------------------------------------------------------+ + ++---------------------------+----------------------------------+----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------+|:diagtext:`incomplete type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`is not allowed in exception specification`| +| || || | +| |+--------------------------------+| | +| ||:diagtext:`pointer to` |nbsp| || | +| |+--------------------------------+| | +| ||:diagtext:`reference to` |nbsp| || | +| |+--------------------------------+| | ++---------------------------+----------------------------------+----------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`exception specification in declaration does not match previous declaration`| ++-----------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`exception specification in explicit instantiation does not match instantiated one`| ++------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is missing exception specification '`:placeholder:`B`:diagtext:`'`| ++--------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`exception specification of overriding function is more lax than base version`| ++-------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-exists +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------+---------------------------------+--------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`dependent` |nbsp| |+-------------------------------+| |nbsp| :diagtext:`declarations are ignored`| +| ||:diagtext:`\_\_if\_not\_exists`|| | +| |+-------------------------------+| | +| ||:diagtext:`\_\_if\_exists` || | +| |+-------------------------------+| | ++--------------------------------------------------------+---------------------------------+--------------------------------------------+ + + +-Wmicrosoft-explicit-constructor-call +------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit constructor calls are a Microsoft extension`| ++-------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-extra-qualification +------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra qualification on member` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-fixed-enum +---------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration types with a fixed underlying type are a Microsoft extension`| ++---------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-flexible-array +-------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------+-----------------------+--------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in otherwise empty` |nbsp| |+---------------------+| |nbsp| :diagtext:`is a Microsoft extension`| +| ||:diagtext:`struct` || | +| |+---------------------+| | +| ||:diagtext:`interface`|| | +| |+---------------------+| | +| ||:diagtext:`union` || | +| |+---------------------+| | +| ||:diagtext:`class` || | +| |+---------------------+| | +| ||:diagtext:`enum` || | +| |+---------------------+| | ++----------------------------------------------------------------------------------------------------------------------------------+-----------------------+--------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in a union is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-goto +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`jump from this goto statement to its label is a Microsoft extension`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-include +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#include resolved using non-portable Microsoft search rules as:` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-mutable-reference +----------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'mutable' on a reference type is a Microsoft extension`| ++---------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-pure-definition +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function definition with pure-specifier is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-redeclare-static +---------------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redeclaring non-static` |nbsp| :placeholder:`A` |nbsp| :diagtext:`as static is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-sealed +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'sealed' keyword is a Microsoft extension`| ++--------------------------------------------------------------------------------+ + + +-Wmicrosoft-template +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`duplicate explicit instantiation of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`ignored as a Microsoft extension`| ++------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of identifier` |nbsp| :placeholder:`A` |nbsp| :diagtext:`found via unqualified lookup into dependent bases of class templates is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit specialization of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`within class scope is a Microsoft extension`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using the undeclared type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`as a default template argument is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-type template argument containing a dereference operation is a Microsoft extension`| ++-----------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------------------------+| |nbsp| :diagtext:`specialization of` |nbsp| :placeholder:`B` |nbsp| :diagtext:`outside namespace enclosing` |nbsp| :placeholder:`C` |nbsp| :diagtext:`is a Microsoft extension`| +| ||:diagtext:`class template` || | +| |+-------------------------------------+| | +| ||:diagtext:`class template partial` || | +| |+-------------------------------------+| | +| ||:diagtext:`variable template` || | +| |+-------------------------------------+| | +| ||:diagtext:`variable template partial`|| | +| |+-------------------------------------+| | +| ||:diagtext:`function template` || | +| |+-------------------------------------+| | +| ||:diagtext:`member function` || | +| |+-------------------------------------+| | +| ||:diagtext:`static data member` || | +| |+-------------------------------------+| | +| ||:diagtext:`member class` || | +| |+-------------------------------------+| | +| ||:diagtext:`member enumeration` || | +| |+-------------------------------------+| | ++---------------------------+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template argument for template type parameter must be a type; omitted 'typename' is a Microsoft extension`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of undeclared identifier` |nbsp| :placeholder:`A`:diagtext:`; unqualified lookup into dependent bases of class template` |nbsp| :placeholder:`B` |nbsp| :diagtext:`is a Microsoft extension`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-union-member-reference +---------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`union member` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has reference type` |nbsp| :placeholder:`B`:diagtext:`, which is a Microsoft extension`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-unqualified-friend +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unqualified friend declaration referring to type outside of the nearest enclosing namespace is a Microsoft extension; add a nested name specifier`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-using-decl +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using declaration referring to inaccessible member '`:placeholder:`A`:diagtext:`' (which refers to accessible member '`:placeholder:`B`:diagtext:`') is a Microsoft compatibility extension`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmicrosoft-void-pseudo-dtor +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pseudo-destructors on type void are a Microsoft extension`| ++------------------------------------------------------------------------------------------------+ + + +-Wmismatched-new-delete +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------+------------------+---------------------------------------------------------------+------------------+-----------------------------------+------------------+--------------+ +|:warning:`warning:` |nbsp| :diagtext:`'delete`|+----------------+|:diagtext:`' applied to a pointer that was allocated with 'new`|+----------------+|:diagtext:`'; did you mean 'delete`|+----------------+|:diagtext:`'?`| +| || || ||:diagtext:`\[\]`|| ||:diagtext:`\[\]`|| | +| |+----------------+| |+----------------+| |+----------------+| | +| ||:diagtext:`\[\]`|| || || || || | +| |+----------------+| |+----------------+| |+----------------+| | ++----------------------------------------------+------------------+---------------------------------------------------------------+------------------+-----------------------------------+------------------+--------------+ + + +-Wmismatched-parameter-types +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting parameter types in implementation of` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------------------------------------+ + + +-Wmismatched-return-types +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting return type in implementation of` |nbsp| :placeholder:`A`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wmismatched-tags +----------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------+--------------------------+------------------------------+-----------------------------------------------------------+--------------------------+------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`C` |nbsp| :diagtext:`defined as` |nbsp| |+------------------------+|+----------------------------+| |nbsp| :diagtext:`here but previously declared as` |nbsp| |+------------------------+|+----------------------------+| +| ||:diagtext:`a struct` ||| || ||:diagtext:`a struct` ||| || +| |+------------------------+|+----------------------------+| |+------------------------+|+----------------------------+| +| ||:diagtext:`an interface`||| |nbsp| :diagtext:`template`|| ||:diagtext:`an interface`||| |nbsp| :diagtext:`template`|| +| |+------------------------+|+----------------------------+| |+------------------------+|+----------------------------+| +| ||:diagtext:`a class` || | ||:diagtext:`a class` || | +| |+------------------------+| | |+------------------------+| | ++---------------------------------------------------------------------------------+--------------------------+------------------------------+-----------------------------------------------------------+--------------------------+------------------------------+ + ++---------------------------+-----------------------+------------------------------+--------------------------------------------------------------------------------+-----------------------+------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------+|+----------------------------+| |nbsp| :placeholder:`C` |nbsp| :diagtext:`was previously declared as a` |nbsp| |+---------------------+|+----------------------------+| +| ||:diagtext:`struct` ||| || ||:diagtext:`struct` ||| || +| |+---------------------+|+----------------------------+| |+---------------------+|+----------------------------+| +| ||:diagtext:`interface`||| |nbsp| :diagtext:`template`|| ||:diagtext:`interface`||| |nbsp| :diagtext:`template`|| +| |+---------------------+|+----------------------------+| |+---------------------+|+----------------------------+| +| ||:diagtext:`class` || | ||:diagtext:`class` || | +| |+---------------------+| | |+---------------------+| | ++---------------------------+-----------------------+------------------------------+--------------------------------------------------------------------------------+-----------------------+------------------------------+ + + +-Wmissing-braces +---------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`suggest braces around initialization of subobject`| ++----------------------------------------------------------------------------------------+ + + +-Wmissing-declarations +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration does not declare anything`| ++----------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' is not permitted on a declaration of a type`| ++-----------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`typedef requires a name`| ++--------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' ignored on this declaration`| ++-------------------------------------------------------------------------------------------------+ + + +-Wmissing-exception-spec +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is missing exception specification '`:placeholder:`B`:diagtext:`'`| ++--------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmissing-field-initializers +---------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing field` |nbsp| :placeholder:`A` |nbsp| :diagtext:`initializer`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wmissing-format-attribute +-------------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wmissing-include-dirs +---------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wmissing-method-return-type +---------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method has no return type specified; defaults to 'id'`| ++--------------------------------------------------------------------------------------------+ + + +-Wmissing-noreturn +------------------ +**Diagnostic text:** + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`block could be declared with attribute 'noreturn'`| ++----------------------------------------------------------------------------------------+ + ++---------------------------+----------------------+---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`could be declared with attribute 'noreturn'`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`method` || | +| |+--------------------+| | ++---------------------------+----------------------+---------------------------------------------------------------------------------------+ + + +-Wmissing-prototype-for-cc +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function with no prototype cannot use the` |nbsp| :placeholder:`A` |nbsp| :diagtext:`calling convention`| ++----------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmissing-prototypes +-------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no previous prototype for function` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------+ + + +-Wmissing-selector-name +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`used as the name of the previous parameter rather than as part of the selector`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmissing-sysroot +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no such sysroot directory: '`:placeholder:`A`:diagtext:`'`| ++------------------------------------------------------------------------------------------------+ + + +-Wmissing-variable-declarations +------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no previous extern declaration for non-static variable` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------------------------------------------+ + + +-Rmodule-build +-------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------+ +|:remark:`remark:` |nbsp| :diagtext:`building module '`:placeholder:`A`:diagtext:`' as '`:placeholder:`B`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------+ +|:remark:`remark:` |nbsp| :diagtext:`finished building module '`:placeholder:`A`:diagtext:`'`| ++--------------------------------------------------------------------------------------------+ + + +-Wmodule-conflict +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`module '`:placeholder:`A`:diagtext:`' conflicts with already-imported module '`:placeholder:`B`:diagtext:`':` |nbsp| :placeholder:`C`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmodule-file-config-mismatch +----------------------------- +This diagnostic is an error by default, but the flag ``-Wno-module-file-config-mismatch`` can be used to disable the error. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`module file` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot be loaded due to a configuration mismatch with the current compilation`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmodule-file-extension +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`duplicate module file extension block name '`:placeholder:`A`:diagtext:`'`| ++----------------------------------------------------------------------------------------------------------------+ + + +-Wmodule-import-in-extern-c +--------------------------- +This diagnostic is an error by default, but the flag ``-Wno-module-import-in-extern-c`` can be used to disable the error. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`import of C++ module '`:placeholder:`A`:diagtext:`' appears within extern "C" language linkage specification`| ++-----------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmodules-ambiguous-internal-linkage +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ambiguous use of internal linkage declaration` |nbsp| :placeholder:`A` |nbsp| :diagtext:`defined in multiple modules`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmodules-import-nested-redundant +--------------------------------- +This diagnostic is an error by default, but the flag ``-Wno-modules-import-nested-redundant`` can be used to disable the error. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`redundant #include of module '`:placeholder:`A`:diagtext:`' appears within` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wmost +------ +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wcast-of-sel-type`_, `-Wchar-subscripts`_, `-Wcomment`_, `-Wdelete-non-virtual-dtor`_, `-Wextern-c-compat`_, `-Wfor-loop-analysis`_, `-Wformat`_, `-Wimplicit`_, `-Winfinite-recursion`_, `-Wmismatched-tags`_, `-Wmissing-braces`_, `-Wmove`_, `-Wmultichar`_, `-Wobjc-designated-initializers`_, `-Wobjc-missing-super-calls`_, `-Woverloaded-virtual`_, `-Wprivate-extern`_, `-Wreorder`_, `-Wreturn-type`_, `-Wself-assign`_, `-Wself-move`_, `-Wsizeof-array-argument`_, `-Wsizeof-array-decay`_, `-Wstring-plus-int`_, `-Wtrigraphs`_, `-Wuninitialized`_, `-Wunknown-pragmas`_, `-Wunused`_, `-Wvolatile-register-var`_. + + +-Wmove +------ +Controls `-Wpessimizing-move`_, `-Wredundant-move`_, `-Wself-move`_. + + +-Wmsvc-include +-------------- +Synonym for `-Wmicrosoft-include`_. + + +-Wmultichar +----------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multi-character character constant`| ++-------------------------------------------------------------------------+ + + +-Wmultiple-move-vbase +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`defaulted move assignment operator of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will move assign virtual base class` |nbsp| :placeholder:`B` |nbsp| :diagtext:`multiple times`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wnarrowing +----------- +Synonym for `-Wc++11-narrowing`_. + + +-Wnested-anon-types +------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------+--------------------+------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`anonymous types declared in an anonymous` |nbsp| |+------------------+| |nbsp| :diagtext:`are an extension`| +| ||:diagtext:`struct`|| | +| |+------------------+| | +| ||:diagtext:`union` || | +| |+------------------+| | ++---------------------------------------------------------------------------------------+--------------------+------------------------------------+ + + +-Wnested-externs +---------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wnew-returns-null +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`should not return a null pointer unless it is declared 'throw()'`|+---------------------------------+| +| || || +| |+---------------------------------+| +| || |nbsp| :diagtext:`or 'noexcept'`|| +| |+---------------------------------+| ++-------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+ + + +-Wnewline-eof +------------- +**Diagnostic text:** + ++----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no newline at end of file`| ++----------------------------------------------------------------+ + ++----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no newline at end of file`| ++----------------------------------------------------------------+ + + +-Wnon-gcc +--------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wconversion`_, `-Wliteral-range`_, `-Wsign-compare`_. + + +-Wnon-literal-null-conversion +----------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression which evaluates to zero treated as a null pointer constant of type` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wnon-modular-include-in-framework-module +----------------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`include of non-modular header inside framework module '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------------------------+ + + +-Wnon-modular-include-in-module +------------------------------- +Also controls `-Wnon-modular-include-in-framework-module`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`include of non-modular header inside module '`:placeholder:`A`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------------+ + + +-Wnon-pod-varargs +----------------- +This diagnostic is an error by default, but the flag ``-Wno-non-pod-varargs`` can be used to disable the error. + +**Diagnostic text:** + ++----------------------------------------------------------------+-------------------------+--------------------------------------------------------------------------------------------+-------------------------+----------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`cannot pass object of` |nbsp| |+-----------------------+| |nbsp| :diagtext:`type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`through variadic` |nbsp| |+-----------------------+|:diagtext:`; call will abort at runtime`| +| ||:diagtext:`non-POD` || ||:diagtext:`function` || | +| |+-----------------------+| |+-----------------------+| | +| ||:diagtext:`non-trivial`|| ||:diagtext:`block` || | +| |+-----------------------+| |+-----------------------+| | +| | | ||:diagtext:`method` || | +| | | |+-----------------------+| | +| | | ||:diagtext:`constructor`|| | +| | | |+-----------------------+| | ++----------------------------------------------------------------+-------------------------+--------------------------------------------------------------------------------------------+-------------------------+----------------------------------------+ + ++------------------------------------------------------+-------------------------+-------------------------------------------------------------------------------------------------+-------------------------+--------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`cannot pass` |nbsp| |+-----------------------+| |nbsp| :diagtext:`object of type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`to variadic` |nbsp| |+-----------------------+|:diagtext:`; expected type from format string was` |nbsp| :placeholder:`D`| +| ||:diagtext:`non-POD` || ||:diagtext:`function` || | +| |+-----------------------+| |+-----------------------+| | +| ||:diagtext:`non-trivial`|| ||:diagtext:`block` || | +| |+-----------------------+| |+-----------------------+| | +| | | ||:diagtext:`method` || | +| | | |+-----------------------+| | +| | | ||:diagtext:`constructor`|| | +| | | |+-----------------------+| | ++------------------------------------------------------+-------------------------+-------------------------------------------------------------------------------------------------+-------------------------+--------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`second argument to 'va\_arg' is of non-POD type` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`second argument to 'va\_arg' is of ARC ownership-qualified type` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------------------------------+ + + +-Wnon-virtual-dtor +------------------ +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has virtual functions but non-virtual destructor`| ++---------------------------------------------------------------------------------------------------------------+ + + +-Wnonnull +--------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`null passed to a callee that requires a non-null argument`| ++------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------+----------------------+---------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`null returned from` |nbsp| |+--------------------+| |nbsp| :diagtext:`that requires a non-null return value`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`method` || | +| |+--------------------+| | ++-----------------------------------------------------------------+----------------------+---------------------------------------------------------+ + + +-Wnonportable-cfstrings +----------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wnonportable-include-path +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-portable path to file '`:placeholder:`A`:diagtext:`'; specified path differs in case from file name on disk`| ++------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wnonportable-system-include-path +--------------------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-portable path to file '`:placeholder:`A`:diagtext:`'; specified path differs in case from file name on disk`| ++------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wnonportable-vector-initialization +----------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`vector initializers are not compatible with NEON intrinsics in big endian mode`| ++---------------------------------------------------------------------------------------------------------------------+ + + +-Wnull-arithmetic +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of NULL in arithmetic operation`| ++--------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison between NULL and non-pointer` |nbsp| |+------------------------------------------------------------+| +| ||+----------------------------------------------------------+|| +| |||:diagtext:`(`:placeholder:`B` |nbsp| :diagtext:`and NULL)`||| +| ||+----------------------------------------------------------+|| +| |+------------------------------------------------------------+| +| ||+----------------------------------------------------------+|| +| |||:diagtext:`(NULL and` |nbsp| :placeholder:`B`:diagtext:`)`||| +| ||+----------------------------------------------------------+|| +| |+------------------------------------------------------------+| ++--------------------------------------------------------------------------------------+--------------------------------------------------------------+ + + +-Wnull-character +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------+--------------------+---------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`null character(s) preserved in` |nbsp| |+------------------+| |nbsp| :diagtext:`literal`| +| ||:diagtext:`char` || | +| |+------------------+| | +| ||:diagtext:`string`|| | +| |+------------------+| | ++-----------------------------------------------------------------------------+--------------------+---------------------------+ + ++-------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`null character ignored`| ++-------------------------------------------------------------+ + + +-Wnull-conversion +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------+---------------------+-------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion of` |nbsp| |+-------------------+| |nbsp| :diagtext:`constant to` |nbsp| :placeholder:`B`| +| ||:diagtext:`NULL` || | +| |+-------------------+| | +| ||:diagtext:`nullptr`|| | +| |+-------------------+| | ++---------------------------------------------------------------------+---------------------+-------------------------------------------------------+ + + +-Wnull-dereference +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`binding dereferenced null pointer to reference has undefined behavior`| ++------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`indirection of non-volatile null pointer will be deleted, not trap`| ++---------------------------------------------------------------------------------------------------------+ + + +-Wnullability +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting nullability specifier on parameter types,` |nbsp| :placeholder:`A` |nbsp| :diagtext:`conflicts with existing specifier` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting nullability specifier on return types,` |nbsp| :placeholder:`A` |nbsp| :diagtext:`conflicts with existing specifier` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`nullability specifier` |nbsp| :placeholder:`A` |nbsp| :diagtext:`conflicts with existing specifier` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`synthesized setter` |nbsp| :placeholder:`A` |nbsp| :diagtext:`for null\_resettable property` |nbsp| :placeholder:`B` |nbsp| :diagtext:`does not handle nil`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`duplicate nullability specifier` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------------+ + + +-Wnullability-completeness +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+----------------------------+-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------+| |nbsp| :diagtext:`is missing a nullability type specifier (\_Nonnull, \_Nullable, or \_Null\_unspecified)`| +| ||:diagtext:`pointer` || | +| |+--------------------------+| | +| ||:diagtext:`block pointer` || | +| |+--------------------------+| | +| ||:diagtext:`member pointer`|| | +| |+--------------------------+| | ++---------------------------+----------------------------+-----------------------------------------------------------------------------------------------------------+ + + +-Wnullability-declspec +---------------------- +This diagnostic is an error by default, but the flag ``-Wno-nullability-declspec`` can be used to disable the error. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------+-------------+ +|:error:`error:` |nbsp| :diagtext:`nullability specifier` |nbsp| :placeholder:`A` |nbsp| :diagtext:`cannot be applied to non-pointer type` |nbsp| :placeholder:`B`:diagtext:`; did you mean to apply the specifier to the` |nbsp| |+-----------------------------------+|:diagtext:`?`| +| ||:diagtext:`pointer` || | +| |+-----------------------------------+| | +| ||:diagtext:`block pointer` || | +| |+-----------------------------------+| | +| ||:diagtext:`member pointer` || | +| |+-----------------------------------+| | +| ||:diagtext:`function pointer` || | +| |+-----------------------------------+| | +| ||:diagtext:`member function pointer`|| | +| |+-----------------------------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------+-------------+ + + +-Wnullability-extension +----------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type nullability specifier` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a Clang extension`| ++---------------------------------------------------------------------------------------------------------------------------------+ + + +-Wnullable-to-nonnull-conversion +-------------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from nullable pointer` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to non-nullable pointer type` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-autosynthesis-property-ivar-name-match +--------------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------+-------------------------+---------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`autosynthesized property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will use` |nbsp| |+-----------------------+| |nbsp| :diagtext:`instance variable` |nbsp| :placeholder:`C`:diagtext:`, not existing instance variable` |nbsp| :placeholder:`D`| +| || || | +| |+-----------------------+| | +| ||:diagtext:`synthesized`|| | +| |+-----------------------+| | ++---------------------------------------------------------------------------------------------------------------------------+-------------------------+---------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-circular-container +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`adding '`:placeholder:`A`:diagtext:`' to '`:placeholder:`B`:diagtext:`' might cause circular dependency in container`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-cocoa-api +---------------- +Synonym for `-Wobjc-redundant-api-use`_. + + +-Wobjc-designated-initializers +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`designated initializer missing a 'super' call to a designated initializer of the super class`| ++-----------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`designated initializer invoked a non-designated initializer`| ++--------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`designated initializer should only invoke a designated initializer on 'super'`| ++--------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method override for the designated initializer of the superclass` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`convenience initializer missing a 'self' call to another initializer`| ++-----------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`convenience initializer should not invoke an initializer on 'super'`| ++----------------------------------------------------------------------------------------------------------+ + + +-Wobjc-forward-class-redefinition +--------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redefinition of forward class` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of a typedef name of an object type is ignored`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-interface-ivars +---------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration of instance variables in the interface is deprecated`| ++-------------------------------------------------------------------------------------------------------+ + + +-Wobjc-literal-compare +---------------------- +This diagnostic is enabled by default. + +Also controls `-Wobjc-string-compare`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------+----------------------------------+------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`direct comparison of` |nbsp| |+--------------------------------+| |nbsp| :diagtext:`has undefined behavior`| +| ||:diagtext:`an array literal` || | +| |+--------------------------------+| | +| ||:diagtext:`a dictionary literal`|| | +| |+--------------------------------+| | +| ||:diagtext:`a numeric literal` || | +| |+--------------------------------+| | +| ||:diagtext:`a boxed expression` || | +| |+--------------------------------+| | +| || || | +| |+--------------------------------+| | ++-------------------------------------------------------------------+----------------------------------+------------------------------------------+ + + +-Wobjc-literal-conversion +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit boolean conversion of Objective-C object literal always evaluates to true`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`object of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not compatible with` |nbsp| |+---------------------------------+| |nbsp| :placeholder:`C`| +| ||:diagtext:`array element type` || | +| |+---------------------------------+| | +| ||:diagtext:`dictionary key type` || | +| |+---------------------------------+| | +| ||:diagtext:`dictionary value type`|| | +| |+---------------------------------+| | ++-------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+------------------------+ + + +-Wobjc-macro-redefinition +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring redefinition of Objective-C qualifier macro`| ++-------------------------------------------------------------------------------------------+ + + +-Wobjc-method-access +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`class method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found (return type defaults to 'id')`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`class method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found (return type defaults to 'id'); did you mean` |nbsp| :placeholder:`C`:diagtext:`?`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instance method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found (return type defaults to 'id')`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instance method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found (return type defaults to 'id'); did you mean` |nbsp| :placeholder:`C`:diagtext:`?`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instance method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`found instead of class method` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instance method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is being used on 'Class' which is not in the root class`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-missing-property-synthesis +--------------------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`auto property synthesis is synthesizing property not explicitly synthesized`| ++------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-missing-super-calls +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method possibly missing a \[super` |nbsp| :placeholder:`A`:diagtext:`\] call`| ++-------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-multiple-method-names +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multiple methods named` |nbsp| :placeholder:`A` |nbsp| :diagtext:`found`| ++--------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-noncopy-retain-block-property +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`retain'ed block property does not copy the block - use copy attribute instead`| ++--------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-nonunified-exceptions +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot catch an exception thrown with @throw in C++ in the non-unified exception model`| ++-----------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-property-implementation +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`class property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires method` |nbsp| :placeholder:`B` |nbsp| :diagtext:`to be defined - use @dynamic or provide a method implementation in this class implementation`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`class property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires method` |nbsp| :placeholder:`B` |nbsp| :diagtext:`to be defined - use @dynamic or provide a method implementation in this category`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires method` |nbsp| :placeholder:`B` |nbsp| :diagtext:`to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires method` |nbsp| :placeholder:`B` |nbsp| :diagtext:`to be defined - use @dynamic or provide a method implementation in this category`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-property-implicit-mismatch +--------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`primary property declaration is implicitly strong while redeclaration in class extension is weak`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-property-matches-cocoa-ownership-rule +-------------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property follows Cocoa naming convention for returning 'owned' objects`| ++-------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-property-no-attribute +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`default property attribute 'assign' not appropriate for non-GC object`| ++------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed`| ++--------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-property-synthesis +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`auto property synthesis will not synthesize property` |nbsp| :placeholder:`A`:diagtext:`; it will be implemented by its superclass, use @dynamic to acknowledge intention`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`auto property synthesis will not synthesize property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`because it is 'readwrite' but it will be synthesized 'readonly' via another property`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`auto property synthesis will not synthesize property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`because it cannot share an ivar with another synthesized property`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-protocol-method-implementation +------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`category is implementing a method which will also be implemented by its primary class`| ++----------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-protocol-property-synthesis +---------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`auto property synthesis will not synthesize property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`declared in protocol` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-protocol-qualifiers +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`parameterized class` |nbsp| :placeholder:`A` |nbsp| :diagtext:`already conforms to the protocols listed; did you forget a '\*'?`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-readonly-with-setter-property +------------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`setter cannot be specified for a readonly property`| ++-----------------------------------------------------------------------------------------+ + + +-Wobjc-redundant-api-use +------------------------ +Synonym for `-Wobjc-redundant-literal-use`_. + + +-Wobjc-redundant-literal-use +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using` |nbsp| :placeholder:`A` |nbsp| :diagtext:`with a literal is redundant`| ++-------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-root-class +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`class` |nbsp| :placeholder:`A` |nbsp| :diagtext:`defined without specifying a base class`| ++-------------------------------------------------------------------------------------------------------------------------------+ + + +-Wobjc-string-compare +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`direct comparison of a string literal has undefined behavior`| ++---------------------------------------------------------------------------------------------------+ + + +-Wobjc-string-concatenation +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`concatenated NSString literal for an NSArray expression - possibly missing a comma`| ++-------------------------------------------------------------------------------------------------------------------------+ + + +-Wodr +----- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has incompatible definitions in different translation units`| ++--------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wold-style-cast +---------------- +**Diagnostic text:** + ++------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of old-style cast`| ++------------------------------------------------------------+ + + +-Wold-style-definition +---------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wopencl-unsupported-rgba +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`vector component name '`:placeholder:`A`:diagtext:`' is an OpenCL version 2.2 feature`| ++----------------------------------------------------------------------------------------------------------------------------+ + + +-Wopenmp-clauses +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`aligned clause will be ignored because the requested alignment is not a power of 2`| ++-------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------+---------------------------------------------------+-------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`zero linear step (`:placeholder:`A` |nbsp| |+-------------------------------------------------+|:diagtext:`should probably be const)`| +| || || | +| |+-------------------------------------------------+| | +| ||:diagtext:`and other variables in clause` |nbsp| || | +| |+-------------------------------------------------+| | ++---------------------------------------------------------------------------------+---------------------------------------------------+-------------------------------------+ + + +-Wopenmp-loop-form +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')`| ++-----------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed`| ++-----------------------------------------------------------------------------------------------------------------------------+ + + +-Wopenmp-target +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration is not declared in any declare target region`| ++-----------------------------------------------------------------------------------------------+ + + +-Woption-ignored +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`option '`:placeholder:`A`:diagtext:`' was ignored by the PS4 toolchain, using '-fPIC'`| ++----------------------------------------------------------------------------------------------------------------------------+ + + +-Wout-of-line-declaration +------------------------- +This diagnostic is an error by default, but the flag ``-Wno-out-of-line-declaration`` can be used to disable the error. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`out-of-line declaration of a member must be a definition`| ++-------------------------------------------------------------------------------------------+ + + +-Wover-aligned +-------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires` |nbsp| :placeholder:`B` |nbsp| :diagtext:`bytes of alignment and the default allocator only guarantees` |nbsp| :placeholder:`C` |nbsp| :diagtext:`bytes`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Woverflow +---------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Woverlength-strings +-------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+-----------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`string literal of length` |nbsp| :placeholder:`A` |nbsp| :diagtext:`exceeds maximum length` |nbsp| :placeholder:`B` |nbsp| :diagtext:`that` |nbsp| |+-------------------+| |nbsp| :diagtext:`compilers are required to support`| +| ||:diagtext:`C90` || | +| |+-------------------+| | +| ||:diagtext:`ISO C99`|| | +| |+-------------------+| | +| ||:diagtext:`C++` || | +| |+-------------------+| | ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+-----------------------------------------------------+ + + +-Woverloaded-shift-op-parentheses +--------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------+----------------+------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`overloaded operator` |nbsp| |+--------------+| |nbsp| :diagtext:`has higher precedence than comparison operator`| +| ||:diagtext:`>>`|| | +| |+--------------+| | +| ||:diagtext:`<<`|| | +| |+--------------+| | ++------------------------------------------------------------------+----------------+------------------------------------------------------------------+ + + +-Woverloaded-virtual +-------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+-----------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`hides overloaded virtual` |nbsp| |+---------------------+| +| ||:diagtext:`function` || +| |+---------------------+| +| ||:diagtext:`functions`|| +| |+---------------------+| ++-----------------------------------------------------------------------------------------------+-----------------------+ + + +-Woverride-module +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`overriding the module target triple with` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------+ + + +-Woverriding-method-mismatch +---------------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting distributed object modifiers on parameter type in declaration of` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting parameter types in declaration of` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting distributed object modifiers on return type in declaration of` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting return type in declaration of` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting variadic declaration of method and its implementation`| ++--------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting parameter types in declaration of` |nbsp| :placeholder:`A`:diagtext:`:` |nbsp| :placeholder:`B` |nbsp| :diagtext:`vs` |nbsp| :placeholder:`C`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`conflicting return type in declaration of` |nbsp| :placeholder:`A`:diagtext:`:` |nbsp| :placeholder:`B` |nbsp| :diagtext:`vs` |nbsp| :placeholder:`C`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Woverriding-t-option +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`overriding '`:placeholder:`A`:diagtext:`' option with '`:placeholder:`B`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------------------------+ + + +-Wpacked +-------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`packed attribute is unnecessary for` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------+ + + +-Wpadded +-------- +**Diagnostic text:** + ++------------------------------------------------------+-----------------------+--------------------------------------------------------------------------------+------------------+---------------+------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`padding` |nbsp| |+---------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`with` |nbsp| :placeholder:`C` |nbsp| |+----------------+|+-------------+| |nbsp| :diagtext:`to align anonymous bit-field`| +| ||:diagtext:`struct` || ||:diagtext:`byte`||| || | +| |+---------------------+| |+----------------+|+-------------+| | +| ||:diagtext:`interface`|| ||:diagtext:`bit` |||:diagtext:`s`|| | +| |+---------------------+| |+----------------+|+-------------+| | +| ||:diagtext:`class` || | | | | +| |+---------------------+| | | | | ++------------------------------------------------------+-----------------------+--------------------------------------------------------------------------------+------------------+---------------+------------------------------------------------+ + ++------------------------------------------------------+-----------------------+--------------------------------------------------------------------------------+------------------+---------------+----------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`padding` |nbsp| |+---------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`with` |nbsp| :placeholder:`C` |nbsp| |+----------------+|+-------------+| |nbsp| :diagtext:`to align` |nbsp| :placeholder:`E`| +| ||:diagtext:`struct` || ||:diagtext:`byte`||| || | +| |+---------------------+| |+----------------+|+-------------+| | +| ||:diagtext:`interface`|| ||:diagtext:`bit` |||:diagtext:`s`|| | +| |+---------------------+| |+----------------+|+-------------+| | +| ||:diagtext:`class` || | | | | +| |+---------------------+| | | | | ++------------------------------------------------------+-----------------------+--------------------------------------------------------------------------------+------------------+---------------+----------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+------------------+---------------+-----------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`padding size of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`with` |nbsp| :placeholder:`B` |nbsp| |+----------------+|+-------------+| |nbsp| :diagtext:`to alignment boundary`| +| ||:diagtext:`byte`||| || | +| |+----------------+|+-------------+| | +| ||:diagtext:`bit` |||:diagtext:`s`|| | +| |+----------------+|+-------------+| | ++--------------------------------------------------------------------------------------------------------------------------------------+------------------+---------------+-----------------------------------------+ + + +-Wparentheses +------------- +This diagnostic is enabled by default. + +Also controls `-Wbitwise-op-parentheses`_, `-Wdangling-else`_, `-Wlogical-not-parentheses`_, `-Wlogical-op-parentheses`_, `-Woverloaded-shift-op-parentheses`_, `-Wparentheses-equality`_, `-Wshift-op-parentheses`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`using the result of an assignment as a condition without parentheses`| ++-----------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has lower precedence than` |nbsp| :placeholder:`B`:diagtext:`;` |nbsp| :placeholder:`B` |nbsp| :diagtext:`will be evaluated first`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`operator '?:' has lower precedence than '`:placeholder:`A`:diagtext:`'; '`:placeholder:`A`:diagtext:`' will be evaluated first`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wparentheses-equality +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`equality comparison with extraneous parentheses`| ++--------------------------------------------------------------------------------------+ + + +-Wpartial-availability +---------------------- +Synonym for `-Wunguarded-availability`_. + + +-Rpass +------ +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-Rpass-analysis +--------------- +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:remark:`remark:` |nbsp| :placeholder:`A`:diagtext:`; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop. If the arrays will always be independent specify '#pragma clang loop vectorize(assume\_safety)' before the loop or provide the '\_\_restrict\_\_' qualifier with the independent array arguments. Erroneous results will occur if these options are incorrectly applied!`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:remark:`remark:` |nbsp| :placeholder:`A`:diagtext:`; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop or by providing the compiler option '-ffast-math'.`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wpass-failed +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-Rpass-missed +------------- +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-Wpch-date-time +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+--------------------------------+-----------------------------------------------------+ +|:warning:`warning:` |nbsp| |+------------------------------+| |nbsp| :diagtext:`uses \_\_DATE\_\_ or \_\_TIME\_\_`| +| ||:diagtext:`precompiled header`|| | +| |+------------------------------+| | +| ||:diagtext:`module` || | +| |+------------------------------+| | ++---------------------------+--------------------------------+-----------------------------------------------------+ + + +-Wpedantic +---------- +Also controls `-Wc++11-extra-semi`_, `-Wc++11-long-long`_, `-Wc++14-binary-literal`_, `-Wc11-extensions`_, `-Wcomplex-component-init`_, `-Wdeclaration-after-statement`_, `-Wdollar-in-identifier-extension`_, `-Wembedded-directive`_, `-Wempty-translation-unit`_, `-Wextended-offsetof`_, `-Wflexible-array-extensions`_, `-Wformat-pedantic`_, `-Wfour-char-constants`_, `-Wgnu-anonymous-struct`_, `-Wgnu-auto-type`_, `-Wgnu-binary-literal`_, `-Wgnu-case-range`_, `-Wgnu-complex-integer`_, `-Wgnu-compound-literal-initializer`_, `-Wgnu-conditional-omitted-operand`_, `-Wgnu-empty-initializer`_, `-Wgnu-empty-struct`_, `-Wgnu-flexible-array-initializer`_, `-Wgnu-flexible-array-union-member`_, `-Wgnu-folding-constant`_, `-Wgnu-imaginary-constant`_, `-Wgnu-include-next`_, `-Wgnu-label-as-value`_, `-Wgnu-redeclared-enum`_, `-Wgnu-statement-expression`_, `-Wgnu-union-cast`_, `-Wgnu-zero-line-directive`_, `-Wgnu-zero-variadic-macro-arguments`_, `-Wimport-preprocessor-directive-pedantic`_, `-Wkeyword-macro`_, `-Wlanguage-extension-token`_, `-Wlong-long`_, `-Wmicrosoft-charize`_, `-Wmicrosoft-comment-paste`_, `-Wmicrosoft-cpp-macro`_, `-Wmicrosoft-end-of-file`_, `-Wmicrosoft-enum-forward-reference`_, `-Wmicrosoft-fixed-enum`_, `-Wmicrosoft-flexible-array`_, `-Wmicrosoft-redeclare-static`_, `-Wnested-anon-types`_, `-Wnullability-extension`_, `-Woverlength-strings`_, `-Wretained-language-linkage`_, `-Wvariadic-macros`_, `-Wvla-extension`_, `-Wzero-length-array`_. + +**Diagnostic text:** + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'enable\_if' is a clang extension`| ++------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`designated initializers are a C99 feature`| ++--------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C++ does not allow 'main' to be used by a program`| ++--------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C++98 requires an accessible copy constructor for class` |nbsp| :placeholder:`C` |nbsp| :diagtext:`when binding a reference to a temporary; was` |nbsp| |+---------------------+| +| ||:diagtext:`private` || +| |+---------------------+| +| ||:diagtext:`protected`|| +| |+---------------------+| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------+ + ++--------------------------------------------------------+--------------------+------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`anonymous` |nbsp| |+------------------+| |nbsp| :diagtext:`cannot be '`:placeholder:`B`:diagtext:`'`| +| ||:diagtext:`struct`|| | +| |+------------------+| | +| ||:diagtext:`union` || | +| |+------------------+| | ++--------------------------------------------------------+--------------------+------------------------------------------------------------+ + ++--------------------------------------------------------------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no viable constructor` |nbsp| |+---------------------------------------+| |nbsp| :diagtext:`of type` |nbsp| :placeholder:`B`:diagtext:`; C++98 requires a copy constructor when binding a reference to a temporary`| +| ||:diagtext:`copying variable` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying parameter` || | +| |+---------------------------------------+| | +| ||:diagtext:`returning object` || | +| |+---------------------------------------+| | +| ||:diagtext:`throwing object` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying member subobject` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying array element` || | +| |+---------------------------------------+| | +| ||:diagtext:`allocating object` || | +| |+---------------------------------------+| | +| ||:diagtext:`copying temporary` || | +| |+---------------------------------------+| | +| ||:diagtext:`initializing base subobject`|| | +| |+---------------------------------------+| | +| ||:diagtext:`initializing vector element`|| | +| |+---------------------------------------+| | +| ||:diagtext:`capturing value` || | +| |+---------------------------------------+| | ++--------------------------------------------------------------------+-----------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`parameter` |nbsp| :placeholder:`A` |nbsp| :diagtext:`was not declared, defaulting to type 'int'`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`qualifier in explicit instantiation of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires a template-id (a typedef is not permitted)`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------+----------------------+-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`is used in an inline function with external linkage`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`variable`|| | +| |+--------------------+| | ++-----------------------------------------------------+----------------------+-----------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C forbids forward references to 'enum' types`| ++---------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------+-------------------+-------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C restricts enumerator values to range of 'int' (`:placeholder:`A` |nbsp| :diagtext:`is too` |nbsp| |+-----------------+|:diagtext:`)`| +| ||:diagtext:`small`|| | +| |+-----------------+| | +| ||:diagtext:`large`|| | +| |+-----------------+| | ++----------------------------------------------------------------------------------------------------------------------------------------------+-------------------+-------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`size of static array must be an integer constant expression`| ++--------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`initializer for aggregate is not a compile-time constant`| ++-----------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`flexible array members are a C99 feature`| ++-------------------------------------------------------------------------------+ + ++---------------------------------------------------------------+-----------------------+--------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid application of '`|+---------------------+|:diagtext:`' to a function type`| +| ||:diagtext:`sizeof` || | +| |+---------------------+| | +| ||:diagtext:`alignof` || | +| |+---------------------+| | +| ||:diagtext:`vec\_step`|| | +| |+---------------------+| | ++---------------------------------------------------------------+-----------------------+--------------------------------+ + ++---------------------------------------------------------------+-----------------------+----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid application of '`|+---------------------+|:diagtext:`' to a void type`| +| ||:diagtext:`sizeof` || | +| |+---------------------+| | +| ||:diagtext:`alignof` || | +| |+---------------------+| | +| ||:diagtext:`vec\_step`|| | +| |+---------------------+| | ++---------------------------------------------------------------+-----------------------+----------------------------+ + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C90 does not allow subscripting non-lvalue array`| ++-------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`subscript of a pointer to void is a GNU extension`| ++----------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C forbids taking the address of an expression of type 'void'`| ++-------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ordered comparison between pointer and zero (`:placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B`:diagtext:`) is an extension`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`equality comparison between function pointer and void pointer (`:placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B`:diagtext:`)`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`arithmetic on`|+---------------------+| |nbsp| :diagtext:`pointer`|+-------------+| |nbsp| :diagtext:`to void is a GNU extension`| +| || |nbsp| :diagtext:`a`|| || || | +| |+---------------------+| |+-------------+| | +| || || ||:diagtext:`s`|| | +| |+---------------------+| |+-------------+| | ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------------------------------+ + ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------+-------------------------+---------------------------------+---------------+------------------------+---------------------------------------------------+--------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`arithmetic on`|+---------------------+| |nbsp| :diagtext:`pointer`|+-------------+| |nbsp| :diagtext:`to`|+-----------------------+| |nbsp| :diagtext:`function type`|+-------------+| |nbsp| :placeholder:`B`|+-------------------------------------------------+| |nbsp| :diagtext:`is a GNU extension`| +| || |nbsp| :diagtext:`a`|| || || || |nbsp| :diagtext:`the`|| || || || || | +| |+---------------------+| |+-------------+| |+-----------------------+| |+-------------+| |+-------------------------------------------------+| | +| || || ||:diagtext:`s`|| || || ||:diagtext:`s`|| ||+-----------------------------------------------+|| | +| |+---------------------+| |+-------------+| |+-----------------------+| |+-------------+| ||| |nbsp| :diagtext:`and` |nbsp| :placeholder:`D`||| | +| | | | | | | | | ||+-----------------------------------------------+|| | +| | | | | | | | | |+-------------------------------------------------+| | ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------+-------------------------+---------------------------------+---------------+------------------------+---------------------------------------------------+--------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C does not support '++'/'--' on complex integer type` |nbsp| :placeholder:`A`| ++-----------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C does not support '~' for complex conjugation of` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`complex numbers are an extension in a freestanding C99 implementation`| ++------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cast between pointer-to-function and pointer-to-object is an extension`| ++-------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion from array size expression of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| |+-----------------------+| |nbsp| :diagtext:`type` |nbsp| :placeholder:`C` |nbsp| :diagtext:`is a C++11 extension`| +| ||:diagtext:`integral` || | +| |+-----------------------+| | +| ||:diagtext:`enumeration`|| | +| |+-----------------------+| | ++---------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+----------------------------------------------------------------------------------------+ + ++---------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------------------------------------+| |nbsp| :diagtext:`converts between void pointer and function pointer`| +| ||:diagtext:`assigning to different types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`passing to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`returning from function with different return type`|| | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`converting between types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`initializing with expression of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++---------------------------+----------------------------------------------------------------+----------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`kernel function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a member function; this may not be accepted by nvcc`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C99 forbids conditional expressions with only one void side`| ++--------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C99 forbids casting nonscalar type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to the same type`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of the` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute is a C++14 extension`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of the` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute is a C++1z extension`| ++---------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+--------------------+---------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`types declared in an anonymous` |nbsp| |+------------------+| |nbsp| :diagtext:`are a Microsoft extension`| +| ||:diagtext:`struct`|| | +| |+------------------+| | +| ||:diagtext:`union` || | +| |+------------------+| | ++-----------------------------------------------------------------------------+--------------------+---------------------------------------------+ + ++---------------------------------------------------+----------------------+-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`void` |nbsp| |+--------------------+| |nbsp| :placeholder:`A` |nbsp| :diagtext:`should not return void expression`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`method` || | +| |+--------------------+| | +| ||:diagtext:`block` || | +| |+--------------------+| | ++---------------------------------------------------+----------------------+-----------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' cannot be signed or unsigned`| ++--------------------------------------------------------------------------------------------------+ + ++---------------------------+----------------------------------+------------------------------+-----------------------+----------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------+|:diagtext:`array size` |nbsp| |+---------------------+|:diagtext:`is a C99 feature`| +| ||:diagtext:`qualifier in` |nbsp| || || || | +| |+--------------------------------+| |+---------------------+| | +| ||:diagtext:`static` |nbsp| || || || | +| |+--------------------------------+| |+---------------------+| | +| || || ||:diagtext:`'\[\*\] '`|| | +| |+--------------------------------+| |+---------------------+| | ++---------------------------+----------------------------------+------------------------------+-----------------------+----------------------------+ + ++--------------------------------------------------------+------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extra ';'` |nbsp| |+----------------------------------------------+| +| ||:diagtext:`outside of a function` || +| |+----------------------------------------------+| +| ||+--------------------------------------------+|| +| |||:diagtext:`inside a` |nbsp| :placeholder:`B`||| +| ||+--------------------------------------------+|| +| |+----------------------------------------------+| +| ||:diagtext:`inside instance variable list` || +| |+----------------------------------------------+| +| ||:diagtext:`after member function definition` || +| |+----------------------------------------------+| ++--------------------------------------------------------+------------------------------------------------+ + ++-----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'\_\_thread' before '`:placeholder:`A`:diagtext:`'`| ++-----------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`type-less parameter names in function declaration`| ++----------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable declaration in for loop is a C99-specific feature`| ++-------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`compound literals are a C99-specific feature`| ++-----------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`commas at the end of enumerator lists are a C99-specific feature`| ++-------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`commas at the end of enumerator lists are a C++11 extension`| ++--------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`enumeration types with a fixed underlying type are a C++11 extension`| ++-----------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of GNU array range extension`| ++-----------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`exception specification of '...' is a Microsoft extension`| ++------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`extern templates are a C++11 extension`| ++-----------------------------------------------------------------------------+ + ++------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multi-line // comment`| ++------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`// comments are not allowed in this language`| ++-----------------------------------------------------------------------------------+ + ++----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no newline at end of file`| ++----------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of non-standard escape character '\\`:placeholder:`A`:diagtext:`'`| ++------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`hexadecimal floating constants are a C99 feature`| ++---------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`hexadecimal floating literals are a C++1z feature`| ++----------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#ident is a language extension`| ++---------------------------------------------------------------------+ + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#warning is a language extension`| ++-----------------------------------------------------------------------+ + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comma operator in operand of #if`| ++-----------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\_\_VA\_ARGS\_\_ can only appear in the expansion of a C99 variadic macro`| ++----------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty macro arguments are a C99 feature`| ++------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`C requires #line number to be less than` |nbsp| :placeholder:`A`:diagtext:`, allowed as extension`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`macro expansion producing 'defined' has undefined behavior`| ++-------------------------------------------------------------------------------------------------+ + + +-Wpedantic-core-features +------------------------ +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`OpenCL extension` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is core feature or supported optional core feature - ignoring`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wpessimizing-move +------------------ +**Diagnostic text:** + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`moving a temporary object prevents copy elision`| ++--------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`moving a local object in a return statement prevents copy elision`| ++--------------------------------------------------------------------------------------------------------+ + + +-Wpointer-arith +--------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------+-------------------------+---------------------------------+---------------+------------------------+---------------------------------------------------+--------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`arithmetic on`|+---------------------+| |nbsp| :diagtext:`pointer`|+-------------+| |nbsp| :diagtext:`to`|+-----------------------+| |nbsp| :diagtext:`function type`|+-------------+| |nbsp| :placeholder:`B`|+-------------------------------------------------+| |nbsp| :diagtext:`is a GNU extension`| +| || |nbsp| :diagtext:`a`|| || || || |nbsp| :diagtext:`the`|| || || || || | +| |+---------------------+| |+-------------+| |+-----------------------+| |+-------------+| |+-------------------------------------------------+| | +| || || ||:diagtext:`s`|| || || ||:diagtext:`s`|| ||+-----------------------------------------------+|| | +| |+---------------------+| |+-------------+| |+-----------------------+| |+-------------+| ||| |nbsp| :diagtext:`and` |nbsp| :placeholder:`D`||| | +| | | | | | | | | ||+-----------------------------------------------+|| | +| | | | | | | | | |+-------------------------------------------------+| | ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------+-------------------------+---------------------------------+---------------+------------------------+---------------------------------------------------+--------------------------------------+ + ++----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`subscript of a pointer to void is a GNU extension`| ++----------------------------------------------------------------------------------------+ + ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`arithmetic on`|+---------------------+| |nbsp| :diagtext:`pointer`|+-------------+| |nbsp| :diagtext:`to void is a GNU extension`| +| || |nbsp| :diagtext:`a`|| || || | +| |+---------------------+| |+-------------+| | +| || || ||:diagtext:`s`|| | +| |+---------------------+| |+-------------+| | ++----------------------------------------------------+-----------------------+---------------------------+---------------+----------------------------------------------+ + ++---------------------------------------------------------------+-----------------------+--------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid application of '`|+---------------------+|:diagtext:`' to a function type`| +| ||:diagtext:`sizeof` || | +| |+---------------------+| | +| ||:diagtext:`alignof` || | +| |+---------------------+| | +| ||:diagtext:`vec\_step`|| | +| |+---------------------+| | ++---------------------------------------------------------------+-----------------------+--------------------------------+ + ++---------------------------------------------------------------+-----------------------+----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid application of '`|+---------------------+|:diagtext:`' to a void type`| +| ||:diagtext:`sizeof` || | +| |+---------------------+| | +| ||:diagtext:`alignof` || | +| |+---------------------+| | +| ||:diagtext:`vec\_step`|| | +| |+---------------------+| | ++---------------------------------------------------------------+-----------------------+----------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`subtraction of pointers to type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of zero size has undefined behavior`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wpointer-bool-conversion +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------+---------------------------+---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`nonnull` |nbsp| |+-------------------------+| |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' will evaluate to 'true' on first encounter`| +| ||:diagtext:`function call`|| | +| |+-------------------------+| | +| ||:diagtext:`parameter` || | +| |+-------------------------+| | ++------------------------------------------------------+---------------------------+---------------------------------------------------------------------------------------------+ + ++-------------------------------------------------+------------------------------+---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`address of`|+----------------------------+| |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' will always evaluate to 'true'`| +| || || | +| |+----------------------------+| | +| || |nbsp| :diagtext:`function`|| | +| |+----------------------------+| | +| || |nbsp| :diagtext:`array` || | +| |+----------------------------+| | ++-------------------------------------------------+------------------------------+---------------------------------------------------------------------------------+ + + +-Wpointer-sign +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+----------------------------------------------------------------+----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------------------------------------------------+| |nbsp| :diagtext:`converts between pointers to integer types with different sign`| +| ||:diagtext:`assigning to different types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`passing to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`returning from function with different return type`|| | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`converting between types` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`initializing with expression of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`sending to parameter of different type` || | +| |+--------------------------------------------------------------+| | +| ||:diagtext:`casting between types` || | +| |+--------------------------------------------------------------+| | ++---------------------------+----------------------------------------------------------------+----------------------------------------------------------------------------------+ + + +-Wpointer-to-int-cast +--------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wpointer-type-mismatch +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pointer type mismatch`| ++------------------------------------------------------------+ + + +-Wpotentially-evaluated-expression +---------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression with side effects will be evaluated despite being used as an operand to 'typeid'`| ++----------------------------------------------------------------------------------------------------------------------------------+ + + +-Wpragma-once-outside-header +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma once in main file`| ++----------------------------------------------------------------+ + + +-Wpragma-system-header-outside-header +------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma system\_header ignored in main file`| ++----------------------------------------------------------------------------------+ + + +-Wpragmas +--------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wignored-pragmas`_, `-Wunknown-pragmas`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------+----------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma redefine\_extname is applicable to external C declarations only; not applied to` |nbsp| |+--------------------+| |nbsp| :placeholder:`B`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`variable`|| | +| |+--------------------+| | ++--------------------------------------------------------------------------------------------------------------------------------------+----------------------+------------------------+ + + +-Wpredefined-identifier-outside-function +---------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`predefined identifier is only valid inside function`| ++------------------------------------------------------------------------------------------+ + + +-Wprivate-extern +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`use of \_\_private\_extern\_\_ on a declaration may not produce external symbol private to the linkage unit and is deprecated`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wprivate-header +---------------- +This diagnostic is an error by default, but the flag ``-Wno-private-header`` can be used to disable the error. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`use of private header from outside its module: '`:placeholder:`A`:diagtext:`'`| ++----------------------------------------------------------------------------------------------------------------+ + + +-Wprofile-instr-out-of-date +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+---------------+---------------------------------------------+-------------------+---------------------------------------------------------------+-------------------+--------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`profile data may be out of date: of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`function`|+-------------+|:diagtext:`,` |nbsp| :placeholder:`B` |nbsp| |+-----------------+| |nbsp| :diagtext:`no data and` |nbsp| :placeholder:`C` |nbsp| |+-----------------+| |nbsp| :diagtext:`mismatched data that will be ignored`| +| || || ||:diagtext:`:has` || ||:diagtext:`:has` || | +| |+-------------+| |+-----------------+| |+-----------------+| | +| ||:diagtext:`s`|| ||:diagtext:`:have`|| ||:diagtext:`:have`|| | +| |+-------------+| |+-----------------+| |+-----------------+| | ++------------------------------------------------------------------------------------------------------------------------------+---------------+---------------------------------------------+-------------------+---------------------------------------------------------------+-------------------+--------------------------------------------------------+ + + +-Wprofile-instr-unprofiled +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no profile data available for file "`:placeholder:`A`:diagtext:`"`| ++--------------------------------------------------------------------------------------------------------+ + + +-Wproperty-access-dot-syntax +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`not found on object of type` |nbsp| :placeholder:`B`:diagtext:`; did you mean to access property` |nbsp| :placeholder:`C`:diagtext:`?`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wproperty-attribute-mismatch +----------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property attribute in class extension does not match the primary class`| ++-------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' attribute on property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`does not match the property inherited from` |nbsp| :placeholder:`C`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`getter name mismatch between property redeclaration (`:placeholder:`B`:diagtext:`) and its original declaration (`:placeholder:`A`:diagtext:`)`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`attribute 'readonly' of property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`restricts attribute 'readwrite' of property inherited from` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wprotocol +---------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method` |nbsp| :placeholder:`A` |nbsp| :diagtext:`in protocol` |nbsp| :placeholder:`B` |nbsp| :diagtext:`not implemented`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wprotocol-property-synthesis-ambiguity +--------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`was selected for synthesis`| ++-----------------------------------------------------------------------------------------------------------------------------+ + + +-Wqualified-void-return-type +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`function cannot return qualified void type` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------------------------------+ + + +-Wrange-loop-analysis +--------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`loop variable` |nbsp| :placeholder:`A` |nbsp| |nbsp| :diagtext:`is initialized with a value of a different type` |nbsp| :diagtext:`resulting in a copy`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`loop variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`creates a copy from type` |nbsp| :placeholder:`C`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`loop variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is always a copy because the range of type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`does not return a reference`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wreadonly-iboutlet-property +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`readonly IBOutlet property` |nbsp| :placeholder:`A` |nbsp| :diagtext:`when auto-synthesized may not work correctly with 'nib' loader`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wreceiver-expr +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`receiver type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not 'id' or interface pointer, consider casting it to 'id'`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wreceiver-forward-class +------------------------ +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`receiver` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a forward class and corresponding @interface may not exist`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`receiver type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`for instance message is a forward declaration`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wredeclared-class-member +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`class member cannot be redeclared`| ++------------------------------------------------------------------------+ + + +-Wredundant-decls +----------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wredundant-move +---------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redundant move in return statement`| ++-------------------------------------------------------------------------+ + + +-Wregister +---------- +This diagnostic is enabled by default. + +Also controls `-Wdeprecated-register`_. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`ISO C++1z does not allow 'register' storage class specifier`| ++----------------------------------------------------------------------------------------------+ + + +-Wreinterpret-base-class +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------+------------------+---------------------------------------------------------+------------------+-------------------------------+-------------------------------------+-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'reinterpret\_cast'` |nbsp| |+----------------+| |nbsp| :diagtext:`class` |nbsp| :placeholder:`A` |nbsp| |+----------------+| |nbsp| :diagtext:`its` |nbsp| |+-----------------------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`behaves differently from 'static\_cast'`| +| ||:diagtext:`from`|| ||:diagtext:`to` || ||:diagtext:`virtual base` || | +| |+----------------+| |+----------------+| |+-----------------------------------+| | +| ||:diagtext:`to` || ||:diagtext:`from`|| ||:diagtext:`base at non-zero offset`|| | +| |+----------------+| |+----------------+| |+-----------------------------------+| | ++------------------------------------------------------------------+------------------+---------------------------------------------------------+------------------+-------------------------------+-------------------------------------+-----------------------------------------------------------------------------------+ + + +-Rremark-backend-plugin +----------------------- +**Diagnostic text:** + +The text of this diagnostic is not controlled by Clang. + + +-Wreorder +--------- +**Diagnostic text:** + ++---------------------------+------------------------+-----------------------------------------------------------------------------+-------------------+------------------------+ +|:warning:`warning:` |nbsp| |+----------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`will be initialized after` |nbsp| |+-----------------+| |nbsp| :placeholder:`D`| +| ||:diagtext:`field` || ||:diagtext:`field`|| | +| |+----------------------+| |+-----------------+| | +| ||:diagtext:`base class`|| ||:diagtext:`base` || | +| |+----------------------+| |+-----------------+| | ++---------------------------+------------------------+-----------------------------------------------------------------------------+-------------------+------------------------+ + + +-Wrequires-super-attribute +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+----------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute cannot be applied to` |nbsp| |+--------------------------------+| +| ||:diagtext:`methods in protocols`|| +| |+--------------------------------+| +| ||:diagtext:`dealloc` || +| |+--------------------------------+| ++-----------------------------------------------------------------------------------------------------+----------------------------------+ + + +-Wreserved-id-macro +------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`macro name is a reserved identifier`| ++--------------------------------------------------------------------------+ + + +-Wreserved-user-defined-literal +------------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wc++11-compat-reserved-user-defined-literal`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid suffix on literal; C++11 requires a space between literal and identifier`| ++-----------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`invalid suffix on literal; C++11 requires a space between literal and identifier`| ++-------------------------------------------------------------------------------------------------------------------+ + + +-Wretained-language-linkage +--------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`friend function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`retaining previous language linkage is an extension`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wreturn-stack-address +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`returning address of label, which is local`| ++---------------------------------------------------------------------------------+ + ++--------------------------------------------------------+--------------------------+------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`returning` |nbsp| |+------------------------+| |nbsp| :diagtext:`local temporary object`| +| ||:diagtext:`address of` || | +| |+------------------------+| | +| ||:diagtext:`reference to`|| | +| |+------------------------+| | ++--------------------------------------------------------+--------------------------+------------------------------------------+ + ++---------------------------+--------------------------+-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+------------------------+| |nbsp| :diagtext:`stack memory associated with local variable` |nbsp| :placeholder:`B` |nbsp| :diagtext:`returned`| +| ||:diagtext:`address of` || | +| |+------------------------+| | +| ||:diagtext:`reference to`|| | +| |+------------------------+| | ++---------------------------+--------------------------+-------------------------------------------------------------------------------------------------------------------+ + + +-Wreturn-type +------------- +This diagnostic is enabled by default. + +Also controls `-Wreturn-type-c-linkage`_. + +**Diagnostic text:** + ++-----------------------+---------------------------+---------------------------------------------------------------------+ +|:error:`error:` |nbsp| |+-------------------------+| |nbsp| :placeholder:`A` |nbsp| :diagtext:`should not return a value`| +| ||:diagtext:`void function`|| | +| |+-------------------------+| | +| ||:diagtext:`void method` || | +| |+-------------------------+| | +| ||:diagtext:`constructor` || | +| |+-------------------------+| | +| ||:diagtext:`destructor` || | +| |+-------------------------+| | ++-----------------------+---------------------------+---------------------------------------------------------------------+ + ++---------------------------------------------------+----------------------+-----------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`non-void` |nbsp| |+--------------------+| |nbsp| :placeholder:`A` |nbsp| :diagtext:`should return a value`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`method` || | +| |+--------------------+| | ++---------------------------------------------------+----------------------+-----------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`control reaches end of non-void function`| ++-------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`control reaches end of non-void lambda`| ++-----------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`control may reach end of non-void function`| ++---------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`control may reach end of non-void lambda`| ++-------------------------------------------------------------------------------+ + ++---------------------------------------------------+----------------------+-----------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`non-void` |nbsp| |+--------------------+| |nbsp| :placeholder:`A` |nbsp| :diagtext:`should return a value`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`method` || | +| |+--------------------+| | ++---------------------------------------------------+----------------------+-----------------------------------------------------------------+ + + +-Wreturn-type-c-linkage +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has C-linkage specified, but returns user-defined type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`which is incompatible with C`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has C-linkage specified, but returns incomplete type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`which could be incompatible with C`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wrtti-for-exceptions +--------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicitly enabling rtti for exception handling`| ++--------------------------------------------------------------------------------------+ + + +-Rsanitize-address +------------------ +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------+ +|:remark:`remark:` |nbsp| :diagtext:`-fsanitize-address-field-padding applied to` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------+ +|:remark:`remark:` |nbsp| :diagtext:`-fsanitize-address-field-padding ignored for` |nbsp| :placeholder:`A` |nbsp| :diagtext:`because it` |nbsp| |+------------------------------------+| +| ||:diagtext:`is not C++` || +| |+------------------------------------+| +| ||:diagtext:`is packed` || +| |+------------------------------------+| +| ||:diagtext:`is a union` || +| |+------------------------------------+| +| ||:diagtext:`is trivially copyable` || +| |+------------------------------------+| +| ||:diagtext:`has trivial destructor` || +| |+------------------------------------+| +| ||:diagtext:`is standard layout` || +| |+------------------------------------+| +| ||:diagtext:`is in a blacklisted file`|| +| |+------------------------------------+| +| ||:diagtext:`is blacklisted` || +| |+------------------------------------+| ++-----------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------+ + + +-Wsection +--------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`section does not match previous declaration`| ++----------------------------------------------------------------------------------+ + + +-Wselector +---------- +Also controls `-Wselector-type-mismatch`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`no method with selector` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is implemented in this translation unit`| ++-------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wselector-type-mismatch +------------------------ +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`several methods with selector` |nbsp| :placeholder:`A` |nbsp| :diagtext:`of mismatched types are found for the @selector expression`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wself-assign +------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wself-assign-field`_. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicitly assigning value of variable of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to itself`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wself-assign-field +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------+-------------------------------+-----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`assigning` |nbsp| |+-----------------------------+| |nbsp| :diagtext:`to itself`| +| ||:diagtext:`field` || | +| |+-----------------------------+| | +| ||:diagtext:`instance variable`|| | +| |+-----------------------------+| | ++--------------------------------------------------------+-------------------------------+-----------------------------+ + + +-Wself-move +----------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicitly moving variable of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to itself`| ++------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsemicolon-before-method-body +------------------------------ +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`semicolon before method body is ignored`| ++------------------------------------------------------------------------------+ + + +-Wsentinel +---------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------+-----------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing sentinel in` |nbsp| |+---------------------------+| +| ||:diagtext:`function call` || +| |+---------------------------+| +| ||:diagtext:`method dispatch`|| +| |+---------------------------+| +| ||:diagtext:`block call` || +| |+---------------------------+| ++------------------------------------------------------------------+-----------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`not enough variable arguments in` |nbsp| :placeholder:`A` |nbsp| :diagtext:`declaration to fit a sentinel`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsequence-point +---------------- +Synonym for `-Wunsequenced`_. + + +-Wserialized-diagnostics +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unable to open file` |nbsp| :placeholder:`A` |nbsp| :diagtext:`for serializing diagnostics (`:placeholder:`B`:diagtext:`)`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unable to merge a subprocess's serialized diagnostics`| ++--------------------------------------------------------------------------------------------+ + + +-Wshadow +-------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wshadow-field-in-constructor-modified`_, `-Wshadow-ivar`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------+-------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration shadows a` |nbsp| |+-----------------------------------------------------------+| +| ||:diagtext:`local variable` || +| |+-----------------------------------------------------------+| +| ||+-----------------------------------------------+ || +| |||:diagtext:`variable in` |nbsp| :placeholder:`C`| || +| ||+-----------------------------------------------+ || +| |+-----------------------------------------------------------+| +| ||+---------------------------------------------------------+|| +| |||:diagtext:`static data member of` |nbsp| :placeholder:`C`||| +| ||+---------------------------------------------------------+|| +| |+-----------------------------------------------------------+| +| ||+--------------------------------------------+ || +| |||:diagtext:`field of` |nbsp| :placeholder:`C`| || +| ||+--------------------------------------------+ || +| |+-----------------------------------------------------------+| ++--------------------------------------------------------------------+-------------------------------------------------------------+ + + +-Wshadow-all +------------ +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wshadow`_, `-Wshadow-field-in-constructor`_. + + +-Wshadow-field-in-constructor +----------------------------- +Also controls `-Wshadow-field-in-constructor-modified`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`constructor parameter` |nbsp| :placeholder:`A` |nbsp| :diagtext:`shadows the field` |nbsp| :placeholder:`B` |nbsp| :diagtext:`of` |nbsp| :placeholder:`C`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wshadow-field-in-constructor-modified +-------------------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`modifying constructor parameter` |nbsp| :placeholder:`A` |nbsp| :diagtext:`that shadows a field of` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wshadow-ivar +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`local declaration of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`hides instance variable`| ++------------------------------------------------------------------------------------------------------------------------------+ + + +-Wshift-count-negative +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`shift count is negative`| ++--------------------------------------------------------------+ + + +-Wshift-count-overflow +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`shift count >= width of type`| ++-------------------------------------------------------------------+ + + +-Wshift-negative-value +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`shifting a negative signed value is undefined`| ++------------------------------------------------------------------------------------+ + + +-Wshift-op-parentheses +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`operator '`:placeholder:`A`:diagtext:`' has lower precedence than '`:placeholder:`B`:diagtext:`'; '`:placeholder:`B`:diagtext:`' will be evaluated first`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wshift-overflow +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`signed shift result (`:placeholder:`A`:diagtext:`) requires` |nbsp| :placeholder:`B` |nbsp| :diagtext:`bits to represent, but` |nbsp| :placeholder:`C` |nbsp| :diagtext:`only has` |nbsp| :placeholder:`D` |nbsp| :diagtext:`bits`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wshift-sign-overflow +--------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`signed shift result (`:placeholder:`A`:diagtext:`) sets the sign bit of the shift expression's type (`:placeholder:`B`:diagtext:`) and becomes negative`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wshorten-64-to-32 +------------------ +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion loses integer precision:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsign-compare +-------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of integers of different signs:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`and` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsign-conversion +----------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion changes signedness:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`operand of ? changes signedness:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsign-promo +------------ +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wsizeof-array-argument +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`sizeof on array function parameter will return size of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`instead of` |nbsp| :placeholder:`B`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsizeof-array-decay +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`sizeof on pointer operation will return size of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`instead of` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsizeof-pointer-memaccess +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'`:placeholder:`A`:diagtext:`' call operates on objects of type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`while the size is based on a different type` |nbsp| :placeholder:`C`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+---------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument to 'sizeof' in` |nbsp| :placeholder:`A` |nbsp| :diagtext:`call is the same pointer type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`as the` |nbsp| |+-----------------------+|:diagtext:`; expected` |nbsp| :placeholder:`D` |nbsp| :diagtext:`or an explicit length`| +| ||:diagtext:`destination`|| | +| |+-----------------------+| | +| ||:diagtext:`source` || | +| |+-----------------------+| | ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+---------------------------------------------------------------------------------------+ + + +-Wsometimes-uninitialized +------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+----------------------+--------------------------------------------------+--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is` |nbsp| |+--------------------+| |nbsp| :diagtext:`uninitialized whenever` |nbsp| |+------------------------------------------------------------------------------------------------------------+| +| ||:diagtext:`used` || ||+---------------------------------------------------------------+-------------------+ || +| |+--------------------+| |||:diagtext:`'`:placeholder:`D`:diagtext:`' condition is` |nbsp| |+-----------------+| || +| ||:diagtext:`captured`|| ||| ||:diagtext:`true` || || +| |+--------------------+| ||| |+-----------------+| || +| | | ||| ||:diagtext:`false`|| || +| | | ||| |+-----------------+| || +| | | ||+---------------------------------------------------------------+-------------------+ || +| | | |+------------------------------------------------------------------------------------------------------------+| +| | | ||+-------------------------------------------------------+--------------------------------------------------+|| +| | | |||:diagtext:`'`:placeholder:`D`:diagtext:`' loop` |nbsp| |+------------------------------------------------+||| +| | | ||| ||:diagtext:`is entered` |||| +| | | ||| |+------------------------------------------------+||| +| | | ||| ||:diagtext:`exits because its condition is false`|||| +| | | ||| |+------------------------------------------------+||| +| | | ||+-------------------------------------------------------+--------------------------------------------------+|| +| | | |+------------------------------------------------------------------------------------------------------------+| +| | | ||+-------------------------------------------------------+--------------------------------------------------+|| +| | | |||:diagtext:`'`:placeholder:`D`:diagtext:`' loop` |nbsp| |+------------------------------------------------+||| +| | | ||| ||:diagtext:`condition is true` |||| +| | | ||| |+------------------------------------------------+||| +| | | ||| ||:diagtext:`exits because its condition is false`|||| +| | | ||| |+------------------------------------------------+||| +| | | ||+-------------------------------------------------------+--------------------------------------------------+|| +| | | |+------------------------------------------------------------------------------------------------------------+| +| | | ||+----------------------------------------------------------------------+ || +| | | |||:diagtext:`switch` |nbsp| :placeholder:`D` |nbsp| :diagtext:`is taken`| || +| | | ||+----------------------------------------------------------------------+ || +| | | |+------------------------------------------------------------------------------------------------------------+| +| | | ||:diagtext:`its declaration is reached` || +| | | |+------------------------------------------------------------------------------------------------------------+| +| | | ||+---------------------------------------------+ || +| | | |||:placeholder:`D` |nbsp| :diagtext:`is called`| || +| | | ||+---------------------------------------------+ || +| | | |+------------------------------------------------------------------------------------------------------------+| ++-----------------------------------------------------------------------------------------------------+----------------------+--------------------------------------------------+--------------------------------------------------------------------------------------------------------------+ + + +-Wsource-uses-openmp +-------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`OpenMP only allows an ordered construct with the simd clause nested in a simd construct`| ++------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unexpected '#pragma omp ...' in program`| ++------------------------------------------------------------------------------+ + + +-Wspir-compat +------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`sampler initializer has invalid` |nbsp| :placeholder:`A` |nbsp| :diagtext:`bits`| ++----------------------------------------------------------------------------------------------------------------------+ + + +-Wstack-protector +----------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstatic-float-init +------------------- +This diagnostic is enabled by default. + +Also controls `-Wgnu-static-float-init`_. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:error:`error:` |nbsp| :diagtext:`in-class initializer for static data member of type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`requires 'constexpr' specifier`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstatic-in-inline +------------------ +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------+----------------------+-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`is used in an inline function with external linkage`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`variable`|| | +| |+--------------------+| | ++-----------------------------------------------------+----------------------+-----------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------+----------------------+-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`is used in an inline function with external linkage`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`variable`|| | +| |+--------------------+| | ++-----------------------------------------------------+----------------------+-----------------------------------------------------------------------------------------------+ + + +-Wstatic-inline-explicit-instantiation +-------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------+--------------------+--------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring '`|+------------------+|:diagtext:`' keyword on explicit template instantiation`| +| ||:diagtext:`static`|| | +| |+------------------+| | +| ||:diagtext:`inline`|| | +| |+------------------+| | ++-------------------------------------------------+--------------------+--------------------------------------------------------+ + + +-Wstatic-local-in-inline +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`non-constant static local variable in inline function may be different in different files`| ++--------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstatic-self-init +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`static variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is suspiciously used within its own initialization`| ++----------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstrict-aliasing +----------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-aliasing=0 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-aliasing=1 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-aliasing=2 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow +----------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow=0 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow=1 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow=2 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow=3 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow=4 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-overflow=5 +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-prototypes +------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wstrict-selector-match +----------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multiple methods named` |nbsp| :placeholder:`A` |nbsp| :diagtext:`found`| ++--------------------------------------------------------------------------------------------------------------+ + + +-Wstring-compare +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------+------------------------------+--------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`result of comparison against` |nbsp| |+----------------------------+| |nbsp| :diagtext:`is unspecified (use strncmp instead)`| +| ||:diagtext:`a string literal`|| | +| |+----------------------------+| | +| ||:diagtext:`@encode` || | +| |+----------------------------+| | ++---------------------------------------------------------------------------+------------------------------+--------------------------------------------------------+ + + +-Wstring-conversion +------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`implicit conversion turns string literal into bool:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstring-plus-char +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`adding` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to a string pointer does not append to the string`| ++------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstring-plus-int +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`adding` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to a string does not append to the string`| ++----------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstrlcpy-strlcat-size +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`size argument in` |nbsp| :placeholder:`A` |nbsp| :diagtext:`call appears to be size of the source; expected the size of the destination`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wstrncat-size +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`the value of the size argument in 'strncat' is too large, might lead to a buffer overflow`| ++--------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`size argument in 'strncat' call appears to be size of the source`| ++-------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`the value of the size argument to 'strncat' is wrong`| ++-------------------------------------------------------------------------------------------+ + + +-Wsuper-class-method-mismatch +----------------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`method parameter type` |nbsp| :diagtext:`does not match super class method parameter type`| ++--------------------------------------------------------------------------------------------------------------------------------+ + + +-Wswitch +-------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`overflow converting case value to switch condition type (`:placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B`:diagtext:`)`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+-----------------------------------------------------------------------------------------------+ || +| |||:diagtext:`:enumeration value` |nbsp| :placeholder:`B` |nbsp| :diagtext:`not handled in switch`| || +| ||+-----------------------------------------------------------------------------------------------+ || +| |+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+-----------------------------------------------------------------------------------------------------------------------------------------------+ || +| |||:diagtext:`:enumeration values` |nbsp| :placeholder:`B` |nbsp| :diagtext:`and` |nbsp| :placeholder:`C` |nbsp| :diagtext:`not handled in switch`| || +| ||+-----------------------------------------------------------------------------------------------------------------------------------------------+ || +| |+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ || +| |||:diagtext:`:enumeration values` |nbsp| :placeholder:`B`:diagtext:`,` |nbsp| :placeholder:`C`:diagtext:`, and` |nbsp| :placeholder:`D` |nbsp| :diagtext:`not handled in switch`| || +| ||+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ || +| |+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|| +| |||:diagtext:`:`:placeholder:`A` |nbsp| :diagtext:`enumeration values not handled in switch:` |nbsp| :placeholder:`B`:diagtext:`,` |nbsp| :placeholder:`C`:diagtext:`,` |nbsp| :placeholder:`D`:diagtext:`...`||| +| ||+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|| +| |+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| ++---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`case value not in enumerated type` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------------------------+ + + +-Wswitch-bool +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`switch condition has boolean value`| ++-------------------------------------------------------------------------+ + + +-Wswitch-default +---------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wswitch-enum +------------- +**Diagnostic text:** + ++---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+----------------------------------------------------------------------------------------------------------+ || +| |||:diagtext:`:enumeration value` |nbsp| :placeholder:`B` |nbsp| :diagtext:`not explicitly handled in switch`| || +| ||+----------------------------------------------------------------------------------------------------------+ || +| |+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+----------------------------------------------------------------------------------------------------------------------------------------------------------+ || +| |||:diagtext:`:enumeration values` |nbsp| :placeholder:`B` |nbsp| :diagtext:`and` |nbsp| :placeholder:`C` |nbsp| :diagtext:`not explicitly handled in switch`| || +| ||+----------------------------------------------------------------------------------------------------------------------------------------------------------+ || +| |+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ || +| |||:diagtext:`:enumeration values` |nbsp| :placeholder:`B`:diagtext:`,` |nbsp| :placeholder:`C`:diagtext:`, and` |nbsp| :placeholder:`D` |nbsp| :diagtext:`not explicitly handled in switch`| || +| ||+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ || +| |+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| +| ||+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|| +| |||:diagtext:`:`:placeholder:`A` |nbsp| :diagtext:`enumeration values not explicitly handled in switch:` |nbsp| :placeholder:`B`:diagtext:`,` |nbsp| :placeholder:`C`:diagtext:`,` |nbsp| :placeholder:`D`:diagtext:`...`||| +| ||+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|| +| |+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| ++---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsync-fetch-and-nand-semantics-changed +--------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wsynth +------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wtautological-compare +---------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wtautological-constant-out-of-range-compare`_, `-Wtautological-overlap-compare`_, `-Wtautological-pointer-compare`_, `-Wtautological-undefined-compare`_. + +**Diagnostic text:** + ++---------------------------+---------------------------+--------------------------------------------------+------------------------+ +|:warning:`warning:` |nbsp| |+-------------------------+|:diagtext:`comparison always evaluates to` |nbsp| |+----------------------+| +| ||:diagtext:`self-` || ||:diagtext:`false` || +| |+-------------------------+| |+----------------------+| +| ||:diagtext:`array` |nbsp| || ||:diagtext:`true` || +| |+-------------------------+| |+----------------------+| +| | | ||:diagtext:`a constant`|| +| | | |+----------------------+| ++---------------------------+---------------------------+--------------------------------------------------+------------------------+ + ++-------------------------------------------------------------------------------------+-------------------+ +|:warning:`warning:` |nbsp| :diagtext:`bitwise comparison always evaluates to` |nbsp| |+-----------------+| +| ||:diagtext:`false`|| +| |+-----------------+| +| ||:diagtext:`true` || +| |+-----------------+| ++-------------------------------------------------------------------------------------+-------------------+ + ++-------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of unsigned`|+------------------------+| |nbsp| :diagtext:`expression` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is always` |nbsp| :placeholder:`B`| +| || || | +| |+------------------------+| | +| || |nbsp| :diagtext:`enum`|| | +| |+------------------------+| | ++-------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------+--------------------------+----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`unsigned`|+------------------------+| |nbsp| :diagtext:`expression is always` |nbsp| :placeholder:`B`| +| || || | +| |+------------------------+| | +| || |nbsp| :diagtext:`enum`|| | +| |+------------------------+| | ++--------------------------------------------------------------------------------------------------------+--------------------------+----------------------------------------------------------------+ + + +-Wtautological-constant-out-of-range-compare +-------------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------+------------------------------------------------+--------------------------------+----------------------------------------------------------+-------------------------------------+-------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of` |nbsp| |+----------------------------------------------+| |nbsp| :diagtext:`with` |nbsp| |+--------------------------------------------------------+| |nbsp| :diagtext:`is always` |nbsp| |+-----------------+| +| ||+--------------------------------------------+|| ||+------------------------------------------------------+|| ||:diagtext:`false`|| +| |||:diagtext:`constant` |nbsp| :placeholder:`A`||| |||:diagtext:`expression of type` |nbsp| :placeholder:`C`||| |+-----------------+| +| ||+--------------------------------------------+|| ||+------------------------------------------------------+|| ||:diagtext:`true` || +| |+----------------------------------------------+| |+--------------------------------------------------------+| |+-----------------+| +| ||:diagtext:`true` || ||:diagtext:`boolean expression` || | | +| |+----------------------------------------------+| |+--------------------------------------------------------+| | | +| ||:diagtext:`false` || | | | | +| |+----------------------------------------------+| | | | | ++------------------------------------------------------------+------------------------------------------------+--------------------------------+----------------------------------------------------------+-------------------------------------+-------------------+ + + +-Wtautological-overlap-compare +------------------------------ +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------+-------------------+ +|:warning:`warning:` |nbsp| :diagtext:`overlapping comparisons always evaluate to` |nbsp| |+-----------------+| +| ||:diagtext:`false`|| +| |+-----------------+| +| ||:diagtext:`true` || +| |+-----------------+| ++-----------------------------------------------------------------------------------------+-------------------+ + + +-Wtautological-pointer-compare +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------+---------------------------+----------------------------------------------------------+-------------------------+----------------------------------------+-------------------+--------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of nonnull` |nbsp| |+-------------------------+| |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`'` |nbsp| |+-----------------------+|:diagtext:`equal to a null pointer is '`|+-----------------+|:diagtext:`' on first encounter`| +| ||:diagtext:`function call`|| ||:diagtext:`not` |nbsp| || ||:diagtext:`true` || | +| |+-------------------------+| |+-----------------------+| |+-----------------+| | +| ||:diagtext:`parameter` || || || ||:diagtext:`false`|| | +| |+-------------------------+| |+-----------------------+| |+-----------------+| | ++--------------------------------------------------------------------+---------------------------+----------------------------------------------------------+-------------------------+----------------------------------------+-------------------+--------------------------------+ + ++------------------------------------------------------------+------------------------+----------------------------------------------------------+-------------------------+-----------------------------------------------------+-------------------+ +|:warning:`warning:` |nbsp| :diagtext:`comparison of` |nbsp| |+----------------------+| |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`'` |nbsp| |+-----------------------+|:diagtext:`equal to a null pointer is always` |nbsp| |+-----------------+| +| ||:diagtext:`address of`|| ||:diagtext:`not` |nbsp| || ||:diagtext:`true` || +| |+----------------------+| |+-----------------------+| |+-----------------+| +| ||:diagtext:`function` || || || ||:diagtext:`false`|| +| |+----------------------+| |+-----------------------+| |+-----------------+| +| ||:diagtext:`array` || | | | | +| |+----------------------+| | | | | ++------------------------------------------------------------+------------------------+----------------------------------------------------------+-------------------------+-----------------------------------------------------+-------------------+ + + +-Wtautological-undefined-compare +-------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to` |nbsp| |+-----------------+| +| ||:diagtext:`true` || +| |+-----------------+| +| ||:diagtext:`false`|| +| |+-----------------+| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to` |nbsp| |+-----------------+| +| ||:diagtext:`true` || +| |+-----------------+| +| ||:diagtext:`false`|| +| |+-----------------+| ++------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------+ + + +-Wtentative-definition-incomplete-type +-------------------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`tentative definition of variable with internal linkage has incomplete non-array type` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wthread-safety +--------------- +Controls `-Wthread-safety-analysis`_, `-Wthread-safety-attributes`_, `-Wthread-safety-precise`_, `-Wthread-safety-reference`_. + + +-Wthread-safety-analysis +------------------------ +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' must be acquired before '`:placeholder:`C`:diagtext:`'`| ++----------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Cycle in acquired\_before/after dependencies, starting with '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot resolve lock expression`| ++---------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`acquiring` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' that is already held`| ++-----------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expecting` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' to be held at start of each loop`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expecting` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' to be held at the end of function`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`cannot call function '`:placeholder:`B`:diagtext:`' while` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`C`:diagtext:`' is held`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`calling function '`:placeholder:`B`:diagtext:`' requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||+------------------------------------------+ || +| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||+------------------------------------------+ || +| |+--------------------------------------------------------+| +| ||+------------------------------------------------------+|| +| |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| ||+------------------------------------------------------+|| +| |+--------------------------------------------------------+| ++---------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' is acquired exclusively and shared in the same scope`| ++--------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' is not held on every path through here`| ++------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' is still held at the end of function`| ++----------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`releasing` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' that was not held`| ++--------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------+-----------------------+--------------------------------------------+-----------------------+--------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`releasing` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' using` |nbsp| |+---------------------+| |nbsp| :diagtext:`access, expected` |nbsp| |+---------------------+| |nbsp| :diagtext:`access`| +| ||:diagtext:`shared` || ||:diagtext:`shared` || | +| |+---------------------+| |+---------------------+| | +| ||:diagtext:`exclusive`|| ||:diagtext:`exclusive`|| | +| |+---------------------+| |+---------------------+| | ++----------------------------------------------------------------------------------------------------------------------------------------+-----------------------+--------------------------------------------+-----------------------+--------------------------+ + ++---------------------------+---------------------+---------------------------------------------------------------------------------------------------+-----------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------+| |nbsp| :diagtext:`the value pointed to by '`:placeholder:`A`:diagtext:`' requires holding` |nbsp| |+---------------------------------+| +| ||:diagtext:`reading`|| ||:diagtext:`any mutex` || +| |+-------------------+| |+---------------------------------+| +| ||:diagtext:`writing`|| ||:diagtext:`any mutex exclusively`|| +| |+-------------------+| |+---------------------------------+| ++---------------------------+---------------------+---------------------------------------------------------------------------------------------------+-----------------------------------+ + ++---------------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------+| |nbsp| :diagtext:`the value pointed to by '`:placeholder:`B`:diagtext:`' requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||:diagtext:`reading`|| ||+------------------------------------------+ || +| |+-------------------+| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||:diagtext:`writing`|| ||+------------------------------------------+ || +| |+-------------------+| |+--------------------------------------------------------+| +| | | ||+------------------------------------------------------+|| +| | | |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| | | ||+------------------------------------------------------+|| +| | | |+--------------------------------------------------------+| ++---------------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + ++---------------------------+---------------------+------------------------------------------------------------------------------------+-----------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------+| |nbsp| :diagtext:`variable '`:placeholder:`A`:diagtext:`' requires holding` |nbsp| |+---------------------------------+| +| ||:diagtext:`reading`|| ||:diagtext:`any mutex` || +| |+-------------------+| |+---------------------------------+| +| ||:diagtext:`writing`|| ||:diagtext:`any mutex exclusively`|| +| |+-------------------+| |+---------------------------------+| ++---------------------------+---------------------+------------------------------------------------------------------------------------+-----------------------------------+ + ++---------------------------+---------------------+------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------+| |nbsp| :diagtext:`variable '`:placeholder:`B`:diagtext:`' requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||:diagtext:`reading`|| ||+------------------------------------------+ || +| |+-------------------+| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||:diagtext:`writing`|| ||+------------------------------------------+ || +| |+-------------------+| |+--------------------------------------------------------+| +| | | ||+------------------------------------------------------+|| +| | | |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| | | ||+------------------------------------------------------+|| +| | | |+--------------------------------------------------------+| ++---------------------------+---------------------+------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + + +-Wthread-safety-attributes +-------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`invalid capability name '`:placeholder:`A`:diagtext:`'; capability name must be 'mutex' or 'role'`| ++----------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute requires arguments whose type is annotated with 'capability' attribute; type here is` |nbsp| :placeholder:`B`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute can only be applied in a context annotated with 'capability("mutex")' attribute`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`only applies to pointer types; type here is` |nbsp| :placeholder:`B`| ++----------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute because its argument is invalid`| ++------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wthread-safety-beta +-------------------- +**Diagnostic text:** + ++------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Thread safety beta warning.`| ++------------------------------------------------------------------+ + + +-Wthread-safety-negative +------------------------ +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`acquiring` |nbsp| :placeholder:`A` |nbsp| :diagtext:`'`:placeholder:`B`:diagtext:`' requires negative capability '`:placeholder:`C`:diagtext:`'`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wthread-safety-precise +----------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`calling function '`:placeholder:`B`:diagtext:`' requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||+------------------------------------------+ || +| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||+------------------------------------------+ || +| |+--------------------------------------------------------+| +| ||+------------------------------------------------------+|| +| |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| ||+------------------------------------------------------+|| +| |+--------------------------------------------------------+| ++---------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + ++---------------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------+| |nbsp| :diagtext:`the value pointed to by '`:placeholder:`B`:diagtext:`' requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||:diagtext:`reading`|| ||+------------------------------------------+ || +| |+-------------------+| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||:diagtext:`writing`|| ||+------------------------------------------+ || +| |+-------------------+| |+--------------------------------------------------------+| +| | | ||+------------------------------------------------------+|| +| | | |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| | | ||+------------------------------------------------------+|| +| | | |+--------------------------------------------------------+| ++---------------------------+---------------------+---------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + ++---------------------------+---------------------+------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+-------------------+| |nbsp| :diagtext:`variable '`:placeholder:`B`:diagtext:`' requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||:diagtext:`reading`|| ||+------------------------------------------+ || +| |+-------------------+| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||:diagtext:`writing`|| ||+------------------------------------------+ || +| |+-------------------+| |+--------------------------------------------------------+| +| | | ||+------------------------------------------------------+|| +| | | |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| | | ||+------------------------------------------------------+|| +| | | |+--------------------------------------------------------+| ++---------------------------+---------------------+------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + + +-Wthread-safety-reference +------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`passing variable '`:placeholder:`B`:diagtext:`' by reference requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||+------------------------------------------+ || +| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||+------------------------------------------+ || +| |+--------------------------------------------------------+| +| ||+------------------------------------------------------+|| +| |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| ||+------------------------------------------------------+|| +| |+--------------------------------------------------------+| ++----------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`passing the value that '`:placeholder:`B`:diagtext:`' points to by reference requires holding` |nbsp| :placeholder:`A` |nbsp| |+--------------------------------------------------------+| +| ||+------------------------------------------+ || +| |||:diagtext:`'`:placeholder:`C`:diagtext:`'`| || +| ||+------------------------------------------+ || +| |+--------------------------------------------------------+| +| ||+------------------------------------------------------+|| +| |||:diagtext:`'`:placeholder:`C`:diagtext:`' exclusively`||| +| ||+------------------------------------------------------+|| +| |+--------------------------------------------------------+| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------+ + + +-Wthread-safety-verbose +----------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`Thread safety verbose warning.`| ++---------------------------------------------------------------------+ + + +-Wtrigraphs +----------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`trigraph converted to '`:placeholder:`A`:diagtext:`' character`| ++-----------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`trigraph ends block comment`| ++------------------------------------------------------------------+ + ++-------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`trigraph ignored`| ++-------------------------------------------------------+ + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignored trigraph would end block comment`| ++-------------------------------------------------------------------------------+ + + +-Wtype-limits +------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wtype-safety +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`specified` |nbsp| :placeholder:`A` |nbsp| :diagtext:`type tag requires a null pointer`| ++----------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`doesn't match specified` |nbsp| :placeholder:`B` |nbsp| :diagtext:`type tag` |nbsp| |+---------------------------------------------------+| +| ||+-------------------------------------------------+|| +| |||:diagtext:`that requires` |nbsp| :placeholder:`D`||| +| ||+-------------------------------------------------+|| +| |+---------------------------------------------------+| +| || || +| |+---------------------------------------------------+| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`this type tag was not designed to be used with this function`| ++---------------------------------------------------------------------------------------------------+ + + +-Wtypedef-redefinition +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redefinition of typedef` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is a C11 feature`| ++--------------------------------------------------------------------------------------------------------------------------+ + + +-Wtypename-missing +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`missing 'typename' prior to dependent type name '`:placeholder:`A`:placeholder:`B`:diagtext:`'`| ++-------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunavailable-declarations +-------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may be unavailable because the receiver type is unknown`| ++----------------------------------------------------------------------------------------------------------------------+ + + +-Wundeclared-selector +--------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`undeclared selector` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`undeclared selector` |nbsp| :placeholder:`A`:diagtext:`; did you mean` |nbsp| :placeholder:`B`:diagtext:`?`| ++-------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wundef +------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not defined, evaluates to 0`| ++---------------------------------------------------------------------------------------------+ + + +-Wundefined-bool-conversion +--------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true`| ++-----------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wundefined-func-template +------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instantiation of function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`required here, but no definition is available`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wundefined-inline +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`inline function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not defined`| ++----------------------------------------------------------------------------------------------------------------+ + + +-Wundefined-internal +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+----------------------+-----------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`has internal linkage but is not defined`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`variable`|| | +| |+--------------------+| | ++---------------------------+----------------------+-----------------------------------------------------------------------------------+ + + +-Wundefined-reinterpret-cast +---------------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`dereference of type` |nbsp| :placeholder:`B` |nbsp| :diagtext:`that was reinterpret\_cast from type` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has undefined behavior`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reinterpret\_cast from` |nbsp| :placeholder:`A` |nbsp| :diagtext:`to` |nbsp| :placeholder:`B` |nbsp| :diagtext:`has undefined behavior`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wundefined-var-template +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`instantiation of variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`required here, but no definition is available`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunevaluated-expression +------------------------ +This diagnostic is enabled by default. + +Also controls `-Wpotentially-evaluated-expression`_. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression with side effects has no effect in an unevaluated context`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wunguarded-availability +------------------------ +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is only available conditionally`| ++----------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`may be partial because the receiver type is unknown`| ++------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is partial:` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is only available on` |nbsp| :placeholder:`B` |nbsp| :placeholder:`C` |nbsp| :diagtext:`or newer`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunicode +--------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incomplete universal character name; treating as '\\' followed by identifier`| ++-------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`\\`:placeholder:`A` |nbsp| :diagtext:`used with no following hex digits; treating as '\\' followed by identifier`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`universal character name refers to a surrogate character`| ++-----------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`universal character names are only valid in C99 or C++; treating as '\\' followed by identifier`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`universal character names are only valid in C99 or C++`| ++---------------------------------------------------------------------------------------------+ + + +-Wunicode-whitespace +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`treating Unicode character as whitespace`| ++-------------------------------------------------------------------------------+ + + +-Wuninitialized +--------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wsometimes-uninitialized`_, `-Wstatic-self-init`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`base class` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is uninitialized when used here to access` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`field` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is uninitialized when used here`| ++-----------------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not yet bound to a value when used here`| ++--------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`block pointer variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is uninitialized when captured by block`| ++------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is uninitialized when used within its own initialization`| ++---------------------------------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`reference` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not yet bound to a value when used within its own initialization`| ++---------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------------------------------------------------------+-------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is uninitialized when` |nbsp| |+-----------------------------+| +| ||:diagtext:`used here` || +| |+-----------------------------+| +| ||:diagtext:`captured by block`|| +| |+-----------------------------+| ++------------------------------------------------------------------------------------------------------------------------+-------------------------------+ + + +-Wunknown-argument +------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown argument ignored in clang-cl: '`:placeholder:`A`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wunknown-attributes +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown attribute` |nbsp| :placeholder:`A` |nbsp| :diagtext:`ignored`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wunknown-escape-sequence +------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown escape sequence '\\`:placeholder:`A`:diagtext:`'`| ++-----------------------------------------------------------------------------------------------+ + + +-Wunknown-pragmas +----------------- +Some of the diagnostics controlled by this flag are enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected 'ON' or 'OFF' or 'DEFAULT' in pragma`| ++------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expected end of directive in pragma`| ++--------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown pragma in STDC namespace`| ++-----------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma diagnostic pop could not pop, no matching push`| ++--------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'`| ++--------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma diagnostic expected option name (e.g. "-Wundef")`| ++----------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unexpected token in pragma diagnostic`| ++----------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown warning group '`:placeholder:`A`:diagtext:`', ignored`| ++----------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown pragma ignored`| ++-------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma include\_alias expected '`:placeholder:`A`:diagtext:`'`| ++----------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma include\_alias expected include filename`| ++--------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`angle-bracketed include <`:placeholder:`A`:diagtext:`> cannot be aliased to double-quoted include "`:placeholder:`B`:diagtext:`"`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`double-quoted include "`:placeholder:`A`:diagtext:`" cannot be aliased to angle-bracketed include <`:placeholder:`B`:diagtext:`>`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma warning expected '`:placeholder:`A`:diagtext:`'`| ++----------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma warning expected a warning number`| ++--------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma warning(push, level) requires a level between 0 and 4`| ++----------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`#pragma warning expected 'push', 'pop', 'default', 'disable', 'error', 'once', 'suppress', 1, 2, 3, or 4`| ++-----------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`pragma STDC FENV\_ACCESS ON is not supported, ignoring pragma`| ++----------------------------------------------------------------------------------------------------+ + + +-Wunknown-sanitizers +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown sanitizer '`:placeholder:`A`:diagtext:`' ignored`| ++-----------------------------------------------------------------------------------------------+ + + +-Wunknown-warning-option +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------+---------------------+---------------------------------------------------------+--------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown` |nbsp| |+-------------------+| |nbsp| :diagtext:`option '`:placeholder:`B`:diagtext:`'`|+------------------------------------------------------------+| +| ||:diagtext:`warning`|| || || +| |+-------------------+| |+------------------------------------------------------------+| +| ||:diagtext:`remark` || ||+----------------------------------------------------------+|| +| |+-------------------+| |||:diagtext:`; did you mean '`:placeholder:`D`:diagtext:`'?`||| +| | | ||+----------------------------------------------------------+|| +| | | |+------------------------------------------------------------+| ++------------------------------------------------------+---------------------+---------------------------------------------------------+--------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unknown` |nbsp| :placeholder:`A` |nbsp| :diagtext:`warning specifier: '`:placeholder:`B`:diagtext:`'`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunnamed-type-template-args +---------------------------- +Some of the diagnostics controlled by this flag are enabled by default. + +Also controls `-Wc++98-compat-unnamed-type-template-args`_. + +**Diagnostic text:** + ++--------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`template argument uses unnamed type`| ++--------------------------------------------------------------------------+ + + +-Wunneeded-internal-declaration +------------------------------- +**Diagnostic text:** + ++---------------------------+----------------------+---------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| |+--------------------+| |nbsp| :placeholder:`B` |nbsp| :diagtext:`is not needed and will not be emitted`| +| ||:diagtext:`function`|| | +| |+--------------------+| | +| ||:diagtext:`variable`|| | +| |+--------------------+| | ++---------------------------+----------------------+---------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'static' function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`declared in header file should be declared 'static inline'`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunneeded-member-function +-------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`member function` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not needed and will not be emitted`| ++---------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunreachable-code +------------------ +Also controls `-Wunreachable-code-loop-increment`_. + +**Diagnostic text:** + ++------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`code will never be executed`| ++------------------------------------------------------------------+ + + +-Wunreachable-code-aggressive +----------------------------- +Controls `-Wunreachable-code`_, `-Wunreachable-code-break`_, `-Wunreachable-code-return`_. + + +-Wunreachable-code-break +------------------------ +**Diagnostic text:** + ++---------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'break' will never be executed`| ++---------------------------------------------------------------------+ + + +-Wunreachable-code-loop-increment +--------------------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`loop will run at most once (loop increment never executed)`| ++-------------------------------------------------------------------------------------------------+ + + +-Wunreachable-code-return +------------------------- +**Diagnostic text:** + ++----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`'return' will never be executed`| ++----------------------------------------------------------------------+ + + +-Wunsequenced +------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`multiple unsequenced modifications to` |nbsp| :placeholder:`A`| ++----------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unsequenced modification and access to` |nbsp| :placeholder:`A`| ++-----------------------------------------------------------------------------------------------------+ + + +-Wunsupported-cb +---------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring '-mcompact-branches=' option because the '`:placeholder:`A`:diagtext:`' architecture does not support it`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunsupported-dll-base-class-template +------------------------------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------+------------------------------------+------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`propagating dll attribute to` |nbsp| |+----------------------------------+| |nbsp| :diagtext:`base class template without dll attribute is not supported`| +| ||:diagtext:`already instantiated` || | +| |+----------------------------------+| | +| ||:diagtext:`explicitly specialized`|| | +| |+----------------------------------+| | ++---------------------------------------------------------------------------+------------------------------------+------------------------------------------------------------------------------+ + + +-Wunsupported-friend +-------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`dependent nested name specifier '`:placeholder:`A`:diagtext:`' for friend template declaration is not supported; ignoring this friend declaration`| ++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`dependent nested name specifier '`:placeholder:`A`:diagtext:`' for friend class declaration is not supported; turning off access control for` |nbsp| :placeholder:`B`| ++-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunsupported-nan +----------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring '-mnan=2008' option because the '`:placeholder:`A`:diagtext:`' architecture does not support it`| ++-----------------------------------------------------------------------------------------------------------------------------------------------+ + ++-------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring '-mnan=legacy' option because the '`:placeholder:`A`:diagtext:`' architecture does not support it`| ++-------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunsupported-visibility +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`target does not support 'protected' visibility; using 'default'`| ++------------------------------------------------------------------------------------------------------+ + + +-Wunused +-------- +Some of the diagnostics controlled by this flag are enabled by default. + +Controls `-Wunused-argument`_, `-Wunused-function`_, `-Wunused-label`_, `-Wunused-local-typedef`_, `-Wunused-private-field`_, `-Wunused-property-ivar`_, `-Wunused-value`_, `-Wunused-variable`_. + + +-Wunused-argument +----------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wunused-command-line-argument +------------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`joined argument expects additional value: '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument '-fdiagnostics-show-hotness' requires profile-guided optimization information`| ++-----------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------+----------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A`:diagtext:`: '`:placeholder:`B`:diagtext:`' input unused`|+--------------------------------------------------------------------+| +| ||+------------------------------------------------------------------+|| +| ||| |nbsp| :diagtext:`when '`:placeholder:`D`:diagtext:`' is present`||| +| ||+------------------------------------------------------------------+|| +| |+--------------------------------------------------------------------+| +| || || +| |+--------------------------------------------------------------------+| ++----------------------------------------------------------------------------------------------------+----------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A`:diagtext:`: '`:placeholder:`B`:diagtext:`' input unused in cpp mode`| ++----------------------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A`:diagtext:`: previously preprocessed input`|+---------------------------------------------------------------------------+| +| ||+-------------------------------------------------------------------------+|| +| ||| |nbsp| :diagtext:`unused when '`:placeholder:`C`:diagtext:`' is present`||| +| ||+-------------------------------------------------------------------------+|| +| |+---------------------------------------------------------------------------+| +| || || +| |+---------------------------------------------------------------------------+| ++--------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+ + ++---------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`argument unused during compilation: '`:placeholder:`A`:diagtext:`'`| ++---------------------------------------------------------------------------------------------------------+ + + +-Wunused-comparison +------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------+-----------------------------------------+--------------------------------------------+ +|:warning:`warning:` |nbsp| |+---------------------------------------+| |nbsp| :diagtext:`comparison result unused`| +| ||+----------------+--------------------+|| | +| |||+--------------+|:diagtext:`equality`||| | +| |||| || ||| | +| |||+--------------+| ||| | +| ||||:diagtext:`in`|| ||| | +| |||+--------------+| ||| | +| ||+----------------+--------------------+|| | +| |+---------------------------------------+| | +| ||:diagtext:`relational` || | +| |+---------------------------------------+| | ++---------------------------+-----------------------------------------+--------------------------------------------+ + + +-Wunused-const-variable +----------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused variable` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------+ + + +-Wunused-exception-parameter +---------------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused exception parameter` |nbsp| :placeholder:`A`| ++-----------------------------------------------------------------------------------------+ + + +-Wunused-function +----------------- +Also controls `-Wunneeded-internal-declaration`_. + +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused function` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------+ + + +-Wunused-getter-return-value +---------------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`property access result unused - getters should not be used for side effects`| ++------------------------------------------------------------------------------------------------------------------+ + + +-Wunused-label +-------------- +**Diagnostic text:** + ++---------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused label` |nbsp| :placeholder:`A`| ++---------------------------------------------------------------------------+ + + +-Wunused-local-typedef +---------------------- +**Diagnostic text:** + ++-----------------------------------------------------+------------------------+------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused` |nbsp| |+----------------------+| |nbsp| :placeholder:`B`| +| ||:diagtext:`typedef` || | +| |+----------------------+| | +| ||:diagtext:`type alias`|| | +| |+----------------------+| | ++-----------------------------------------------------+------------------------+------------------------+ + + +-Wunused-local-typedefs +----------------------- +Synonym for `-Wunused-local-typedef`_. + + +-Wunused-macros +--------------- +**Diagnostic text:** + ++--------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`macro is not used`| ++--------------------------------------------------------+ + + +-Wunused-member-function +------------------------ +Also controls `-Wunneeded-member-function`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused member function` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------+ + + +-Wunused-parameter +------------------ +**Diagnostic text:** + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused parameter` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------+ + + +-Wunused-private-field +---------------------- +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`private field` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is not used`| ++-----------------------------------------------------------------------------------------------------------+ + + +-Wunused-property-ivar +---------------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ivar` |nbsp| :placeholder:`A` |nbsp| :diagtext:`which backs the property is not referenced in this property's accessor`| ++-------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunused-result +--------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring return value of function declared with` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wunused-value +-------------- +This diagnostic is enabled by default. + +Also controls `-Wunevaluated-expression`_, `-Wunused-comparison`_, `-Wunused-result`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ignoring return value of function declared with` |nbsp| :placeholder:`A` |nbsp| :diagtext:`attribute`| ++-------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`container access result unused - container access should not be used for side effects`| ++----------------------------------------------------------------------------------------------------------------------------+ + ++---------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression result unused`| ++---------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression result unused; should this cast be to 'void'?`| ++-----------------------------------------------------------------------------------------------+ + + +-Wunused-variable +----------------- +Also controls `-Wunused-const-variable`_. + +**Diagnostic text:** + ++------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`unused variable` |nbsp| :placeholder:`A`| ++------------------------------------------------------------------------------+ + + +-Wunused-volatile-lvalue +------------------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`expression result unused; assign into a variable to force a volatile load`| ++----------------------------------------------------------------------------------------------------------------+ + + +-Wused-but-marked-unused +------------------------ +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`was marked unused but was used`| ++---------------------------------------------------------------------------------------------+ + + +-Wuser-defined-literals +----------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------+----------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`user-defined literal suffixes not starting with '\_' are reserved`|+--------------------------------------------------+| +| ||:diagtext:`; no literal will invoke this operator`|| +| |+--------------------------------------------------+| +| || || +| |+--------------------------------------------------+| ++--------------------------------------------------------------------------------------------------------+----------------------------------------------------+ + + +-Wvarargs +--------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++-----------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`second argument to 'va\_start' is not the last named parameter`| ++-----------------------------------------------------------------------------------------------------+ + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`second argument to 'va\_arg' is of promotable type` |nbsp| :placeholder:`A`:diagtext:`; this va\_arg has undefined behavior because arguments will be promoted to` |nbsp| :placeholder:`B`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + ++------------------------------------------------------+-----------------------------------------------------------------+---------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`passing` |nbsp| |+---------------------------------------------------------------+| |nbsp| :diagtext:`to 'va\_start' has undefined behavior`| +| ||:diagtext:`an object that undergoes default argument promotion`|| | +| |+---------------------------------------------------------------+| | +| ||:diagtext:`an object of reference type` || | +| |+---------------------------------------------------------------+| | +| ||:diagtext:`a parameter declared with the 'register' keyword` || | +| |+---------------------------------------------------------------+| | ++------------------------------------------------------+-----------------------------------------------------------------+---------------------------------------------------------+ + + +-Wvariadic-macros +----------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`named variadic macros are a GNU extension`| ++--------------------------------------------------------------------------------+ + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variadic macros are a C99 feature`| ++------------------------------------------------------------------------+ + + +-Wvector-conversion +------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------+----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`incompatible vector types` |nbsp| |+--------------------------------------------------------------+| +| ||:diagtext:`assigning to different types` || +| |+--------------------------------------------------------------+| +| ||:diagtext:`passing to parameter of different type` || +| |+--------------------------------------------------------------+| +| ||:diagtext:`returning from function with different return type`|| +| |+--------------------------------------------------------------+| +| ||:diagtext:`converting between types` || +| |+--------------------------------------------------------------+| +| ||:diagtext:`initializing with expression of different type` || +| |+--------------------------------------------------------------+| +| ||:diagtext:`sending to parameter of different type` || +| |+--------------------------------------------------------------+| +| ||:diagtext:`casting between types` || +| |+--------------------------------------------------------------+| ++------------------------------------------------------------------------+----------------------------------------------------------------+ + + +-Wvector-conversions +-------------------- +Synonym for `-Wvector-conversion`_. + + +-Wvexing-parse +-------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`empty parentheses interpreted as a function declaration`| ++----------------------------------------------------------------------------------------------+ + ++-----------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`parentheses were disambiguated as a function declaration`| ++-----------------------------------------------------------------------------------------------+ + + +-Wvisibility +------------ +This diagnostic is enabled by default. + +**Diagnostic text:** + ++---------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`declaration of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will not be visible outside of this function`| ++---------------------------------------------------------------------------------------------------------------------------------------------+ + ++----------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`redefinition of` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will not be visible outside of this function`| ++----------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wvla +----- +**Diagnostic text:** + ++-----------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable length array used`| ++-----------------------------------------------------------------+ + + +-Wvla-extension +--------------- +**Diagnostic text:** + ++-------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`variable length arrays are a C99 feature`| ++-------------------------------------------------------------------------------+ + + +-Wvoid-ptr-dereference +---------------------- +This diagnostic is enabled by default. + +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C++ does not allow indirection on operand of type` |nbsp| :placeholder:`A`| ++--------------------------------------------------------------------------------------------------------------------+ + + +-Wvolatile-register-var +----------------------- +This diagnostic flag exists for GCC compatibility, and has no effect in Clang. + +-Wweak-template-vtables +----------------------- +**Diagnostic text:** + ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`explicit template instantiation` |nbsp| :placeholder:`A` |nbsp| :diagtext:`will emit a vtable in every translation unit`| ++--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wweak-vtables +-------------- +**Diagnostic text:** + ++------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit`| ++------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + + +-Wwritable-strings +------------------ +This diagnostic is enabled by default. + +Also controls `-Wdeprecated-writable-strings`_. + +**Diagnostic text:** + ++-------------------------------------------------------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`ISO C++11 does not allow conversion from string literal to` |nbsp| :placeholder:`A`| ++-------------------------------------------------------------------------------------------------------------------------+ + + +-Wwrite-strings +--------------- +Synonym for `-Wwritable-strings`_. + + +-Wzero-length-array +------------------- +**Diagnostic text:** + ++------------------------------------------------------------------------+ +|:warning:`warning:` |nbsp| :diagtext:`zero size arrays are an extension`| ++------------------------------------------------------------------------+ + + diff --git a/docs/HowToSetupToolingForLLVM.rst b/docs/HowToSetupToolingForLLVM.rst index 924774210b3..3812fc9f46e 100644 --- a/docs/HowToSetupToolingForLLVM.rst +++ b/docs/HowToSetupToolingForLLVM.rst @@ -13,7 +13,7 @@ Introduction Clang Tooling needs a compilation database to figure out specific build options for each file. Currently it can create a compilation database -from the ``compilation_commands.json`` file, generated by CMake. When +from the ``compile_commands.json`` file, generated by CMake. When invoking clang tools, you can either specify a path to a build directory using a command line parameter ``-p`` or let Clang Tooling find this file in your source tree. In either case you need to configure your diff --git a/docs/JSONCompilationDatabase.rst b/docs/JSONCompilationDatabase.rst index 926dcba6a4a..8631e8365ce 100644 --- a/docs/JSONCompilationDatabase.rst +++ b/docs/JSONCompilationDatabase.rst @@ -78,6 +78,11 @@ The contracts for each field in the command object are: Parameters use shell quoting and shell escaping of quotes, with '``"``' and '``\``' being the only special characters. Shell expansion is not supported. +- **arguments:** The compile command executed as list of strings. + Either **arguments** or **command** is required. +- **output:** The name of the output created by this compilation step. + This field is optional. It can be used to distinguish different processing + modes of the same input file. Build System Integration ======================== diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index 51ac3ab1a8c..64e6ffb7f3e 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -1865,6 +1865,82 @@ The types ``T`` currently supported are: Note that the compiler does not guarantee that non-temporal loads or stores will be used. +C++ Coroutines support builtins +-------------------------------- + +.. warning:: + This is a work in progress. Compatibility across Clang/LLVM releases is not + guaranteed. + +Clang provides experimental builtins to support C++ Coroutines as defined by +http://wg21.link/P0057. The following four are intended to be used by the +standard library to implement `std::experimental::coroutine_handle` type. + +**Syntax**: + +.. code-block:: c + + void __builtin_coro_resume(void *addr); + void __builtin_coro_destroy(void *addr); + bool __builtin_coro_done(void *addr); + void *__builtin_coro_promise(void *addr, int alignment, bool from_promise) + +**Example of use**: + +.. code-block:: c++ + + template <> struct coroutine_handle { + void resume() const { __builtin_coro_resume(ptr); } + void destroy() const { __builtin_coro_destroy(ptr); } + bool done() const { return __builtin_coro_done(ptr); } + // ... + protected: + void *ptr; + }; + + template struct coroutine_handle : coroutine_handle<> { + // ... + Promise &promise() const { + return *reinterpret_cast( + __builtin_coro_promise(ptr, alignof(Promise), /*from-promise=*/false)); + } + static coroutine_handle from_promise(Promise &promise) { + coroutine_handle p; + p.ptr = __builtin_coro_promise(&promise, alignof(Promise), + /*from-promise=*/true); + return p; + } + }; + + +Other coroutine builtins are either for internal clang use or for use during +development of the coroutine feature. See `Coroutines in LLVM +`_ 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 +an appropriate value during the emission. + +**Syntax**: + +.. code-block:: c + + size_t __builtin_coro_size() + void *__builtin_coro_frame() + void *__builtin_coro_free(void *coro_frame) + + void *__builtin_coro_id(int align, void *promise, void *fnaddr, void *parts) + bool __builtin_coro_alloc() + void *__builtin_coro_begin(void *memory) + void __builtin_coro_end(void *coro_frame, bool unwind) + char __builtin_coro_suspend(bool final) + bool __builtin_coro_param(void *original, void *copy) + +Note that there is no builtin matching the `llvm.coro.save` intrinsic. LLVM +automatically will insert one if the first argument to `llvm.coro.suspend` is +token `none`. If a user calls `__builin_suspend`, clang will insert `token none` +as the first argument to the intrinsic. + Non-standard C++11 Attributes ============================= diff --git a/docs/LibASTMatchers.rst b/docs/LibASTMatchers.rst index 738de79d5da..aea9f3233b4 100644 --- a/docs/LibASTMatchers.rst +++ b/docs/LibASTMatchers.rst @@ -103,7 +103,7 @@ you can :ref:`bind ` the node they represent to ids for later processing. ``VariadicDynCastAllOfMatchers`` are callable classes that model variadic -template functions in C++03. They take an aribtrary number of +template functions in C++03. They take an arbitrary number of ``Matcher`` and return a ``Matcher``. ``AST_MATCHER_P(Type, Name, ParamType, Param)`` diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html index 70c83ea5cca..4ee953f1838 100644 --- a/docs/LibASTMatchersReference.html +++ b/docs/LibASTMatchersReference.html @@ -599,7 +599,7 @@

Node Matchers

Matcher<Stmt>cStyleCastExprMatcher<CStyleCastExpr>...
Matches a C-style cast expression.
 
-Example: Matches (int*) 2.2f in
+Example: Matches (int) 2.2f in
   int i = (int) 2.2f;
 
@@ -1318,6 +1318,17 @@

Node Matchers

+Matcher<TemplateName>templateNameMatcher<TemplateName>... +
Matches template name.
+
+Given
+  template <typename T> class X { };
+  X<int> xi;
+templateName()
+  matches 'X' in X<int>.
+
+ + Matcher<TypeLoc>typeLocMatcher<TypeLoc>...
Matches TypeLocs in the clang AST.
 
@@ -2419,7 +2430,8 @@

Narrowing Matchers

Matcher<FieldDecl>hasBitWidthunsigned Width -
Matches non-static data members that are bit-fields.
+
Matches non-static data members that are bit-fields of the specified
+bit width.
 
 Given
   class C {
@@ -2427,7 +2439,7 @@ 

Narrowing Matchers

int b : 4; int c : 2; }; -fieldDecl(isBitField()) +fieldDecl(hasBitWidth(2)) matches 'int a;' and 'int c;' but not 'int b;'.
@@ -2599,6 +2611,22 @@

Narrowing Matchers

+Matcher<FunctionDecl>isStaticStorageClass +
Matches variablefunction declarations that have "static" storage
+class specifier ("static" keyword) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+  extern int j;
+  int k;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+ + Matcher<FunctionDecl>isTemplateInstantiation
Matches template instantiations of function, class, or static
 member variable template instantiations.
@@ -2729,6 +2757,26 @@ 

Narrowing Matchers

+Matcher<NamedDecl>hasExternalFormalLinkage +
Matches a declaration that has external formal linkage.
+
+Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
+void f() {
+  int x;
+  static int y;
+}
+int z;
+
+Example matches f() because it has external formal linkage despite being
+unique to the translation unit as though it has internal likage
+(matcher = functionDecl(hasExternalFormalLinkage()))
+
+namespace {
+void f() {}
+}
+
+ + Matcher<NamedDecl>hasNamestd::string Name
Matches NamedDecl nodes that have the specified name.
 
@@ -2975,7 +3023,7 @@ 

Narrowing Matchers

void a(int); void b(unsigned long); void c(double); -functionDecl(hasAnyParameter(hasType(isInteger()))) +functionDecl(hasAnyParameter(hasType(isSignedInteger()))) matches "a(int)", but not "b(unsigned long)" and "c(double)".
@@ -2987,7 +3035,7 @@

Narrowing Matchers

void a(int); void b(unsigned long); void c(double); -functionDecl(hasAnyParameter(hasType(isInteger()))) +functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) matches "b(unsigned long)", but not "a(int)" and "c(double)". @@ -3349,15 +3397,19 @@

Narrowing Matchers

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.
 
-Example matches y and a, but not x or z.
-(matcher = varDecl(hasStaticStorageDuration())
 void f() {
   int x;
   static int y;
   thread_local int z;
 }
 int a;
+static int b;
+extern int c;
+varDecl(hasStaticStorageDuration())
+  matches the function declaration y, a, b and c.
 
@@ -3430,6 +3482,34 @@

Narrowing Matchers

+Matcher<VarDecl>isExternC +
Matches extern "C" function declarations.
+
+Given:
+  extern "C" void f() {}
+  extern "C" { void g() {} }
+  void h() {}
+functionDecl(isExternC())
+  matches the declaration of f and g, but not the declaration h
+
+ + +Matcher<VarDecl>isStaticStorageClass +
Matches variablefunction declarations that have "static" storage
+class specifier ("static" keyword) written in the source.
+
+Given:
+  static void f() {}
+  static int i = 0;
+  extern int j;
+  int k;
+functionDecl(isStaticStorageClass())
+  matches the function declaration f.
+varDecl(isStaticStorageClass())
+  matches the variable declaration i.
+
+ + Matcher<VarDecl>isTemplateInstantiation
Matches template instantiations of function, class, or static
 member variable template instantiations.
@@ -3679,8 +3759,8 @@ 

AST Traversal Matchers

-Matcher<AddrLabelExpr>hasDeclarationMatcher<Decl> InnerMatcher -
Matches a node if the declaration associated with that node
+Matcher<AddrLabelExpr>hasDeclarationMatcher<Decl>  InnerMatcher
+
Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -3688,16 +3768,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -3918,16 +4000,18 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -4091,6 +4175,30 @@

AST Traversal Matchers

+Matcher<CXXNewExpr>hasDeclarationMatcher<Decl> InnerMatcher +
Matches a node if the declaration associated with that node
+matches the given matcher.
+
+The associated declaration is:
+- for type nodes, the declaration of the underlying type
+- for CallExpr, the declaration of the callee
+- for MemberExpr, the declaration of the referenced member
+- for CXXConstructExpr, the declaration of the constructor
+- for CXXNewExpr, the declaration of the operator new
+
+Also usable as Matcher<T> for any T supporting the getDecl() member
+function. e.g. various subtypes of clang::Type and various expressions.
+
+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
Matches the first method of a class or struct that satisfies InnerMatcher.
 
@@ -4211,16 +4319,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -4240,30 +4350,44 @@

AST Traversal Matchers

Matcher<ClassTemplateSpecializationDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher -
Matches classTemplateSpecializations that have at least one
-TemplateArgument matching the given InnerMatcher.
+
Matches classTemplateSpecializations, templateSpecializationType and
+functionDecl that have at least one TemplateArgument matching the given
+InnerMatcher.
 
 Given
   template<typename T> class A {};
   template<> class A<double> {};
   A<int> a;
+
+  template<typename T> f() {};
+  void func() { f<int>(); };
+
 classTemplateSpecializationDecl(hasAnyTemplateArgument(
     refersToType(asString("int"))))
   matches the specialization A<int>
+
+functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
+  matches the specialization f<int>
 
Matcher<ClassTemplateSpecializationDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher -
Matches classTemplateSpecializations where the n'th TemplateArgument
-matches the given InnerMatcher.
+
Matches classTemplateSpecializations, templateSpecializationType and
+functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
 
 Given
   template<typename T, typename U> class A {};
   A<bool, int> b;
   A<int, bool> c;
+
+  template<typename T> f() {};
+  void func() { f<int>(); };
 classTemplateSpecializationDecl(hasTemplateArgument(
     1, refersToType(asString("int"))))
   matches the specialization A<bool, int>
+
+functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
+  matches the specialization f<int>
 
@@ -4315,8 +4439,8 @@

AST Traversal Matchers

-Matcher<DeclRefExpr>hasDeclarationMatcher<Decl> InnerMatcher -
Matches a node if the declaration associated with that node
+Matcher<DeclRefExpr>hasDeclarationMatcher<Decl>  InnerMatcher
+
Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -4324,16 +4448,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -4477,8 +4603,8 @@

AST Traversal Matchers

-Matcher<EnumType>hasDeclarationMatcher<Decl> InnerMatcher -
Matches a node if the declaration associated with that node
+Matcher<EnumType>hasDeclarationMatcher<Decl>  InnerMatcher
+
Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -4486,16 +4612,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -4623,6 +4751,22 @@

AST Traversal Matchers

+Matcher<FieldDecl>hasInClassInitializerMatcher<Expr> InnerMatcher +
Matches non-static data members that have an in-class initializer.
+
+Given
+  class C {
+    int a = 2;
+    int b = 3;
+    int c;
+  };
+fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
+  matches 'int a;' but not 'int b;'.
+fieldDecl(hasInClassInitializer(anything()))
+  matches 'int a;' and 'int b;' but not 'int c;'.
+
+ + Matcher<ForStmt>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
@@ -4679,6 +4823,28 @@ 

AST Traversal Matchers

+Matcher<FunctionDecl>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher +
Matches classTemplateSpecializations, templateSpecializationType and
+functionDecl that have at least one TemplateArgument matching the given
+InnerMatcher.
+
+Given
+  template<typename T> class A {};
+  template<> class A<double> {};
+  A<int> a;
+
+  template<typename T> f() {};
+  void func() { f<int>(); };
+
+classTemplateSpecializationDecl(hasAnyTemplateArgument(
+    refersToType(asString("int"))))
+  matches the specialization A<int>
+
+functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
+  matches the specialization f<int>
+
+ + Matcher<FunctionDecl>hasBodyMatcher<Stmt> InnerMatcher
Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
@@ -4704,6 +4870,26 @@ 

AST Traversal Matchers

+Matcher<FunctionDecl>hasTemplateArgumentunsigned N, Matcher<TemplateArgument> InnerMatcher +
Matches classTemplateSpecializations, templateSpecializationType and
+functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
+
+Given
+  template<typename T, typename U> class A {};
+  A<bool, int> b;
+  A<int, bool> c;
+
+  template<typename T> f() {};
+  void func() { f<int>(); };
+classTemplateSpecializationDecl(hasTemplateArgument(
+    1, refersToType(asString("int"))))
+  matches the specialization A<bool, int>
+
+functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
+  matches the specialization f<int>
+
+ + Matcher<FunctionDecl>returnsMatcher<QualType> InnerMatcher
Matches the return type of a function declaration.
 
@@ -4765,8 +4951,8 @@ 

AST Traversal Matchers

-Matcher<InjectedClassNameType>hasDeclarationMatcher<Decl> InnerMatcher -
Matches a node if the declaration associated with that node
+Matcher<InjectedClassNameType>hasDeclarationMatcher<Decl>  InnerMatcher
+
Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -4774,21 +4960,23 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>hasDeclarationMatcher<Decl> InnerMatcher -
Matches a node if the declaration associated with that node
+Matcher<LabelStmt>hasDeclarationMatcher<Decl>  InnerMatcher
+
Matches a node if the declaration associated with that node
 matches the given matcher.
 
 The associated declaration is:
@@ -4796,16 +4984,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -4818,16 +5008,18 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -4891,6 +5083,19 @@

AST Traversal Matchers

+Matcher<NamedDecl>hasUnderlyingDeclMatcher<NamedDecl> InnerMatcher +
Matches a NamedDecl whose underlying declaration matches the given
+matcher.
+
+Given
+  namespace N { template<class T> void f(T t); }
+  template <class T> void g() { using N::f; f(T()); }
+unresolvedLookupExpr(hasAnyDeclaration(
+    namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
+  matches the use of f in g() .
+
+ + Matcher<NestedNameSpecifierLoc>hasPrefixMatcher<NestedNameSpecifierLoc> InnerMatcher
Matches on the prefix of a NestedNameSpecifierLoc.
 
@@ -4978,6 +5183,23 @@ 

AST Traversal Matchers


 
 
+Matcher<OverloadExpr>hasAnyDeclarationMatcher<Decl> InnerMatcher
+
Matches an OverloadExpr if any of the declarations in the set of
+overloads matches the given matcher.
+
+Given
+  template <typename T> void foo(T);
+  template <typename T> void bar(T);
+  template <typename T> void baz(T t) {
+    foo(t);
+    bar(t);
+  }
+unresolvedLookupExpr(hasAnyDeclaration(
+    functionTemplateDecl(hasName("foo"))))
+  matches foo in foo(t); but not bar in bar(t);
+
+ + Matcher<ParenType>innerTypeMatcher<Type>
Matches ParenType nodes where the inner type is a specific type.
 
@@ -5046,16 +5268,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -5116,16 +5340,18 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -5212,6 +5438,20 @@

AST Traversal Matchers

+Matcher<SubstTemplateTypeParmType>hasReplacementTypeMatcher<Type> +
Matches template type parameter substitutions that have a replacement
+type that matches the provided matcher.
+
+Given
+  template <typename T>
+  double F(T t);
+  int i;
+  double j = F(i);
+
+substTemplateTypeParmType(hasReplacementType(type())) matches int
+
+ + Matcher<SwitchStmt>forEachSwitchCaseMatcher<SwitchCase> InnerMatcher
Matches each case or default statement belonging to the given switch
 statement. This matcher may produce multiple matches.
@@ -5243,16 +5483,18 @@ 

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -5297,6 +5539,19 @@

AST Traversal Matchers

+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 {};"
+  X<Y> xi;
+classTemplateSpecializationDecl(hasAnyTemplateArgument(
+    refersToTemplate(templateName())))
+  matches the specialization X<Y>
+
+ + Matcher<TemplateArgument>refersToTypeMatcher<QualType> InnerMatcher
Matches a TemplateArgument that refers to a certain type.
 
@@ -5311,16 +5566,24 @@ 

AST Traversal Matchers

Matcher<TemplateSpecializationType>hasAnyTemplateArgumentMatcher<TemplateArgument> InnerMatcher -
Matches classTemplateSpecializations that have at least one
-TemplateArgument matching the given InnerMatcher.
+
Matches classTemplateSpecializations, templateSpecializationType and
+functionDecl that have at least one TemplateArgument matching the given
+InnerMatcher.
 
 Given
   template<typename T> class A {};
   template<> class A<double> {};
   A<int> a;
+
+  template<typename T> f() {};
+  void func() { f<int>(); };
+
 classTemplateSpecializationDecl(hasAnyTemplateArgument(
     refersToType(asString("int"))))
   matches the specialization A<int>
+
+functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
+  matches the specialization f<int>
 
@@ -5333,30 +5596,38 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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 -
Matches classTemplateSpecializations where the n'th TemplateArgument
-matches the given InnerMatcher.
+
Matches classTemplateSpecializations, templateSpecializationType and
+functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
 
 Given
   template<typename T, typename U> class A {};
   A<bool, int> b;
   A<int, bool> c;
+
+  template<typename T> f() {};
+  void func() { f<int>(); };
 classTemplateSpecializationDecl(hasTemplateArgument(
     1, refersToType(asString("int"))))
   matches the specialization A<bool, int>
+
+functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
+  matches the specialization f<int>
 
@@ -5369,16 +5640,18 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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>
@@ -5420,16 +5693,30 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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 +
Matches if the matched type matches the unqualified desugared
+type of the matched node.
+
+For example, in:
+  class A {};
+  using B = A;
+The matcher type(hasUniqualifeidDesugaredType(recordType())) matches
+both B and A.
 
@@ -5461,16 +5748,18 @@

AST Traversal Matchers

- for CallExpr, the declaration of the callee - for MemberExpr, the declaration of the referenced member - for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new Also usable as Matcher<T> for any T supporting the getDecl() member function. e.g. various subtypes of clang::Type and various expressions. -Usable as: Matcher<CallExpr>, Matcher<CXXConstructExpr>, - Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, - Matcher<LabelStmt>, Matcher<AddrLabelExpr>, 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> diff --git a/docs/LibASTMatchersTutorial.rst b/docs/LibASTMatchersTutorial.rst index 603b2faf01d..baf2c1c3e69 100644 --- a/docs/LibASTMatchersTutorial.rst +++ b/docs/LibASTMatchersTutorial.rst @@ -496,9 +496,9 @@ And change ``LoopPrinter::run`` to void LoopPrinter::run(const MatchFinder::MatchResult &Result) { ASTContext *Context = Result.Context; - const ForStmt *FS = Result.Nodes.getStmtAs("forLoop"); + const ForStmt *FS = Result.Nodes.getNodeAs("forLoop"); // We do not want to convert header files! - if (!FS || !Context->getSourceManager().isFromMainFile(FS->getForLoc())) + if (!FS || !Context->getSourceManager().isWrittenInMainFile(FS->getForLoc())) return; const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName"); const VarDecl *CondVar = Result.Nodes.getNodeAs("condVarName"); diff --git a/docs/MSVCCompatibility.rst b/docs/MSVCCompatibility.rst index ead0ae847a2..b82869b267c 100644 --- a/docs/MSVCCompatibility.rst +++ b/docs/MSVCCompatibility.rst @@ -72,14 +72,11 @@ The status of major ABI-impacting C++ features: .. _/vm: http://msdn.microsoft.com/en-us/library/yad46a6z.aspx .. _pointer to a member of a virtual base class: http://llvm.org/PR15713 -* Debug info: :partial:`Minimal`. Clang emits both CodeView line tables - (similar to what MSVC emits when given the ``/Z7`` flag) and DWARF debug - information into the object file. - Microsoft's link.exe will transform the CodeView line tables into a PDB, - enabling stack traces in all modern Windows debuggers. Clang does not emit - any CodeView-compatible type info or description of variable layout. - Binaries linked with either binutils' ld or LLVM's lld should be usable with - GDB however sophisticated C++ expressions are likely to fail. +* Debug info: :good:`Mostly complete`. Clang emits relatively complete CodeView + debug information if ``/Z7`` or ``/Zi`` is passed. Microsoft's link.exe will + transform the CodeView debug information into a PDB that works in Windows + debuggers and other tools that consume PDB files like ETW. Work to teach lld + about CodeView and PDBs is ongoing. * RTTI: :good:`Complete`. Generation of RTTI data structures has been finished, along with support for the ``/GR`` flag. diff --git a/docs/MemorySanitizer.rst b/docs/MemorySanitizer.rst index 4e58588b801..8088ecdf561 100644 --- a/docs/MemorySanitizer.rst +++ b/docs/MemorySanitizer.rst @@ -76,14 +76,14 @@ whether MemorySanitizer is enabled. :ref:`\_\_has\_feature # endif #endif -``__attribute__((no_sanitize_memory))`` +``__attribute__((no_sanitize("memory")))`` ----------------------------------------------- Some code should not be checked by MemorySanitizer. One may use the function -attribute `no_sanitize_memory` to disable uninitialized checks in a particular -function. MemorySanitizer may still instrument such functions to avoid false -positives. This attribute may not be supported by other compilers, so we -suggest to use it together with ``__has_feature(memory_sanitizer)``. +attribute ``no_sanitize("memory")`` to disable uninitialized checks in a +particular function. MemorySanitizer may still instrument such functions to +avoid false positives. This attribute may not be supported by other compilers, +so we suggest to use it together with ``__has_feature(memory_sanitizer)``. Blacklist --------- diff --git a/docs/Modules.rst b/docs/Modules.rst index 0ea3b5bb377..141d3b85753 100644 --- a/docs/Modules.rst +++ b/docs/Modules.rst @@ -174,6 +174,9 @@ Command-line parameters ``-fmodules`` Enable the modules feature. +``-fbuiltin-module-map`` + Load the Clang builtins module map file. (Equivalent to ``-fmodule-map-file=/include/module.modulemap``) + ``-fimplicit-module-maps`` Enable implicit search for module map files named ``module.modulemap`` and similar. This option is implied by ``-fmodules``. If this is disabled with ``-fno-implicit-module-maps``, module map files will only be loaded if they are explicitly specified via ``-fmodule-map-file`` or transitively used by another module map file. @@ -213,6 +216,9 @@ Command-line parameters ``-fmodule-file=`` Load the given precompiled module file. +``-fprebuilt-module-path=`` + Specify the path to the prebuilt modules. If specified, we will look for modules in this directory for a given top-level module name. We don't need a module map for loading prebuilt modules in this directory and the compiler will not try to rebuild these modules. This can be specified multiple times. + Module Semantics ================ @@ -362,6 +368,8 @@ The ``system`` attribute specifies that the module is a system module. When a sy The ``extern_c`` attribute specifies that the module contains C code that can be used from within C++. When such a module is built for use in C++ code, all of the module's headers will be treated as if they were contained within an implicit ``extern "C"`` block. An import for a module with this attribute can appear within an ``extern "C"`` block. No other restrictions are lifted, however: the module currently cannot be imported within an ``extern "C"`` block in a namespace. +The ``no_undeclared_includes`` attribute specifies that the module can only reach non-modular headers and headers from used modules. Since some headers could be present in more than one search path and map to different modules in each path, this mechanism helps clang to find the right header, i.e., prefer the one for the current module or in a submodule instead of the first usual match in the search paths. + Modules can have a number of different kinds of members, each of which is described below: .. parsed-literal:: @@ -410,6 +418,12 @@ cplusplus cplusplus11 C++11 support is available. +freestanding + A freestanding environment is available. + +gnuinlineasm + GNU inline ASM is available. + objc Objective-C support is available. diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index cdbf7e696be..25ea577ba51 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -1,6 +1,6 @@ -===================================== -Clang 3.9 (In-Progress) Release Notes -===================================== +======================================= +Clang 4.0.0 (In-Progress) Release Notes +======================================= .. contents:: :local: @@ -10,15 +10,15 @@ Written by the `LLVM Team `_ .. warning:: - These are in-progress notes for the upcoming Clang 3.9 release. You may - prefer the `Clang 3.8 Release Notes - `_. + These are in-progress notes for the upcoming Clang 4.0.0 release. You may + prefer the `Clang 3.9 Release Notes + `_. Introduction ============ This document contains the release notes for the Clang C/C++/Objective-C -frontend, part of the LLVM Compiler Infrastructure, release 3.9. Here we +frontend, part of the LLVM Compiler Infrastructure, release 4.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 @@ -31,13 +31,8 @@ the latest release, please check out the main 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 `_. - -What's New in Clang 3.9? -======================== +What's New in Clang 4.0.0? +========================== Some of the major new features and improvements to Clang are listed here. Generic improvements to Clang as a whole or to its underlying @@ -47,28 +42,55 @@ sections with improvements to Clang's support for those languages. Major New Features ------------------ -- Clang will no longer passes --build-id by default to the linker. In modern - linkers that is a relatively expensive option. It can be passed explicitly - with -Wl,--build-id. To have clang always pass it, build clang with - -DENABLE_LINKER_BUILD_ID. -- On Itanium ABI targets, attribute abi_tag is now supported for compatibility - with GCC. Clang implementation of abi_tag is mostly compatible with GCC ABI - version 10. +- The ``diagnose_if`` attribute has been added to clang. This attribute allows + clang to emit a warning or error if a function call meets one or more + user-specified conditions. + +- Enhanced devirtualization with + `-fstrict-vtable-pointers `_. + Clang devirtualizes across different basic blocks, like loops: + + .. code-block:: c++ + + struct A { + virtual void foo(); + }; + void indirect(A &a, int n) { + for (int i = 0 ; i < n; i++) + a.foo(); + } + void test(int n) { + A a; + indirect(a, n); + } + + +- ... + +Improvements to ThinLTO (-flto=thin) +------------------------------------ +- Integration with profile data (PGO). When available, profile data enables + more accurate function importing decisions, as well as cross-module indirect + call promotion. +- Significant build-time and binary-size improvements when compiling with debug + info (-g). Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Clang's diagnostics are constantly being improved to catch more issues, -explain them more clearly, and provide more accurate source information -about them. The improvements since the 3.8 release include: - - ... New Compiler Flags ------------------ -The option .... +The option -Og has been added to optimize the debugging experience. +For now, this option is exactly the same as -O1. However, in the future, +some other optimizations might be enabled or disabled. + +The option -MJ has been added to simplify adding JSON compilation +database output into existing build systems. +The option .... New Pragmas in Clang ----------------------- @@ -79,31 +101,18 @@ Clang now supports the ... Attribute Changes in Clang -------------------------- -- The ``nodebug`` attribute may now be applied to static, global, and local - variables (but not parameters or non-static data members). This will suppress - all debugging information for the variable (and its type, if there are no - other uses of the type). - +- ... Windows Support --------------- Clang's support for building native Windows programs ... -TLS is enabled for Cygwin defaults to -femulated-tls. - -Proper support, including correct mangling and overloading, added for -MS-specific "__unaligned" type qualifier. - C Language Changes in Clang --------------------------- -The -faltivec and -maltivec flags no longer silently include altivec.h on Power platforms. -`RenderScript -`_ -support added to the Frontend and enabled by the '-x renderscript' option or -the '.rs' file extension. +- ... ... @@ -115,61 +124,11 @@ C11 Feature Support C++ Language Changes in Clang ----------------------------- -- Clang now enforces the rule that a *using-declaration* cannot name an enumerator of a - scoped enumeration. - - .. code-block:: c++ - - namespace Foo { enum class E { e }; } - namespace Bar { - using Foo::E::e; // error - constexpr auto e = Foo::E::e; // ok - } - -- Clang now enforces the rule that an enumerator of an unscoped enumeration declared at - class scope can only be named by a *using-declaration* in a derived class. - - .. code-block:: c++ - - class Foo { enum E { e }; } - using Foo::e; // error - static constexpr auto e = Foo::e; // ok - ... C++1z Feature Support ^^^^^^^^^^^^^^^^^^^^^ -Clang's experimental support for the upcoming C++1z standard can be enabled with ``-std=c++1z``. -Changes to C++1z features since Clang 3.8: - -- The ``[[fallthrough]]``, ``[[nodiscard]]``, and ``[[maybe_unused]]`` attributes are - supported in C++11 onwards, and are largely synonymous with Clang's existing attributes - ``[[clang::fallthrough]]``, ``[[gnu::warn_unused_result]]``, and ``[[gnu::unused]]``. - Use ``-Wimplicit-fallthrough`` to warn on unannotated fallthrough within ``switch`` - statements. - -- In C++1z mode, aggregate initialization can be performed for classes with base classes: - - .. code-block:: c++ - - struct A { int n; }; - struct B : A { int x, y; }; - B b = { 1, 2, 3 }; // b.n == 1, b.x == 2, b.y == 3 - -- The range in a range-based ``for`` statement can have different types for its ``begin`` - and ``end`` iterators. This is permitted as an extension in C++11 onwards. - -- Lambda-expressions can explicitly capture ``*this`` (to capture the surrounding object - by copy). This is permitted as an extension in C++11 onwards. - -- Objects of enumeration type can be direct-list-initialized from a value of the underlying - type. ``E{n}`` is equivalent to ``E(n)``, except that it implies a check for a narrowing - conversion. - -- Unary *fold-expression*\s over an empty pack are now rejected for all operators - other than ``&&``, ``||``, and ``,``. - ... Objective-C Language Changes in Clang @@ -185,22 +144,12 @@ OpenCL C Language Changes in Clang OpenMP Support in Clang ---------------------------------- -Added support for all non-offloading features from OpenMP 4.5, including using -data members in private clauses of non-static member functions. Additionally, -data members can be used as loop control variables in loop-based directives. - -Currently Clang supports OpenMP 3.1 and all non-offloading features of -OpenMP 4.0/4.5. Offloading features are under development. Clang defines macro -_OPENMP and sets it to OpenMP 3.1 (in accordance with OpenMP standard) by -default. User may change this value using ``-fopenmp-version=[31|40|45]`` option. - -The codegen for OpenMP constructs was significantly improved to produce much -more stable and faster code. +... Internal API Changes -------------------- -These are major API changes that have happened since the 3.8 release of +These are major API changes that have happened since the 3.9 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. @@ -209,14 +158,6 @@ this section should help get you past the largest hurdles of upgrading. AST Matchers ------------ -- has and hasAnyArgument: Matchers no longer ignores parentheses and implicit - casts on the argument before applying the inner matcher. The fix was done to - allow for greater control by the user. In all existing checkers that use this - matcher all instances of code ``hasAnyArgument()`` or - ``has()`` must be changed to - ``hasAnyArgument(ignoringParenImpCasts())`` or - ``has(ignoringParenImpCasts())``. - ... libclang @@ -224,6 +165,10 @@ libclang ... +With the option --show-description, scan-build's list of defects will also +show the description of the defects. + + Static Analyzer --------------- diff --git a/docs/SanitizerCoverage.rst b/docs/SanitizerCoverage.rst index f7ec65fdd15..3e8102a12f6 100644 --- a/docs/SanitizerCoverage.rst +++ b/docs/SanitizerCoverage.rst @@ -114,7 +114,7 @@ Sancov matches these files using module names and binaries file names. -print - Print coverage addresses -covered-functions - Print all covered functions. -not-covered-functions - Print all not covered functions. - -html-report - Print HTML coverage report. + -symbolize - Symbolizes the report. Options -blacklist= - Blacklist file (sanitizer blacklist format). @@ -122,13 +122,21 @@ Sancov matches these files using module names and binaries file names. -strip_path_prefix= - Strip this prefix from file paths in reports -Automatic HTML Report Generation +Coverage Reports (Experimental) ================================ -If ``*SAN_OPTIONS`` contains ``html_cov_report=1`` option set, then html -coverage report would be automatically generated alongside the coverage files. -The ``sancov`` binary should be present in ``PATH`` or -``sancov_path= my_program.123.symcov + +The ``.symcov`` file can be browsed overlayed over the source code by +running ``tools/sancov/coverage-report-server.py`` script that will start +an HTTP server. How good is the coverage? @@ -321,23 +329,133 @@ by the user. So, these flags do not require the other sanitizer to be used. This mechanism is used for fuzzing the Linux kernel (https://github.com/google/syzkaller) and can be used with `AFL `__. +Tracing PCs with guards +======================= +Another *experimental* feature that tries to combine the functionality of `trace-pc`, +`8bit-counters` and boolean coverage. + +With ``-fsanitize-coverage=trace-pc-guard`` the compiler will insert the following code +on every edge: + +.. code-block:: none + + if (guard_variable) + __sanitizer_cov_trace_pc_guard(&guard_variable) + +Every edge will have its own `guard_variable` (uint32_t). + +The compler will also insert a module constructor that will call + +.. code-block:: c++ + + // The guards are [start, stop). + // This function may be called multiple times with the same values of start/stop. + __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop); + +Similarly to `trace-pc,indirect-calls`, with `trace-pc-guards,indirect-calls` +``__sanitizer_cov_trace_pc_indirect(void *callee)`` will be inserted on every indirect call. + +The functions `__sanitizer_cov_trace_pc_*` should be defined by the user. + +Example: + +.. code-block:: c++ + + // trace-pc-guard-cb.cc + #include + #include + #include + + // This callback is inserted by the compiler as a module constructor + // into every compilation unit. 'start' and 'stop' correspond to the + // beginning and end of the section with the guards for the entire + // binary (executable or DSO) and so it will be called multiple times + // with the same parameters. + extern "C" void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, + uint32_t *stop) { + static uint64_t N; // Counter for the guards. + if (start == stop || *start) return; // Initialize only once. + printf("INIT: %p %p\n", start, stop); + for (uint32_t *x = start; x < stop; x++) + *x = ++N; // Guards should start from 1. + } + + // This callback is inserted by the compiler on every edge in the + // control flow (some optimizations apply). + // Typically, the compiler will emit the code like this: + // if(*guard) + // __sanitizer_cov_trace_pc_guard(guard); + // But for large functions it will emit a simple call: + // __sanitizer_cov_trace_pc_guard(guard); + extern "C" void __sanitizer_cov_trace_pc_guard(uint32_t *guard) { + if (!*guard) return; // Duplicate the guard check. + // If you set *guard to 0 this code will not be called again for this edge. + // Now you can get the PC and do whatever you want: + // store it somewhere or symbolize it and print right away. + // The values of `*guard` are as you set them in + // __sanitizer_cov_trace_pc_guard_init and so you can make them consecutive + // and use them to dereference an array or a bit vector. + void *PC = __builtin_return_address(0); + char PcDescr[1024]; + // This function is a part of the sanitizer run-time. + // To use it, link with AddressSanitizer or other sanitizer. + __sanitizer_symbolize_pc(PC, "%p %F %L", PcDescr, sizeof(PcDescr)); + printf("guard: %p %x PC %s\n", guard, *guard, PcDescr); + } + +.. code-block:: c++ + + // trace-pc-guard-example.cc + void foo() { } + int main(int argc, char **argv) { + if (argc > 1) foo(); + } + +.. code-block:: console + + clang++ -g -fsanitize-coverage=trace-pc-guard trace-pc-guard-example.cc -c + clang++ trace-pc-guard-cb.cc trace-pc-guard-example.o -fsanitize=address + ASAN_OPTIONS=strip_path_prefix=`pwd`/ ./a.out + +.. code-block:: console + + INIT: 0x71bcd0 0x71bce0 + guard: 0x71bcd4 2 PC 0x4ecd5b in main trace-pc-guard-example.cc:2 + guard: 0x71bcd8 3 PC 0x4ecd9e in main trace-pc-guard-example.cc:3:7 + +.. code-block:: console + + ASAN_OPTIONS=strip_path_prefix=`pwd`/ ./a.out with-foo + + +.. code-block:: console + + INIT: 0x71bcd0 0x71bce0 + guard: 0x71bcd4 2 PC 0x4ecd5b in main trace-pc-guard-example.cc:3 + guard: 0x71bcdc 4 PC 0x4ecdc7 in main trace-pc-guard-example.cc:4:17 + guard: 0x71bcd0 1 PC 0x4ecd20 in foo() trace-pc-guard-example.cc:2:14 + + Tracing data flow ================= -An *experimental* feature to support data-flow-guided fuzzing. +Support for data-flow-guided fuzzing. With ``-fsanitize-coverage=trace-cmp`` the compiler will insert extra instrumentation around comparison instructions and switch statements. -The fuzzer will need to define the following functions, -they will be called by the instrumented code. +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 `_ +(to capture array indices). .. code-block:: c++ // Called before a comparison instruction. - // SizeAndType is a packed value containing - // - [63:32] the Size of the operands of comparison in bits - // - [31:0] the Type of comparison (one of ICMP_EQ, ... ICMP_SLE) // Arg1 and Arg2 are arguments of the comparison. - void __sanitizer_cov_trace_cmp(uint64_t SizeAndType, uint64_t Arg1, uint64_t Arg2); + void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2); + void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2); + void __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2); + void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2); // Called before a switch statement. // Val is the switch operand. @@ -346,6 +464,16 @@ they will be called by the instrumented code. // Cases[2:] are the case constants. void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases); + // Called before a division statement. + // Val is the second argument of division. + void __sanitizer_cov_trace_div4(uint32_t Val); + void __sanitizer_cov_trace_div8(uint64_t Val); + + // Called before a GetElemementPtr (GEP) instruction + // for every non-constant array index. + void __sanitizer_cov_trace_gep(uintptr_t Idx); + + This interface is a subject to change. The current implementation is not thread-safe and thus can be safely used only for single-threaded targets. diff --git a/docs/SourceBasedCodeCoverage.rst b/docs/SourceBasedCodeCoverage.rst index 8d0a51fd331..abb682355b1 100644 --- a/docs/SourceBasedCodeCoverage.rst +++ b/docs/SourceBasedCodeCoverage.rst @@ -61,7 +61,7 @@ To compile code with coverage enabled, pass ``-fprofile-instr-generate % clang++ -fprofile-instr-generate -fcoverage-mapping foo.cc -o foo Note that linking together code with and without coverage instrumentation is -supported: any uninstrumented code simply won't be accounted for. +supported. Uninstrumented code simply won't be accounted for in reports. Running the instrumented program ================================ @@ -95,28 +95,22 @@ Creating coverage reports ========================= Raw profiles have to be **indexed** before they can be used to generate -coverage reports. This is done using the "merge" tool in ``llvm-profdata``, so -named because it can combine and index profiles at the same time: +coverage reports. This is done using the "merge" tool in ``llvm-profdata`` +(which can combine multiple raw profiles and index them at the same time): .. code-block:: console # Step 3(a): Index the raw profile. % llvm-profdata merge -sparse foo.profraw -o foo.profdata -There are multiple different ways to render coverage reports. One option is to -generate a line-oriented report: +There are multiple different ways to render coverage reports. The simplest +option is to generate a line-oriented report: .. code-block:: console # Step 3(b): Create a line-oriented coverage report. % llvm-cov show ./foo -instr-profile=foo.profdata -To demangle any C++ identifiers in the output, use: - -.. code-block:: console - - % llvm-cov show ./foo -instr-profile=foo.profdata | c++filt -n - This report includes a summary view as well as dedicated sub-views for templated functions and their instantiations. For our example program, we get distinct views for ``foo(...)`` and ``foo(...)``. If @@ -125,38 +119,43 @@ region counts (even in macro expansions): .. code-block:: none - 20| 1|#define BAR(x) ((x) || (x)) + 1| 20|#define BAR(x) ((x) || (x)) ^20 ^2 2| 2|template void foo(T x) { - 22| 3| for (unsigned I = 0; I < 10; ++I) { BAR(I); } + 3| 22| for (unsigned I = 0; I < 10; ++I) { BAR(I); } ^22 ^20 ^20^20 - 2| 4|} + 4| 2|} ------------------ | void foo(int): - | 1| 2|template void foo(T x) { - | 11| 3| for (unsigned I = 0; I < 10; ++I) { BAR(I); } + | 2| 1|template void foo(T x) { + | 3| 11| for (unsigned I = 0; I < 10; ++I) { BAR(I); } | ^11 ^10 ^10^10 - | 1| 4|} + | 4| 1|} ------------------ | void foo(int): - | 1| 2|template void foo(T x) { - | 11| 3| for (unsigned I = 0; I < 10; ++I) { BAR(I); } + | 2| 1|template void foo(T x) { + | 3| 11| for (unsigned I = 0; I < 10; ++I) { BAR(I); } | ^11 ^10 ^10^10 - | 1| 4|} + | 4| 1|} ------------------ -It's possible to generate a file-level summary of coverage statistics (instead -of a line-oriented report) with: +To generate a file-level summary of coverage statistics instead of a +line-oriented report, try: .. code-block:: console # Step 3(c): Create a coverage summary. % llvm-cov report ./foo -instr-profile=foo.profdata - Filename Regions Miss Cover Functions Executed - ----------------------------------------------------------------------- - /tmp/foo.cc 13 0 100.00% 3 100.00% - ----------------------------------------------------------------------- - TOTAL 13 0 100.00% 3 100.00% + Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover + -------------------------------------------------------------------------------------------------------------------------------------- + /tmp/foo.cc 13 0 100.00% 3 0 100.00% 13 0 100.00% + -------------------------------------------------------------------------------------------------------------------------------------- + TOTAL 13 0 100.00% 3 0 100.00% 13 0 100.00% + +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: @@ -177,6 +176,40 @@ A few final notes: % llvm-profdata merge -sparse foo1.profraw foo2.profdata -o foo3.profdata +Exporting coverage data +======================= + +Coverage data can be exported into JSON using the ``llvm-cov export`` +sub-command. There is a comprehensive reference which defines the structure of +the exported data at a high level in the llvm-cov source code. + +Interpreting reports +==================== + +There are four statistics tracked in a coverage summary: + +* Function coverage is the percentage of functions which have been executed at + least once. A function is considered to be executed if any of its + instantiations are executed. + +* Instantiation coverage is the percentage of function instantiations which + have been executed at least once. Template functions and static inline + functions from headers are two kinds of functions which may have multiple + instantiations. + +* Line coverage is the percentage of code lines which have been executed at + least once. Only executable lines within function bodies are considered to be + code lines. + +* Region coverage is the percentage of code regions which have been executed at + least once. A code region may span multiple lines (e.g in a large function + body with no control flow). However, it's also possible for a single line to + contain multiple code regions (e.g in "return x || y && z"). + +Of these four statistics, function coverage is usually the least granular while +region coverage is the most granular. The project-wide totals for each +statistic are listed in the summary. + Format compatibility guarantees =============================== @@ -189,9 +222,14 @@ Format compatibility guarantees These formats are not forwards-compatible: i.e, a tool which uses format version X will not be able to understand format version (X+k). -* There is a third format in play: the format of the coverage mappings emitted - into instrumented binaries. Tools must retain **backwards** compatibility - with these formats. These formats are not forwards-compatible. +* Tools must also retain **backwards** compatibility with the format of the + coverage mappings emitted into instrumented binaries. These formats are not + forwards-compatible. + +* The JSON coverage export format has a (major, minor, patch) version triple. + Only a major version increment indicates a backwards-incompatible change. A + minor version increment is for added functionality, and patch version + increments are for bugfixes. Using the profiling runtime without static initializers ======================================================= @@ -218,6 +256,18 @@ without using static initializers, do this manually: otherwise. Calling this function multiple times appends profile data to an existing on-disk raw profile. +Collecting coverage reports for the llvm project +================================================ + +To prepare a coverage report for llvm (and any of its sub-projects), add +``-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On`` to the cmake configuration. Raw +profiles will be written to ``$BUILD_DIR/profiles/``. To prepare an html +report, run ``llvm/utils/prepare-code-coverage-artifact.py``. + +To specify an alternate directory for raw profiles, use +``-DLLVM_PROFILE_DATA_DIR``. To change the size of the profile merge pool, use +``-DLLVM_PROFILE_MERGE_POOL_SIZE``. + Drawbacks and limitations ========================= diff --git a/docs/ThinLTO.rst b/docs/ThinLTO.rst new file mode 100644 index 00000000000..7c7d9513025 --- /dev/null +++ b/docs/ThinLTO.rst @@ -0,0 +1,159 @@ +======= +ThinLTO +======= + +.. contents:: + :local: + +Introduction +============ + +*ThinLTO* compilation is a new type of LTO that is both scalable and +incremental. *LTO* (Link Time Optimization) achieves better +runtime performance through whole-program analysis and cross-module +optimization. However, monolithic LTO implements this by merging all +input into a single module, which is not scalable +in time or memory, and also prevents fast incremental compiles. + +In ThinLTO mode, as with regular LTO, clang emits LLVM bitcode after the +compile phase. The ThinLTO bitcode is augmented with a compact summary +of the module. During the link step, only the summaries are read and +merged into a combined summary index, which includes an index of function +locations for later cross-module function importing. Fast and efficient +whole-program analysis is then performed on the combined summary index. + +However, all transformations, including function importing, occur +later when the modules are optimized in fully parallel backends. +By default, linkers_ that support ThinLTO are set up to launch +the ThinLTO backends in threads. So the usage model is not affected +as the distinction between the fast serial thin link step and the backends +is transparent to the user. + +For more information on the ThinLTO design and current performance, +see the LLVM blog post `ThinLTO: Scalable and Incremental LTO +`_. +While tuning is still in progress, results in the blog post show that +ThinLTO already performs well compared to LTO, in many cases matching +the performance improvement. + +Current Status +============== + +Clang/LLVM +---------- +.. _compiler: + +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 +------- +.. _linkers: +.. _linker: + +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**: + Starting with r284050 (ELF only). + +Usage +===== + +Basic +----- + +To utilize ThinLTO, simply add the -flto=thin option to compile and link. E.g. + +.. code-block:: console + + % clang -flto=thin -O2 file1.c file2.c -c + % clang -flto=thin -O2 file1.o file2.o -o a.out + +As mentioned earlier, by default the linkers will launch the ThinLTO backend +threads in parallel, passing the resulting native object files back to the +linker for the final native link. As such, the usage model the same as +non-LTO. + +With gold, if you see an error during the link of the form: + +.. code-block:: console + + /usr/bin/ld: error: /path/to/clang/bin/../lib/LLVMgold.so: could not load plugin library: /path/to/clang/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory + +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 `_. + +Controlling Backend Parallelism +------------------------------- +.. _parallelism: + +By default, the ThinLTO link step will launch up to +``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 +may be too aggressive, in which case the amount of parallelism can +be reduced to ``N`` via: + +- gold: + ``-Wl,-plugin-opt,jobs=N`` +- ld64: + ``-Wl,-mllvm,-threads=N`` +- lld: + ``-Wl,--thinlto-jobs=N`` + +Incremental +----------- +.. _incremental: + +ThinLTO supports fast incremental builds through the use of a cache, +which currently must be enabled through a linker option. + +- gold (as of LLVM r279883): + ``-Wl,-plugin-opt,cache-dir=/path/to/cache`` +- ld64 (support in clang 3.9 and Xcode 8): + ``-Wl,-cache_path_lto,/path/to/cache`` + +Clang Bootstrap +--------------- + +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 `_. +#. Use the following additional `CMake variables + `_ + when configuring the bootstrap compiler build: + + * ``-DLLVM_ENABLE_LTO=Thin`` + * ``-DLLVM_PARALLEL_LINK_JOBS=1`` + (since the ThinLTO link invokes parallel backend jobs) + * ``-DCMAKE_C_COMPILER=/path/to/host/clang`` + * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++`` + * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib`` + * ``-DCMAKE_AR=/path/to/host/llvm-ar`` + +#. To use additional linker arguments for controlling the backend + parallelism_ or enabling incremental_ builds of the bootstrap compiler, + after configuring the build, modify the resulting CMakeCache.txt file in the + build directory. Specify any additional linker options after + ``CMAKE_EXE_LINKER_FLAGS:STRING=``. Note the configure may fail if + linker plugin options are instead specified directly in the previous step. + +More Information +================ + +* From LLVM project blog: + `ThinLTO: Scalable and Incremental LTO + `_ diff --git a/docs/ThreadSanitizer.rst b/docs/ThreadSanitizer.rst index cfb0a952e12..cfbaa63d643 100644 --- a/docs/ThreadSanitizer.rst +++ b/docs/ThreadSanitizer.rst @@ -83,11 +83,11 @@ this purpose. # endif #endif -``__attribute__((no_sanitize_thread))`` +``__attribute__((no_sanitize("thread")))`` ----------------------------------------------- Some code should not be instrumented by ThreadSanitizer. One may use the -function attribute `no_sanitize_thread` to disable instrumentation of plain +function attribute ``no_sanitize("thread")`` to disable instrumentation of plain (non-atomic) loads/stores in a particular function. ThreadSanitizer still instruments such functions to avoid false positives and provide meaningful stack traces. This attribute may not be supported by other compilers, so we suggest @@ -99,9 +99,9 @@ Blacklist ThreadSanitizer supports ``src`` and ``fun`` entity types in :doc:`SanitizerSpecialCaseList`, that can be used to suppress data race reports in the specified source files or functions. Unlike functions marked with -`no_sanitize_thread` attribute, blacklisted functions are not instrumented at -all. This can lead to false positives due to missed synchronization via atomic -operations and missed stack frames in reports. +``no_sanitize("thread")`` attribute, blacklisted functions are not instrumented +at all. This can lead to false positives due to missed synchronization via +atomic operations and missed stack frames in reports. Limitations ----------- diff --git a/docs/Toolchain.rst b/docs/Toolchain.rst new file mode 100644 index 00000000000..6ae8888c693 --- /dev/null +++ b/docs/Toolchain.rst @@ -0,0 +1,354 @@ +=============================== +Assembling a Complete Toolchain +=============================== + +.. contents:: + :local: + :depth: 2 + +Introduction +============ + +Clang is only one component in a complete tool chain for C family +programming languages. In order to assemble a complete toolchain, +additional tools and runtime libraries are required. Clang is designed +to interoperate with existing tools and libraries for its target +platforms, and the LLVM project provides alternatives for a number +of these components. + +This document describes the required and optional components in a +complete toolchain, where to find them, and the supported versions +and limitations of each option. + +.. warning:: + + This document currently describes Clang configurations on POSIX-like + operating systems with the GCC-compatible ``clang`` driver. When + targeting Windows with the MSVC-compatible ``clang-cl`` driver, some + of the details are different. + +Tools +===== + +.. FIXME: Describe DWARF-related tools + +A complete compilation of C family programming languages typically +involves the following pipeline of tools, some of which are omitted +in some compilations: + +* **Preprocessor**: This performs the actions of the C preprocessor: + expanding #includes and #defines. + The ``-E`` flag instructs Clang to stop after this step. + +* **Parsing**: This parses and semantically analyzes the source language and + builds a source-level intermediate representation ("AST"), producing a + :ref:`precompiled header (PCH) `, + preamble, or + :doc:`precompiled module file (PCM) `, + depending on the input. + The ``-precompile`` flag instructs Clang to stop after this step. This is + the default when the input is a header file. + +* **IR generation**: This converts the source-level intermediate representation + into an optimizer-specific intermediate representation (IR); for Clang, this + is LLVM IR. + The ``-emit-llvm`` flag instructs Clang to stop after this step. If combined + with ``-S``, Clang will produce textual LLVM IR; otherwise, it will produce + LLVM IR bitcode. + +* **Compiler backend**: This converts the intermediate representation + into target-specific assembly code. + The ``-S`` flag instructs Clang to stop after this step. + +* **Assembler**: This converts target-specific assembly code into + target-specific machine code object files. + The ``-c`` flag instructs Clang to stop after this step. + +* **Linker**: This combines multiple object files into a single image + (either a shared object or an executable). + +Clang provides all of these pieces other than the linker. When multiple +steps are performed by the same tool, it is common for the steps to be +fused together to avoid creating intermediate files. + +When given an output of one of the above steps as an input, earlier steps +are skipped (for instance, a ``.s`` file input will be assembled and linked). + +The Clang driver can be invoked with the ``-###`` flag (this argument will need +to be escaped under most shells) to see which commands it would run for the +above steps, without running them. The ``-v`` (verbose) flag will print the +commands in addition to running them. + +Clang frontend +-------------- + +The Clang frontend (``clang -cc1``) is used to compile C family languages. The +command-line interface of the frontend is considered to be an implementation +detail, intentionally has no external documentation, and is subject to change +without notice. + +Language frontends for other languages +-------------------------------------- + +Clang can be provided with inputs written in non-C-family languages. In such +cases, an external tool will be used to compile the input. The +currently-supported languages are: + +* Ada (``-x ada``, ``.ad[bs]``) +* Fortran (``-x f95``, ``.f``, ``.f9[05]``, ``.for``, ``.fpp``, case-insensitive) +* Java (``-x java``) + +In each case, GCC will be invoked to compile the input. + +Assember +-------- + +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 integrataed assembler on all targets where it is +supported. If you wish to use the system assember instead, use the +``-fno-integrated-as`` option. + +Linker +------ + +Clang can be configured to use one of several different linkers: + +* GNU ld +* GNU gold +* LLVM's `lld `_ +* MSVC's link.exe + +Link-time optimization is natively supported by lld, and supported via +a `linker plugin `_ when using gold. + +The default linker varies between targets, and can be overridden via the +``-fuse-ld=`` flag. + +Runtime libraries +================= + +A number of different runtime libraries are required to provide different +layers of support for C family programs. Clang will implicitly link an +appropriate implementation of each runtime library, selected based on +target defaults or explicitly selected by the ``--rtlib=`` and ``--stdlib=`` +flags. + +The set of implicitly-linked libraries depend on the language mode. As a +consequence, you should use ``clang++`` when linking C++ programs in order +to ensure the C++ runtimes are provided. + +.. note:: + + There may exist other implementations for these components not described + below. Please let us know how well those other implementations work with + Clang so they can be added to this list! + +.. FIXME: Describe Objective-C runtime libraries +.. FIXME: Describe profiling runtime library +.. FIXME: Describe cuda/openmp/opencl/... runtime libraries + +Compiler runtime +---------------- + +The compiler runtime library provides definitions of functions implicitly +invoked by the compiler to support operations not natively supported by +the underlying hardware (for instance, 128-bit integer multiplications), +and where inline expansion of the operation is deemed unsuitable. + +The default runtime library is target-specific. For targets where GCC is +the dominant compiler, Clang currently defaults to using libgcc_s. On most +other targets, compiler-rt is used by default. + +compiler-rt (LLVM) +^^^^^^^^^^^^^^^^^^ + +`LLVM's compiler runtime library `_ provides a +complete set of runtime library functions containing all functions that +Clang will implicitly call, in ``libclang_rt.builtins..a``. + +You can instruct Clang to use compiler-rt with the ``--rtlib=compiler-rt`` flag. +This is not supported on every platform. + +If using libc++ and/or libc++abi, you may need to configure them to use +compiler-rt rather than libgcc_s by passing ``-DLIBCXX_USE_COMPILER_RT=YES`` +and/or ``-DLIBCXXABI_USE_COMPILER_RT=YES`` to ``cmake``. Otherwise, you +may end up with both runtime libraries linked into your program (this is +typically harmless, but wasteful). + +libgcc_s (GNU) +^^^^^^^^^^^^^^ + +`GCC's runtime library `_ +can be used in place of compiler-rt. However, it lacks several functions +that LLVM may emit references to, particularly when using Clang's +``__builtin_*_overflow`` family of intrinsics. + +You can instruct Clang to use libgcc_s with the ``--rtlib=libgcc`` flag. +This is not supported on every platform. + +Atomics library +--------------- + +If your program makes use of atomic operations and the compiler is not able +to lower them all directly to machine instructions (because there either is +no known suitable machine instruction or the operand is not known to be +suitably aligned), a call to a runtime library ``__atomic_*`` function +will be generated. A runtime library containing these atomics functions is +necessary for such programs. + +compiler-rt (LLVM) +^^^^^^^^^^^^^^^^^^ + +compiler-rt contains an implementation of an atomics library. + +libatomic (GNU) +^^^^^^^^^^^^^^^ + +libgcc_s does not provide an implementation of an atomics library. Instead, +`GCC's libatomic library `_ can be +used to supply these when using libgcc_s. + +.. note:: + + Clang does not currently automatically link against libatomic when using + libgcc_s. You may need to manually add ``-latomic`` to support this + configuration when using non-native atomic operations (if you see link errors + referring to ``__atomic_*`` functions). + +Unwind library +-------------- + +The unwind library provides a family of ``_Unwind_*`` functions implementing +the language-neutral stack unwinding portion of the Itanium C++ ABI +(`Level I `_). +It is a dependency of the C++ ABI library, and sometimes is a dependency +of other runtimes. + +libunwind (LLVM) +^^^^^^^^^^^^^^^^ + +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 + +When checked out into projects/libunwind within an LLVM checkout, +it should be automatically picked up by the LLVM build system. + +If using libc++abi, you may need to configure it to use libunwind +rather than libgcc_s by passing ``-DLIBCXXABI_USE_LLVM_UNWINDER=YES`` +to ``cmake``. If libc++abi is configured to use some version of +libunwind, that library will be implicitly linked into binaries that +link to libc++abi. + +libgcc_s (GNU) +^^^^^^^^^^^^^^ + +libgcc_s has an integrated unwinder, and does not need an external unwind +library to be provided. + +libunwind (nongnu.org) +^^^^^^^^^^^^^^^^^^^^^^ + +This is another implementation of the libunwind specification. +See `libunwind (nongnu.org) `_. + +libunwind (PathScale) +^^^^^^^^^^^^^^^^^^^^^ + +This is another implementation of the libunwind specification. +See `libunwind (pathscale) `_. + +Sanitizer runtime +----------------- + +The instrumentation added by Clang's sanitizers (``-fsanitize=...``) implicitly +makes calls to a runtime library, in order to maintain side state about the +execution of the program and to issue diagnostic messages when a problem is +detected. + +The only supported implementation of these runtimes is provided by LLVM's +compiler-rt, and the relevant portion of that library +(``libclang_rt...a``) +will be implicitly linked when linking with a ``-fsanitize=...`` flag. + +C standard library +------------------ + +Clang supports a wide variety of +`C standard library `_ +implementations. + +C++ ABI library +--------------- + +The C++ ABI library provides an implementation of the library portion of +the Itanium C++ ABI, covering both the +`support functionality in the main Itanium C++ ABI document +`_ and +`Level II of the exception handling support +`_. +References to the functions and objects in this library are implicitly +generated by Clang when compiling C++ code. + +While it is possible to link C++ code using libstdc++ and code using libc++ +together into the same program (so long as you do not attempt to pass C++ +standard library objects across the boundary), it is not generally possible +to have more than one C++ ABI library in a program. + +The version of the C++ ABI library used by Clang will be the one that the +chosen C++ standard library was linked against. Several implementations are +available: + +libc++abi (LLVM) +^^^^^^^^^^^^^^^^ + +`libc++abi `_ is LLVM's implementation of this +specification. + +libsupc++ (GNU) +^^^^^^^^^^^^^^^ + +libsupc++ is GCC's implementation of this specification. However, this +library is only used when libstdc++ is linked statically. The dynamic +library version of libstdc++ contains a copy of libsupc++. + +.. note:: + + Clang does not currently automatically link against libatomic when statically + linking libstdc++. You may need to manually add ``-lsupc++`` to support this + configuration when using ``-static`` or ``-static-libstdc++``. + +libcxxrt (PathScale) +^^^^^^^^^^^^^^^^^^^^ + +This is another implementation of the Itanium C++ ABI specification. +See `libcxxrt `_. + +C++ standard library +-------------------- + +Clang supports use of either LLVM's libc++ or GCC's libstdc++ implementation +of the `C++ standard library `_. + +libc++ (LLVM) +^^^^^^^^^^^^^ + +`libc++ `_ is LLVM's implementation of the C++ +standard library, aimed at being a complete implementation of the C++ +standards from C++11 onwards. + +You can instruct Clang to use libc++ with the ``-stdlib=libc++`` flag. + +libstdc++ (GNU) +^^^^^^^^^^^^^^^ + +`libstdc++ `_ is GCC's implementation +of the C++ standard library. Clang supports a wide range of versions of +libstdc++, from around version 4.2 onwards, and will implicitly work around +some bugs in older versions of libstdc++. + +You can instruct Clang to use libstdc++ with the ``-stdlib=libstdc++`` flag. diff --git a/docs/UndefinedBehaviorSanitizer.rst b/docs/UndefinedBehaviorSanitizer.rst index 7babb96a65a..09ee78f5876 100644 --- a/docs/UndefinedBehaviorSanitizer.rst +++ b/docs/UndefinedBehaviorSanitizer.rst @@ -66,8 +66,8 @@ pointer. .. _ubsan-checks: -Availablle checks -================= +Available checks +================ Available checks are: diff --git a/docs/UsersManual.rst b/docs/UsersManual.rst index 2ebcbdf6031..04023dd2060 100644 --- a/docs/UsersManual.rst +++ b/docs/UsersManual.rst @@ -2,6 +2,8 @@ Clang Compiler User's Manual ============================ +.. include:: + .. contents:: :local: @@ -23,6 +25,10 @@ processes code, please see :doc:`InternalsManual`. If you are interested in the `Clang Static Analyzer `_, please see its web page. +Clang is one component in a complete toolchain for C family languages. +A separate document describes the other pieces necessary to +:doc:`assemble a complete toolchain `. + Clang is designed to support the C family of programming languages, which includes :ref:`C `, :ref:`Objective-C `, :ref:`C++ `, and :ref:`Objective-C++ ` as well as many dialects of those. For @@ -35,6 +41,7 @@ specific section: variants depending on base language. - :ref:`C++ Language ` - :ref:`Objective C++ Language ` +- :ref:`OpenCL C Language `: v1.0, v1.1, v1.2, v2.0. In addition to these base languages and their dialects, Clang supports a broad variety of language extensions, which are documented in the @@ -105,6 +112,8 @@ Options to Control Error and Warning Messages .. option:: -Wfoo Enable warning "foo". + See the :doc:`diagnostics reference ` for a complete + list of the warning flags that can be specified in this way. .. option:: -Wno-foo @@ -313,6 +322,28 @@ output format of the diagnostics that it generates. by category, so it should be a high level category. We want dozens of these, not hundreds or thousands of them. +.. _opt_fdiagnostics-show-hotness: + +**-f[no-]diagnostics-show-hotness** + Enable profile hotness information in diagnostic line. + + This option, which defaults to off, controls whether Clang prints the + profile hotness associated with a diagnostics in the presence of + profile-guided optimization information. This is currently supported with + optimization remarks (see :ref:`Options to Emit Optimization Reports + `). The hotness information allows users to focus on the hot + optimization remarks that are likely to be more relevant for run-time + performance. + + For example, in this output, the block containing the callsite of `foo` was + executed 3000 times according to the profile data: + + :: + + s.c:7:10: remark: foo inlined into bar (hotness: 3000) [-Rpass-analysis=inline] + sum += foo(x, x - 2); + ^ + .. _opt_fdiagnostics-fixit-info: **-f[no-]diagnostics-fixit-info** @@ -531,6 +562,8 @@ control the crash diagnostics. The -fno-crash-diagnostics flag can be helpful for speeding the process of generating a delta reduced test case. +.. _rpass: + Options to Emit Optimization Reports ------------------------------------ @@ -574,6 +607,10 @@ outside of the major transformations (e.g., inlining, vectorization, loop optimizations) and not every optimization pass supports this feature. +Note that when using profile-guided optimization information, profile hotness +information can be included in the remarks (see +:ref:`-fdiagnostics-show-hotness `). + Current limitations ^^^^^^^^^^^^^^^^^^^ @@ -1060,6 +1097,14 @@ are listed below. the behavior of sanitizers in the ``cfi`` group to allow checking of cross-DSO virtual and indirect calls. + +.. option:: -fstrict-vtable-pointers + + Enable optimizations based on the strict rules for overwriting polymorphic + C++ objects, i.e. the vptr is invariant during an object's lifetime. + This enables better devirtualization. Turned off by default, because it is + still experimental. + .. option:: -ffast-math Enable fast-math mode. This defines the ``__FAST_MATH__`` preprocessor @@ -1073,6 +1118,15 @@ are listed below. ``Inf``, and * ``+0`` and ``-0`` are interchangeable. +.. option:: -fdenormal-fp-math=[values] + + Select which denormal numbers the code is permitted to require. + + Valid values are: ``ieee``, ``preserve-sign``, and ``positive-zero``, + which correspond to IEEE 754 denormal numbers, the sign of a + flushed-to-zero number is preserved in the sign of 0, denormals are + flushed to positive zero, respectively. + .. option:: -fwhole-program-vtables Enable whole-program vtable optimizations, such as single-implementation @@ -1470,8 +1524,13 @@ instrumentation: 2. Run the instrumented executable with inputs that reflect the typical usage. By default, the profile data will be written to a ``default.profraw`` file - in the current directory. You can override that default by setting the - ``LLVM_PROFILE_FILE`` environment variable to specify an alternate file. + in the current directory. You can override that default by using option + ``-fprofile-instr-generate=`` or by setting the ``LLVM_PROFILE_FILE`` + environment variable to specify an alternate file. If non-default file name + is specified by both the environment variable and the command line option, + the environment variable takes precedence. The file name pattern specified + can include different modifiers: ``%p``, ``%h``, and ``%m``. + Any instance of ``%p`` in that file name will be replaced by the process ID, so that you can easily distinguish the profile output from multiple runs. @@ -1480,6 +1539,33 @@ instrumentation: $ LLVM_PROFILE_FILE="code-%p.profraw" ./code + The modifier ``%h`` can be used in scenarios where the same instrumented + binary is run in multiple different host machines dumping profile data + to a shared network based storage. The ``%h`` specifier will be substituted + with the hostname so that profiles collected from different hosts do not + clobber each other. + + While the use of ``%p`` specifier can reduce the likelihood for the profiles + dumped from different processes to clobber each other, such clobbering can still + happen because of the ``pid`` re-use by the OS. Another side-effect of using + ``%p`` is that the storage requirement for raw profile data files is greatly + increased. To avoid issues like this, the ``%m`` specifier can used in the profile + name. When this specifier is used, the profiler runtime will substitute ``%m`` + with a unique integer identifier associated with the instrumented binary. Additionally, + multiple raw profiles dumped from different processes that share a file system (can be + on different hosts) will be automatically merged by the profiler runtime during the + dumping. If the program links in multiple instrumented shared libraries, each library + will dump the profile data into its own profile data file (with its unique integer + id embedded in the profile name). Note that the merging enabled by ``%m`` is for raw + profile data generated by profiler runtime. The resulting merged "raw" profile data + file still needs to be converted to a different format expected by the compiler ( + see step 3 below). + + .. code-block:: console + + $ LLVM_PROFILE_FILE="code-%m.profraw" ./code + + 3. Combine profiles from multiple runs and convert the "raw" profile format to the input expected by clang. Use the ``merge`` command of the ``llvm-profdata`` tool to do this. @@ -1514,27 +1600,31 @@ profile creation and use. The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use an alterantive instrumentation method for profile generation. When given a directory name, it generates the profile file - ``default.profraw`` in the directory named ``dirname``. If ``dirname`` - does not exist, it will be created at runtime. The environment variable - ``LLVM_PROFILE_FILE`` can be used to override the directory and - filename for the profile file at runtime. For example, + ``default_%m.profraw`` in the directory named ``dirname`` if specified. + If ``dirname`` does not exist, it will be created at runtime. ``%m`` specifier + will be substibuted with a unique id documented in step 2 above. In other words, + with ``-fprofile-generate[=]`` option, the "raw" profile data automatic + merging is turned on by default, so there will no longer any risk of profile + clobbering from different running processes. For example, .. code-block:: console $ clang++ -O2 -fprofile-generate=yyy/zzz code.cc -o code When ``code`` is executed, the profile will be written to the file - ``yyy/zzz/default.profraw``. This can be altered at runtime via the - ``LLVM_PROFILE_FILE`` environment variable: + ``yyy/zzz/default_xxxx.profraw``. - .. code-block:: console + To generate the profile data file with the compiler readable format, the + ``llvm-profdata`` tool can be used with the profile directory as the input: + + .. code-block:: console - $ LLVM_PROFILE_FILE=/tmp/myprofile/code.profraw ./code + $ llvm-profdata merge -output=code.profdata yyy/zzz/ - The above invocation will produce the profile file - ``/tmp/myprofile/code.profraw`` instead of ``yyy/zzz/default.profraw``. - Notice that ``LLVM_PROFILE_FILE`` overrides the directory *and* the file - name for the profile file. + If the user wants to turn off the auto-merging feature, or simply override the + the profile dumping path specified at command line, the environment variable + ``LLVM_PROFILE_FILE`` can still be used to override + the directory and filename for the profile file at runtime. .. option:: -fprofile-use[=] @@ -1614,7 +1704,7 @@ features. You can "tune" the debug info for one of several different debuggers. .. option:: -ggdb, -glldb, -gsce - Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer Entertainment + Tune the debug info for the ``gdb``, ``lldb``, or Sony PlayStation\ |reg| debugger, respectively. Each of these options implies **-g**. (Therefore, if you want both **-gline-tables-only** and debugger tuning, the tuning option must come first.) @@ -1749,6 +1839,10 @@ extensions are not implemented yet: ... local_function(1); +- clang only supports global register variables when the register specified + is non-allocatable (e.g. the stack pointer). Support for general global + register variables is unlikely to be implemented soon because it requires + additional LLVM backend support. - clang does not support static initialization of flexible array members. This appears to be a rarely used extension, but could be implemented pending user demand. @@ -1888,6 +1982,365 @@ Controlling implementation limits is provided or target does not support TLS, code generation for threadprivate variables relies on OpenMP runtime library. +.. _opencl: + +OpenCL Features +=============== + +Clang can be used to compile OpenCL kernels for execution on a device +(e.g. GPU). It is possible to compile the kernel into a binary (e.g. for AMD or +Nvidia targets) that can be uploaded to run directly on a device (e.g. using +`clCreateProgramWithBinary +`_) or +into generic bitcode files loadable into other toolchains. + +Compiling to a binary using the default target from the installation can be done +as follows: + + .. code-block:: console + + $ echo "kernel void k(){}" > test.cl + $ clang test.cl + +Compiling for a specific target can be done by specifying the triple corresponding +to the target, for example: + + .. code-block:: console + + $ clang -target nvptx64-unknown-unknown test.cl + $ clang -target amdgcn-amd-amdhsa-opencl test.cl + +Compiling to bitcode can be done as follows: + + .. code-block:: console + + $ clang -c -emit-llvm test.cl + +This will produce a generic test.bc file that can be used in vendor toolchains +to perform machine code generation. + +Clang currently supports OpenCL C language standards up to v2.0. + +OpenCL Specific Options +----------------------- + +Most of the OpenCL build options from `the specification v2.0 section 5.8.4 +`_ are available. + +Examples: + + .. code-block:: console + + $ clang -cl-std=CL2.0 -cl-single-precision-constant test.cl + +Some extra options are available to support special OpenCL features. + +.. option:: -finclude-default-header + +Loads standard includes during compilations. By default OpenCL headers are not +loaded and therefore standard library includes are not available. To load them +automatically a flag has been added to the frontend (see also :ref:`the section +on the OpenCL Header `): + + .. code-block:: console + + $ clang -Xclang -finclude-default-header test.cl + +Alternatively ``-include`` or ``-I`` followed by the path to the header location +can be given manually. + + .. code-block:: console + + $ clang -I/lib/Headers/opencl-c.h test.cl + +In this case the kernel code should contain ``#include `` just as a +regular C include. + +.. option:: -cl-ext + +Disables support of OpenCL extensions. All OpenCL targets provide a list +of extensions that they support. Clang allows to amend this using the ``-cl-ext`` +flag with a comma-separated list of extensions prefixed with ``'+'`` or ``'-'``. +The syntax: ``-cl-ext=<(['-'|'+'][,])+>``, where extensions +can be either one of `the OpenCL specification extensions +`_ +or any known vendor extension. Alternatively, ``'all'`` can be used to enable +or disable all known extensions. +Example disabling double support for the 64-bit SPIR target: + + .. code-block:: console + + $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl + +Enabling all extensions except double support in R600 AMD GPU can be done using: + + .. code-block:: console + + $ clang -cc1 -triple r600-unknown-unknown -cl-ext=-all,+cl_khr_fp16 test.cl + +.. _opencl_fake_address_space_map: + +.. option:: -ffake-address-space-map + +Overrides the target address space map with a fake map. +This allows adding explicit address space IDs to the bitcode for non-segmented +memory architectures that don't have separate IDs for each of the OpenCL +logical address spaces by default. Passing ``-ffake-address-space-map`` will +add/override address spaces of the target compiled for with the following values: +``1-global``, ``2-constant``, ``3-local``, ``4-generic``. The private address +space is represented by the absence of an address space attribute in the IR (see +also :ref:`the section on the address space attribute `). + + .. code-block:: console + + $ clang -ffake-address-space-map test.cl + +Some other flags used for the compilation for C can also be passed while +compiling for OpenCL, examples: ``-c``, ``-O<1-4|s>``, ``-o``, ``-emit-llvm``, etc. + +OpenCL Targets +-------------- + +OpenCL targets are derived from the regular Clang target classes. The OpenCL +specific parts of the target representation provide address space mapping as +well as a set of supported extensions. + +Specific Targets +^^^^^^^^^^^^^^^^ + +There is a set of concrete HW architectures that OpenCL can be compiled for. + +- For AMD target: + + .. code-block:: console + + $ clang -target amdgcn-amd-amdhsa-opencl test.cl + +- For Nvidia architectures: + + .. code-block:: console + + $ clang -target nvptx64-unknown-unknown test.cl + + +Generic Targets +^^^^^^^^^^^^^^^ + +- SPIR is available as a generic target to allow portable bitcode to be produced + that can be used across GPU toolchains. The implementation follows `the SPIR + specification `_. There are two flavors + available for 32 and 64 bits. + + .. code-block:: console + + $ clang -target spir-unknown-unknown test.cl + $ clang -target spir64-unknown-unknown test.cl + + All known OpenCL extensions are supported in the SPIR targets. Clang will + generate SPIR v1.2 compatible IR for OpenCL versions up to 2.0 and SPIR v2.0 + for OpenCL v2.0. + +- x86 is used by some implementations that are x86 compatible and currently + remains for backwards compatibility (with older implementations prior to + SPIR target support). For "non-SPMD" targets which cannot spawn multiple + work-items on the fly using hardware, which covers practically all non-GPU + devices such as CPUs and DSPs, additional processing is needed for the kernels + to support multiple work-item execution. For this, a 3rd party toolchain, + such as for example `POCL `_, can be used. + + This target does not support multiple memory segments and, therefore, the fake + address space map can be added using the :ref:`-ffake-address-space-map + ` flag. + +.. _opencl_header: + +OpenCL Header +------------- + +By default Clang will not include standard headers and therefore OpenCL builtin +functions and some types (i.e. vectors) are unknown. The default CL header is, +however, provided in the Clang installation and can be enabled by passing the +``-finclude-default-header`` flag to the Clang frontend. + + .. code-block:: console + + $ echo "bool is_wg_uniform(int i){return get_enqueued_local_size(i)==get_local_size(i);}" > test.cl + $ clang -Xclang -finclude-default-header -cl-std=CL2.0 test.cl + +Because the header is very large and long to parse, PCH (:doc:`PCHInternals`) +and modules (:doc:`Modules`) are used internally to improve the compilation +speed. + +To enable modules for OpenCL: + + .. code-block:: console + + $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path= test.cl + +OpenCL Metadata +--------------- + +Clang uses metadata to provide additional OpenCL semantics in IR needed for +backends and OpenCL runtime. + +Each kernel will have function metadata attached to it, specifying the arguments. +Kernel argument metadata is used to provide source level information for querying +at runtime, for example using the `clGetKernelArgInfo +`_ +call. + +Note that ``-cl-kernel-arg-info`` enables more information about the original CL +code to be added e.g. kernel parameter names will appear in the OpenCL metadata +along with other information. + +The IDs used to encode the OpenCL's logical address spaces in the argument info +metadata follows the SPIR address space mapping as defined in the SPIR +specification `section 2.2 +`_ + +OpenCL-Specific Attributes +-------------------------- + +OpenCL support in Clang contains a set of attribute taken directly from the +specification as well as additional attributes. + +See also :doc:`AttributeReference`. + +nosvm +^^^^^ + +Clang supports this attribute to comply to OpenCL v2.0 conformance, but it +does not have any effect on the IR. For more details reffer to the specification +`section 6.7.2 +`_ + + +opencl_hint_unroll +^^^^^^^^^^^^^^^^^^ + +The implementation of this feature mirrors the unroll hint for C. +More details on the syntax can be found in the specification +`section 6.11.5 +`_ + +convergent +^^^^^^^^^^ + +To make sure no invalid optimizations occur for single program multiple data +(SPMD) / single instruction multiple thread (SIMT) Clang provides attributes that +can be used for special functions that have cross work item semantics. +An example is the subgroup operations such as `intel_sub_group_shuffle +`_ + + .. code-block:: c + + // Define custom my_sub_group_shuffle(data, c) + // that makes use of intel_sub_group_shuffle + r1 = … + if (r0) r1 = computeA(); + // Shuffle data from r1 into r3 + // of threads id r2. + r3 = my_sub_group_shuffle(r1, r2); + if (r0) r3 = computeB(); + +with non-SPMD semantics this is optimized to the following equivalent code: + + .. code-block:: c + + r1 = … + if (!r0) + // Incorrect functionality! The data in r1 + // have not been computed by all threads yet. + r3 = my_sub_group_shuffle(r1, r2); + else { + r1 = computeA(); + r3 = my_sub_group_shuffle(r1, r2); + r3 = computeB(); + } + +Declaring the function ``my_sub_group_shuffle`` with the convergent attribute +would prevent this: + + .. code-block:: c + + my_sub_group_shuffle() __attribute__((convergent)); + +Using ``convergent`` guarantees correct execution by keeping CFG equivalence +wrt operations marked as ``convergent``. CFG ``G´`` is equivalent to ``G`` wrt +node ``Ni`` : ``iff ∀ Nj (i≠j)`` domination and post-domination relations with +respect to ``Ni`` remain the same in both ``G`` and ``G´``. + +noduplicate +^^^^^^^^^^^ + +``noduplicate`` is more restrictive with respect to optimizations than +``convergent`` because a convergent function only preserves CFG equivalence. +This allows some optimizations to happen as long as the control flow remains +unmodified. + + .. code-block:: c + + for (int i=0; i<4; i++) + my_sub_group_shuffle() + +can be modified to: + + .. code-block:: c + + my_sub_group_shuffle(); + my_sub_group_shuffle(); + my_sub_group_shuffle(); + my_sub_group_shuffle(); + +while using ``noduplicate`` would disallow this. Also ``noduplicate`` doesn't +have the same safe semantics of CFG as ``convergent`` and can cause changes in +CFG that modify semantics of the original program. + +``noduplicate`` is kept for backwards compatibility only and it considered to be +deprecated for future uses. + +.. _opencl_addrsp: + +address_space +^^^^^^^^^^^^^ + +Clang has arbitrary address space support using the ``address_space(N)`` +attribute, where ``N`` is an integer number in the range ``0`` to ``16777215`` +(``0xffffffu``). + +An OpenCL implementation provides a list of standard address spaces using +keywords: ``private``, ``local``, ``global``, and ``generic``. In the AST and +in the IR local, global, or generic will be represented by the address space +attribute with the corresponding unique number. Note that private does not have +any corresponding attribute added and, therefore, is represented by the absence +of an address space number. The specific IDs for an address space do not have to +match between the AST and the IR. Typically in the AST address space numbers +represent logical segments while in the IR they represent physical segments. +Therefore, machines with flat memory segments can map all AST address space +numbers to the same physical segment ID or skip address space attribute +completely while generating the IR. However, if the address space information +is needed by the IR passes e.g. to improve alias analysis, it is recommended +to keep it and only lower to reflect physical memory segments in the late +machine passes. + +OpenCL builtins +--------------- + +There are some standard OpenCL functions that are implemented as Clang builtins: + +- All pipe functions from `section 6.13.16.2/6.13.16.3 + `_ of + the OpenCL v2.0 kernel language specification. ` + +- Address space qualifier conversion functions ``to_global``/``to_local``/``to_private`` + from `section 6.13.9 + `_. + +- All the ``enqueue_kernel`` functions from `section 6.13.17.1 + `_ and + enqueue query functions from `section 6.13.17.5 + `_. + .. _target_features: Target-Specific Features and Limitations @@ -2017,7 +2470,7 @@ Clang expects the GCC executable "gcc.exe" compiled for clang-cl ======== -clang-cl is an alternative command-line interface to Clang driver, designed for +clang-cl is an alternative command-line interface to Clang, designed for compatibility with the Visual C++ compiler, cl.exe. To enable clang-cl to find system headers, libraries, and the linker when run @@ -2025,7 +2478,7 @@ from the command-line, it should be executed inside a Visual Studio Native Tools Command Prompt or a regular Command Prompt where the environment has been set up using e.g. `vcvars32.bat `_. -clang-cl can also be used from inside Visual Studio by using an LLVM Platform +clang-cl can also be used from inside Visual Studio by using an LLVM Platform Toolset. Command-Line Options @@ -2060,116 +2513,125 @@ Execute ``clang-cl /?`` to see a list of supported options: :: CL.EXE COMPATIBILITY OPTIONS: - /? Display available 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 - /C Don't discard comments when preprocessing - /c Compile only - /D Define macro - /EH Exception handling model - /EP Disable linemarker output and preprocess to stdout - /E Preprocess to stdout - /fallback Fall back to cl.exe if clang-cl fails to compile - /FA Output assembly code file during compilation - /Fa Output assembly code to this file during compilation (with /FA) - /Fe Set output executable file or directory (ends in / or \) - /FI Include file before parsing - /Fi Set preprocess output file name (with /P) - /Fo Set output object file, or directory (ends in / or \) (with /c) + /? Display available 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 + /C Don't discard comments when preprocessing + /c Compile only + /D Define macro + /EH Exception handling model + /EP Disable linemarker output and preprocess to stdout + /execution-charset: + Runtime encoding, supports only UTF-8 + /E Preprocess to stdout + /fallback Fall back to cl.exe if clang-cl fails to compile + /FA Output assembly code file during compilation + /Fa Output assembly code to this file during compilation (with /FA) + /Fe Set output executable file or directory (ends in / or \) + /FI Include file before parsing + /Fi Set preprocess output file name (with /P) + /Fo Set output object file, or directory (ends in / or \) (with /c) /fp:except- /fp:except /fp:fast /fp:precise /fp:strict - /Fp Set pch filename (with /Yc and /Yu) - /GA Assume thread-local variables are defined in the executable - /Gd Set __cdecl as a default calling convention - /GF- Disable string pooling - /GR- Disable emission of RTTI data - /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 - /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- Enable exception handling - /GX Enable exception handling - /Gy- Don't put each function in its own section - /Gy Put each function in its own section - /Gz Set __stdcall as a default calling convention - /help Display available options - /imsvc Add directory to system include search path, as if part of %INCLUDE% - /I Add directory to include search path - /J Make char type unsigned - /LDd Create debug DLL - /LD Create DLL - /link Forward options to the linker - /MDd Use DLL debug run-time - /MD Use DLL run-time - /MTd Use static debug run-time - /MT Use static run-time - /Od Disable optimization - /Oi- Disable use of builtin functions - /Oi Enable use of builtin functions - /Os Optimize for size - /Ot Optimize for speed - /O Optimization level - /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 - /showIncludes Print info about included files to stderr - /std: Language standard to compile for - /TC Treat all source files as C - /Tc Specify a C source file - /TP Treat all source files as C++ - /Tp Specify a C++ source file - /U Undefine macro - /vd Control vtordisp placement - /vmb Use a best-case representation method for member pointers - /vmg Use a most-general representation for member pointers - /vmm Set the default most-general representation to multiple inheritance - /vms Set the default most-general representation to single inheritance - /vmv Set the default most-general representation to virtual inheritance - /volatile:iso Volatile loads and stores have standard semantics - /volatile:ms Volatile loads and stores have acquire and release semantics - /W0 Disable all warnings - /W1 Enable -Wall - /W2 Enable -Wall - /W3 Enable -Wall - /W4 Enable -Wall and -Wextra - /Wall Enable -Wall and -Wextra - /WX- Do not treat warnings as errors - /WX Treat warnings as errors - /w Disable all warnings - /Y- Disable precompiled headers, overrides /Yc and /Yu - /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:sizedDealloc- Disable C++14 sized global deallocation functions - /Zc:sizedDealloc Enable C++14 sized global deallocation functions - /Zc:strictStrings Treat string literals as const - /Zc:threadSafeInit- Disable thread-safe initialization of static variables - /Zc:threadSafeInit Enable thread-safe initialization of static variables - /Zc:trigraphs- Disable trigraphs (default) - /Zc:trigraphs Enable trigraphs - /Zd Emit debug line number tables only - /Zi Alias for /Z7. Does not produce PDBs. - /Zl Don't mention any default libraries in the object file - /Zp Set the default maximum struct packing alignment to 1 - /Zp Specify the default maximum struct packing alignment - /Zs Syntax-check only + /Fp Set pch filename (with /Yc and /Yu) + /GA Assume thread-local variables are defined in the executable + /Gd Set __cdecl as a default calling convention + /GF- Disable string pooling + /GR- Disable emission of RTTI data + /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 + /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- Enable exception handling + /GX Enable exception handling + /Gy- Don't put each function in its own section + /Gy Put each function in its own section + /Gz Set __stdcall as a default calling convention + /help Display available options + /imsvc Add directory to system include search path, as if part of %INCLUDE% + /I Add directory to include search path + /J Make char type unsigned + /LDd Create debug DLL + /LD Create DLL + /link Forward options to the linker + /MDd Use DLL debug run-time + /MD Use DLL run-time + /MTd Use static debug run-time + /MT Use static run-time + /Od Disable optimization + /Oi- Disable use of builtin functions + /Oi Enable use of builtin functions + /Os Optimize for size + /Ot Optimize for speed + /O Optimization level + /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 + /showIncludes Print info about included files to stderr + /source-charset: Source encoding, supports only UTF-8 + /std: Language standard to compile for + /TC Treat all source files as C + /Tc Specify a C source file + /TP Treat all source files as C++ + /Tp Specify a C++ source file + /utf-8 Set source and runtime encoding to UTF-8 (default) + /U Undefine macro + /vd Control vtordisp placement + /vmb Use a best-case representation method for member pointers + /vmg Use a most-general representation for member pointers + /vmm Set the default most-general representation to multiple inheritance + /vms Set the default most-general representation to single inheritance + /vmv Set the default most-general representation to virtual inheritance + /volatile:iso Volatile loads and stores have standard semantics + /volatile:ms Volatile loads and stores have acquire and release semantics + /W0 Disable all warnings + /W1 Enable -Wall + /W2 Enable -Wall + /W3 Enable -Wall + /W4 Enable -Wall and -Wextra + /Wall Enable -Wall and -Wextra + /WX- Do not treat warnings as errors + /WX Treat warnings as errors + /w Disable all warnings + /Y- Disable precompiled headers, overrides /Yc and /Yu + /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:sizedDealloc- Disable C++14 sized global deallocation functions + /Zc:sizedDealloc Enable C++14 sized global deallocation functions + /Zc:strictStrings Treat string literals as const + /Zc:threadSafeInit- Disable thread-safe initialization of static variables + /Zc:threadSafeInit Enable thread-safe initialization of static variables + /Zc:trigraphs- Disable trigraphs (default) + /Zc:trigraphs Enable trigraphs + /Zd Emit debug line number tables only + /Zi Alias for /Z7. Does not produce PDBs. + /Zl Don't mention any default libraries in the object file + /Zp Set the default maximum struct packing alignment to 1 + /Zp Specify the default maximum struct packing alignment + /Zs Syntax-check only OPTIONS: -### Print (but do not run) the commands to run for this compilation --analyze Run the static analyzer -fansi-escape-codes Use ANSI escape codes for diagnostics -fcolor-diagnostics Use colors in diagnostics + -fdelayed-template-parsing + Parse templated function definitions at the end of the translation unit + -fdiagnostics-absolute-paths + Print absolute paths in diagnostics -fdiagnostics-parseable-fixits Print fix-its in machine parseable form + -flto Enable LTO in 'full' mode -fms-compatibility-version= Dot-separated value representing the Microsoft compiler version number to report in _MSC_VER (0 = don't define it (default)) @@ -2177,12 +2639,23 @@ Execute ``clang-cl /?`` to see a list of supported options: -fms-extensions Accept some non-standard constructs supported by the Microsoft compiler -fmsc-version= Microsoft compiler version number to report in _MSC_VER (0 = don't define it (default)) + -fno-delayed-template-parsing + Disable delayed template parsing -fno-sanitize-coverage= Disable specified features of coverage instrumentation for Sanitizers -fno-sanitize-recover= Disable recovery for specified sanitizers -fno-sanitize-trap= Disable trapping for specified sanitizers + -fno-standalone-debug Limit debug information produced to reduce size of debug binary + -fprofile-instr-generate= + Generate instrumented code to collect execution counts into + (overridden by LLVM_PROFILE_FILE env var) + -fprofile-instr-generate + Generate instrumented code to collect execution counts into default.profraw file + (overridden by '=' form of option or LLVM_PROFILE_FILE env var) + -fprofile-instr-use= + Use instrumentation data for profile-guided optimization -fsanitize-blacklist= Path to blacklist file for sanitizers -fsanitize-coverage= @@ -2192,6 +2665,7 @@ Execute ``clang-cl /?`` to see a list of supported options: -fsanitize-trap= Enable trapping for specified sanitizers -fsanitize= Turn on runtime checks for various forms of undefined or suspicious behavior. See user manual for available checks + -fstandalone-debug Emit full debug info for all types used by the program -gcodeview Generate CodeView debug information -gline-tables-only Emit debug line number tables only -miamcu Use Intel MCU ABI diff --git a/docs/analyzer/DebugChecks.rst b/docs/analyzer/DebugChecks.rst index bfa3142efbd..ecf11ca0f13 100644 --- a/docs/analyzer/DebugChecks.rst +++ b/docs/analyzer/DebugChecks.rst @@ -138,6 +138,17 @@ ExprInspection checks clang_analyzer_warnIfReached(); // no-warning } +- void clang_analyzer_numTimesReached(); + + Same as above, but include the number of times this call expression + gets reached by the analyzer during the current analysis. + + Example usage:: + + for (int x = 0; x < 3; ++x) { + clang_analyzer_numTimesReached(); // expected-warning{{3}} + } + - void clang_analyzer_warnOnDeadSymbol(int); Subscribe for a delayed warning when the symbol that represents the value of @@ -180,6 +191,18 @@ ExprInspection checks clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}} } +- void clang_analyzer_dump(a single argument of any type); + + Similar to clang_analyzer_explain, but produces a raw dump of the value, + same as SVal::dump(). + + Example usage:: + + void clang_analyzer_dump(int); + void foo(int x) { + clang_analyzer_dump(x); // expected-warning{{reg_$0}} + } + - size_t clang_analyzer_getExtent(void *); This function returns the value that represents the extent of a memory region @@ -197,6 +220,22 @@ ExprInspection checks clang_analyzer_explain(ys); // expected-warning{{'8'}} } +- void clang_analyzer_printState(); + + Dumps the current ProgramState to the stderr. Quickly lookup the program state + at any execution point without ViewExplodedGraph or re-compiling the program. + This is not very useful for writing tests (apart from testing how ProgramState + gets printed), but useful for debugging tests. Also, this method doesn't + produce a warning, so it gets printed on the console before all other + ExprInspection warnings. + + Example usage:: + + void foo() { + int x = 1; + clang_analyzer_printState(); // Read the stderr! + } + Statistics ========== diff --git a/docs/analyzer/IPA.txt b/docs/analyzer/IPA.txt index 14da71e0903..3842075fcd6 100644 --- a/docs/analyzer/IPA.txt +++ b/docs/analyzer/IPA.txt @@ -303,7 +303,7 @@ Currently, there are 2 modes: DynamicDispatchModeConservative - Models the case where the dynamic type information is assumed to be incorrect, for example, implies that the method - definition is overriden in a subclass. In such cases, ExprEngine does not + definition is overridden in a subclass. In such cases, ExprEngine does not inline the methods sent to the receiver (MemoryRegion), even if a candidate definition is available. This mode is conservative about simulating the effects of a call. diff --git a/docs/analyzer/conf.py b/docs/analyzer/conf.py index afbfbee6f37..6b54b0646ec 100644 --- a/docs/analyzer/conf.py +++ b/docs/analyzer/conf.py @@ -49,9 +49,9 @@ # built documents. # # The short X.Y version. -version = '3.9' +version = '4.0' # The full version, including alpha/beta/rc tags. -release = '3.9' +release = '4.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/conf.py b/docs/conf.py index 1e8894ac8fe..4683ca567ec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -49,9 +49,9 @@ # built documents. # # The short X.Y version. -version = '3.9' +version = '4.0' # The full version, including alpha/beta/rc tags. -release = '3.9' +release = '4.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 296054766d6..61f9c2c4942 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,8 +17,10 @@ Using Clang as a Compiler :maxdepth: 1 UsersManual + Toolchain LanguageExtensions AttributeReference + DiagnosticsReference CrossCompilation ThreadSafetyAnalysis AddressSanitizer @@ -36,6 +38,7 @@ Using Clang as a Compiler SourceBasedCodeCoverage Modules MSVCCompatibility + ThinLTO CommandGuide/index FAQ diff --git a/examples/AnnotateFunctions/CMakeLists.txt b/examples/AnnotateFunctions/CMakeLists.txt index cf564d527d6..5684abf2380 100644 --- a/examples/AnnotateFunctions/CMakeLists.txt +++ b/examples/AnnotateFunctions/CMakeLists.txt @@ -1,4 +1,4 @@ -add_llvm_loadable_module(AnnotateFunctions AnnotateFunctions.cpp) +add_llvm_loadable_module(AnnotateFunctions 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 5a00d5036fb..f5f818866ca 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) +add_llvm_loadable_module(PrintFunctionNames PrintFunctionNames.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) target_link_libraries(PrintFunctionNames PRIVATE diff --git a/examples/PrintFunctionNames/PrintFunctionNames.cpp b/examples/PrintFunctionNames/PrintFunctionNames.cpp index 9f8f6e3f050..9f6d495caec 100644 --- a/examples/PrintFunctionNames/PrintFunctionNames.cpp +++ b/examples/PrintFunctionNames/PrintFunctionNames.cpp @@ -69,8 +69,9 @@ class PrintFunctionsConsumer : public ASTConsumer { v.TraverseDecl(context.getTranslationUnitDecl()); clang::Sema &sema = Instance.getSema(); for (const FunctionDecl *FD : v.LateParsedDecls) { - clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD); - sema.LateTemplateParser(sema.OpaqueParser, *LPT); + clang::LateParsedTemplate &LPT = + *sema.LateParsedTemplateMap.find(FD)->second; + sema.LateTemplateParser(sema.OpaqueParser, LPT); llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n"; } } diff --git a/examples/clang-interpreter/main.cpp b/examples/clang-interpreter/main.cpp index 9b4a257bcba..f7832291f2b 100644 --- a/examples/clang-interpreter/main.cpp +++ b/examples/clang-interpreter/main.cpp @@ -145,7 +145,7 @@ int main(int argc, const char **argv, char * const *envp) { // Create a compiler instance to handle the actual work. CompilerInstance Clang; - Clang.setInvocation(CI.release()); + Clang.setInvocation(std::move(CI)); // Create the compilers actual diagnostics engine. Clang.createDiagnostics(); diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 13db2085ba6..15fde19eb97 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 35 +#define CINDEX_VERSION_MINOR 37 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -326,7 +326,7 @@ clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); * * \param tu the translation unit * -* \param file_name the name of the file. + * \param file_name the name of the file. * * \returns the file handle for the named file in the translation unit \p tu, * or a NULL file handle if the file was not a part of this translation unit. @@ -626,6 +626,15 @@ typedef struct { CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, CXFile file); +/** + * \brief Retrieve all ranges from all files that were skipped by the + * preprocessor. + * + * The preprocessor will skip lines when they are surrounded by an + * if/ifdef/ifndef directive whose condition does not evaluate to true. + */ +CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu); + /** * \brief Destroy the given \c CXSourceRangeList. */ @@ -2325,7 +2334,47 @@ enum CXCursorKind { */ CXCursor_OMPTargetParallelForSimdDirective = 269, - CXCursor_LastStmt = CXCursor_OMPTargetParallelForSimdDirective, + /** \brief OpenMP target simd directive. + */ + CXCursor_OMPTargetSimdDirective = 270, + + /** \brief OpenMP teams distribute directive. + */ + CXCursor_OMPTeamsDistributeDirective = 271, + + /** \brief OpenMP teams distribute simd directive. + */ + CXCursor_OMPTeamsDistributeSimdDirective = 272, + + /** \brief OpenMP teams distribute parallel for simd directive. + */ + CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, + + /** \brief OpenMP teams distribute parallel for directive. + */ + CXCursor_OMPTeamsDistributeParallelForDirective = 274, + + /** \brief OpenMP target teams directive. + */ + CXCursor_OMPTargetTeamsDirective = 275, + + /** \brief OpenMP target teams distribute directive. + */ + CXCursor_OMPTargetTeamsDistributeDirective = 276, + + /** \brief OpenMP target teams distribute parallel for directive. + */ + CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, + + /** \brief OpenMP target teams distribute parallel for simd directive. + */ + CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, + + /** \brief OpenMP target teams distribute simd directive. + */ + CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, + + CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective, /** * \brief Cursor that represents the translation unit itself. @@ -2383,8 +2432,12 @@ enum CXCursorKind { * \brief A static_assert or _Static_assert node */ CXCursor_StaticAssert = 602, + /** + * \brief a friend declaration. + */ + CXCursor_FriendDecl = 603, CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, - CXCursor_LastExtraDecl = CXCursor_StaticAssert, + CXCursor_LastExtraDecl = CXCursor_FriendDecl, /** * \brief A code completion overload candidate. @@ -3001,7 +3054,7 @@ enum CXCallingConv { CXCallingConv_X86Pascal = 5, CXCallingConv_AAPCS = 6, CXCallingConv_AAPCS_VFP = 7, - /* Value 8 was PnaclCall, but it was never used, so it could safely be re-used. */ + CXCallingConv_X86RegCall = 8, CXCallingConv_IntelOclBicc = 9, CXCallingConv_X86_64Win64 = 10, CXCallingConv_X86_64SysV = 11, @@ -3491,11 +3544,8 @@ enum CXRefQualifierKind { }; /** - * \brief Returns the number of template arguments for given class template - * specialization, or -1 if type \c T is not a class template specialization. - * - * Variadic argument packs count as only one argument, and can not be inspected - * further. + * \brief Returns the number of template arguments for given template + * specialization, or -1 if type \c T is not a template specialization. */ CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); @@ -5239,6 +5289,25 @@ CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E); */ CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E); +/** + * \brief Returns the evaluation result as a long long integer if the + * kind is Int. This prevents overflows that may happen if the result is + * returned with clang_EvalResult_getAsInt. + */ +CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E); + +/** + * \brief Returns a non-zero value if the kind is Int and the evaluation + * result resulted in an unsigned integer. + */ +CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E); + +/** + * \brief Returns the evaluation result as an unsigned integer if + * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. + */ +CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E); + /** * \brief Returns the evaluation result as double if the * kind is double. diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h index e58c21923f5..7c431f3be8c 100644 --- a/include/clang/AST/APValue.h +++ b/include/clang/AST/APValue.h @@ -135,14 +135,15 @@ class APValue { } APValue(const APValue &RHS); APValue(APValue &&RHS) : Kind(Uninitialized) { swap(RHS); } - APValue(LValueBase B, const CharUnits &O, NoLValuePath N, unsigned CallIndex) + APValue(LValueBase B, const CharUnits &O, NoLValuePath N, unsigned CallIndex, + bool IsNullPtr = false) : Kind(Uninitialized) { - MakeLValue(); setLValue(B, O, N, CallIndex); + MakeLValue(); setLValue(B, O, N, CallIndex, IsNullPtr); } APValue(LValueBase B, const CharUnits &O, ArrayRef Path, - bool OnePastTheEnd, unsigned CallIndex) + bool OnePastTheEnd, unsigned CallIndex, bool IsNullPtr = false) : Kind(Uninitialized) { - MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex); + MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex, IsNullPtr); } APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) { MakeArray(InitElts, Size); @@ -254,6 +255,7 @@ class APValue { bool hasLValuePath() const; ArrayRef getLValuePath() const; unsigned getLValueCallIndex() const; + bool isNullPointer() const; APValue &getVectorElt(unsigned I) { assert(isVector() && "Invalid accessor"); @@ -374,10 +376,10 @@ class APValue { ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I); } void setLValue(LValueBase B, const CharUnits &O, NoLValuePath, - unsigned CallIndex); + unsigned CallIndex, bool IsNullPtr); void setLValue(LValueBase B, const CharUnits &O, ArrayRef Path, bool OnePastTheEnd, - unsigned CallIndex); + unsigned CallIndex, bool IsNullPtr); void setUnion(const FieldDecl *Field, const APValue &Value) { assert(isUnion() && "Invalid accessor"); ((UnionData*)(char*)Data.buffer)->Field = Field; diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h index 0b1f0068fa6..ad368c86c79 100644 --- a/include/clang/AST/ASTConsumer.h +++ b/include/clang/AST/ASTConsumer.h @@ -14,8 +14,6 @@ #ifndef LLVM_CLANG_AST_ASTCONSUMER_H #define LLVM_CLANG_AST_ASTCONSUMER_H -#include "llvm/ADT/StringRef.h" - namespace clang { class ASTContext; class CXXMethodDecl; diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 1d223f47a9a..1c9ce821438 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -19,73 +19,107 @@ #include "clang/AST/CanonicalType.h" #include "clang/AST/CommentCommandTraits.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclarationName.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/ExternalASTSource.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/PrettyPrinter.h" #include "clang/AST/RawCommentList.h" +#include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include "clang/Basic/AddressSpaces.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/Linkage.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/Module.h" #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/SanitizerBlacklist.h" -#include "clang/Basic/VersionTuple.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/TinyPtrVector.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/AlignOf.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" +#include +#include +#include +#include #include +#include +#include +#include #include namespace llvm { - struct fltSemantics; -} + +struct fltSemantics; + +} // end namespace llvm namespace clang { - class FileManager; - class AtomicExpr; - class ASTRecordLayout; - class BlockExpr; - class CharUnits; - class DiagnosticsEngine; - class Expr; - class ASTMutationListener; - class IdentifierTable; - class MaterializeTemporaryExpr; - class SelectorTable; - class TargetInfo; - class CXXABI; - class MangleNumberingContext; - // Decls - class MangleContext; - class ObjCIvarDecl; - class ObjCPropertyDecl; - class UnresolvedSetIterator; - class UsingDecl; - class UsingShadowDecl; - class VTableContextBase; - - namespace Builtin { class Context; } - enum BuiltinTemplateKind : int; - - namespace comments { - class FullComment; - } - - struct TypeInfo { - uint64_t Width; - unsigned Align; - bool AlignIsRequired : 1; - TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {} - TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired) - : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} - }; + +class ASTMutationListener; +class ASTRecordLayout; +class AtomicExpr; +class BlockExpr; +class CharUnits; +class CXXABI; +class DiagnosticsEngine; +class Expr; +class MangleNumberingContext; +class MaterializeTemporaryExpr; +class TargetInfo; +// Decls +class MangleContext; +class ObjCIvarDecl; +class ObjCPropertyDecl; +class UnresolvedSetIterator; +class UsingDecl; +class UsingShadowDecl; +class VTableContextBase; + +namespace Builtin { + + class Context; + +} // end namespace Builtin + +enum BuiltinTemplateKind : int; + +namespace comments { + + class FullComment; + +} // end namespace comments + +struct TypeInfo { + uint64_t Width; + unsigned Align; + bool AlignIsRequired : 1; + + TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {} + TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired) + : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} +}; /// \brief Holds long-lived AST nodes (such as types and decls) that can be /// referred to throughout the semantic analysis of a file. @@ -114,6 +148,7 @@ class ASTContext : public RefCountedBase { mutable llvm::FoldingSet DependentTypeOfExprTypes; mutable llvm::FoldingSet DependentDecltypeTypes; mutable llvm::FoldingSet TemplateTypeParmTypes; + mutable llvm::FoldingSet ObjCTypeParamTypes; mutable llvm::FoldingSet SubstTemplateTypeParmTypes; mutable llvm::FoldingSet @@ -312,13 +347,24 @@ class ASTContext : public RefCountedBase { /// definitions of that entity. llvm::DenseMap> MergedDefModules; + /// \brief Initializers for a module, in order. Each Decl will be either + /// something that has a semantic effect on startup (such as a variable with + /// a non-constant initializer), or an ImportDecl (which recursively triggers + /// initialization of another module). + struct PerModuleInitializers { + llvm::SmallVector Initializers; + llvm::SmallVector LazyInitializers; + + void resolve(ASTContext &Ctx); + }; + llvm::DenseMap ModuleInitializers; + public: /// \brief A type synonym for the TemplateOrInstantiation mapping. typedef llvm::PointerUnion TemplateOrSpecializationInfo; private: - /// \brief A mapping to contain the template or declaration that /// a variable declaration describes or was instantiated from, /// respectively. @@ -352,11 +398,11 @@ class ASTContext : public RefCountedBase { llvm::DenseMap TemplateOrInstantiation; - /// \brief Keeps track of the declaration from which a UsingDecl was + /// \brief Keeps track of the declaration from which a using declaration was /// created during instantiation. /// - /// The source declaration is always a UsingDecl, an UnresolvedUsingValueDecl, - /// or an UnresolvedUsingTypenameDecl. + /// The source and target declarations are always a UsingDecl, an + /// UnresolvedUsingValueDecl, or an UnresolvedUsingTypenameDecl. /// /// For example: /// \code @@ -375,7 +421,7 @@ class ASTContext : public RefCountedBase { /// /// This mapping will contain an entry that maps from the UsingDecl in /// B to the UnresolvedUsingDecl in B. - llvm::DenseMap InstantiatedFromUsingDecl; + llvm::DenseMap InstantiatedFromUsingDecl; llvm::DenseMap InstantiatedFromUsingShadowDecl; @@ -394,7 +440,7 @@ class ASTContext : public RefCountedBase { /// \brief Mapping from each declaration context to its corresponding /// mangling numbering context (used for constructs like lambdas which /// need to be consistently numbered for the mangler). - llvm::DenseMap + llvm::DenseMap> MangleNumberingContexts; /// \brief Side-table of mangling numbers for declarations which rarely @@ -514,6 +560,7 @@ class ASTContext : public RefCountedBase { size_t size() const { return end() - begin(); } bool empty() const { return begin() == end(); } + const DynTypedNode &operator[](size_t N) const { assert(N < size() && "Out of bounds!"); return *(begin() + N); @@ -569,7 +616,7 @@ class ASTContext : public RefCountedBase { return BumpAlloc.Allocate(Size, Align); } template T *Allocate(size_t Num = 1) const { - return static_cast(Allocate(Num * sizeof(T), llvm::alignOf())); + return static_cast(Allocate(Num * sizeof(T), alignof(T))); } void Deallocate(void *Ptr) const { } @@ -802,11 +849,11 @@ class ASTContext : public RefCountedBase { /// \brief If the given using decl \p Inst is an instantiation of a /// (possibly unresolved) using decl from a template instantiation, /// return it. - NamedDecl *getInstantiatedFromUsingDecl(UsingDecl *Inst); + NamedDecl *getInstantiatedFromUsingDecl(NamedDecl *Inst); /// \brief Remember that the using decl \p Inst is an instantiation /// of the using decl \p Pattern of a class template. - void setInstantiatedFromUsingDecl(UsingDecl *Inst, NamedDecl *Pattern); + void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern); void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern); @@ -883,6 +930,17 @@ class ASTContext : public RefCountedBase { return MergedIt->second; } + /// Add a declaration to the list of declarations that are initialized + /// for a module. This will typically be a global variable (with internal + /// linkage) that runs module initializers, such as the iostream initializer, + /// or an ImportDecl nominating another module that has initializers. + void addModuleInitializer(Module *M, Decl *Init); + + void addLazyModuleInitializers(Module *M, ArrayRef IDs); + + /// Get the initializations to perform when importing a module, if any. + ArrayRef getModuleInitializers(Module *M); + TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; } ExternCContextDecl *getExternCContextDecl() const; @@ -928,7 +986,8 @@ class ASTContext : public RefCountedBase { ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents, SelectorTable &sels, Builtin::Context &builtins); - + ASTContext(const ASTContext &) = delete; + ASTContext &operator=(const ASTContext &) = delete; ~ASTContext(); /// \brief Attach an external AST source to the AST context. @@ -987,6 +1046,8 @@ class ASTContext : public RefCountedBase { QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const; + QualType getPipeType(QualType T, bool ReadOnly) const; + public: /// \brief Return the uniqued reference to the type for an address space /// qualified type with the specified type and address space. @@ -996,6 +1057,14 @@ class ASTContext : public RefCountedBase { /// replaced. QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const; + /// \brief Apply Objective-C protocol qualifiers to the given type. + /// \param allowOnPointerType specifies if we can apply protocol + /// qualifiers on ObjCObjectPointerType. It can be set to true when + /// contructing the canonical type of a Objective-C type parameter. + QualType applyObjCProtocolQualifiers(QualType type, + ArrayRef protocols, bool &hasError, + bool allowOnPointerType = false) const; + /// \brief Return the uniqued reference to the type for an Objective-C /// gc-qualified type. /// @@ -1040,6 +1109,10 @@ class ASTContext : public RefCountedBase { /// \brief Change the result type of a function type once it is deduced. void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType); + /// \brief Determine whether two function types are the same, ignoring + /// exception specifications in cases where they're part of the type. + bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U); + /// \brief Change the exception specification on a function once it is /// delay-parsed, instantiated, or computed. void adjustExceptionSpec(FunctionDecl *FD, @@ -1088,8 +1161,10 @@ class ASTContext : public RefCountedBase { /// blocks. QualType getBlockDescriptorType() const; - /// \brief Return pipe type for the specified type. - QualType getPipeType(QualType T) const; + /// \brief Return a read_only pipe type for the specified type. + QualType getReadPipeType(QualType T) const; + /// \brief Return a write_only pipe type for the specified type. + QualType getWritePipeType(QualType T) const; /// Gets the struct used to keep track of the extended descriptor for /// pointer to blocks. @@ -1192,8 +1267,17 @@ class ASTContext : public RefCountedBase { /// \brief Return a normal function type with a typed argument list. QualType getFunctionType(QualType ResultTy, ArrayRef Args, - const FunctionProtoType::ExtProtoInfo &EPI) const; + const FunctionProtoType::ExtProtoInfo &EPI) const { + return getFunctionTypeInternal(ResultTy, Args, EPI, false); + } + +private: + /// \brief Return a normal function type with a typed argument list. + QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef Args, + const FunctionProtoType::ExtProtoInfo &EPI, + bool OnlyWantCanonical) const; +public: /// \brief Return the unique reference to the type for the specified type /// declaration. QualType getTypeDeclType(const TypeDecl *Decl, @@ -1271,6 +1355,12 @@ class ASTContext : public RefCountedBase { ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef Args) const; + /// Get a template argument list with one argument per template parameter + /// in a template parameter list, such as for the injected class name of + /// a class template. + void getInjectedTemplateArgs(const TemplateParameterList *Params, + SmallVectorImpl &Args); + QualType getPackExpansionType(QualType Pattern, Optional NumExpansions); @@ -1286,6 +1376,10 @@ class ASTContext : public RefCountedBase { ArrayRef typeArgs, ArrayRef protocols, bool isKindOf) const; + + QualType getObjCTypeParamType(const ObjCTypeParamDecl *Decl, + ArrayRef protocols, + QualType Canonical = QualType()) const; bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl); /// QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in @@ -1440,7 +1534,6 @@ class ASTContext : public RefCountedBase { return getObjCSelType(); return ObjCSelRedefinitionType; } - /// \brief Set the user-written type that redefines 'SEL'. void setObjCSelRedefinitionType(QualType RedefType) { @@ -1569,16 +1662,12 @@ class ASTContext : public RefCountedBase { /// /// \returns true if an error occurred (e.g., because one of the parameter /// types is incomplete), false otherwise. - bool getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, std::string& S); + std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const; /// \brief Emit the encoded type for the method declaration \p Decl into /// \p S. - /// - /// \returns true if an error occurred (e.g., because one of the parameter - /// types is incomplete), false otherwise. - bool getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S, - bool Extended = false) - const; + std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, + bool Extended = false) const; /// \brief Return the encoded type for this block declaration. std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const; @@ -1587,9 +1676,8 @@ class ASTContext : public RefCountedBase { /// this method declaration. If non-NULL, Container must be either /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should /// only be NULL when getting encodings for protocol properties. - void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, - const Decl *Container, - std::string &S) const; + std::string getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, + const Decl *Container) const; bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, ObjCProtocolDecl *rProto) const; @@ -1834,6 +1922,11 @@ class ASTContext : public RefCountedBase { unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; } unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; } + /// \brief Return the ABI-specified alignment of a type, in bits, or 0 if + /// the type is incomplete and we cannot determine the alignment (for + /// example, from alignment attributes). + unsigned getTypeAlignIfKnown(QualType T) const; + /// \brief Return the ABI-specified alignment of a (complete) type \p T, in /// characters. CharUnits getTypeAlignInChars(QualType T) const; @@ -1860,7 +1953,7 @@ class ASTContext : public RefCountedBase { /// \brief Return the default alignment for __attribute__((aligned)) on /// this target, to be used if no alignment value is specified. - unsigned getTargetDefaultAlignForAttributeAligned(void) const; + unsigned getTargetDefaultAlignForAttributeAligned() const; /// \brief Return the alignment in bits that should be given to a /// global variable with type \p T. @@ -2212,6 +2305,10 @@ class ASTContext : public RefCountedBase { return (*AddrSpaceMap)[AS - LangAS::Offset]; } + /// Get target-dependent integer value for null pointer which is used for + /// constant folding. + uint64_t getTargetNullPointerValue(QualType QT) const; + bool addressSpaceMapManglingFor(unsigned AS) const { return AddrSpaceMapMangling || AS < LangAS::Offset || @@ -2223,7 +2320,6 @@ class ASTContext : public RefCountedBase { unsigned getIntegerRank(const Type *T) const; public: - //===--------------------------------------------------------------------===// // Type Compatibility Predicates //===--------------------------------------------------------------------===// @@ -2399,12 +2495,6 @@ class ASTContext : public RefCountedBase { void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD); - void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD, - unsigned ParmIdx, Expr *DAE); - - Expr *getDefaultArgExprForConstructor(const CXXConstructorDecl *CD, - unsigned ParmIdx); - void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND); TypedefNameDecl *getTypedefNameForUnnamedTagDecl(const TagDecl *TD); @@ -2423,7 +2513,7 @@ class ASTContext : public RefCountedBase { /// DeclContext. MangleNumberingContext &getManglingNumberContext(const DeclContext *DC); - MangleNumberingContext *createMangleNumberingContext() const; + std::unique_ptr createMangleNumberingContext() const; /// \brief Used by ParmVarDecl to store on the side the /// index of the parameter when it exceeds the size of the normal bitfield. @@ -2484,10 +2574,6 @@ class ASTContext : public RefCountedBase { /// declarations were built. static unsigned NumImplicitDestructorsDeclared; -private: - ASTContext(const ASTContext &) = delete; - void operator=(const ASTContext &) = delete; - public: /// \brief Initialize built-in types. /// @@ -2567,6 +2653,7 @@ class ASTContext : public RefCountedBase { friend class DeclContext; friend class DeclarationNameTable; + void ReleaseDeclContextMaps(); void ReleaseParentMapEntries(); @@ -2589,7 +2676,8 @@ class ASTContext : public RefCountedBase { DeclaratorDecl *Decl; SourceLocation PragmaSectionLocation; int SectionFlags; - SectionInfo() {} + + SectionInfo() = default; SectionInfo(DeclaratorDecl *Decl, SourceLocation PragmaSectionLocation, int SectionFlags) @@ -2711,4 +2799,4 @@ typename clang::LazyGenerationalUpdatePtr::ValueType return Value; } -#endif +#endif // LLVM_CLANG_AST_ASTCONTEXT_H diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index e116abaef79..66b9cd394b9 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -24,6 +24,7 @@ namespace clang { class ASTContext; class CXXCtorInitializer; + class CXXBaseSpecifier; class Decl; class DeclContext; class DiagnosticsEngine; @@ -39,7 +40,9 @@ namespace clang { class ASTImporter { public: typedef llvm::DenseSet > NonEquivalentDeclSet; - + typedef llvm::DenseMap + ImportedCXXBaseSpecifierMap; + private: /// \brief The contexts we're importing to and from. ASTContext &ToContext, &FromContext; @@ -68,7 +71,12 @@ namespace clang { /// \brief Mapping from the already-imported FileIDs in the "from" source /// manager to the corresponding FileIDs in the "to" source manager. llvm::DenseMap ImportedFileIDs; - + + /// \brief Mapping from the already-imported CXXBasesSpecifier in + /// the "from" source manager to the corresponding CXXBasesSpecifier + /// in the "to" source manager. + ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers; + /// \brief Imported, anonymous tag declarations that are missing their /// corresponding typedefs. SmallVector AnonTagsWithPendingTypedefs; @@ -212,8 +220,13 @@ namespace clang { /// \returns the equivalent initializer in the "to" context. CXXCtorInitializer *Import(CXXCtorInitializer *FromInit); + /// \brief Import the given CXXBaseSpecifier from the "from" context into + /// the "to" context. + /// + /// \returns the equivalent CXXBaseSpecifier in the source manager of the + /// "to" context. + CXXBaseSpecifier *Import(const CXXBaseSpecifier *FromSpec); - /// \brief Import the definition of the given declaration, including all of /// the declarations it contains. /// diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h index e2d184d654e..a8eff1a2fcb 100644 --- a/include/clang/AST/ASTMutationListener.h +++ b/include/clang/AST/ASTMutationListener.h @@ -22,6 +22,7 @@ namespace clang { class CXXRecordDecl; class Decl; class DeclContext; + class FieldDecl; class FunctionDecl; class FunctionTemplateDecl; class Module; @@ -93,6 +94,9 @@ class ASTMutationListener { /// \brief A default argument was instantiated. virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {} + /// \brief A default member initializer was instantiated. + virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D) {} + /// \brief A new objc category class was added for an interface. virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD) {} diff --git a/include/clang/AST/ASTTypeTraits.h b/include/clang/AST/ASTTypeTraits.h index ad301b14829..51d60a90a14 100644 --- a/include/clang/AST/ASTTypeTraits.h +++ b/include/clang/AST/ASTTypeTraits.h @@ -121,6 +121,7 @@ class ASTNodeKind { enum NodeKindId { NKI_None, NKI_TemplateArgument, + NKI_TemplateName, NKI_NestedNameSpecifierLoc, NKI_QualType, NKI_TypeLoc, @@ -175,6 +176,7 @@ class ASTNodeKind { }; KIND_TO_KIND_ID(CXXCtorInitializer) KIND_TO_KIND_ID(TemplateArgument) +KIND_TO_KIND_ID(TemplateName) KIND_TO_KIND_ID(NestedNameSpecifier) KIND_TO_KIND_ID(NestedNameSpecifierLoc) KIND_TO_KIND_ID(QualType) @@ -470,6 +472,10 @@ template <> struct DynTypedNode::BaseConverter< TemplateArgument, void> : public ValueConverter {}; +template <> +struct DynTypedNode::BaseConverter< + TemplateName, void> : public ValueConverter {}; + template <> struct DynTypedNode::BaseConverter< NestedNameSpecifierLoc, diff --git a/include/clang/AST/ASTVector.h b/include/clang/AST/ASTVector.h index 79453bf1087..9ae5fd62c65 100644 --- a/include/clang/AST/ASTVector.h +++ b/include/clang/AST/ASTVector.h @@ -20,7 +20,6 @@ #include "clang/AST/AttrIterator.h" #include "llvm/ADT/PointerIntPair.h" -#include "llvm/Support/Allocator.h" #include "llvm/Support/type_traits.h" #include #include @@ -381,7 +380,7 @@ void ASTVector::grow(const ASTContext &C, size_t MinSize) { NewCapacity = MinSize; // Allocate the memory from the ASTContext. - T *NewElts = new (C, llvm::alignOf()) T[NewCapacity]; + T *NewElts = new (C, alignof(T)) T[NewCapacity]; // Copy the elements over. if (Begin != End) { diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index a94b161a04b..bbe320c28a3 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -24,8 +24,6 @@ #include "clang/Basic/Sanitizers.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/VersionTuple.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -57,21 +55,20 @@ class Attr { unsigned IsLateParsed : 1; unsigned DuplicatesAllowed : 1; - void *operator new(size_t bytes) LLVM_NOEXCEPT { + void *operator new(size_t bytes) noexcept { llvm_unreachable("Attrs cannot be allocated with regular 'new'."); } - void operator delete(void *data) LLVM_NOEXCEPT { + void operator delete(void *data) noexcept { llvm_unreachable("Attrs cannot be released with regular 'delete'."); } public: // Forward so that the regular new and delete do not hide global ones. void *operator new(size_t Bytes, ASTContext &C, - size_t Alignment = 8) LLVM_NOEXCEPT { + size_t Alignment = 8) noexcept { return ::operator new(Bytes, C, Alignment); } - void operator delete(void *Ptr, ASTContext &C, - size_t Alignment) LLVM_NOEXCEPT { + void operator delete(void *Ptr, ASTContext &C, size_t Alignment) noexcept { return ::operator delete(Ptr, C, Alignment); } diff --git a/include/clang/AST/AttrIterator.h b/include/clang/AST/AttrIterator.h index a0c803096af..fb9b049e5d6 100644 --- a/include/clang/AST/AttrIterator.h +++ b/include/clang/AST/AttrIterator.h @@ -39,8 +39,7 @@ 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. -typedef SmallVector AttrVec; -typedef SmallVector ConstAttrVec; +typedef SmallVector AttrVec; /// specific_attr_iterator - Iterates over a subrange of an AttrVec, only /// providing attributes that are of a specific type. diff --git a/include/clang/AST/CXXInheritance.h b/include/clang/AST/CXXInheritance.h index 8587260049a..3cf058f26bc 100644 --- a/include/clang/AST/CXXInheritance.h +++ b/include/clang/AST/CXXInheritance.h @@ -16,7 +16,6 @@ #include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" -#include "clang/AST/DeclarationName.h" #include "clang/AST/Type.h" #include "clang/AST/TypeOrdering.h" #include "llvm/ADT/MapVector.h" @@ -24,7 +23,6 @@ #include "llvm/ADT/SmallVector.h" #include #include -#include namespace clang { @@ -174,7 +172,7 @@ class CXXBasePaths { /// paths for a derived-to-base search. explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true, bool DetectVirtual = true) - : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths), + : Origin(), FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths), DetectVirtual(DetectVirtual), DetectedVirtual(nullptr), NumDeclsFound(0) {} diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h index 77510afeec1..25f6172be9b 100644 --- a/include/clang/AST/CanonicalType.h +++ b/include/clang/AST/CanonicalType.h @@ -630,8 +630,8 @@ CanQual CanQual::CreateUnsafe(QualType Other) { template template CanProxy CanQual::getAs() const { - ArrayType_cannot_be_used_with_getAs at; - (void)at; + static_assert(!TypeIsArrayType::value, + "ArrayType cannot be used with getAs!"); if (Stored.isNull()) return CanProxy(); @@ -645,8 +645,8 @@ CanProxy CanQual::getAs() const { template template CanProxy CanQual::castAs() const { - ArrayType_cannot_be_used_with_getAs at; - (void)at; + static_assert(!TypeIsArrayType::value, + "ArrayType cannot be used with castAs!"); assert(!Stored.isNull() && isa(Stored.getTypePtr())); return CanQual::CreateUnsafe(Stored); diff --git a/include/clang/AST/CommentLexer.h b/include/clang/AST/CommentLexer.h index f190b932c0a..5bb075807be 100644 --- a/include/clang/AST/CommentLexer.h +++ b/include/clang/AST/CommentLexer.h @@ -17,7 +17,6 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/raw_ostream.h" diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 109036f9588..8b52891af2f 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -251,7 +251,7 @@ class NamedDecl : public Decl { // FIXME: Deprecated, move clients to getName(). std::string getNameAsString() const { return Name.getAsString(); } - void printName(raw_ostream &os) const { os << Name; } + virtual void printName(raw_ostream &os) const; /// getDeclName - Get the actual, stored name of the declaration, /// which may be a special name. @@ -789,7 +789,7 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { protected: // A pointer union of Stmt * and EvaluatedStmt *. When an EvaluatedStmt, we - // have allocated the auxilliary struct of information there. + // have allocated the auxiliary struct of information there. // // TODO: It is a bit unfortunate to use a PointerUnion inside the VarDecl for // this as *many* VarDecls are ParmVarDecls that don't have default @@ -865,6 +865,11 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { unsigned : NumVarDeclBits; + // FIXME: We need something similar to CXXRecordDecl::DefinitionData. + /// \brief Whether this variable is a definition which was demoted due to + /// module merge. + unsigned IsThisDeclarationADemotedDefinition : 1; + /// \brief Whether this variable is the exception variable in a C++ catch /// or an Objective-C @catch statement. unsigned ExceptionVar : 1; @@ -1025,7 +1030,7 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { /// void foo() { int x; static int y; extern int z; } /// bool isLocalVarDecl() const { - if (getKind() != Decl::Var) + if (getKind() != Decl::Var && getKind() != Decl::Decomposition) return false; if (const DeclContext *DC = getLexicalDeclContext()) return DC->getRedeclContext()->isFunctionOrMethod(); @@ -1040,7 +1045,7 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { /// isFunctionOrMethodVarDecl - Similar to isLocalVarDecl, but /// excludes variables declared in blocks. bool isFunctionOrMethodVarDecl() const { - if (getKind() != Decl::Var) + if (getKind() != Decl::Var && getKind() != Decl::Decomposition) return false; const DeclContext *DC = getLexicalDeclContext()->getRedeclContext(); return DC->isFunctionOrMethod() && DC->getDeclKind() != Decl::Block; @@ -1198,12 +1203,28 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { InitializationStyle getInitStyle() const { return static_cast(VarDeclBits.InitStyle); } - /// \brief Whether the initializer is a direct-initializer (list or call). bool isDirectInit() const { return getInitStyle() != CInit; } + /// \brief If this definition should pretend to be a declaration. + bool isThisDeclarationADemotedDefinition() const { + return isa(this) ? false : + NonParmVarDeclBits.IsThisDeclarationADemotedDefinition; + } + + /// \brief This is a definition which should be demoted to a declaration. + /// + /// In some cases (mostly module merging) we can end up with two visible + /// definitions one of which needs to be demoted to a declaration to keep + /// the AST invariants. + void demoteThisDefinitionToDeclaration() { + assert (isThisDeclarationADefinition() && "Not a definition!"); + assert (!isa(this) && "Cannot demote ParmVarDecls!"); + NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1; + } + /// \brief Determine whether this variable is the exception variable in a /// C++ catch statememt or an Objective-C \@catch statement. bool isExceptionVariable() const { @@ -1302,6 +1323,10 @@ class VarDecl : public DeclaratorDecl, public Redeclarable { NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same; } + /// \brief Retrieve the variable declaration from which this variable could + /// be instantiated, if it is an instantiation (rather than a non-template). + VarDecl *getTemplateInstantiationPattern() const; + /// \brief If this variable is an instantiated static data member of a /// class template specialization, returns the templated static data member /// from which it was instantiated. @@ -1576,11 +1601,6 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, /// no formals. ParmVarDecl **ParamInfo; - /// DeclsInPrototypeScope - Array of pointers to NamedDecls for - /// decls defined in the function prototype that are not parameters. E.g. - /// 'enum Y' in 'void f(enum Y {AA} x) {}'. - ArrayRef DeclsInPrototypeScope; - LazyDeclStmtPtr Body; // FIXME: This can be packed into the bitfields in DeclContext. @@ -1607,6 +1627,11 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, /// skipped. unsigned HasSkippedBody : 1; + /// Indicates if the function declaration will have a body, once we're done + /// parsing it. (We don't set it to false when we're done parsing, in the + /// hopes this is simpler.) + unsigned WillHaveBody : 1; + /// \brief End part of this FunctionDecl's source range. /// /// We could compute the full range in getSourceRange(). However, when we're @@ -1676,25 +1701,21 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, protected: FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - const DeclarationNameInfo &NameInfo, - QualType T, TypeSourceInfo *TInfo, - StorageClass S, bool isInlineSpecified, + const DeclarationNameInfo &NameInfo, QualType T, + TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, bool isConstexprSpecified) - : DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo, - StartLoc), - DeclContext(DK), - redeclarable_base(C), - ParamInfo(nullptr), Body(), - SClass(S), - IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified), - IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false), - HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false), - IsDefaulted(false), IsExplicitlyDefaulted(false), - HasImplicitReturnZero(false), IsLateTemplateParsed(false), - IsConstexpr(isConstexprSpecified), UsesSEHTry(false), - HasSkippedBody(false), EndRangeLoc(NameInfo.getEndLoc()), - TemplateOrSpecialization(), - DNLoc(NameInfo.getInfo()) {} + : DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo, + StartLoc), + DeclContext(DK), redeclarable_base(C), ParamInfo(nullptr), Body(), + SClass(S), IsInline(isInlineSpecified), + IsInlineSpecified(isInlineSpecified), IsVirtualAsWritten(false), + IsPure(false), HasInheritedPrototype(false), HasWrittenPrototype(true), + IsDeleted(false), IsTrivial(false), IsDefaulted(false), + IsExplicitlyDefaulted(false), HasImplicitReturnZero(false), + IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified), + UsesSEHTry(false), HasSkippedBody(false), WillHaveBody(false), + EndRangeLoc(NameInfo.getEndLoc()), TemplateOrSpecialization(), + DNLoc(NameInfo.getInfo()) {} typedef Redeclarable redeclarable_base; FunctionDecl *getNextRedeclarationImpl() override { @@ -1976,6 +1997,10 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, bool hasSkippedBody() const { return HasSkippedBody; } void setHasSkippedBody(bool Skipped = true) { HasSkippedBody = Skipped; } + /// True if this function will eventually have a body, once it's fully parsed. + bool willHaveBody() const { return WillHaveBody; } + void setWillHaveBody(bool V = true) { WillHaveBody = V; } + void setPreviousDeclaration(FunctionDecl * PrevDecl); FunctionDecl *getCanonicalDecl() override; @@ -2020,11 +2045,6 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, setParams(getASTContext(), NewParamInfo); } - ArrayRef getDeclsInPrototypeScope() const { - return DeclsInPrototypeScope; - } - void setDeclsInPrototypeScope(ArrayRef NewDecls); - /// getMinRequiredArguments - Returns the minimum number of arguments /// needed to call this function. This may be fewer than the number of /// function parameters, if some of the parameters have default @@ -2041,6 +2061,10 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, /// limited representation in the AST. SourceRange getReturnTypeSourceRange() const; + /// \brief Attempt to compute an informative source range covering the + /// function exception specification, if any. + SourceRange getExceptionSpecSourceRange() const; + /// \brief Determine the type of an expression that calls this function. QualType getCallResultType() const { assert(getType()->getAs() && "Expected a FunctionType!"); @@ -3784,6 +3808,55 @@ class ImportDecl final : public Decl, static bool classofKind(Kind K) { return K == Import; } }; +/// \brief Represents a C++ Modules TS module export declaration. +/// +/// For example: +/// \code +/// export void foo(); +/// \endcode +class ExportDecl final : public Decl, public DeclContext { + virtual void anchor(); +private: + /// \brief The source location for the right brace (if valid). + SourceLocation RBraceLoc; + + ExportDecl(DeclContext *DC, SourceLocation ExportLoc) + : Decl(Export, DC, ExportLoc), DeclContext(Export), + RBraceLoc(SourceLocation()) { } + + friend class ASTDeclReader; + +public: + static ExportDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation ExportLoc); + static ExportDecl *CreateDeserialized(ASTContext &C, unsigned ID); + + SourceLocation getExportLoc() const { return getLocation(); } + SourceLocation getRBraceLoc() const { return RBraceLoc; } + void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } + + SourceLocation getLocEnd() const LLVM_READONLY { + if (RBraceLoc.isValid()) + return RBraceLoc; + // No braces: get the end location of the (only) declaration in context + // (if present). + return decls_empty() ? getLocation() : decls_begin()->getLocEnd(); + } + + SourceRange getSourceRange() const override LLVM_READONLY { + return SourceRange(getLocation(), getLocEnd()); + } + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Export; } + static DeclContext *castToDeclContext(const ExportDecl *D) { + return static_cast(const_cast(D)); + } + static ExportDecl *castFromDeclContext(const DeclContext *DC) { + return static_cast(const_cast(DC)); + } +}; + /// \brief Represents an empty-declaration. class EmptyDecl : public Decl { virtual void anchor(); diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index ec8bb3aaa30..5de1d0588e8 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -17,6 +17,7 @@ #include "clang/AST/AttrIterator.h" #include "clang/AST/DeclarationName.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/VersionTuple.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" @@ -32,6 +33,7 @@ class DeclContext; class DeclarationName; class DependentDiagnostic; class EnumDecl; +class ExportDecl; class FunctionDecl; class FunctionType; enum Linkage : unsigned char; @@ -566,6 +568,10 @@ class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) Decl { return NextInContextAndBits.getInt() & ModulePrivateFlag; } + /// \brief Whether this declaration is exported (by virtue of being lexically + /// within an ExportDecl or by being a NamespaceDecl). + bool isExported() const; + /// Return true if this declaration has an attribute which acts as /// definition of the entity, such as 'alias' or 'ifunc'. bool hasDefiningAttr() const; @@ -603,7 +609,12 @@ class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) Decl { /// AR_Available, will be set to a (possibly empty) message /// describing why the declaration has not been introduced, is /// deprecated, or is unavailable. - AvailabilityResult getAvailability(std::string *Message = nullptr) const; + /// + /// \param EnclosingVersion The version to compare with. If empty, assume the + /// deployment target version. + AvailabilityResult + getAvailability(std::string *Message = nullptr, + VersionTuple EnclosingVersion = VersionTuple()) const; /// \brief Determine whether this declaration is marked 'deprecated'. /// @@ -1129,6 +1140,7 @@ class DeclContextLookupResult { /// ObjCMethodDecl /// ObjCContainerDecl /// LinkageSpecDecl +/// ExportDecl /// BlockDecl /// OMPDeclareReductionDecl /// @@ -1273,7 +1285,8 @@ class DeclContext { /// \brief Test whether the context supports looking up names. bool isLookupContext() const { - return !isFunctionOrMethod() && DeclKind != Decl::LinkageSpec; + return !isFunctionOrMethod() && DeclKind != Decl::LinkageSpec && + DeclKind != Decl::Export; } bool isFileContext() const { @@ -1321,6 +1334,9 @@ class DeclContext { /// linkage specification context that specifies C linkage. bool isExternCContext() const; + /// \brief Retrieve the nearest enclosing C linkage specification context. + const LinkageSpecDecl *getExternCContext() const; + /// \brief Determines whether this context or some of its ancestors is a /// linkage specification context that specifies C++ linkage. bool isExternCXXContext() const; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 66acfee60db..0ca08db1629 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -139,7 +139,6 @@ class AccessSpecDecl : public Decl { static bool classofKind(Kind K) { return K == AccessSpec; } }; - /// \brief Represents a base class of a C++ class. /// /// Each CXXBaseSpecifier represents a single, direct base class (or @@ -536,11 +535,10 @@ class CXXRecordDecl : public RecordDecl { MethodTyInfo(Info) { IsLambda = true; - // C++11 [expr.prim.lambda]p3: - // This class type is neither an aggregate nor a literal type. + // C++1z [expr.prim.lambda]p4: + // This class type is not an aggregate type. Aggregate = false; PlainOldData = false; - HasNonLiteralTypeFieldsOrBases = true; } /// \brief Whether this lambda is known to be dependent, even if its @@ -573,7 +571,7 @@ class CXXRecordDecl : public RecordDecl { /// actual DeclContext does not suffice. This is used for lambdas that /// occur within default arguments of function parameters within the class /// or within a data member initializer. - Decl *ContextDecl; + LazyDeclPtr ContextDecl; /// \brief The list of captures, both explicit and implicit, for this /// lambda. @@ -995,7 +993,11 @@ class CXXRecordDecl : public RecordDecl { !hasUserDeclaredCopyConstructor() && !hasUserDeclaredCopyAssignment() && !hasUserDeclaredMoveConstructor() && - !hasUserDeclaredDestructor(); + !hasUserDeclaredDestructor() && + // C++1z [expr.prim.lambda]p21: "the closure type has a deleted copy + // assignment operator". The intent is that this counts as a user + // declared copy assignment, but we do not model it that way. + !isLambda(); } /// \brief Determine whether we need to eagerly declare a move assignment @@ -1149,6 +1151,12 @@ class CXXRecordDecl : public RecordDecl { /// \note This does NOT include a check for union-ness. bool isEmpty() const { return data().Empty; } + /// \brief Determine whether this class has direct non-static data members. + bool hasDirectFields() const { + auto &D = data(); + return D.HasPublicFields || D.HasProtectedFields || D.HasPrivateFields; + } + /// Whether this class is polymorphic (C++ [class.virtual]), /// which means that the class contains or inherits a virtual function. bool isPolymorphic() const { return data().Polymorphic; } @@ -1339,11 +1347,15 @@ class CXXRecordDecl : public RecordDecl { /// /// We resolve DR1361 by ignoring the second bullet. We resolve DR1452 by /// treating types with trivial default constructors as literal types. + /// + /// Only in C++1z and beyond, are lambdas literal types. bool isLiteral() const { return hasTrivialDestructor() && - (isAggregate() || hasConstexprNonCopyMoveConstructor() || - hasTrivialDefaultConstructor()) && - !hasNonLiteralTypeFieldsOrBases(); + (!isLambda() || getASTContext().getLangOpts().CPlusPlus1z) && + !hasNonLiteralTypeFieldsOrBases() && + (isAggregate() || isLambda() || + hasConstexprNonCopyMoveConstructor() || + hasTrivialDefaultConstructor()); } /// \brief If this record is an instantiation of a member class, @@ -1665,10 +1677,7 @@ class CXXRecordDecl : public RecordDecl { /// the declaration in which the lambda occurs, e.g., the function parameter /// or the non-static data member. Otherwise, it returns NULL to imply that /// the declaration context suffices. - Decl *getLambdaContextDecl() const { - assert(isLambda() && "Not a lambda closure type!"); - return getLambdaData().ContextDecl; - } + Decl *getLambdaContextDecl() const; /// \brief Set the mangling number and context declaration for a lambda /// class. @@ -1919,8 +1928,7 @@ class CXXMethodDecl : public FunctionDecl { /// B(A& a) : A(a), f(3.14159) { } /// }; /// \endcode -class CXXCtorInitializer final - : private llvm::TrailingObjects { +class CXXCtorInitializer final { /// \brief Either the base class name/delegating constructor type (stored as /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field /// (IndirectFieldDecl*) being initialized. @@ -1958,14 +1966,8 @@ class CXXCtorInitializer final unsigned IsWritten : 1; /// If IsWritten is true, then this number keeps track of the textual order - /// of this initializer in the original sources, counting from 0; otherwise, - /// it stores the number of array index variables stored after this object - /// in memory. - unsigned SourceOrderOrNumArrayIndices : 13; - - CXXCtorInitializer(ASTContext &Context, FieldDecl *Member, - SourceLocation MemberLoc, SourceLocation L, Expr *Init, - SourceLocation R, VarDecl **Indices, unsigned NumIndices); + /// of this initializer in the original sources, counting from 0. + unsigned SourceOrder : 13; public: /// \brief Creates a new base-class initializer. @@ -1991,13 +1993,6 @@ class CXXCtorInitializer final CXXCtorInitializer(ASTContext &Context, TypeSourceInfo *TInfo, SourceLocation L, Expr *Init, SourceLocation R); - /// \brief Creates a new member initializer that optionally contains - /// array indices used to describe an elementwise initialization. - static CXXCtorInitializer *Create(ASTContext &Context, FieldDecl *Member, - SourceLocation MemberLoc, SourceLocation L, - Expr *Init, SourceLocation R, - VarDecl **Indices, unsigned NumIndices); - /// \brief Determine whether this initializer is initializing a base class. bool isBaseInitializer() const { return Initializee.is() && !IsDelegating; @@ -2102,7 +2097,7 @@ class CXXCtorInitializer final /// \brief Return the source position of the initializer, counting from 0. /// If the initializer was implicit, -1 is returned. int getSourceOrder() const { - return IsWritten ? static_cast(SourceOrderOrNumArrayIndices) : -1; + return IsWritten ? static_cast(SourceOrder) : -1; } /// \brief Set the source order of this initializer. @@ -2112,49 +2107,22 @@ class CXXCtorInitializer final /// /// This assumes that the initializer was written in the source code, and /// ensures that isWritten() returns true. - void setSourceOrder(int pos) { + void setSourceOrder(int Pos) { assert(!IsWritten && + "setSourceOrder() used on implicit initializer"); + assert(SourceOrder == 0 && "calling twice setSourceOrder() on the same initializer"); - assert(SourceOrderOrNumArrayIndices == 0 && - "setSourceOrder() used when there are implicit array indices"); - assert(pos >= 0 && + assert(Pos >= 0 && "setSourceOrder() used to make an initializer implicit"); IsWritten = true; - SourceOrderOrNumArrayIndices = static_cast(pos); + SourceOrder = static_cast(Pos); } SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } - /// \brief Determine the number of implicit array indices used while - /// described an array member initialization. - unsigned getNumArrayIndices() const { - return IsWritten ? 0 : SourceOrderOrNumArrayIndices; - } - - /// \brief Retrieve a particular array index variable used to - /// describe an array member initialization. - VarDecl *getArrayIndex(unsigned I) { - assert(I < getNumArrayIndices() && "Out of bounds member array index"); - return getTrailingObjects()[I]; - } - const VarDecl *getArrayIndex(unsigned I) const { - assert(I < getNumArrayIndices() && "Out of bounds member array index"); - return getTrailingObjects()[I]; - } - void setArrayIndex(unsigned I, VarDecl *Index) { - assert(I < getNumArrayIndices() && "Out of bounds member array index"); - getTrailingObjects()[I] = Index; - } - ArrayRef getArrayIndices() { - return llvm::makeArrayRef(getTrailingObjects(), - getNumArrayIndices()); - } - /// \brief Get the initializer. Expr *getInit() const { return static_cast(Init); } - - friend TrailingObjects; }; /// Description of a constructor that was inherited from a base class. @@ -2952,11 +2920,10 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl { dyn_cast(Target)), ConstructedBaseClassShadowDecl(NominatedBaseClassShadowDecl), IsVirtual(TargetInVirtualBase) { - // If we found a constructor for a non-virtual base class, but it chains to - // a constructor for a virtual base, we should directly call the virtual - // base constructor instead. + // If we found a constructor that chains to a constructor for a virtual + // base, we should directly call that virtual base constructor instead. // FIXME: This logic belongs in Sema. - if (!TargetInVirtualBase && NominatedBaseClassShadowDecl && + if (NominatedBaseClassShadowDecl && NominatedBaseClassShadowDecl->constructsVirtualBase()) { ConstructedBaseClassShadowDecl = NominatedBaseClassShadowDecl->ConstructedBaseClassShadowDecl; @@ -2964,7 +2931,9 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl { } } ConstructorUsingShadowDecl(ASTContext &C, EmptyShell Empty) - : UsingShadowDecl(ConstructorUsingShadow, C, Empty) {} + : UsingShadowDecl(ConstructorUsingShadow, C, Empty), + NominatedBaseClassShadowDecl(), ConstructedBaseClassShadowDecl(), + IsVirtual(false) {} public: static ConstructorUsingShadowDecl *Create(ASTContext &C, DeclContext *DC, @@ -3171,6 +3140,77 @@ class UsingDecl : public NamedDecl, public Mergeable { friend class ASTDeclWriter; }; +/// Represents a pack of using declarations that a single +/// using-declarator pack-expanded into. +/// +/// \code +/// template struct X : T... { +/// using T::operator()...; +/// using T::operator T...; +/// }; +/// \endcode +/// +/// In the second case above, the UsingPackDecl will have the name +/// 'operator T' (which contains an unexpanded pack), but the individual +/// UsingDecls and UsingShadowDecls will have more reasonable names. +class UsingPackDecl final + : public NamedDecl, public Mergeable, + private llvm::TrailingObjects { + void anchor() override; + + /// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from + /// which this waas instantiated. + NamedDecl *InstantiatedFrom; + + /// The number of using-declarations created by this pack expansion. + unsigned NumExpansions; + + UsingPackDecl(DeclContext *DC, NamedDecl *InstantiatedFrom, + ArrayRef UsingDecls) + : NamedDecl(UsingPack, DC, + InstantiatedFrom ? InstantiatedFrom->getLocation() + : SourceLocation(), + InstantiatedFrom ? InstantiatedFrom->getDeclName() + : DeclarationName()), + InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) { + std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(), + getTrailingObjects()); + } + +public: + /// Get the using declaration from which this was instantiated. This will + /// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl + /// that is a pack expansion. + NamedDecl *getInstantiatedFromUsingDecl() const { return InstantiatedFrom; } + + /// Get the set of using declarations that this pack expanded into. Note that + /// some of these may still be unresolved. + ArrayRef expansions() const { + return llvm::makeArrayRef(getTrailingObjects(), NumExpansions); + } + + static UsingPackDecl *Create(ASTContext &C, DeclContext *DC, + NamedDecl *InstantiatedFrom, + ArrayRef UsingDecls); + + static UsingPackDecl *CreateDeserialized(ASTContext &C, unsigned ID, + unsigned NumExpansions); + + SourceRange getSourceRange() const override LLVM_READONLY { + return InstantiatedFrom->getSourceRange(); + } + + UsingPackDecl *getCanonicalDecl() override { return getFirstDecl(); } + const UsingPackDecl *getCanonicalDecl() const { return getFirstDecl(); } + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == UsingPack; } + + friend class ASTDeclReader; + friend class ASTDeclWriter; + friend TrailingObjects; +}; + /// \brief Represents a dependent using declaration which was not marked with /// \c typename. /// @@ -3189,6 +3229,9 @@ class UnresolvedUsingValueDecl : public ValueDecl, /// \brief The source location of the 'using' keyword SourceLocation UsingLocation; + /// \brief If this is a pack expansion, the location of the '...'. + SourceLocation EllipsisLoc; + /// \brief The nested-name-specifier that precedes the name. NestedNameSpecifierLoc QualifierLoc; @@ -3199,11 +3242,12 @@ class UnresolvedUsingValueDecl : public ValueDecl, UnresolvedUsingValueDecl(DeclContext *DC, QualType Ty, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, - const DeclarationNameInfo &NameInfo) + const DeclarationNameInfo &NameInfo, + SourceLocation EllipsisLoc) : ValueDecl(UnresolvedUsingValue, DC, NameInfo.getLoc(), NameInfo.getName(), Ty), - UsingLocation(UsingLoc), QualifierLoc(QualifierLoc), - DNLoc(NameInfo.getInfo()) + UsingLocation(UsingLoc), EllipsisLoc(EllipsisLoc), + QualifierLoc(QualifierLoc), DNLoc(NameInfo.getInfo()) { } public: @@ -3229,10 +3273,20 @@ class UnresolvedUsingValueDecl : public ValueDecl, return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } + /// \brief Determine whether this is a pack expansion. + bool isPackExpansion() const { + return EllipsisLoc.isValid(); + } + + /// \brief Get the location of the ellipsis if this is a pack expansion. + SourceLocation getEllipsisLoc() const { + return EllipsisLoc; + } + static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, - const DeclarationNameInfo &NameInfo); + const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc); static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID); @@ -3273,6 +3327,9 @@ class UnresolvedUsingTypenameDecl /// \brief The source location of the 'typename' keyword SourceLocation TypenameLocation; + /// \brief If this is a pack expansion, the location of the '...'. + SourceLocation EllipsisLoc; + /// \brief The nested-name-specifier that precedes the name. NestedNameSpecifierLoc QualifierLoc; @@ -3280,10 +3337,12 @@ class UnresolvedUsingTypenameDecl SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, - IdentifierInfo *TargetName) + IdentifierInfo *TargetName, + SourceLocation EllipsisLoc) : TypeDecl(UnresolvedUsingTypename, DC, TargetNameLoc, TargetName, UsingLoc), - TypenameLocation(TypenameLoc), QualifierLoc(QualifierLoc) { } + TypenameLocation(TypenameLoc), EllipsisLoc(EllipsisLoc), + QualifierLoc(QualifierLoc) { } friend class ASTDeclReader; @@ -3303,10 +3362,25 @@ class UnresolvedUsingTypenameDecl return QualifierLoc.getNestedNameSpecifier(); } + DeclarationNameInfo getNameInfo() const { + return DeclarationNameInfo(getDeclName(), getLocation()); + } + + /// \brief Determine whether this is a pack expansion. + bool isPackExpansion() const { + return EllipsisLoc.isValid(); + } + + /// \brief Get the location of the ellipsis if this is a pack expansion. + SourceLocation getEllipsisLoc() const { + return EllipsisLoc; + } + static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, - SourceLocation TargetNameLoc, DeclarationName TargetName); + SourceLocation TargetNameLoc, DeclarationName TargetName, + SourceLocation EllipsisLoc); static UnresolvedUsingTypenameDecl * CreateDeserialized(ASTContext &C, unsigned ID); @@ -3364,6 +3438,104 @@ class StaticAssertDecl : public Decl { friend class ASTDeclReader; }; +/// A binding in a decomposition declaration. For instance, given: +/// +/// int n[3]; +/// auto &[a, b, c] = n; +/// +/// a, b, and c are BindingDecls, whose bindings are the expressions +/// x[0], x[1], and x[2] respectively, where x is the implicit +/// DecompositionDecl of type 'int (&)[3]'. +class BindingDecl : public ValueDecl { + void anchor() override; + + /// The binding represented by this declaration. References to this + /// declaration are effectively equivalent to this expression (except + /// that it is only evaluated once at the point of declaration of the + /// binding). + Expr *Binding; + + BindingDecl(DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id) + : ValueDecl(Decl::Binding, DC, IdLoc, Id, QualType()), Binding(nullptr) {} + +public: + static BindingDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation IdLoc, IdentifierInfo *Id); + static BindingDecl *CreateDeserialized(ASTContext &C, unsigned ID); + + /// Get the expression to which this declaration is bound. This may be null + /// in two different cases: while parsing the initializer for the + /// decomposition declaration, and when the initializer is type-dependent. + Expr *getBinding() const { return Binding; } + + /// Get the variable (if any) that holds the value of evaluating the binding. + /// Only present for user-defined bindings for tuple-like types. + VarDecl *getHoldingVar() const; + + /// Set the binding for this BindingDecl, along with its declared type (which + /// should be a possibly-cv-qualified form of the type of the binding, or a + /// reference to such a type). + void setBinding(QualType DeclaredType, Expr *Binding) { + setType(DeclaredType); + this->Binding = Binding; + } + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Decl::Binding; } + + friend class ASTDeclReader; +}; + +/// A decomposition declaration. For instance, given: +/// +/// int n[3]; +/// auto &[a, b, c] = n; +/// +/// the second line declares a DecompositionDecl of type 'int (&)[3]', and +/// three BindingDecls (named a, b, and c). An instance of this class is always +/// unnamed, but behaves in almost all other respects like a VarDecl. +class DecompositionDecl final + : public VarDecl, + private llvm::TrailingObjects { + void anchor() override; + + /// The number of BindingDecl*s following this object. + unsigned NumBindings; + + DecompositionDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, + SourceLocation LSquareLoc, QualType T, + TypeSourceInfo *TInfo, StorageClass SC, + ArrayRef Bindings) + : VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo, + SC), + NumBindings(Bindings.size()) { + std::uninitialized_copy(Bindings.begin(), Bindings.end(), + getTrailingObjects()); + } + +public: + static DecompositionDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation StartLoc, + SourceLocation LSquareLoc, + QualType T, TypeSourceInfo *TInfo, + StorageClass S, + ArrayRef Bindings); + static DecompositionDecl *CreateDeserialized(ASTContext &C, unsigned ID, + unsigned NumBindings); + + ArrayRef bindings() const { + return llvm::makeArrayRef(getTrailingObjects(), NumBindings); + } + + void printName(raw_ostream &os) const override; + + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Decomposition; } + + friend TrailingObjects; + friend class ASTDeclReader; +}; + /// An instance of this class represents the declaration of a property /// member. This is a Microsoft extension to C++, first introduced in /// Visual Studio .NET 2003 as a parallel to similar features in C# diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index 5b2e2d9915e..172c46a44ac 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -82,6 +82,7 @@ class FriendDecl final FriendDecl(EmptyShell Empty, unsigned NumFriendTypeTPLists) : Decl(Decl::Friend, Empty), NextFriend(), + UnsupportedFriend(false), NumTPLists(NumFriendTypeTPLists) { } FriendDecl *getNextFriend() { @@ -166,6 +167,7 @@ class FriendDecl final friend class ASTDeclReader; friend class ASTDeclWriter; + friend class ASTNodeImporter; friend TrailingObjects; }; diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index c84bb5e6048..6353b26f7bf 100644 --- a/include/clang/AST/DeclGroup.h +++ b/include/clang/AST/DeclGroup.h @@ -84,7 +84,7 @@ class DeclGroupRef { bool isDeclGroup() const { return getKind() == DeclGroupKind; } Decl *getSingleDecl() { - assert(isSingleDecl() && "Isn't a declgroup"); + assert(isSingleDecl() && "Isn't a single decl"); return D; } const Decl *getSingleDecl() const { diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index ad9b5a26b7c..f5098f06a9f 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -394,7 +394,7 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext { /// createImplicitParams - Used to lazily create the self and cmd /// implict parameters. This must be called prior to using getSelfDecl() - /// or getCmdDecl(). The call is ignored if the implicit paramters + /// or getCmdDecl(). The call is ignored if the implicit parameters /// have already been created. void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID); @@ -463,6 +463,9 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext { ImplementationControl getImplementationControl() const { return ImplementationControl(DeclImplementation); } + bool isOptional() const { + return getImplementationControl() == Optional; + } /// Returns true if this specific method declaration is marked with the /// designated initializer attribute. @@ -870,6 +873,9 @@ class ObjCPropertyDecl : public NamedDecl { PropertyControl getPropertyImplementation() const { return PropertyControl(PropertyImplementation); } + bool isOptional() const { + return getPropertyImplementation() == PropertyControl::Optional; + } void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { PropertyIvarDecl = Ivar; diff --git a/include/clang/AST/DeclOpenMP.h b/include/clang/AST/DeclOpenMP.h index 1975bc551ca..30ca79e9d00 100644 --- a/include/clang/AST/DeclOpenMP.h +++ b/include/clang/AST/DeclOpenMP.h @@ -173,18 +173,21 @@ class OMPCapturedExprDecl final : public VarDecl { void anchor() override; OMPCapturedExprDecl(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, - QualType Type) - : VarDecl(OMPCapturedExpr, C, DC, SourceLocation(), SourceLocation(), Id, - Type, nullptr, SC_None) { + QualType Type, SourceLocation StartLoc) + : VarDecl(OMPCapturedExpr, C, DC, StartLoc, SourceLocation(), Id, Type, + nullptr, SC_None) { setImplicit(); } public: static OMPCapturedExprDecl *Create(ASTContext &C, DeclContext *DC, - IdentifierInfo *Id, QualType T); + IdentifierInfo *Id, QualType T, + SourceLocation StartLoc); static OMPCapturedExprDecl *CreateDeserialized(ASTContext &C, unsigned ID); + SourceRange getSourceRange() const override LLVM_READONLY; + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == OMPCapturedExpr; } diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 4ac8cdc9bee..dc50a190de4 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -21,7 +21,6 @@ #include "llvm/ADT/PointerUnion.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/TrailingObjects.h" -#include #include namespace clang { @@ -44,10 +43,13 @@ class VarTemplatePartialSpecializationDecl; typedef llvm::PointerUnion3 TemplateParameter; +NamedDecl *getAsNamedDecl(TemplateParameter P); + /// \brief Stores a list of template parameters for a TemplateDecl and its /// derived classes. class TemplateParameterList final - : private llvm::TrailingObjects { + : private llvm::TrailingObjects { /// The location of the 'template' keyword. SourceLocation TemplateLoc; @@ -57,26 +59,35 @@ class TemplateParameterList final /// The number of template parameters in this template /// parameter list. - unsigned NumParams : 31; + unsigned NumParams : 30; /// Whether this template parameter list contains an unexpanded parameter /// pack. unsigned ContainsUnexpandedParameterPack : 1; + /// Whether this template parameter list has an associated requires-clause + unsigned HasRequiresClause : 1; + protected: size_t numTrailingObjects(OverloadToken) const { return NumParams; } + size_t numTrailingObjects(OverloadToken) const { + return HasRequiresClause; + } + TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, - ArrayRef Params, SourceLocation RAngleLoc); + ArrayRef Params, SourceLocation RAngleLoc, + Expr *RequiresClause); public: static TemplateParameterList *Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef Params, - SourceLocation RAngleLoc); + SourceLocation RAngleLoc, + Expr *RequiresClause); /// \brief Iterates through the template parameters in this list. typedef NamedDecl** iterator; @@ -128,6 +139,16 @@ class TemplateParameterList final return ContainsUnexpandedParameterPack; } + /// \brief The constraint-expression of the associated requires-clause. + Expr *getRequiresClause() { + return HasRequiresClause ? *getTrailingObjects() : nullptr; + } + + /// \brief The constraint-expression of the associated requires-clause. + const Expr *getRequiresClause() const { + return HasRequiresClause ? *getTrailingObjects() : nullptr; + } + SourceLocation getTemplateLoc() const { return TemplateLoc; } SourceLocation getLAngleLoc() const { return LAngleLoc; } SourceLocation getRAngleLoc() const { return RAngleLoc; } @@ -137,36 +158,37 @@ class TemplateParameterList final } friend TrailingObjects; - template friend class FixedSizeTemplateParameterListStorage; + + template + friend class FixedSizeTemplateParameterListStorage; + +public: + // FIXME: workaround for MSVC 2013; remove when no longer needed + using FixedSizeStorageOwner = TrailingObjects::FixedSizeStorageOwner; }; -/// \brief Stores a list of template parameters for a TemplateDecl and its -/// derived classes. Suitable for creating on the stack. -template class FixedSizeTemplateParameterListStorage { - // This is kinda ugly: TemplateParameterList usually gets allocated - // in a block of memory with NamedDecls appended to it. Here, to get - // it stack allocated, we include the params as a separate - // variable. After allocation, the TemplateParameterList object - // treats them as part of itself. - TemplateParameterList List; - NamedDecl *Params[N]; +/// \brief Stores a list of template parameters and the associated +/// requires-clause (if any) for a TemplateDecl and its derived classes. +/// Suitable for creating on the stack. +template +class FixedSizeTemplateParameterListStorage + : public TemplateParameterList::FixedSizeStorageOwner { + typename TemplateParameterList::FixedSizeStorage< + NamedDecl *, Expr *>::with_counts< + N, HasRequiresClause ? 1u : 0u + >::type storage; public: FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef Params, - SourceLocation RAngleLoc) - : List(TemplateLoc, LAngleLoc, Params, RAngleLoc) { - // Because we're doing an evil layout hack above, have some - // asserts, just to double-check everything is laid out like - // expected. - assert(sizeof(*this) == - TemplateParameterList::totalSizeToAlloc(N) && - "Object layout not as expected"); - assert(this->Params == List.getTrailingObjects() && - "Object layout not as expected"); - } - TemplateParameterList *get() { return &List; } + SourceLocation RAngleLoc, + Expr *RequiresClause) + : FixedSizeStorageOwner( + (assert(N == Params.size()), + assert(HasRequiresClause == static_cast(RequiresClause)), + new (static_cast(&storage)) TemplateParameterList( + TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause))) {} }; /// \brief A template argument list. @@ -354,6 +376,11 @@ class TemplateDecl : public NamedDecl { return TemplateParams; } + /// Get the constraint-expression from the associated requires-clause (if any) + const Expr *getRequiresClause() const { + return TemplateParams ? TemplateParams->getRequiresClause() : nullptr; + } + /// Get the underlying, templated declaration. NamedDecl *getTemplatedDecl() const { return TemplatedDecl.getPointer(); } @@ -2001,8 +2028,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl { SourceLocation L, DeclarationName Name, TemplateParameterList *Params, - NamedDecl *Decl, - ClassTemplateDecl *PrevDecl); + NamedDecl *Decl); /// \brief Create an empty class template node. static ClassTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -2912,6 +2938,14 @@ class VarTemplateDecl : public RedeclarableTemplateDecl { friend class ASTDeclWriter; }; +inline NamedDecl *getAsNamedDecl(TemplateParameter P) { + if (auto *PD = P.dyn_cast()) + return PD; + if (auto *PD = P.dyn_cast()) + return PD; + return P.get(); +} + } /* end of namespace clang */ #endif diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 9179c7736a9..56b99ccd897 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -445,6 +445,11 @@ class Expr : public Stmt { return const_cast(this)->getSourceBitField(); } + Decl *getReferencedDeclOfCallee(); + const Decl *getReferencedDeclOfCallee() const { + return const_cast(this)->getReferencedDeclOfCallee(); + } + /// \brief If this expression is an l-value for an Objective C /// property, find the underlying property reference expression. const ObjCPropertyRefExpr *getObjCProperty() const; @@ -646,7 +651,8 @@ class Expr : public Stmt { /// constant. bool EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx, const FunctionDecl *Callee, - ArrayRef Args) const; + ArrayRef Args, + const Expr *This = nullptr) const; /// \brief If the current Expr is a pointer, this will try to statically /// determine the number of bytes available where the pointer is pointing. @@ -823,12 +829,22 @@ class Expr : public Stmt { /// behavior if the object isn't dynamically of the derived type. const CXXRecordDecl *getBestDynamicClassType() const; + /// \brief Get the inner expression that determines the best dynamic class. + /// If this is a prvalue, we guarantee that it is of the most-derived type + /// for the object itself. + const Expr *getBestDynamicClassTypeExpr() const; + /// Walk outwards from an expression we want to bind a reference to and /// find the expression whose lifetime needs to be extended. Record /// the LHSs of comma expressions and adjustments needed along the path. const Expr *skipRValueSubobjectAdjustments( SmallVectorImpl &CommaLHS, SmallVectorImpl &Adjustments) const; + const Expr *skipRValueSubobjectAdjustments() const { + SmallVector CommaLHSs; + SmallVector Adjustments; + return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + } static bool classof(const Stmt *T) { return T->getStmtClass() >= firstExprConstant && @@ -2406,8 +2422,8 @@ class MemberExpr final /// \brief Retrieve the member declaration to which this expression refers. /// - /// The returned declaration will either be a FieldDecl or (in C++) - /// a CXXMethodDecl. + /// The returned declaration will be a FieldDecl or (in C++) a VarDecl (for + /// static data members), a CXXMethodDecl, or an EnumConstantDecl. ValueDecl *getMemberDecl() const { return MemberDecl; } void setMemberDecl(ValueDecl *D) { MemberDecl = D; } @@ -3771,17 +3787,26 @@ class InitListExpr : public Expr { /// \brief Build an empty initializer list. explicit InitListExpr(EmptyShell Empty) - : Expr(InitListExprClass, Empty) { } + : Expr(InitListExprClass, Empty), AltForm(nullptr, true) { } unsigned getNumInits() const { return InitExprs.size(); } /// \brief Retrieve the set of initializers. Expr **getInits() { return reinterpret_cast(InitExprs.data()); } + /// \brief Retrieve the set of initializers. + Expr * const *getInits() const { + return reinterpret_cast(InitExprs.data()); + } + ArrayRef inits() { return llvm::makeArrayRef(getInits(), getNumInits()); } + ArrayRef inits() const { + return llvm::makeArrayRef(getInits(), getNumInits()); + } + const Expr *getInit(unsigned Init) const { assert(Init < getNumInits() && "Initializer access out of range!"); return cast_or_null(InitExprs[Init]); @@ -3862,7 +3887,7 @@ class InitListExpr : public Expr { // Explicit InitListExpr's originate from source code (and have valid source // locations). Implicit InitListExpr's are created by the semantic analyzer. - bool isExplicit() { + bool isExplicit() const { return LBraceLoc.isValid() && RBraceLoc.isValid(); } @@ -3870,6 +3895,11 @@ class InitListExpr : public Expr { // literal or an @encode? bool isStringLiteralInit() const; + /// Is this a transparent initializer list (that is, an InitListExpr that is + /// purely syntactic, and whose semantics are that of the sole contained + /// initializer)? + bool isTransparent() const; + SourceLocation getLBraceLoc() const { return LBraceLoc; } void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; } SourceLocation getRBraceLoc() const { return RBraceLoc; } @@ -4304,6 +4334,98 @@ class DesignatedInitUpdateExpr : public Expr { } }; +/// \brief Represents a loop initializing the elements of an array. +/// +/// The need to initialize the elements of an array occurs in a number of +/// contexts: +/// +/// * in the implicit copy/move constructor for a class with an array member +/// * when a lambda-expression captures an array by value +/// * when a decomposition declaration decomposes an array +/// +/// There are two subexpressions: a common expression (the source array) +/// that is evaluated once up-front, and a per-element initializer that +/// runs once for each array element. +/// +/// Within the per-element initializer, the common expression may be referenced +/// via an OpaqueValueExpr, and the current index may be obtained via an +/// ArrayInitIndexExpr. +class ArrayInitLoopExpr : public Expr { + Stmt *SubExprs[2]; + + explicit ArrayInitLoopExpr(EmptyShell Empty) + : Expr(ArrayInitLoopExprClass, Empty), SubExprs{} {} + +public: + explicit ArrayInitLoopExpr(QualType T, Expr *CommonInit, Expr *ElementInit) + : Expr(ArrayInitLoopExprClass, T, VK_RValue, OK_Ordinary, false, + CommonInit->isValueDependent() || ElementInit->isValueDependent(), + T->isInstantiationDependentType(), + CommonInit->containsUnexpandedParameterPack() || + ElementInit->containsUnexpandedParameterPack()), + SubExprs{CommonInit, ElementInit} {} + + /// Get the common subexpression shared by all initializations (the source + /// array). + OpaqueValueExpr *getCommonExpr() const { + return cast(SubExprs[0]); + } + + /// Get the initializer to use for each array element. + Expr *getSubExpr() const { return cast(SubExprs[1]); } + + llvm::APInt getArraySize() const { + return cast(getType()->castAsArrayTypeUnsafe()) + ->getSize(); + } + + static bool classof(const Stmt *S) { + return S->getStmtClass() == ArrayInitLoopExprClass; + } + + SourceLocation getLocStart() const LLVM_READONLY { + return getCommonExpr()->getLocStart(); + } + SourceLocation getLocEnd() const LLVM_READONLY { + return getCommonExpr()->getLocEnd(); + } + + child_range children() { + return child_range(SubExprs, SubExprs + 2); + } + + friend class ASTReader; + friend class ASTStmtReader; + friend class ASTStmtWriter; +}; + +/// \brief Represents the index of the current element of an array being +/// initialized by an ArrayInitLoopExpr. This can only appear within the +/// subexpression of an ArrayInitLoopExpr. +class ArrayInitIndexExpr : public Expr { + explicit ArrayInitIndexExpr(EmptyShell Empty) + : Expr(ArrayInitIndexExprClass, Empty) {} + +public: + explicit ArrayInitIndexExpr(QualType T) + : Expr(ArrayInitIndexExprClass, T, VK_RValue, OK_Ordinary, + false, false, false, false) {} + + static bool classof(const Stmt *S) { + return S->getStmtClass() == ArrayInitIndexExprClass; + } + + SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); } + SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); } + + child_range children() { + return child_range(child_iterator(), child_iterator()); + } + + friend class ASTReader; + friend class ASTStmtReader; +}; + /// \brief Represents an implicitly-generated value initialization of /// an object of a given type. /// @@ -4447,11 +4569,19 @@ class GenericSelectionExpr : public Expr { return cast(SubExprs[END_EXPR+i]); } Expr *getAssocExpr(unsigned i) { return cast(SubExprs[END_EXPR+i]); } - + ArrayRef getAssocExprs() const { + return NumAssocs + ? llvm::makeArrayRef( + &reinterpret_cast(SubExprs)[END_EXPR], NumAssocs) + : None; + } const TypeSourceInfo *getAssocTypeSourceInfo(unsigned i) const { return AssocTypes[i]; } TypeSourceInfo *getAssocTypeSourceInfo(unsigned i) { return AssocTypes[i]; } + ArrayRef getAssocTypeSourceInfos() const { + return NumAssocs ? llvm::makeArrayRef(&AssocTypes[0], NumAssocs) : None; + } QualType getAssocType(unsigned i) const { if (const TypeSourceInfo *TS = getAssocTypeSourceInfo(i)) diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 86cbfb2cd0b..37e59771a72 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -76,6 +76,19 @@ class CXXOperatorCallExpr : public CallExpr { /// expression refers to. OverloadedOperatorKind getOperator() const { return Operator; } + static bool isAssignmentOp(OverloadedOperatorKind Opc) { + return Opc == OO_Equal || Opc == OO_StarEqual || + Opc == OO_SlashEqual || Opc == OO_PercentEqual || + Opc == OO_PlusEqual || Opc == OO_MinusEqual || + Opc == OO_LessLessEqual || Opc == OO_GreaterGreaterEqual || + Opc == OO_AmpEqual || Opc == OO_CaretEqual || + Opc == OO_PipeEqual; + } + bool isAssignmentOp() const { return isAssignmentOp(getOperator()); } + + /// \brief Is this written as an infix binary operator? + bool isInfixBinaryOp() const; + /// \brief Returns the location of the operator symbol in the expression. /// /// When \c getOperator()==OO_Call, this is the location of the right @@ -1500,9 +1513,8 @@ class CXXTemporaryObjectExpr : public CXXConstructExpr { /// C++1y introduces a new form of "capture" called an init-capture that /// includes an initializing expression (rather than capturing a variable), /// and which can never occur implicitly. -class LambdaExpr final - : public Expr, - private llvm::TrailingObjects { +class LambdaExpr final : public Expr, + private llvm::TrailingObjects { /// \brief The source range that covers the lambda introducer ([...]). SourceRange IntroducerRange; @@ -1523,10 +1535,6 @@ class LambdaExpr final /// \brief Whether this lambda had the result type explicitly specified. unsigned ExplicitResultType : 1; - /// \brief Whether there are any array index variables stored at the end of - /// this lambda expression. - unsigned HasArrayIndexVars : 1; - /// \brief The location of the closing brace ('}') that completes /// the lambda. /// @@ -1537,28 +1545,19 @@ class LambdaExpr final /// module file just to determine the source range. SourceLocation ClosingBrace; - size_t numTrailingObjects(OverloadToken) const { - return NumCaptures + 1; - } - - size_t numTrailingObjects(OverloadToken) const { - return HasArrayIndexVars ? NumCaptures + 1 : 0; - } - /// \brief Construct a lambda expression. LambdaExpr(QualType T, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, ArrayRef Captures, bool ExplicitParams, bool ExplicitResultType, - ArrayRef CaptureInits, ArrayRef ArrayIndexVars, - ArrayRef ArrayIndexStarts, SourceLocation ClosingBrace, + ArrayRef CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack); /// \brief Construct an empty lambda expression. - LambdaExpr(EmptyShell Empty, unsigned NumCaptures, bool HasArrayIndexVars) + LambdaExpr(EmptyShell Empty, unsigned NumCaptures) : Expr(LambdaExprClass, Empty), NumCaptures(NumCaptures), CaptureDefault(LCD_None), ExplicitParams(false), - ExplicitResultType(false), HasArrayIndexVars(true) { + ExplicitResultType(false) { getStoredStmts()[NumCaptures] = nullptr; } @@ -1566,21 +1565,6 @@ class LambdaExpr final Stmt *const *getStoredStmts() const { return getTrailingObjects(); } - /// \brief Retrieve the mapping from captures to the first array index - /// variable. - unsigned *getArrayIndexStarts() { return getTrailingObjects(); } - - const unsigned *getArrayIndexStarts() const { - return getTrailingObjects(); - } - - /// \brief Retrieve the complete set of array-index variables. - VarDecl **getArrayIndexVars() { return getTrailingObjects(); } - - VarDecl *const *getArrayIndexVars() const { - return getTrailingObjects(); - } - public: /// \brief Construct a new lambda expression. static LambdaExpr * @@ -1588,15 +1572,12 @@ class LambdaExpr final LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, ArrayRef Captures, bool ExplicitParams, bool ExplicitResultType, ArrayRef CaptureInits, - ArrayRef ArrayIndexVars, - ArrayRef ArrayIndexStarts, SourceLocation ClosingBrace, - bool ContainsUnexpandedParameterPack); + SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack); /// \brief Construct a new lambda expression that will be deserialized from /// an external source. static LambdaExpr *CreateDeserialized(const ASTContext &C, - unsigned NumCaptures, - unsigned NumArrayIndexVars); + unsigned NumCaptures); /// \brief Determine the default capture kind for this lambda. LambdaCaptureDefault getCaptureDefault() const { @@ -1695,14 +1676,6 @@ class LambdaExpr final return capture_init_begin() + NumCaptures; } - /// \brief Retrieve the set of index variables used in the capture - /// initializer of an array captured by copy. - /// - /// \param Iter The iterator that points at the capture initializer for - /// which we are extracting the corresponding index variables. - ArrayRef - getCaptureInitIndexVars(const_capture_init_iterator Iter) const; - /// \brief Retrieve the source range covering the lambda introducer, /// which contains the explicit capture list surrounded by square /// brackets ([...]). @@ -1828,11 +1801,13 @@ class CXXNewExpr : public Expr { unsigned GlobalNew : 1; /// Do we allocate an array? If so, the first SubExpr is the size expression. unsigned Array : 1; + /// Should the alignment be passed to the allocation function? + unsigned PassAlignment : 1; /// If this is an array allocation, does the usual deallocation /// function for the allocated type want to know the allocated size? unsigned UsualArrayDeleteWantsSize : 1; /// The number of placement new arguments. - unsigned NumPlacementArgs : 13; + unsigned NumPlacementArgs : 26; /// What kind of initializer do we have? Could be none, parens, or braces. /// In storage, we distinguish between "none, and no initializer expr", and /// "none, but an implicit initializer expr". @@ -1848,8 +1823,8 @@ class CXXNewExpr : public Expr { }; CXXNewExpr(const ASTContext &C, bool globalNew, FunctionDecl *operatorNew, - FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize, - ArrayRef placementArgs, + FunctionDecl *operatorDelete, bool PassAlignment, + bool usualArrayDeleteWantsSize, ArrayRef placementArgs, SourceRange typeIdParens, Expr *arraySize, InitializationStyle initializationStyle, Expr *initializer, QualType ty, TypeSourceInfo *AllocatedTypeInfo, @@ -1937,10 +1912,16 @@ class CXXNewExpr : public Expr { } /// \brief Returns the CXXConstructExpr from this new-expression, or null. - const CXXConstructExpr* getConstructExpr() const { + const CXXConstructExpr *getConstructExpr() const { return dyn_cast_or_null(getInitializer()); } + /// Indicates whether the required alignment should be implicitly passed to + /// the allocation function. + bool passAlignment() const { + return PassAlignment; + } + /// Answers whether the usual array deallocation function for the /// allocated type expects the size of the allocation as a /// parameter. @@ -4011,6 +3992,12 @@ class MaterializeTemporaryExpr : public Expr { // within a default initializer. if (isa(ExtendingDecl)) return SD_Automatic; + // FIXME: This only works because storage class specifiers are not allowed + // on decomposition declarations. + if (isa(ExtendingDecl)) + return ExtendingDecl->getDeclContext()->isFunctionOrMethod() + ? SD_Automatic + : SD_Static; return cast(ExtendingDecl)->getStorageDuration(); } diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index 5f9623db241..cd938175861 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -90,7 +90,7 @@ class ObjCBoolLiteralExpr : public Expr { /// ObjCBoxedExpr - used for generalized expression boxing. /// as in: @(strdup("hello world")), @(random()) or @(view.frame) /// Also used for boxing non-parenthesized numeric literals; -/// as in: @42 or \@true (c++/objc++) or \@__yes (c/objc). +/// as in: @42 or \@true (c++/objc++) or \@__objc_yes (c/objc). class ObjCBoxedExpr : public Expr { Stmt *SubExpr; ObjCMethodDecl *BoxingMethod; diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h index 81cf631c7a4..2e99f395f49 100644 --- a/include/clang/AST/ExternalASTSource.h +++ b/include/clang/AST/ExternalASTSource.h @@ -503,8 +503,9 @@ class LazyVector { /// We define this as a wrapping iterator around an int. The /// iterator_adaptor_base class forwards the iterator methods to basic integer /// arithmetic. - class iterator : public llvm::iterator_adaptor_base< - iterator, int, std::random_access_iterator_tag, T, int> { + class iterator + : public llvm::iterator_adaptor_base< + iterator, int, std::random_access_iterator_tag, T, int, T *, T &> { LazyVector *Self; iterator(LazyVector *Self, int Position) diff --git a/include/clang/AST/Mangle.h b/include/clang/AST/Mangle.h index 6e3ef9da0c3..7a45d88c23c 100644 --- a/include/clang/AST/Mangle.h +++ b/include/clang/AST/Mangle.h @@ -14,14 +14,14 @@ #ifndef LLVM_CLANG_AST_MANGLE_H #define LLVM_CLANG_AST_MANGLE_H -#include "clang/AST/Decl.h" #include "clang/AST/Type.h" #include "clang/Basic/ABI.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/raw_ostream.h" + +namespace llvm { + class raw_ostream; +} namespace clang { class ASTContext; diff --git a/include/clang/AST/MangleNumberingContext.h b/include/clang/AST/MangleNumberingContext.h index 7a818557fdb..869221dbf31 100644 --- a/include/clang/AST/MangleNumberingContext.h +++ b/include/clang/AST/MangleNumberingContext.h @@ -16,7 +16,6 @@ #define LLVM_CLANG_AST_MANGLENUMBERINGCONTEXT_H #include "clang/Basic/LLVM.h" -#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" namespace clang { @@ -30,7 +29,7 @@ class VarDecl; /// \brief Keeps track of the mangled names of lambda expressions and block /// literals within a particular context. -class MangleNumberingContext : public RefCountedBase { +class MangleNumberingContext { public: virtual ~MangleNumberingContext() {} diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h index 43988cd864b..3e4c4bc7ea4 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -4228,50 +4228,153 @@ class OMPFromClause final /// 'use_device_ptr' with the variables 'a' and 'b'. /// class OMPUseDevicePtrClause final - : public OMPVarListClause, - private llvm::TrailingObjects { + : public OMPMappableExprListClause, + private llvm::TrailingObjects< + OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned, + OMPClauseMappableExprCommon::MappableComponent> { friend TrailingObjects; friend OMPVarListClause; + friend OMPMappableExprListClause; friend class OMPClauseReader; - /// Build clause with number of variables \a N. + + /// Define the sizes of each trailing object array except the last one. This + /// is required for TrailingObjects to work properly. + size_t numTrailingObjects(OverloadToken) const { + return 3 * varlist_size(); + } + size_t numTrailingObjects(OverloadToken) const { + return getUniqueDeclarationsNum(); + } + size_t numTrailingObjects(OverloadToken) const { + return getUniqueDeclarationsNum() + getTotalComponentListNum(); + } + + /// Build clause with number of variables \a NumVars. /// /// \param StartLoc Starting location of the clause. - /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. - /// \param N Number of the variables in the clause. + /// \param NumVars Number of expressions listed in this clause. + /// \param NumUniqueDeclarations Number of unique base declarations in this + /// clause. + /// \param NumComponentLists Number of component lists in this clause. + /// \param NumComponents Total number of expression components in the clause. /// - OMPUseDevicePtrClause(SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc, unsigned N) - : OMPVarListClause(OMPC_use_device_ptr, StartLoc, - LParenLoc, EndLoc, N) {} + explicit OMPUseDevicePtrClause(SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc, unsigned NumVars, + unsigned NumUniqueDeclarations, + unsigned NumComponentLists, + unsigned NumComponents) + : OMPMappableExprListClause(OMPC_use_device_ptr, StartLoc, LParenLoc, + EndLoc, NumVars, NumUniqueDeclarations, + NumComponentLists, NumComponents) {} - /// \brief Build an empty clause. + /// Build an empty clause. /// - /// \param N Number of variables. + /// \param NumVars Number of expressions listed in this clause. + /// \param NumUniqueDeclarations Number of unique base declarations in this + /// clause. + /// \param NumComponentLists Number of component lists in this clause. + /// \param NumComponents Total number of expression components in the clause. /// - explicit OMPUseDevicePtrClause(unsigned N) - : OMPVarListClause( - OMPC_use_device_ptr, SourceLocation(), SourceLocation(), - SourceLocation(), N) {} + explicit OMPUseDevicePtrClause(unsigned NumVars, + unsigned NumUniqueDeclarations, + unsigned NumComponentLists, + unsigned NumComponents) + : OMPMappableExprListClause(OMPC_use_device_ptr, SourceLocation(), + SourceLocation(), SourceLocation(), NumVars, + NumUniqueDeclarations, NumComponentLists, + NumComponents) {} + + /// Sets the list of references to private copies with initializers for new + /// private variables. + /// \param VL List of references. + void setPrivateCopies(ArrayRef VL); + + /// Gets the list of references to private copies with initializers for new + /// private variables. + MutableArrayRef getPrivateCopies() { + return MutableArrayRef(varlist_end(), varlist_size()); + } + ArrayRef getPrivateCopies() const { + return llvm::makeArrayRef(varlist_end(), varlist_size()); + } + + /// Sets the list of references to initializer variables for new private + /// variables. + /// \param VL List of references. + void setInits(ArrayRef VL); + + /// Gets the list of references to initializer variables for new private + /// variables. + MutableArrayRef getInits() { + return MutableArrayRef(getPrivateCopies().end(), varlist_size()); + } + ArrayRef getInits() const { + return llvm::makeArrayRef(getPrivateCopies().end(), varlist_size()); + } public: - /// Creates clause with a list of variables \a VL. + /// Creates clause with a list of variables \a Vars. /// /// \param C AST context. /// \param StartLoc Starting location of the clause. - /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. - /// \param VL List of references to the variables. + /// \param Vars The original expression used in the clause. + /// \param PrivateVars Expressions referring to private copies. + /// \param Inits Expressions referring to private copy initializers. + /// \param Declarations Declarations used in the clause. + /// \param ComponentLists Component lists used in the clause. /// static OMPUseDevicePtrClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc, ArrayRef VL); - /// Creates an empty clause with the place for \a N variables. + SourceLocation EndLoc, ArrayRef Vars, + ArrayRef PrivateVars, ArrayRef Inits, + ArrayRef Declarations, + MappableExprComponentListsRef ComponentLists); + + /// Creates an empty clause with the place for \a NumVars variables. /// /// \param C AST context. - /// \param N The number of variables. + /// \param NumVars Number of expressions listed in the clause. + /// \param NumUniqueDeclarations Number of unique base declarations in this + /// clause. + /// \param NumComponentLists Number of unique base declarations in this + /// clause. + /// \param NumComponents Total number of expression components in the clause. /// - static OMPUseDevicePtrClause *CreateEmpty(const ASTContext &C, unsigned N); + static OMPUseDevicePtrClause *CreateEmpty(const ASTContext &C, + unsigned NumVars, + unsigned NumUniqueDeclarations, + unsigned NumComponentLists, + unsigned NumComponents); + + typedef MutableArrayRef::iterator private_copies_iterator; + typedef ArrayRef::iterator private_copies_const_iterator; + typedef llvm::iterator_range private_copies_range; + typedef llvm::iterator_range + private_copies_const_range; + + private_copies_range private_copies() { + return private_copies_range(getPrivateCopies().begin(), + getPrivateCopies().end()); + } + private_copies_const_range private_copies() const { + return private_copies_const_range(getPrivateCopies().begin(), + getPrivateCopies().end()); + } + + typedef MutableArrayRef::iterator inits_iterator; + typedef ArrayRef::iterator inits_const_iterator; + typedef llvm::iterator_range inits_range; + typedef llvm::iterator_range inits_const_range; + + inits_range inits() { + return inits_range(getInits().begin(), getInits().end()); + } + inits_const_range inits() const { + return inits_const_range(getInits().begin(), getInits().end()); + } child_range children() { return child_range(reinterpret_cast(varlist_begin()), @@ -4293,50 +4396,94 @@ class OMPUseDevicePtrClause final /// 'is_device_ptr' with the variables 'a' and 'b'. /// class OMPIsDevicePtrClause final - : public OMPVarListClause, - private llvm::TrailingObjects { + : public OMPMappableExprListClause, + private llvm::TrailingObjects< + OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned, + OMPClauseMappableExprCommon::MappableComponent> { friend TrailingObjects; friend OMPVarListClause; + friend OMPMappableExprListClause; friend class OMPClauseReader; - /// Build clause with number of variables \a N. + + /// Define the sizes of each trailing object array except the last one. This + /// is required for TrailingObjects to work properly. + size_t numTrailingObjects(OverloadToken) const { + return varlist_size(); + } + size_t numTrailingObjects(OverloadToken) const { + return getUniqueDeclarationsNum(); + } + size_t numTrailingObjects(OverloadToken) const { + return getUniqueDeclarationsNum() + getTotalComponentListNum(); + } + /// Build clause with number of variables \a NumVars. /// /// \param StartLoc Starting location of the clause. - /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. - /// \param N Number of the variables in the clause. + /// \param NumVars Number of expressions listed in this clause. + /// \param NumUniqueDeclarations Number of unique base declarations in this + /// clause. + /// \param NumComponentLists Number of component lists in this clause. + /// \param NumComponents Total number of expression components in the clause. /// - OMPIsDevicePtrClause(SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc, unsigned N) - : OMPVarListClause(OMPC_is_device_ptr, StartLoc, - LParenLoc, EndLoc, N) {} + explicit OMPIsDevicePtrClause(SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc, + unsigned NumVars, + unsigned NumUniqueDeclarations, + unsigned NumComponentLists, + unsigned NumComponents) + : OMPMappableExprListClause(OMPC_is_device_ptr, StartLoc, LParenLoc, + EndLoc, NumVars, NumUniqueDeclarations, + NumComponentLists, NumComponents) {} /// Build an empty clause. /// - /// \param N Number of variables. + /// \param NumVars Number of expressions listed in this clause. + /// \param NumUniqueDeclarations Number of unique base declarations in this + /// clause. + /// \param NumComponentLists Number of component lists in this clause. + /// \param NumComponents Total number of expression components in the clause. /// - explicit OMPIsDevicePtrClause(unsigned N) - : OMPVarListClause( - OMPC_is_device_ptr, SourceLocation(), SourceLocation(), - SourceLocation(), N) {} + explicit OMPIsDevicePtrClause(unsigned NumVars, + unsigned NumUniqueDeclarations, + unsigned NumComponentLists, + unsigned NumComponents) + : OMPMappableExprListClause(OMPC_is_device_ptr, SourceLocation(), + SourceLocation(), SourceLocation(), NumVars, + NumUniqueDeclarations, NumComponentLists, + NumComponents) {} public: - /// Creates clause with a list of variables \a VL. + /// Creates clause with a list of variables \a Vars. /// /// \param C AST context. /// \param StartLoc Starting location of the clause. - /// \param LParenLoc Location of '('. /// \param EndLoc Ending location of the clause. - /// \param VL List of references to the variables. + /// \param Vars The original expression used in the clause. + /// \param Declarations Declarations used in the clause. + /// \param ComponentLists Component lists used in the clause. /// static OMPIsDevicePtrClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, - SourceLocation EndLoc, ArrayRef VL); - /// Creates an empty clause with the place for \a N variables. + SourceLocation EndLoc, ArrayRef Vars, + ArrayRef Declarations, + MappableExprComponentListsRef ComponentLists); + + /// Creates an empty clause with the place for \a NumVars variables. /// /// \param C AST context. - /// \param N The number of variables. + /// \param NumVars Number of expressions listed in the clause. + /// \param NumUniqueDeclarations Number of unique base declarations in this + /// clause. + /// \param NumComponentLists Number of unique base declarations in this + /// clause. + /// \param NumComponents Total number of expression components in the clause. /// - static OMPIsDevicePtrClause *CreateEmpty(const ASTContext &C, unsigned N); + static OMPIsDevicePtrClause *CreateEmpty(const ASTContext &C, + unsigned NumVars, + unsigned NumUniqueDeclarations, + unsigned NumComponentLists, + unsigned NumComponents); child_range children() { return child_range(reinterpret_cast(varlist_begin()), diff --git a/include/clang/AST/OperationKinds.def b/include/clang/AST/OperationKinds.def index 82f494bec99..2d48a7df47b 100644 --- a/include/clang/AST/OperationKinds.def +++ b/include/clang/AST/OperationKinds.def @@ -321,9 +321,14 @@ CAST_OPERATION(BuiltinFnToFnPtr) // Convert a zero value for OpenCL event_t initialization. CAST_OPERATION(ZeroToOCLEvent) +// Convert a zero value for OpenCL queue_t initialization. +CAST_OPERATION(ZeroToOCLQueue) + // Convert a pointer to a different address space. CAST_OPERATION(AddressSpaceConversion) +// Convert an integer initializer to an OpenCL sampler. +CAST_OPERATION(IntToOCLSampler) //===- Binary Operations -------------------------------------------------===// // Operators listed in order of precedence. diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index f918b830d42..10a930abe6f 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -14,10 +14,10 @@ #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H -#include - #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclarationName.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" @@ -27,7 +27,9 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/ExprOpenMP.h" +#include "clang/AST/LambdaCapture.h" #include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/OpenMPClause.h" #include "clang/AST/Stmt.h" #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" @@ -36,6 +38,15 @@ #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" #include "clang/AST/TypeLoc.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/OpenMPKinds.h" +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Casting.h" +#include +#include +#include // The following three macros are used for meta programming. The code // using them is responsible for defining macro OPERATOR(). @@ -70,7 +81,7 @@ namespace clang { do { \ if (!getDerived().CALL_EXPR) \ return false; \ - } while (0) + } while (false) /// \brief A class that does preordor or postorder /// depth-first traversal on the entire Clang AST and visits each node. @@ -264,10 +275,12 @@ template class RecursiveASTVisitor { /// \returns false if the visitation was terminated early, true otherwise. bool TraverseConstructorInitializer(CXXCtorInitializer *Init); - /// \brief Recursively visit a lambda capture. + /// \brief Recursively visit a lambda capture. \c Init is the expression that + /// will be used to initialize the capture. /// /// \returns false if the visitation was terminated early, true otherwise. - bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C); + bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, + Expr *Init); /// \brief Recursively visit the body of a lambda expression. /// @@ -327,7 +340,7 @@ template class RecursiveASTVisitor { do { \ if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \ return false; \ - } while (0) + } while (false) public: // Declare Traverse*() for all concrete Stmt classes. @@ -355,7 +368,8 @@ template class RecursiveASTVisitor { #define OPERATOR(NAME) \ bool TraverseUnary##NAME(UnaryOperator *S, \ DataRecursionQueue *Queue = nullptr) { \ - TRY_TO(WalkUpFromUnary##NAME(S)); \ + if (!getDerived().shouldTraversePostOrder()) \ + TRY_TO(WalkUpFromUnary##NAME(S)); \ TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \ return true; \ } \ @@ -480,6 +494,11 @@ template class RecursiveASTVisitor { private: // These are helper methods used by more than one Traverse* method. bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL); + + // Traverses template parameter lists of either a DeclaratorDecl or TagDecl. + template + bool TraverseDeclTemplateParameterLists(T *D); + #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND) \ bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D); DEF_TRAVERSE_TMPL_INST(Class) @@ -565,7 +584,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, #undef DISPATCH_STMT - template bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { switch (S->getStmtClass()) { @@ -754,7 +772,6 @@ bool RecursiveASTVisitor::TraverseDeclarationNameInfo( case DeclarationName::CXXConversionFunctionName: if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo()) TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc())); - break; case DeclarationName::Identifier: @@ -869,25 +886,18 @@ bool RecursiveASTVisitor::TraverseConstructorInitializer( if (Init->isWritten() || getDerived().shouldVisitImplicitCode()) TRY_TO(TraverseStmt(Init->getInit())); - if (getDerived().shouldVisitImplicitCode()) - // The braces for this one-line loop are required for MSVC2013. It - // refuses to compile - // for (int i : int_vec) - // do {} while(false); - // without braces on the for loop. - for (VarDecl *VD : Init->getArrayIndices()) { - TRY_TO(TraverseDecl(VD)); - } - return true; } template bool RecursiveASTVisitor::TraverseLambdaCapture(LambdaExpr *LE, - const LambdaCapture *C) { + const LambdaCapture *C, + Expr *Init) { if (LE->isInitCapture(C)) TRY_TO(TraverseDecl(C->getCapturedVar())); + else + TRY_TO(TraverseStmt(Init)); return true; } @@ -1034,6 +1044,8 @@ DEF_TRAVERSE_TYPE(DependentTemplateSpecializationType, { DEF_TRAVERSE_TYPE(PackExpansionType, { TRY_TO(TraverseType(T->getPattern())); }) +DEF_TRAVERSE_TYPE(ObjCTypeParamType, {}) + DEF_TRAVERSE_TYPE(ObjCInterfaceType, {}) DEF_TRAVERSE_TYPE(ObjCObjectType, { @@ -1265,6 +1277,8 @@ DEF_TRAVERSE_TYPELOC(DependentTemplateSpecializationType, { DEF_TRAVERSE_TYPELOC(PackExpansionType, { TRY_TO(TraverseTypeLoc(TL.getPatternLoc())); }) +DEF_TRAVERSE_TYPELOC(ObjCTypeParamType, {}) + DEF_TRAVERSE_TYPELOC(ObjCInterfaceType, {}) DEF_TRAVERSE_TYPELOC(ObjCObjectType, { @@ -1383,6 +1397,8 @@ DEF_TRAVERSE_DECL(ClassScopeFunctionSpecializationDecl, { DEF_TRAVERSE_DECL(LinkageSpecDecl, {}) +DEF_TRAVERSE_DECL(ExportDecl, {}) + DEF_TRAVERSE_DECL(ObjCPropertyImplDecl, {// FIXME: implement this }) @@ -1489,6 +1505,8 @@ DEF_TRAVERSE_DECL(UsingDecl, { TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo())); }) +DEF_TRAVERSE_DECL(UsingPackDecl, {}) + DEF_TRAVERSE_DECL(UsingDirectiveDecl, { TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); }) @@ -1526,6 +1544,16 @@ bool RecursiveASTVisitor::TraverseTemplateParameterListHelper( return true; } +template +template +bool RecursiveASTVisitor::TraverseDeclTemplateParameterLists(T *D) { + for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) { + TemplateParameterList *TPL = D->getTemplateParameterList(i); + TraverseTemplateParameterListHelper(TPL); + } + return true; +} + template bool RecursiveASTVisitor::TraverseTemplateInstantiations( ClassTemplateDecl *D) { @@ -1687,6 +1715,8 @@ DEF_TRAVERSE_DECL(UnresolvedUsingTypenameDecl, { }) DEF_TRAVERSE_DECL(EnumDecl, { + TRY_TO(TraverseDeclTemplateParameterLists(D)); + if (D->getTypeForDecl()) TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0))); @@ -1701,6 +1731,7 @@ bool RecursiveASTVisitor::TraverseRecordHelper(RecordDecl *D) { // We shouldn't traverse D->getTypeForDecl(); it's a result of // declaring the type, not something that was written in the source. + TRY_TO(TraverseDeclTemplateParameterLists(D)); TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); return true; } @@ -1795,6 +1826,7 @@ DEF_TRAVERSE_DECL(IndirectFieldDecl, {}) template bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl *D) { + TRY_TO(TraverseDeclTemplateParameterLists(D)); TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); if (D->getTypeSourceInfo()) TRY_TO(TraverseTypeLoc(D->getTypeSourceInfo()->getTypeLoc())); @@ -1803,6 +1835,18 @@ bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl *D) { return true; } +DEF_TRAVERSE_DECL(DecompositionDecl, { + TRY_TO(TraverseVarHelper(D)); + for (auto *Binding : D->bindings()) { + TRY_TO(TraverseDecl(Binding)); + } +}) + +DEF_TRAVERSE_DECL(BindingDecl, { + if (getDerived().shouldVisitImplicitCode()) + TRY_TO(TraverseStmt(D->getBinding())); +}) + DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); }) DEF_TRAVERSE_DECL(FieldDecl, { @@ -1829,6 +1873,7 @@ DEF_TRAVERSE_DECL(ObjCIvarDecl, { template bool RecursiveASTVisitor::TraverseFunctionHelper(FunctionDecl *D) { + TRY_TO(TraverseDeclTemplateParameterLists(D)); TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); TRY_TO(TraverseDeclarationNameInfo(D->getNameInfo())); @@ -2041,6 +2086,7 @@ DEF_TRAVERSE_STMT(ObjCAtThrowStmt, {}) DEF_TRAVERSE_STMT(ObjCAtTryStmt, {}) DEF_TRAVERSE_STMT(ObjCForCollectionStmt, {}) DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, {}) + DEF_TRAVERSE_STMT(CXXForRangeStmt, { if (!getDerived().shouldVisitImplicitCode()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt()); @@ -2050,10 +2096,12 @@ DEF_TRAVERSE_STMT(CXXForRangeStmt, { ShouldVisitChildren = false; } }) + DEF_TRAVERSE_STMT(MSDependentExistsStmt, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo())); }) + DEF_TRAVERSE_STMT(ReturnStmt, {}) DEF_TRAVERSE_STMT(SwitchStmt, {}) DEF_TRAVERSE_STMT(WhileStmt, {}) @@ -2249,10 +2297,11 @@ DEF_TRAVERSE_STMT(CXXTemporaryObjectExpr, { // Walk only the visible parts of lambda expressions. DEF_TRAVERSE_STMT(LambdaExpr, { - for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), - CEnd = S->explicit_capture_end(); - C != CEnd; ++C) { - TRY_TO(TraverseLambdaCapture(S, C)); + for (unsigned I = 0, N = S->capture_size(); I != N; ++I) { + const LambdaCapture *C = S->capture_begin() + I; + if (C->isExplicit() || getDerived().shouldVisitImplicitCode()) { + TRY_TO(TraverseLambdaCapture(S, C, S->capture_init_begin()[I])); + } } TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc(); @@ -2300,23 +2349,31 @@ DEF_TRAVERSE_STMT(CXXMemberCallExpr, {}) DEF_TRAVERSE_STMT(AddrLabelExpr, {}) DEF_TRAVERSE_STMT(ArraySubscriptExpr, {}) DEF_TRAVERSE_STMT(OMPArraySectionExpr, {}) + DEF_TRAVERSE_STMT(BlockExpr, { TRY_TO(TraverseDecl(S->getBlockDecl())); return true; // no child statements to loop through. }) + DEF_TRAVERSE_STMT(ChooseExpr, {}) DEF_TRAVERSE_STMT(CompoundLiteralExpr, { TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc())); }) DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, {}) DEF_TRAVERSE_STMT(CXXBoolLiteralExpr, {}) -DEF_TRAVERSE_STMT(CXXDefaultArgExpr, {}) + +DEF_TRAVERSE_STMT(CXXDefaultArgExpr, { + if (getDerived().shouldVisitImplicitCode()) + TRY_TO(TraverseStmt(S->getExpr())); +}) + DEF_TRAVERSE_STMT(CXXDefaultInitExpr, {}) DEF_TRAVERSE_STMT(CXXDeleteExpr, {}) DEF_TRAVERSE_STMT(ExprWithCleanups, {}) DEF_TRAVERSE_STMT(CXXInheritedCtorInitExpr, {}) DEF_TRAVERSE_STMT(CXXNullPtrLiteralExpr, {}) DEF_TRAVERSE_STMT(CXXStdInitializerListExpr, {}) + DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc())); if (TypeSourceInfo *ScopeInfo = S->getScopeTypeInfo()) @@ -2324,6 +2381,7 @@ DEF_TRAVERSE_STMT(CXXPseudoDestructorExpr, { if (TypeSourceInfo *DestroyedTypeInfo = S->getDestroyedTypeInfo()) TRY_TO(TraverseTypeLoc(DestroyedTypeInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(CXXThisExpr, {}) DEF_TRAVERSE_STMT(CXXThrowExpr, {}) DEF_TRAVERSE_STMT(UserDefinedLiteral, {}) @@ -2333,25 +2391,38 @@ DEF_TRAVERSE_STMT(ExtVectorElementExpr, {}) DEF_TRAVERSE_STMT(GNUNullExpr, {}) DEF_TRAVERSE_STMT(ImplicitValueInitExpr, {}) DEF_TRAVERSE_STMT(NoInitExpr, {}) +DEF_TRAVERSE_STMT(ArrayInitLoopExpr, { + // FIXME: The source expression of the OVE should be listed as + // a child of the ArrayInitLoopExpr. + if (OpaqueValueExpr *OVE = S->getCommonExpr()) + TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(OVE->getSourceExpr()); +}) +DEF_TRAVERSE_STMT(ArrayInitIndexExpr, {}) DEF_TRAVERSE_STMT(ObjCBoolLiteralExpr, {}) + DEF_TRAVERSE_STMT(ObjCEncodeExpr, { if (TypeSourceInfo *TInfo = S->getEncodedTypeSourceInfo()) TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(ObjCIsaExpr, {}) DEF_TRAVERSE_STMT(ObjCIvarRefExpr, {}) + DEF_TRAVERSE_STMT(ObjCMessageExpr, { if (TypeSourceInfo *TInfo = S->getClassReceiverTypeInfo()) TRY_TO(TraverseTypeLoc(TInfo->getTypeLoc())); }) + DEF_TRAVERSE_STMT(ObjCPropertyRefExpr, {}) DEF_TRAVERSE_STMT(ObjCSubscriptRefExpr, {}) DEF_TRAVERSE_STMT(ObjCProtocolExpr, {}) DEF_TRAVERSE_STMT(ObjCSelectorExpr, {}) DEF_TRAVERSE_STMT(ObjCIndirectCopyRestoreExpr, {}) + DEF_TRAVERSE_STMT(ObjCBridgedCastExpr, { TRY_TO(TraverseTypeLoc(S->getTypeInfoAsWritten()->getTypeLoc())); }) + DEF_TRAVERSE_STMT(ObjCAvailabilityCheckExpr, {}) DEF_TRAVERSE_STMT(ParenExpr, {}) DEF_TRAVERSE_STMT(ParenListExpr, {}) @@ -2574,6 +2645,36 @@ DEF_TRAVERSE_STMT(OMPDistributeSimdDirective, DEF_TRAVERSE_STMT(OMPTargetParallelForSimdDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPTargetSimdDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTeamsDistributeDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTeamsDistributeSimdDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTeamsDistributeParallelForSimdDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTeamsDistributeParallelForDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTargetTeamsDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + +DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + // OpenMP clauses. template bool RecursiveASTVisitor::TraverseOMPClause(OMPClause *C) { diff --git a/include/clang/AST/Redeclarable.h b/include/clang/AST/Redeclarable.h index eaa22f8d010..cd5f186a208 100644 --- a/include/clang/AST/Redeclarable.h +++ b/include/clang/AST/Redeclarable.h @@ -15,7 +15,6 @@ #define LLVM_CLANG_AST_REDECLARABLE_H #include "clang/AST/ExternalASTSource.h" -#include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/Casting.h" #include @@ -280,6 +279,68 @@ class Mergeable { bool isFirstDecl() const { return getFirstDecl() == this; } }; -} +/// A wrapper class around a pointer that always points to its canonical +/// declaration. +/// +/// CanonicalDeclPtr behaves just like decl_type*, except we call +/// decl_type::getCanonicalDecl() on construction. +/// +/// This is useful for hashtables that you want to be keyed on a declaration's +/// canonical decl -- if you use CanonicalDeclPtr as the key, you don't need to +/// remember to call getCanonicalDecl() everywhere. +template class CanonicalDeclPtr { +public: + CanonicalDeclPtr() : Ptr(nullptr) {} + CanonicalDeclPtr(decl_type *Ptr) + : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {} + CanonicalDeclPtr(const CanonicalDeclPtr &) = default; + CanonicalDeclPtr &operator=(const CanonicalDeclPtr &) = default; + + operator decl_type *() { return Ptr; } + operator const decl_type *() const { return Ptr; } + + decl_type *operator->() { return Ptr; } + const decl_type *operator->() const { return Ptr; } + + decl_type &operator*() { return *Ptr; } + const decl_type &operator*() const { return *Ptr; } + +private: + friend struct llvm::DenseMapInfo>; + + decl_type *Ptr; +}; +} // namespace clang + +namespace llvm { +template +struct DenseMapInfo> { + using CanonicalDeclPtr = clang::CanonicalDeclPtr; + using BaseInfo = DenseMapInfo; + + static CanonicalDeclPtr getEmptyKey() { + // Construct our CanonicalDeclPtr this way because the regular constructor + // would dereference P.Ptr, which is not allowed. + CanonicalDeclPtr P; + P.Ptr = BaseInfo::getEmptyKey(); + return P; + } + + static CanonicalDeclPtr getTombstoneKey() { + CanonicalDeclPtr P; + P.Ptr = BaseInfo::getTombstoneKey(); + return P; + } + + static unsigned getHashValue(const CanonicalDeclPtr &P) { + return BaseInfo::getHashValue(P); + } + + static bool isEqual(const CanonicalDeclPtr &LHS, + const CanonicalDeclPtr &RHS) { + return BaseInfo::isEqual(LHS, RHS); + } +}; +} // namespace llvm #endif diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 96847cf88f9..e28675d6a82 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -56,7 +56,7 @@ namespace clang { /// Stmt - This represents one statement. /// -class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt { +class alignas(void *) Stmt { public: enum StmtClass { NoStmtClass = 0, @@ -71,10 +71,10 @@ class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt { // Make vanilla 'new' and 'delete' illegal for Stmts. protected: - void *operator new(size_t bytes) LLVM_NOEXCEPT { + void *operator new(size_t bytes) noexcept { llvm_unreachable("Stmts cannot be allocated with regular 'new'."); } - void operator delete(void *data) LLVM_NOEXCEPT { + void operator delete(void *data) noexcept { llvm_unreachable("Stmts cannot be released with regular 'delete'."); } @@ -284,12 +284,12 @@ class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt { return operator new(bytes, *C, alignment); } - void *operator new(size_t bytes, void *mem) LLVM_NOEXCEPT { return mem; } + void *operator new(size_t bytes, void *mem) noexcept { return mem; } - void operator delete(void *, const ASTContext &, unsigned) LLVM_NOEXCEPT {} - void operator delete(void *, const ASTContext *, unsigned) LLVM_NOEXCEPT {} - void operator delete(void *, size_t) LLVM_NOEXCEPT {} - void operator delete(void *, void *) LLVM_NOEXCEPT {} + void operator delete(void *, const ASTContext &, unsigned) noexcept {} + void operator delete(void *, const ASTContext *, unsigned) noexcept {} + void operator delete(void *, size_t) noexcept {} + void operator delete(void *, void *) noexcept {} public: /// \brief A placeholder type used to construct an empty shell of a @@ -340,7 +340,7 @@ class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt { public: Stmt(StmtClass SC) { - static_assert(sizeof(*this) % llvm::AlignOf::Alignment == 0, + static_assert(sizeof(*this) % alignof(void *) == 0, "Insufficient alignment!"); StmtBits.sClass = SC; if (StatisticsEnabled) Stmt::addStmtClass(SC); @@ -387,6 +387,9 @@ class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt { /// Skip past any implicit AST nodes which might surround this /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes. Stmt *IgnoreImplicit(); + const Stmt *IgnoreImplicit() const { + return const_cast(this)->IgnoreImplicit(); + } /// \brief Skip no-op (attributed, compound) container stmts and skip captured /// stmt at the top, if \a IgnoreCaptured is true. @@ -933,6 +936,8 @@ class IfStmt : public Stmt { bool isConstexpr() const { return IfStmtBits.IsConstexpr; } void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; } + bool isObjCAvailabilityCheck() const; + SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; } SourceLocation getLocEnd() const LLVM_READONLY { if (SubExprs[ELSE]) diff --git a/include/clang/AST/StmtCXX.h b/include/clang/AST/StmtCXX.h index 1d29c228a4b..8eef34cb21b 100644 --- a/include/clang/AST/StmtCXX.h +++ b/include/clang/AST/StmtCXX.h @@ -304,6 +304,8 @@ class CoroutineBodyStmt : public Stmt { FinalSuspend, ///< The final suspend statement, run after the body. OnException, ///< Handler for exceptions thrown in the body. OnFallthrough, ///< Handler for control flow falling off the body. + Allocate, ///< Coroutine frame memory allocation. + Deallocate, ///< Coroutine frame memory deallocation. ReturnValue, ///< Return value for thunk function. FirstParamMove ///< First offset for move construction of parameter copies. }; @@ -313,6 +315,7 @@ class CoroutineBodyStmt : public Stmt { public: CoroutineBodyStmt(Stmt *Body, Stmt *Promise, Stmt *InitSuspend, Stmt *FinalSuspend, Stmt *OnException, Stmt *OnFallthrough, + Expr *Allocate, Stmt *Deallocate, Expr *ReturnValue, ArrayRef ParamMoves) : Stmt(CoroutineBodyStmtClass) { SubStmts[CoroutineBodyStmt::Body] = Body; @@ -321,6 +324,8 @@ class CoroutineBodyStmt : public Stmt { SubStmts[CoroutineBodyStmt::FinalSuspend] = FinalSuspend; SubStmts[CoroutineBodyStmt::OnException] = OnException; SubStmts[CoroutineBodyStmt::OnFallthrough] = OnFallthrough; + SubStmts[CoroutineBodyStmt::Allocate] = Allocate; + SubStmts[CoroutineBodyStmt::Deallocate] = Deallocate; SubStmts[CoroutineBodyStmt::ReturnValue] = ReturnValue; // FIXME: Tail-allocate space for parameter move expressions and store them. assert(ParamMoves.empty() && "not implemented yet"); @@ -345,6 +350,9 @@ class CoroutineBodyStmt : public Stmt { return SubStmts[SubStmt::OnFallthrough]; } + Expr *getAllocate() const { return cast(SubStmts[SubStmt::Allocate]); } + Stmt *getDeallocate() const { return SubStmts[SubStmt::Deallocate]; } + Expr *getReturnValueInit() const { return cast(SubStmts[SubStmt::ReturnValue]); } @@ -405,10 +413,13 @@ class CoreturnStmt : public Stmt { SourceLocation getLocStart() const LLVM_READONLY { return CoreturnLoc; } SourceLocation getLocEnd() const LLVM_READONLY { - return getOperand()->getLocEnd(); + return getOperand() ? getOperand()->getLocEnd() : getLocStart(); } child_range children() { + if (!getOperand()) + return child_range(SubStmts + SubStmt::PromiseCall, + SubStmts + SubStmt::Count); return child_range(SubStmts, SubStmts + SubStmt::Count); } diff --git a/include/clang/AST/StmtGraphTraits.h b/include/clang/AST/StmtGraphTraits.h index ab636a5ddc4..92eb64430f7 100644 --- a/include/clang/AST/StmtGraphTraits.h +++ b/include/clang/AST/StmtGraphTraits.h @@ -25,18 +25,18 @@ namespace llvm { template <> struct GraphTraits { - typedef clang::Stmt NodeType; + typedef clang::Stmt * NodeRef; typedef clang::Stmt::child_iterator ChildIteratorType; typedef llvm::df_iterator nodes_iterator; - static NodeType* getEntryNode(clang::Stmt* S) { return S; } + static NodeRef getEntryNode(clang::Stmt *S) { return S; } - static inline ChildIteratorType child_begin(NodeType* N) { + static ChildIteratorType child_begin(NodeRef N) { if (N) return N->child_begin(); else return ChildIteratorType(); } - static inline ChildIteratorType child_end(NodeType* N) { + static ChildIteratorType child_end(NodeRef N) { if (N) return N->child_end(); else return ChildIteratorType(); } @@ -52,18 +52,18 @@ template <> struct GraphTraits { template <> struct GraphTraits { - typedef const clang::Stmt NodeType; + typedef const clang::Stmt * NodeRef; typedef clang::Stmt::const_child_iterator ChildIteratorType; typedef llvm::df_iterator nodes_iterator; - static NodeType* getEntryNode(const clang::Stmt* S) { return S; } + static NodeRef getEntryNode(const clang::Stmt *S) { return S; } - static inline ChildIteratorType child_begin(NodeType* N) { + static ChildIteratorType child_begin(NodeRef N) { if (N) return N->child_begin(); else return ChildIteratorType(); } - static inline ChildIteratorType child_end(NodeType* N) { + static ChildIteratorType child_end(NodeRef N) { if (N) return N->child_end(); else return ChildIteratorType(); } diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h index 1e357263461..ec532ecd588 100644 --- a/include/clang/AST/StmtOpenMP.h +++ b/include/clang/AST/StmtOpenMP.h @@ -70,7 +70,7 @@ class OMPExecutableDirective : public Stmt { : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)), EndLoc(std::move(EndLoc)), NumClauses(NumClauses), NumChildren(NumChildren), - ClausesOffset(llvm::alignTo(sizeof(T), llvm::alignOf())) {} + ClausesOffset(llvm::alignTo(sizeof(T), alignof(OMPClause *))) {} /// \brief Sets the list of variables for this clause. /// @@ -773,7 +773,12 @@ class OMPLoopDirective : public OMPExecutableDirective { T->getStmtClass() == OMPDistributeParallelForDirectiveClass || T->getStmtClass() == OMPDistributeParallelForSimdDirectiveClass || T->getStmtClass() == OMPDistributeSimdDirectiveClass || - T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass; + T->getStmtClass() == OMPTargetParallelForSimdDirectiveClass || + T->getStmtClass() == OMPTargetSimdDirectiveClass || + T->getStmtClass() == OMPTeamsDistributeDirectiveClass || + T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass || + T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass || + T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass; } }; @@ -3090,6 +3095,691 @@ class OMPTargetParallelForSimdDirective final : public OMPLoopDirective { } }; +/// This represents '#pragma omp target simd' directive. +/// +/// \code +/// #pragma omp target simd private(a) map(b) safelen(c) +/// \endcode +/// In this example directive '#pragma omp target simd' has clauses 'private' +/// with the variable 'a', 'map' with the variable 'b' and 'safelen' with +/// the variable 'c'. +/// +class OMPTargetSimdDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTargetSimdDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, + OMPD_target_simd, StartLoc, EndLoc, CollapsedNum, + NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd, + SourceLocation(),SourceLocation(), CollapsedNum, + NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTargetSimdDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTargetSimdDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetSimdDirectiveClass; + } +}; + +/// This represents '#pragma omp teams distribute' directive. +/// +/// \code +/// #pragma omp teams distribute private(a,b) +/// \endcode +/// In this example directive '#pragma omp teams distribute' has clauses +/// 'private' with the variables 'a' and 'b' +/// +class OMPTeamsDistributeDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, + OMPD_teams_distribute, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTeamsDistributeDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, + OMPD_teams_distribute, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTeamsDistributeDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTeamsDistributeDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTeamsDistributeDirectiveClass; + } +}; + +/// This represents '#pragma omp teams distribute simd' +/// combined directive. +/// +/// \code +/// #pragma omp teams distribute simd private(a,b) +/// \endcode +/// In this example directive '#pragma omp teams distribute simd' +/// has clause 'private' with the variables 'a' and 'b' +/// +class OMPTeamsDistributeSimdDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTeamsDistributeSimdDirective(SourceLocation StartLoc, + SourceLocation EndLoc, unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass, + OMPD_teams_distribute_simd, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTeamsDistributeSimdDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeSimdDirectiveClass, + OMPD_teams_distribute_simd, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTeamsDistributeSimdDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place + /// for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTeamsDistributeSimdDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass; + } +}; + +/// This represents '#pragma omp teams distribute parallel for simd' composite +/// directive. +/// +/// \code +/// #pragma omp teams distribute parallel for simd private(x) +/// \endcode +/// In this example directive '#pragma omp teams distribute parallel for simd' +/// has clause 'private' with the variables 'x' +/// +class OMPTeamsDistributeParallelForSimdDirective final + : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, + OMPD_teams_distribute_parallel_for_simd, StartLoc, + EndLoc, CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, + OMPD_teams_distribute_parallel_for_simd, + SourceLocation(), SourceLocation(), CollapsedNum, + NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTeamsDistributeParallelForSimdDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTeamsDistributeParallelForSimdDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTeamsDistributeParallelForSimdDirectiveClass; + } +}; + +/// This represents '#pragma omp teams distribute parallel for' composite +/// directive. +/// +/// \code +/// #pragma omp teams distribute parallel for private(x) +/// \endcode +/// In this example directive '#pragma omp teams distribute parallel for' +/// has clause 'private' with the variables 'x' +/// +class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTeamsDistributeParallelForDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass, + OMPD_teams_distribute_parallel_for, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTeamsDistributeParallelForDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass, + OMPD_teams_distribute_parallel_for, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTeamsDistributeParallelForDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTeamsDistributeParallelForDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass; + } +}; + +/// This represents '#pragma omp target teams' directive. +/// +/// \code +/// #pragma omp target teams if(a>0) +/// \endcode +/// In this example directive '#pragma omp target teams' has clause 'if' with +/// condition 'a>0'. +/// +class OMPTargetTeamsDirective final : public OMPExecutableDirective { + friend class ASTStmtReader; + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param NumClauses Number of clauses. + /// + OMPTargetTeamsDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned NumClauses) + : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass, + OMPD_target_teams, StartLoc, EndLoc, NumClauses, + 1) {} + + /// Build an empty directive. + /// + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetTeamsDirective(unsigned NumClauses) + : OMPExecutableDirective(this, OMPTargetTeamsDirectiveClass, + OMPD_target_teams, SourceLocation(), + SourceLocation(), NumClauses, 1) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// + static OMPTargetTeamsDirective *Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef Clauses, + Stmt *AssociatedStmt); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param NumClauses Number of clauses. + /// + static OMPTargetTeamsDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetTeamsDirectiveClass; + } +}; + +/// This represents '#pragma omp target teams distribute' combined directive. +/// +/// \code +/// #pragma omp target teams distribute private(x) +/// \endcode +/// In this example directive '#pragma omp target teams distribute' has clause +/// 'private' with the variables 'x' +/// +class OMPTargetTeamsDistributeDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTargetTeamsDistributeDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass, + OMPD_target_teams_distribute, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetTeamsDistributeDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetTeamsDistributeDirectiveClass, + OMPD_target_teams_distribute, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTargetTeamsDistributeDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTargetTeamsDistributeDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetTeamsDistributeDirectiveClass; + } +}; + +/// This represents '#pragma omp target teams distribute parallel for' combined +/// directive. +/// +/// \code +/// #pragma omp target teams distribute parallel for private(x) +/// \endcode +/// In this example directive '#pragma omp target teams distribute parallel +/// for' has clause 'private' with the variables 'x' +/// +class OMPTargetTeamsDistributeParallelForDirective final + : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTargetTeamsDistributeParallelForDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, + OMPTargetTeamsDistributeParallelForDirectiveClass, + OMPD_target_teams_distribute_parallel_for, StartLoc, + EndLoc, CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetTeamsDistributeParallelForDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective( + this, OMPTargetTeamsDistributeParallelForDirectiveClass, + OMPD_target_teams_distribute_parallel_for, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTargetTeamsDistributeParallelForDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTargetTeamsDistributeParallelForDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == + OMPTargetTeamsDistributeParallelForDirectiveClass; + } +}; + +/// This represents '#pragma omp target teams distribute parallel for simd' +/// combined directive. +/// +/// \code +/// #pragma omp target teams distribute parallel for simd private(x) +/// \endcode +/// In this example directive '#pragma omp target teams distribute parallel +/// for simd' has clause 'private' with the variables 'x' +/// +class OMPTargetTeamsDistributeParallelForSimdDirective final + : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTargetTeamsDistributeParallelForSimdDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, + OMPTargetTeamsDistributeParallelForSimdDirectiveClass, + OMPD_target_teams_distribute_parallel_for_simd, + StartLoc, EndLoc, CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetTeamsDistributeParallelForSimdDirective( + unsigned CollapsedNum, unsigned NumClauses) + : OMPLoopDirective( + this, OMPTargetTeamsDistributeParallelForSimdDirectiveClass, + OMPD_target_teams_distribute_parallel_for_simd, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTargetTeamsDistributeParallelForSimdDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTargetTeamsDistributeParallelForSimdDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == + OMPTargetTeamsDistributeParallelForSimdDirectiveClass; + } +}; + +/// This represents '#pragma omp target teams distribute simd' combined +/// directive. +/// +/// \code +/// #pragma omp target teams distribute simd private(x) +/// \endcode +/// In this example directive '#pragma omp target teams distribute simd' +/// has clause 'private' with the variables 'x' +/// +class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + OMPTargetTeamsDistributeSimdDirective(SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass, + OMPD_target_teams_distribute_simd, StartLoc, EndLoc, + CollapsedNum, NumClauses) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum, + unsigned NumClauses) + : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass, + OMPD_target_teams_distribute_simd, SourceLocation(), + SourceLocation(), CollapsedNum, NumClauses) {} + +public: + /// Creates directive with a list of \a Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPTargetTeamsDistributeSimdDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with the place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param CollapsedNum Number of collapsed nested loops. + /// \param NumClauses Number of clauses. + /// + static OMPTargetTeamsDistributeSimdDirective * + CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass; + } +}; + } // end namespace clang #endif diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h index b9c2c08943e..7f289862578 100644 --- a/include/clang/AST/TemplateBase.h +++ b/include/clang/AST/TemplateBase.h @@ -301,6 +301,10 @@ class TemplateArgument { Integer.Type = T.getAsOpaquePtr(); } + /// \brief If this is a non-type template argument, get its type. Otherwise, + /// returns a null QualType. + QualType getNonTypeTemplateArgumentType() const; + /// \brief Retrieve the template argument as an expression. Expr *getAsExpr() const { assert(getKind() == Expression && "Unexpected kind"); @@ -326,8 +330,8 @@ class TemplateArgument { /// \brief Iterator range referencing all of the elements of a template /// argument pack. - llvm::iterator_range pack_elements() const { - return llvm::make_range(pack_begin(), pack_end()); + ArrayRef pack_elements() const { + return llvm::makeArrayRef(pack_begin(), pack_end()); } /// \brief The number of template arguments in the given template argument @@ -592,6 +596,10 @@ struct ASTTemplateArgumentListInfo final return getTrailingObjects(); } + llvm::ArrayRef arguments() const { + return llvm::makeArrayRef(getTemplateArgs(), NumTemplateArgs); + } + const TemplateArgumentLoc &operator[](unsigned I) const { return getTemplateArgs()[I]; } @@ -607,7 +615,7 @@ struct ASTTemplateArgumentListInfo final /// as such, doesn't contain the array of TemplateArgumentLoc itself, /// but expects the containing object to also provide storage for /// that. -struct LLVM_ALIGNAS(LLVM_PTR_SIZE) ASTTemplateKWAndArgsInfo { +struct alignas(void *) ASTTemplateKWAndArgsInfo { /// \brief The source location of the left angle bracket ('<'). SourceLocation LAngleLoc; diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 1067c086c76..744a408e579 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -88,6 +88,7 @@ namespace clang { class ObjCInterfaceDecl; class ObjCProtocolDecl; class ObjCMethodDecl; + class ObjCTypeParamDecl; class UnresolvedUsingTypenameDecl; class Expr; class Stmt; @@ -984,6 +985,7 @@ class QualType { void dump(const char *s) const; void dump() const; + void dump(llvm::raw_ostream &OS) const; void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(getAsOpaquePtr()); @@ -1377,7 +1379,7 @@ class Type : public ExtQualsTypeCommonBase { /// Extra information which affects how the function is called, like /// regparm and the calling convention. - unsigned ExtInfo : 9; + unsigned ExtInfo : 10; /// Used only by FunctionProtoType, put here to pack with the /// other bitfields. @@ -1728,7 +1730,8 @@ class Type : public ExtQualsTypeCommonBase { bool isObjCARCBridgableType() const; bool isCARCBridgableType() const; bool isTemplateTypeParmType() const; // C++ template type parameter - bool isNullPtrType() const; // C++0x nullptr_t + bool isNullPtrType() const; // C++11 std::nullptr_t + bool isAlignValT() const; // C++17 std::align_val_t bool isAtomicType() const; // C11 _Atomic() #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ @@ -2003,6 +2006,7 @@ class Type : public ExtQualsTypeCommonBase { } CanQualType getCanonicalTypeUnqualified() const; // in CanonicalType.h void dump() const; + void dump(llvm::raw_ostream &OS) const; friend class ASTReader; friend class ASTWriter; @@ -2262,19 +2266,15 @@ class AdjustedType : public Type, public llvm::FoldingSetNode { /// Represents a pointer type decayed from an array or function type. class DecayedType : public AdjustedType { - DecayedType(QualType OriginalType, QualType DecayedPtr, QualType CanonicalPtr) - : AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) { - assert(isa(getAdjustedType())); - } + inline + DecayedType(QualType OriginalType, QualType Decayed, QualType Canonical); friend class ASTContext; // ASTContext creates these. public: QualType getDecayedType() const { return getAdjustedType(); } - QualType getPointeeType() const { - return cast(getDecayedType())->getPointeeType(); - } + inline QualType getPointeeType() const; static bool classof(const Type *T) { return T->getTypeClass() == Decayed; } }; @@ -2812,7 +2812,8 @@ class VectorType : public Type, public llvm::FoldingSetNode { /// __attribute__((ext_vector_type(n)), where "n" is the number of elements. /// Unlike vector_size, ext_vector_type is only allowed on typedef's. This /// class enables syntactic extensions, like Vector Components for accessing -/// points, colors, and textures (modeled after OpenGL Shading Language). +/// points (as .xyzw), colors (as .rgba), and textures (modeled after OpenGL +/// Shading Language). class ExtVectorType : public VectorType { ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) : VectorType(ExtVector, vecType, nElements, canonType, GenericVector) {} @@ -2821,10 +2822,10 @@ class ExtVectorType : public VectorType { static int getPointAccessorIdx(char c) { switch (c) { default: return -1; - case 'x': return 0; - case 'y': return 1; - case 'z': return 2; - case 'w': return 3; + case 'x': case 'r': return 0; + case 'y': case 'g': return 1; + case 'z': case 'b': return 2; + case 'w': case 'a': return 3; } } static int getNumericAccessorIdx(char c) { @@ -2855,13 +2856,15 @@ class ExtVectorType : public VectorType { } } - static int getAccessorIdx(char c) { - if (int idx = getPointAccessorIdx(c)+1) return idx-1; - return getNumericAccessorIdx(c); + static int getAccessorIdx(char c, bool isNumericAccessor) { + if (isNumericAccessor) + return getNumericAccessorIdx(c); + else + return getPointAccessorIdx(c); } - bool isAccessorWithinNumElements(char c) const { - if (int idx = getAccessorIdx(c)+1) + bool isAccessorWithinNumElements(char c, bool isNumericAccessor) const { + if (int idx = getAccessorIdx(c, isNumericAccessor)+1) return unsigned(idx-1) < getNumElements(); return false; } @@ -2902,19 +2905,19 @@ class FunctionType : public Type { // * AST read and write // * Codegen class ExtInfo { - // Feel free to rearrange or add bits, but if you go over 9, + // Feel free to rearrange or add bits, but if you go over 10, // you'll need to adjust both the Bits field below and // Type::FunctionTypeBitfields. // | CC |noreturn|produces|regparm| - // |0 .. 3| 4 | 5 | 6 .. 8| + // |0 .. 4| 5 | 6 | 7 .. 9| // // regparm is either 0 (no regparm attribute) or the regparm value+1. - enum { CallConvMask = 0xF }; - enum { NoReturnMask = 0x10 }; - enum { ProducesResultMask = 0x20 }; + enum { CallConvMask = 0x1F }; + enum { NoReturnMask = 0x20 }; + enum { ProducesResultMask = 0x40 }; enum { RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask), - RegParmOffset = 6 }; // Assumed to be the last field + RegParmOffset = 7 }; // Assumed to be the last field uint16_t Bits; @@ -3318,6 +3321,9 @@ class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode { } /// Return whether this function has a dependent exception spec. bool hasDependentExceptionSpec() const; + /// Return whether this function has an instantiation-dependent exception + /// spec. + bool hasInstantiationDependentExceptionSpec() const; /// Result type of getNoexceptSpec(). enum NoexceptResult { NR_NoNoexcept, ///< There is no noexcept specifier. @@ -3359,9 +3365,15 @@ class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode { return reinterpret_cast(param_type_end())[1]; } /// Determine whether this function type has a non-throwing exception + /// specification. + CanThrowResult canThrow(const ASTContext &Ctx) const; + /// Determine whether this function type has a non-throwing exception /// specification. If this depends on template arguments, returns /// \c ResultIfDependent. - bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent = false) const; + bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent = false) const { + return ResultIfDependent ? canThrow(Ctx) != CT_Can + : canThrow(Ctx) == CT_Cannot; + } bool isVariadic() const { return Variadic; } @@ -3462,7 +3474,8 @@ class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode { void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx); static void Profile(llvm::FoldingSetNodeID &ID, QualType Result, param_type_iterator ArgTys, unsigned NumArgs, - const ExtProtoInfo &EPI, const ASTContext &Context); + const ExtProtoInfo &EPI, const ASTContext &Context, + bool Canonical); }; /// \brief Represents the dependent type named by a dependently-scoped @@ -3788,6 +3801,7 @@ class AttributedType : public Type, public llvm::FoldingSetNode { attr_fastcall, attr_stdcall, attr_thiscall, + attr_regcall, attr_pascal, attr_swiftcall, attr_vectorcall, @@ -4078,18 +4092,22 @@ class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode { /// \brief Represents a C++11 auto or C++14 decltype(auto) type. /// /// These types are usually a placeholder for a deduced type. However, before -/// the initializer is attached, or if the initializer is type-dependent, there -/// is no deduced type and an auto type is canonical. In the latter case, it is -/// also a dependent type. +/// the initializer is attached, or (usually) if the initializer is +/// type-dependent, there is no deduced type and an auto type is canonical. In +/// the latter case, it is also a dependent type. class AutoType : public Type, public llvm::FoldingSetNode { AutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) : Type(Auto, DeducedType.isNull() ? QualType(this, 0) : DeducedType, /*Dependent=*/IsDependent, /*InstantiationDependent=*/IsDependent, - /*VariablyModified=*/false, - /*ContainsParameterPack=*/DeducedType.isNull() - ? false : DeducedType->containsUnexpandedParameterPack()) { - assert((DeducedType.isNull() || !IsDependent) && - "auto deduced to dependent type"); + /*VariablyModified=*/false, /*ContainsParameterPack=*/false) { + if (!DeducedType.isNull()) { + if (DeducedType->isDependentType()) + setDependent(); + if (DeducedType->isInstantiationDependentType()) + setInstantiationDependent(); + if (DeducedType->containsUnexpandedParameterPack()) + setContainsUnexpandedParameterPack(); + } AutoTypeBits.Keyword = (unsigned)Keyword; } @@ -4696,6 +4714,102 @@ class PackExpansionType : public Type, public llvm::FoldingSetNode { } }; +/// This class wraps the list of protocol qualifiers. For types that can +/// take ObjC protocol qualifers, they can subclass this class. +template +class ObjCProtocolQualifiers { +protected: + ObjCProtocolQualifiers() {} + ObjCProtocolDecl * const *getProtocolStorage() const { + return const_cast(this)->getProtocolStorage(); + } + + ObjCProtocolDecl **getProtocolStorage() { + return static_cast(this)->getProtocolStorageImpl(); + } + void setNumProtocols(unsigned N) { + static_cast(this)->setNumProtocolsImpl(N); + } + void initialize(ArrayRef protocols) { + setNumProtocols(protocols.size()); + assert(getNumProtocols() == protocols.size() && + "bitfield overflow in protocol count"); + if (!protocols.empty()) + memcpy(getProtocolStorage(), protocols.data(), + protocols.size() * sizeof(ObjCProtocolDecl*)); + } + +public: + typedef ObjCProtocolDecl * const *qual_iterator; + typedef llvm::iterator_range qual_range; + + qual_range quals() const { return qual_range(qual_begin(), qual_end()); } + qual_iterator qual_begin() const { return getProtocolStorage(); } + qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); } + + bool qual_empty() const { return getNumProtocols() == 0; } + + /// Return the number of qualifying protocols in this type, or 0 if + /// there are none. + unsigned getNumProtocols() const { + return static_cast(this)->getNumProtocolsImpl(); + } + + /// Fetch a protocol by index. + ObjCProtocolDecl *getProtocol(unsigned I) const { + assert(I < getNumProtocols() && "Out-of-range protocol access"); + return qual_begin()[I]; + } + + /// Retrieve all of the protocol qualifiers. + ArrayRef getProtocols() const { + return ArrayRef(qual_begin(), getNumProtocols()); + } +}; + +/// Represents a type parameter type in Objective C. It can take +/// a list of protocols. +class ObjCTypeParamType : public Type, + public ObjCProtocolQualifiers, + public llvm::FoldingSetNode { + friend class ASTContext; + friend class ObjCProtocolQualifiers; + + /// The number of protocols stored on this type. + unsigned NumProtocols : 6; + + ObjCTypeParamDecl *OTPDecl; + /// The protocols are stored after the ObjCTypeParamType node. In the + /// canonical type, the list of protocols are sorted alphabetically + /// and uniqued. + ObjCProtocolDecl **getProtocolStorageImpl(); + /// Return the number of qualifying protocols in this interface type, + /// or 0 if there are none. + unsigned getNumProtocolsImpl() const { + return NumProtocols; + } + void setNumProtocolsImpl(unsigned N) { + NumProtocols = N; + } + ObjCTypeParamType(const ObjCTypeParamDecl *D, + QualType can, + ArrayRef protocols); +public: + bool isSugared() const { return true; } + QualType desugar() const { return getCanonicalTypeInternal(); } + + static bool classof(const Type *T) { + return T->getTypeClass() == ObjCTypeParam; + } + + void Profile(llvm::FoldingSetNodeID &ID); + static void Profile(llvm::FoldingSetNodeID &ID, + const ObjCTypeParamDecl *OTPDecl, + ArrayRef protocols); + + ObjCTypeParamDecl *getDecl() const { return OTPDecl; } +}; + /// Represents a class type in Objective C. /// /// Every Objective C type is a combination of a base type, a set of @@ -4724,7 +4838,9 @@ class PackExpansionType : public Type, public llvm::FoldingSetNode { /// 'id

' is an ObjCObjectPointerType whose pointee is an ObjCObjectType /// with base BuiltinType::ObjCIdType and protocol list [P]. Eventually /// this should get its own sugar class to better represent the source. -class ObjCObjectType : public Type { +class ObjCObjectType : public Type, + public ObjCProtocolQualifiers { + friend class ObjCProtocolQualifiers; // ObjCObjectType.NumTypeArgs - the number of type arguments stored // after the ObjCObjectPointerType node. // ObjCObjectType.NumProtocols - the number of protocols stored @@ -4744,16 +4860,20 @@ class ObjCObjectType : public Type { mutable llvm::PointerIntPair CachedSuperClassType; - ObjCProtocolDecl * const *getProtocolStorage() const { - return const_cast(this)->getProtocolStorage(); - } - QualType *getTypeArgStorage(); const QualType *getTypeArgStorage() const { return const_cast(this)->getTypeArgStorage(); } - ObjCProtocolDecl **getProtocolStorage(); + ObjCProtocolDecl **getProtocolStorageImpl(); + /// Return the number of qualifying protocols in this interface type, + /// or 0 if there are none. + unsigned getNumProtocolsImpl() const { + return ObjCObjectTypeBits.NumProtocols; + } + void setNumProtocolsImpl(unsigned N) { + ObjCObjectTypeBits.NumProtocols = N; + } protected: ObjCObjectType(QualType Canonical, QualType Base, @@ -4830,30 +4950,6 @@ class ObjCObjectType : public Type { ObjCObjectTypeBits.NumTypeArgs); } - typedef ObjCProtocolDecl * const *qual_iterator; - typedef llvm::iterator_range qual_range; - - qual_range quals() const { return qual_range(qual_begin(), qual_end()); } - qual_iterator qual_begin() const { return getProtocolStorage(); } - qual_iterator qual_end() const { return qual_begin() + getNumProtocols(); } - - bool qual_empty() const { return getNumProtocols() == 0; } - - /// Return the number of qualifying protocols in this interface type, - /// or 0 if there are none. - unsigned getNumProtocols() const { return ObjCObjectTypeBits.NumProtocols; } - - /// Fetch a protocol by index. - ObjCProtocolDecl *getProtocol(unsigned I) const { - assert(I < getNumProtocols() && "Out-of-range protocol access"); - return qual_begin()[I]; - } - - /// Retrieve all of the protocol qualifiers. - ArrayRef getProtocols() const { - return ArrayRef(qual_begin(), getNumProtocols()); - } - /// Whether this is a "__kindof" type as written. bool isKindOfTypeAsWritten() const { return ObjCObjectTypeBits.IsKindOf; } @@ -4916,11 +5012,16 @@ inline QualType *ObjCObjectType::getTypeArgStorage() { return reinterpret_cast(static_cast(this)+1); } -inline ObjCProtocolDecl **ObjCObjectType::getProtocolStorage() { +inline ObjCProtocolDecl **ObjCObjectType::getProtocolStorageImpl() { return reinterpret_cast( getTypeArgStorage() + ObjCObjectTypeBits.NumTypeArgs); } +inline ObjCProtocolDecl **ObjCTypeParamType::getProtocolStorageImpl() { + return reinterpret_cast( + static_cast(this)+1); +} + /// Interfaces are the core concept in Objective-C for object oriented design. /// They basically correspond to C++ classes. There are two kinds of interface /// types: normal interfaces like `NSString`, and qualified interfaces, which @@ -5189,17 +5290,17 @@ class AtomicType : public Type, public llvm::FoldingSetNode { /// PipeType - OpenCL20. class PipeType : public Type, public llvm::FoldingSetNode { QualType ElementType; + bool isRead; - PipeType(QualType elemType, QualType CanonicalPtr) : + PipeType(QualType elemType, QualType CanonicalPtr, bool isRead) : Type(Pipe, CanonicalPtr, elemType->isDependentType(), elemType->isInstantiationDependentType(), elemType->isVariablyModifiedType(), elemType->containsUnexpandedParameterPack()), - ElementType(elemType) {} + ElementType(elemType), isRead(isRead) {} friend class ASTContext; // ASTContext creates these. public: - QualType getElementType() const { return ElementType; } bool isSugared() const { return false; } @@ -5207,18 +5308,19 @@ class PipeType : public Type, public llvm::FoldingSetNode { QualType desugar() const { return QualType(this, 0); } void Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, getElementType()); + Profile(ID, getElementType(), isReadOnly()); } - static void Profile(llvm::FoldingSetNodeID &ID, QualType T) { + static void Profile(llvm::FoldingSetNodeID &ID, QualType T, bool isRead) { ID.AddPointer(T.getAsOpaquePtr()); + ID.AddBoolean(isRead); } - static bool classof(const Type *T) { return T->getTypeClass() == Pipe; } + bool isReadOnly() const { return isRead; } }; /// A qualifier set is used to build a set of qualifiers. @@ -5696,8 +5798,8 @@ inline bool Type::isNullPtrType() const { return false; } -extern bool IsEnumDeclComplete(EnumDecl *); -extern bool IsEnumDeclScoped(EnumDecl *); +bool IsEnumDeclComplete(EnumDecl *); +bool IsEnumDeclScoped(EnumDecl *); inline bool Type::isIntegerType() const { if (const BuiltinType *BT = dyn_cast(CanonicalType)) @@ -5807,17 +5909,15 @@ inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, // Helper class template that is used by Type::getAs to ensure that one does // not try to look through a qualified type to get to an array type. -template ::value || - std::is_base_of::value)> -struct ArrayType_cannot_be_used_with_getAs {}; - -template -struct ArrayType_cannot_be_used_with_getAs; +template +using TypeIsArrayType = + std::integral_constant::value || + std::is_base_of::value>; // Member-template getAs'. template const T *Type::getAs() const { - ArrayType_cannot_be_used_with_getAs at; - (void)at; + static_assert(!TypeIsArrayType::value, + "ArrayType cannot be used with getAs!"); // If this is directly a T type, return it. if (const T *Ty = dyn_cast(this)) @@ -5847,8 +5947,8 @@ inline const ArrayType *Type::getAsArrayTypeUnsafe() const { } template const T *Type::castAs() const { - ArrayType_cannot_be_used_with_getAs at; - (void) at; + static_assert(!TypeIsArrayType::value, + "ArrayType cannot be used with castAs!"); if (const T *ty = dyn_cast(this)) return ty; assert(isa(CanonicalType)); @@ -5861,6 +5961,23 @@ inline const ArrayType *Type::castAsArrayTypeUnsafe() const { return cast(getUnqualifiedDesugaredType()); } +DecayedType::DecayedType(QualType OriginalType, QualType DecayedPtr, + QualType CanonicalPtr) + : AdjustedType(Decayed, OriginalType, DecayedPtr, CanonicalPtr) { +#ifndef NDEBUG + QualType Adjusted = getAdjustedType(); + (void)AttributedType::stripOuterNullability(Adjusted); + assert(isa(Adjusted)); +#endif +} + +QualType DecayedType::getPointeeType() const { + QualType Decayed = getDecayedType(); + (void)AttributedType::stripOuterNullability(Decayed); + return cast(Decayed)->getPointeeType(); +} + + } // end namespace clang #endif diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 67adf4a638b..5b7d9e6e3ce 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -347,7 +347,7 @@ class ConcreteTypeLoc : public Base { public: unsigned getLocalDataAlignment() const { - return std::max(llvm::alignOf(), + return std::max(unsigned(alignof(LocalData)), asDerived()->getExtraLocalDataAlignment()); } unsigned getLocalDataSize() const { @@ -487,8 +487,10 @@ class TypeSpecTypeLoc : public ConcreteTypeLoc { public: - enum { LocalDataSize = sizeof(TypeSpecLocInfo), - LocalDataAlignment = llvm::AlignOf::Alignment }; + enum { + LocalDataSize = sizeof(TypeSpecLocInfo), + LocalDataAlignment = alignof(TypeSpecLocInfo) + }; SourceLocation getNameLoc() const { return this->getLocalData()->NameLoc; @@ -510,7 +512,7 @@ class TypeSpecTypeLoc : public ConcreteTypeLoc { public: SourceLocation getBuiltinLoc() const { - return getLocalData()->BuiltinLoc; + return getLocalData()->BuiltinRange.getBegin(); } void setBuiltinLoc(SourceLocation Loc) { - getLocalData()->BuiltinLoc = Loc; + getLocalData()->BuiltinRange = Loc; + } + void expandBuiltinRange(SourceRange Range) { + SourceRange &BuiltinRange = getLocalData()->BuiltinRange; + if (!BuiltinRange.getBegin().isValid()) { + BuiltinRange = Range; + } else { + BuiltinRange.setBegin(std::min(Range.getBegin(), BuiltinRange.getBegin())); + BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd())); + } } SourceLocation getNameLoc() const { return getBuiltinLoc(); } @@ -548,11 +559,11 @@ class BuiltinTypeLoc : public ConcreteTypeLoc() : 1; + return needsExtraLocalData() ? alignof(WrittenBuiltinSpecs) : 1; } SourceRange getLocalSourceRange() const { - return SourceRange(getBuiltinLoc(), getBuiltinLoc()); + return getLocalData()->BuiltinRange; } TypeSpecifierSign getWrittenSignSpec() const { @@ -693,6 +704,91 @@ class TemplateTypeParmTypeLoc : TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); } }; +struct ObjCTypeParamTypeLocInfo { + SourceLocation NameLoc; +}; + +/// ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for +/// protocol qualifiers are stored after Info. +class ObjCTypeParamTypeLoc : public ConcreteTypeLoc { + // SourceLocations are stored after Info, one for each protocol qualifier. + SourceLocation *getProtocolLocArray() const { + return (SourceLocation*)this->getExtraLocalData() + 2; + } + +public: + ObjCTypeParamDecl *getDecl() const { return getTypePtr()->getDecl(); } + + SourceLocation getNameLoc() const { + return this->getLocalData()->NameLoc; + } + + void setNameLoc(SourceLocation Loc) { + this->getLocalData()->NameLoc = Loc; + } + + SourceLocation getProtocolLAngleLoc() const { + return getNumProtocols() ? + *((SourceLocation*)this->getExtraLocalData()) : + SourceLocation(); + } + void setProtocolLAngleLoc(SourceLocation Loc) { + *((SourceLocation*)this->getExtraLocalData()) = Loc; + } + + SourceLocation getProtocolRAngleLoc() const { + return getNumProtocols() ? + *((SourceLocation*)this->getExtraLocalData() + 1) : + SourceLocation(); + } + void setProtocolRAngleLoc(SourceLocation Loc) { + *((SourceLocation*)this->getExtraLocalData() + 1) = Loc; + } + + unsigned getNumProtocols() const { + return this->getTypePtr()->getNumProtocols(); + } + + SourceLocation getProtocolLoc(unsigned i) const { + assert(i < getNumProtocols() && "Index is out of bounds!"); + return getProtocolLocArray()[i]; + } + void setProtocolLoc(unsigned i, SourceLocation Loc) { + assert(i < getNumProtocols() && "Index is out of bounds!"); + getProtocolLocArray()[i] = Loc; + } + + ObjCProtocolDecl *getProtocol(unsigned i) const { + assert(i < getNumProtocols() && "Index is out of bounds!"); + return *(this->getTypePtr()->qual_begin() + i); + } + + ArrayRef getProtocolLocs() const { + return llvm::makeArrayRef(getProtocolLocArray(), getNumProtocols()); + } + + void initializeLocal(ASTContext &Context, SourceLocation Loc); + + unsigned getExtraLocalDataSize() const { + if (!this->getNumProtocols()) return 0; + // When there are protocol qualifers, we have LAngleLoc and RAngleLoc + // as well. + return (this->getNumProtocols() + 2) * sizeof(SourceLocation) ; + } + unsigned getExtraLocalDataAlignment() const { + return alignof(SourceLocation); + } + SourceRange getLocalSourceRange() const { + SourceLocation start = getNameLoc(); + SourceLocation end = getProtocolRAngleLoc(); + if (end.isInvalid()) return SourceRange(start, start); + return SourceRange(start, end); + } +}; + /// \brief Wrapper for substituted template type parameters. class SubstTemplateTypeParmTypeLoc : public InheritingConcreteTypeLoc() - >= llvm::alignOf() && - "not enough alignment for tail-allocated data"); - return llvm::alignOf(); + static_assert(alignof(ObjCObjectTypeLoc) >= alignof(TypeSourceInfo *), + "not enough alignment for tail-allocated data"); + return alignof(TypeSourceInfo *); } QualType getInnerType() const { @@ -1256,6 +1351,19 @@ class FunctionTypeLoc : public ConcreteTypeLoc { + bool hasExceptionSpec() const { + if (auto *FPT = dyn_cast(getTypePtr())) { + return FPT->hasExceptionSpec(); + } + return false; + } + + SourceRange *getExceptionSpecRangePtr() const { + assert(hasExceptionSpec() && "No exception spec range"); + // After the Info comes the ParmVarDecl array, and after that comes the + // exception specification information. + return (SourceRange *)(getParmArray() + getNumParams()); + } public: SourceLocation getLocalRangeBegin() const { return getLocalData()->LocalRangeBegin; @@ -1289,6 +1397,16 @@ class FunctionTypeLoc : public ConcreteTypeLoc getParams() const { return llvm::makeArrayRef(getParmArray(), getNumParams()); } @@ -1321,17 +1439,18 @@ class FunctionTypeLoc : public ConcreteTypeLoc(); - } + unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); } QualType getInnerType() const { return getTypePtr()->getReturnType(); } }; @@ -1525,7 +1644,7 @@ class TemplateSpecializationTypeLoc : } unsigned getExtraLocalDataAlignment() const { - return llvm::alignOf(); + return alignof(TemplateArgumentLocInfo); } private: @@ -1935,7 +2054,7 @@ class DependentTemplateSpecializationTypeLoc : } unsigned getExtraLocalDataAlignment() const { - return llvm::alignOf(); + return alignof(TemplateArgumentLocInfo); } private: diff --git a/include/clang/AST/TypeNodes.def b/include/clang/AST/TypeNodes.def index 8caf1024142..27ab21bf7fc 100644 --- a/include/clang/AST/TypeNodes.def +++ b/include/clang/AST/TypeNodes.def @@ -101,6 +101,7 @@ DEPENDENT_TYPE(InjectedClassName, Type) DEPENDENT_TYPE(DependentName, Type) DEPENDENT_TYPE(DependentTemplateSpecialization, Type) NON_CANONICAL_UNLESS_DEPENDENT_TYPE(PackExpansion, Type) +NON_CANONICAL_TYPE(ObjCTypeParam, Type) TYPE(ObjCObject, Type) TYPE(ObjCInterface, ObjCObjectType) TYPE(ObjCObjectPointer, Type) diff --git a/include/clang/AST/UnresolvedSet.h b/include/clang/AST/UnresolvedSet.h index c1be2aa0f20..b63c6eb2176 100644 --- a/include/clang/AST/UnresolvedSet.h +++ b/include/clang/AST/UnresolvedSet.h @@ -17,7 +17,6 @@ #include "clang/AST/DeclAccessPair.h" #include "clang/Basic/LLVM.h" -#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/iterator.h" @@ -39,7 +38,9 @@ class UnresolvedSetIterator : public llvm::iterator_adaptor_base< : iterator_adaptor_base(const_cast(Iter)) {} public: - UnresolvedSetIterator() {} + // Work around a bug in MSVC 2013 where explicitly default constructed + // temporaries with defaulted ctors are not zero initialized. + UnresolvedSetIterator() : iterator_adaptor_base(nullptr) {} NamedDecl *getDecl() const { return I->getDecl(); } void setDecl(NamedDecl *ND) const { return I->setDecl(ND); } diff --git a/include/clang/AST/VTTBuilder.h b/include/clang/AST/VTTBuilder.h index 727bf5109ad..b4a6fe3bdb9 100644 --- a/include/clang/AST/VTTBuilder.h +++ b/include/clang/AST/VTTBuilder.h @@ -20,7 +20,6 @@ #include "clang/AST/GlobalDecl.h" #include "clang/AST/RecordLayout.h" #include "clang/Basic/ABI.h" -#include "llvm/ADT/SetVector.h" #include namespace clang { diff --git a/include/clang/AST/VTableBuilder.h b/include/clang/AST/VTableBuilder.h index 481fd11d6af..5cbcf51dd69 100644 --- a/include/clang/AST/VTableBuilder.h +++ b/include/clang/AST/VTableBuilder.h @@ -20,7 +20,6 @@ #include "clang/AST/RecordLayout.h" #include "clang/Basic/ABI.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SetVector.h" #include #include @@ -219,76 +218,76 @@ class VTableComponent { class VTableLayout { public: typedef std::pair VTableThunkTy; - - typedef const VTableComponent *vtable_component_iterator; - typedef const VTableThunkTy *vtable_thunk_iterator; - typedef llvm::iterator_range - vtable_component_range; - - typedef llvm::DenseMap AddressPointsMapTy; + struct AddressPointLocation { + unsigned VTableIndex, AddressPointIndex; + }; + typedef llvm::DenseMap + AddressPointsMapTy; private: - uint64_t NumVTableComponents; - std::unique_ptr VTableComponents; + // Stores the component indices of the first component of each virtual table in + // the virtual table group. To save a little memory in the common case where + // the vtable group contains a single vtable, an empty vector here represents + // the vector {0}. + OwningArrayRef VTableIndices; + + OwningArrayRef VTableComponents; /// \brief Contains thunks needed by vtables, sorted by indices. - uint64_t NumVTableThunks; - std::unique_ptr VTableThunks; + OwningArrayRef VTableThunks; /// \brief Address points for all vtables. AddressPointsMapTy AddressPoints; - bool IsMicrosoftABI; - public: - VTableLayout(uint64_t NumVTableComponents, - const VTableComponent *VTableComponents, - uint64_t NumVTableThunks, - const VTableThunkTy *VTableThunks, - const AddressPointsMapTy &AddressPoints, - bool IsMicrosoftABI); + VTableLayout(ArrayRef VTableIndices, + ArrayRef VTableComponents, + ArrayRef VTableThunks, + const AddressPointsMapTy &AddressPoints); ~VTableLayout(); - uint64_t getNumVTableComponents() const { - return NumVTableComponents; + ArrayRef vtable_components() const { + return VTableComponents; } - vtable_component_range vtable_components() const { - return vtable_component_range(vtable_component_begin(), - vtable_component_end()); + ArrayRef vtable_thunks() const { + return VTableThunks; } - vtable_component_iterator vtable_component_begin() const { - return VTableComponents.get(); + AddressPointLocation getAddressPoint(BaseSubobject Base) const { + assert(AddressPoints.count(Base) && "Did not find address point!"); + return AddressPoints.find(Base)->second; } - vtable_component_iterator vtable_component_end() const { - return VTableComponents.get() + NumVTableComponents; + const AddressPointsMapTy &getAddressPoints() const { + return AddressPoints; } - uint64_t getNumVTableThunks() const { return NumVTableThunks; } - - vtable_thunk_iterator vtable_thunk_begin() const { - return VTableThunks.get(); + size_t getNumVTables() const { + if (VTableIndices.empty()) + return 1; + return VTableIndices.size(); } - vtable_thunk_iterator vtable_thunk_end() const { - return VTableThunks.get() + NumVTableThunks; + size_t getVTableOffset(size_t i) const { + if (VTableIndices.empty()) { + assert(i == 0); + return 0; + } + return VTableIndices[i]; } - uint64_t getAddressPoint(BaseSubobject Base) const { - assert(AddressPoints.count(Base) && - "Did not find address point!"); - - uint64_t AddressPoint = AddressPoints.lookup(Base); - assert(AddressPoint != 0 || IsMicrosoftABI); - (void)IsMicrosoftABI; + size_t getVTableSize(size_t i) const { + if (VTableIndices.empty()) { + assert(i == 0); + return vtable_components().size(); + } - return AddressPoint; - } - - const AddressPointsMapTy &getAddressPoints() const { - return AddressPoints; + size_t thisIndex = VTableIndices[i]; + size_t nextIndex = (i + 1 == VTableIndices.size()) + ? vtable_components().size() + : VTableIndices[i + 1]; + return nextIndex - thisIndex; } }; @@ -339,8 +338,9 @@ class ItaniumVTableContext : public VTableContextBase { typedef llvm::DenseMap MethodVTableIndicesTy; MethodVTableIndicesTy MethodVTableIndices; - typedef llvm::DenseMap - VTableLayoutMapTy; + typedef llvm::DenseMap> + VTableLayoutMapTy; VTableLayoutMapTy VTableLayouts; typedef std::pair createConstructionVTableLayout( + const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset, + bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass); /// \brief Locate a virtual function in the vtable. /// @@ -399,21 +397,21 @@ struct VPtrInfo { typedef SmallVector BasePath; VPtrInfo(const CXXRecordDecl *RD) - : ReusingBase(RD), BaseWithVPtr(RD), NextBaseToMangle(RD) {} + : ObjectWithVPtr(RD), IntroducingObject(RD), NextBaseToMangle(RD) {} + + /// This is the most derived class that has this vptr at offset zero. When + /// single inheritance is used, this is always the most derived class. If + /// multiple inheritance is used, it may be any direct or indirect base. + const CXXRecordDecl *ObjectWithVPtr; - /// The vtable will hold all of the virtual bases or virtual methods of - /// ReusingBase. This may or may not be the same class as VPtrSubobject.Base. - /// A derived class will reuse the vptr of the first non-virtual base - /// subobject that has one. - const CXXRecordDecl *ReusingBase; + /// This is the class that introduced the vptr by declaring new virtual + /// methods or virtual bases. + const CXXRecordDecl *IntroducingObject; - /// BaseWithVPtr is at this offset from its containing complete object or + /// IntroducingObject is at this offset from its containing complete object or /// virtual base. CharUnits NonVirtualOffset; - /// The vptr is stored inside this subobject. - const CXXRecordDecl *BaseWithVPtr; - /// The bases from the inheritance path that got used to mangle the vbtable /// name. This is not really a full path like a CXXBasePath. It holds the /// subset of records that need to be mangled into the vbtable symbol name in @@ -432,7 +430,7 @@ struct VPtrInfo { /// This holds the base classes path from the complete type to the first base /// with the given vfptr offset, in the base-to-derived order. Only used for /// vftables. - BasePath PathToBaseWithVPtr; + BasePath PathToIntroducingObject; /// Static offset from the top of the most derived class to this vfptr, /// including any virtual base offset. Only used for vftables. @@ -444,14 +442,12 @@ struct VPtrInfo { } }; -typedef SmallVector VPtrInfoVector; +typedef SmallVector, 2> VPtrInfoVector; /// All virtual base related information about a given record decl. Includes /// information on all virtual base tables and the path components that are used /// to mangle them. struct VirtualBaseInfo { - ~VirtualBaseInfo() { llvm::DeleteContainerPointers(VBPtrPaths); } - /// A map from virtual base to vbtable index for doing a conversion from the /// the derived class to the a base. llvm::DenseMap VBTableIndices; @@ -504,15 +500,17 @@ class MicrosoftVTableContext : public VTableContextBase { MethodVFTableLocationsTy; MethodVFTableLocationsTy MethodVFTableLocations; - typedef llvm::DenseMap - VFPtrLocationsMapTy; + typedef llvm::DenseMap + VFPtrLocationsMapTy; VFPtrLocationsMapTy VFPtrLocations; typedef std::pair VFTableIdTy; - typedef llvm::DenseMap VFTableLayoutMapTy; + typedef llvm::DenseMap> + VFTableLayoutMapTy; VFTableLayoutMapTy VFTableLayouts; - llvm::DenseMap VBaseInfo; + llvm::DenseMap> + VBaseInfo; void enumerateVFPtrs(const CXXRecordDecl *ForClass, VPtrInfoVector &Result); @@ -522,7 +520,7 @@ class MicrosoftVTableContext : public VTableContextBase { const MethodVFTableLocationsTy &NewMethods, raw_ostream &); - const VirtualBaseInfo * + const VirtualBaseInfo & computeVBTableRelatedInformation(const CXXRecordDecl *RD); void computeVTablePaths(bool ForVBTables, const CXXRecordDecl *RD, diff --git a/include/clang/ASTMatchers/ASTMatchFinder.h b/include/clang/ASTMatchers/ASTMatchFinder.h index 042408859c9..389af1b6e25 100644 --- a/include/clang/ASTMatchers/ASTMatchFinder.h +++ b/include/clang/ASTMatchers/ASTMatchFinder.h @@ -158,6 +158,8 @@ class MatchFinder { MatchCallback *Action); void addMatcher(const TypeLocMatcher &NodeMatch, MatchCallback *Action); + void addMatcher(const CXXCtorInitializerMatcher &NodeMatch, + MatchCallback *Action); /// @} /// \brief Adds a matcher to execute when running over the AST. @@ -208,6 +210,7 @@ class MatchFinder { std::vector> NestedNameSpecifierLoc; std::vector> TypeLoc; + std::vector> CtorInit; /// \brief All the callbacks in one container to simplify iteration. llvm::SmallPtrSet AllCallbacks; }; @@ -229,6 +232,10 @@ class MatchFinder { /// Multiple results occur when using matchers like \c forEachDescendant, /// which generate a result for each sub-match. /// +/// If you want to find all matches on the sub-tree rooted at \c Node (rather +/// than only the matches on \c Node itself), surround the \c Matcher with a +/// \c findAll(). +/// /// \see selectFirst /// @{ template diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index aef4b4eafd9..6a5224febab 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -51,7 +51,6 @@ #include "clang/AST/DeclTemplate.h" #include "clang/ASTMatchers/ASTMatchersInternal.h" #include "clang/ASTMatchers/ASTMatchersMacros.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/Regex.h" #include @@ -76,18 +75,6 @@ class BoundNodes { return MyBoundNodes.getNodeAs(ID); } - /// \brief Deprecated. Please use \c getNodeAs instead. - /// @{ - template - const T *getDeclAs(StringRef ID) const { - return getNodeAs(ID); - } - template - const T *getStmtAs(StringRef ID) const { - return getNodeAs(ID); - } - /// @} - /// \brief Type of mapping from binding identifiers to bound nodes. This type /// is an associative container with a key type of \c std::string and a value /// type of \c clang::ast_type_traits::DynTypedNode @@ -126,6 +113,7 @@ typedef internal::Matcher TypeMatcher; typedef internal::Matcher TypeLocMatcher; typedef internal::Matcher NestedNameSpecifierMatcher; typedef internal::Matcher NestedNameSpecifierLocMatcher; +typedef internal::Matcher CXXCtorInitializerMatcher; /// @} /// \brief Matches any node. @@ -447,6 +435,17 @@ const internal::VariadicAllOfMatcher cxxCtorInitializer; /// matches 'int' in C. const internal::VariadicAllOfMatcher templateArgument; +/// \brief Matches template name. +/// +/// Given +/// \code +/// template class X { }; +/// X xi; +/// \endcode +/// templateName() +/// matches 'X' in X. +const internal::VariadicAllOfMatcher templateName; + /// \brief Matches non-type template parameter declarations. /// /// Given @@ -534,7 +533,8 @@ AST_MATCHER(FieldDecl, isBitField) { return Node.isBitField(); } -/// \brief Matches non-static data members that are bit-fields. +/// \brief Matches non-static data members that are bit-fields of the specified +/// bit width. /// /// Given /// \code @@ -544,35 +544,66 @@ AST_MATCHER(FieldDecl, isBitField) { /// int c : 2; /// }; /// \endcode -/// fieldDecl(isBitField()) +/// fieldDecl(hasBitWidth(2)) /// matches 'int a;' and 'int c;' but not 'int b;'. AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) { return Node.isBitField() && Node.getBitWidthValue(Finder->getASTContext()) == Width; } +/// \brief Matches non-static data members that have an in-class initializer. +/// +/// Given +/// \code +/// class C { +/// int a = 2; +/// int b = 3; +/// int c; +/// }; +/// \endcode +/// fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) +/// matches 'int a;' but not 'int b;'. +/// fieldDecl(hasInClassInitializer(anything())) +/// matches 'int a;' and 'int b;' but not 'int c;'. +AST_MATCHER_P(FieldDecl, hasInClassInitializer, internal::Matcher, + InnerMatcher) { + const Expr *Initializer = Node.getInClassInitializer(); + return (Initializer != nullptr && + InnerMatcher.matches(*Initializer, Finder, Builder)); +} + /// \brief Matches a declaration that has been implicitly added /// by the compiler (eg. implicit default/copy constructors). AST_MATCHER(Decl, isImplicit) { return Node.isImplicit(); } -/// \brief Matches classTemplateSpecializations that have at least one -/// TemplateArgument matching the given InnerMatcher. +/// \brief Matches classTemplateSpecializations, templateSpecializationType and +/// functionDecl that have at least one TemplateArgument matching the given +/// InnerMatcher. /// /// Given /// \code /// template class A {}; /// template<> class A {}; /// A a; +/// +/// template f() {}; +/// void func() { f(); }; +/// \endcode +/// /// \endcode /// classTemplateSpecializationDecl(hasAnyTemplateArgument( /// refersToType(asString("int")))) /// matches the specialization \c A +/// +/// functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) +/// matches the specialization \c f AST_POLYMORPHIC_MATCHER_P( hasAnyTemplateArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, - TemplateSpecializationType), + TemplateSpecializationType, + FunctionDecl), internal::Matcher, InnerMatcher) { ArrayRef List = internal::getTemplateSpecializationArgs(Node); @@ -699,22 +730,29 @@ AST_MATCHER_P(QualType, ignoringParens, return InnerMatcher.matches(Node.IgnoreParens(), Finder, Builder); } -/// \brief Matches classTemplateSpecializations where the n'th TemplateArgument -/// matches the given InnerMatcher. +/// \brief Matches classTemplateSpecializations, templateSpecializationType and +/// functionDecl where the n'th TemplateArgument matches the given InnerMatcher. /// /// Given /// \code /// template class A {}; /// A b; /// A c; +/// +/// template f() {}; +/// void func() { f(); }; /// \endcode /// classTemplateSpecializationDecl(hasTemplateArgument( /// 1, refersToType(asString("int")))) /// matches the specialization \c A +/// +/// functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) +/// matches the specialization \c f AST_POLYMORPHIC_MATCHER_P2( hasTemplateArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, - TemplateSpecializationType), + TemplateSpecializationType, + FunctionDecl), unsigned, N, internal::Matcher, InnerMatcher) { ArrayRef List = internal::getTemplateSpecializationArgs(Node); @@ -758,6 +796,24 @@ AST_MATCHER_P(TemplateArgument, refersToType, return InnerMatcher.matches(Node.getAsType(), Finder, Builder); } +/// \brief Matches a TemplateArgument that refers to a certain template. +/// +/// Given +/// \code +/// template