diff options
Diffstat (limited to 'include')
205 files changed, 2560 insertions, 2164 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 0ad90010ccd94..65dada38b0501 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -160,7 +160,7 @@ typedef struct CXVersion { int Major; /** * The minor version number, e.g., the '7' in '10.7.3'. This value - * will be negative if no minor version number was provided, e.g., for + * will be negative if no minor version number was provided, e.g., for * version '10'. */ int Minor; @@ -387,7 +387,7 @@ CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID); * multiple inclusions, either with the conventional * \#ifndef/\#define/\#endif macro guards or with \#pragma once. */ -CINDEX_LINKAGE unsigned +CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); /** @@ -786,7 +786,7 @@ typedef void *CXDiagnostic; * A group of CXDiagnostics. */ typedef void *CXDiagnosticSet; - + /** * Determine the number of diagnostics in a CXDiagnosticSet. */ @@ -802,7 +802,7 @@ CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); * via a call to \c clang_disposeDiagnostic(). */ CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, - unsigned Index); + unsigned Index); /** * Describes the kind of error that occurred (if any) in a call to @@ -813,26 +813,26 @@ enum CXLoadDiag_Error { * Indicates that no error occurred. */ CXLoadDiag_None = 0, - + /** * Indicates that an unknown error occurred while attempting to * deserialize diagnostics. */ CXLoadDiag_Unknown = 1, - + /** * Indicates that the file containing the serialized diagnostics * could not be opened. */ CXLoadDiag_CannotLoad = 2, - + /** * Indicates that the serialized diagnostics file is invalid or * corrupt. */ CXLoadDiag_InvalidFile = 3 }; - + /** * Deserialize a set of diagnostics from a Clang diagnostics bitcode * file. @@ -856,7 +856,7 @@ CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file, CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); /** - * Retrieve the child diagnostics of a CXDiagnostic. + * Retrieve the child diagnostics of a CXDiagnostic. * * This CXDiagnosticSet does not need to be released by * clang_disposeDiagnosticSet. @@ -888,7 +888,7 @@ CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, * \param Unit the translation unit to query. */ CINDEX_LINKAGE CXDiagnosticSet - clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); + clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); /** * Destroy a diagnostic. @@ -934,7 +934,7 @@ enum CXDiagnosticDisplayOptions { * \c -fdiagnostics-print-source-range-info. */ CXDiagnostic_DisplaySourceRanges = 0x04, - + /** * Display the option name associated with this diagnostic, if any. * @@ -943,12 +943,12 @@ enum CXDiagnosticDisplayOptions { * \c -fdiagnostics-show-option. */ CXDiagnostic_DisplayOption = 0x08, - + /** * Display the category number associated with this diagnostic, if any. * * The category number is displayed within brackets after the diagnostic text. - * This option corresponds to the clang flag + * This option corresponds to the clang flag * \c -fdiagnostics-show-category=id. */ CXDiagnostic_DisplayCategoryId = 0x10, @@ -957,7 +957,7 @@ enum CXDiagnosticDisplayOptions { * Display the category name associated with this diagnostic, if any. * * The category name is displayed within brackets after the diagnostic text. - * This option corresponds to the clang flag + * This option corresponds to the clang flag * \c -fdiagnostics-show-category=name. */ CXDiagnostic_DisplayCategoryName = 0x20 @@ -1019,7 +1019,7 @@ CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); * diagnostic (if any). * * \returns A string that contains the command-line option used to enable this - * warning, such as "-Wconversion" or "-pedantic". + * warning, such as "-Wconversion" or "-pedantic". */ CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, CXString *Disable); @@ -1028,7 +1028,7 @@ CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, * Retrieve the category number for this diagnostic. * * Diagnostics can be categorized into groups along with other, related - * diagnostics (e.g., diagnostics under the same warning flag). This routine + * diagnostics (e.g., diagnostics under the same warning flag). This routine * retrieves the category number for the given diagnostic. * * \returns The number of the category that contains this diagnostic, or zero @@ -1041,7 +1041,7 @@ CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); * is now deprecated. Use clang_getDiagnosticCategoryText() * instead. * - * \param Category A diagnostic category number, as returned by + * \param Category A diagnostic category number, as returned by * \c clang_getDiagnosticCategory(). * * \returns The name of the given diagnostic category. @@ -1055,7 +1055,7 @@ CXString clang_getDiagnosticCategoryName(unsigned Category); * \returns The text of the given diagnostic category. */ CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); - + /** * Determine the number of source ranges associated with the given * diagnostic. @@ -1242,9 +1242,9 @@ enum CXTranslationUnit_Flags { * intent of producing a precompiled header. */ CXTranslationUnit_Incomplete = 0x02, - + /** - * Used to indicate that the translation unit should be built with an + * Used to indicate that the translation unit should be built with an * implicit precompiled header for the preamble. * * An implicit precompiled header is used as an optimization when a @@ -1258,7 +1258,7 @@ enum CXTranslationUnit_Flags { * precompiled header to improve parsing performance. */ CXTranslationUnit_PrecompiledPreamble = 0x04, - + /** * Used to indicate that the translation unit should cache some * code-completion results with each reparse of the source file. @@ -1343,7 +1343,7 @@ enum CXTranslationUnit_Flags { * to indicate that the translation unit is likely to be reparsed many times, * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag - * set contains an unspecified set of optimizations (e.g., the precompiled + * set contains an unspecified set of optimizations (e.g., the precompiled * preamble) geared toward improving the performance of these routines. The * set of optimizations enabled may change from one version to the next. */ @@ -1374,7 +1374,7 @@ clang_parseTranslationUnit(CXIndex CIdx, * command-line arguments so that the compilation can be configured in the same * way that the compiler is configured on the command line. * - * \param CIdx The index object with which the translation unit will be + * \param CIdx The index object with which the translation unit will be * associated. * * \param source_filename The name of the source file to load, or NULL if the @@ -1383,7 +1383,7 @@ clang_parseTranslationUnit(CXIndex CIdx, * \param command_line_args The command-line arguments that would be * passed to the \c clang executable if it were being invoked out-of-process. * These command-line options will be parsed and will affect how the translation - * unit is parsed. Note that the following options are ignored: '-c', + * unit is parsed. Note that the following options are ignored: '-c', * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \<output file>'. * * \param num_command_line_args The number of command-line arguments in @@ -1463,32 +1463,32 @@ enum CXSaveError { * Indicates that no error occurred while saving a translation unit. */ CXSaveError_None = 0, - + /** * Indicates that an unknown error occurred while attempting to save * the file. * - * This error typically indicates that file I/O failed when attempting to + * This error typically indicates that file I/O failed when attempting to * write the file. */ CXSaveError_Unknown = 1, - + /** * Indicates that errors during translation prevented this attempt * to save the translation unit. - * + * * Errors that prevent the translation unit from being saved can be * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). */ CXSaveError_TranslationErrors = 2, - + /** * Indicates that the translation unit to be saved was somehow * invalid (e.g., NULL). */ CXSaveError_InvalidTU = 3 }; - + /** * Saves a translation unit into a serialized representation of * that translation unit on disk. @@ -1509,7 +1509,7 @@ enum CXSaveError { * CXSaveTranslationUnit_XXX flags. * * \returns A value that will match one of the enumerators of the CXSaveError - * enumeration. Zero (CXSaveError_None) indicates that the translation unit was + * enumeration. Zero (CXSaveError_None) indicates that the translation unit was * saved successfully, while a non-zero value indicates that a problem occurred. */ CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, @@ -1543,7 +1543,7 @@ enum CXReparse_Flags { */ CXReparse_None = 0x0 }; - + /** * Returns the set of flags that is suitable for reparsing a translation * unit. @@ -1551,7 +1551,7 @@ enum CXReparse_Flags { * The set of flags returned provide options for * \c clang_reparseTranslationUnit() by default. The returned flag * set contains an unspecified set of optimizations geared toward common uses - * of reparsing. The set of optimizations enabled may change from one version + * of reparsing. The set of optimizations enabled may change from one version * to the next. */ CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); @@ -1563,17 +1563,17 @@ CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); * created the given translation unit, for example because those source files * have changed (either on disk or as passed via \p unsaved_files). The * source code will be reparsed with the same command-line options as it - * was originally parsed. + * was originally parsed. * * Reparsing a translation unit invalidates all cursors and source locations * that refer into that translation unit. This makes reparsing a translation * unit semantically equivalent to destroying the translation unit and then * creating a new translation unit with the same command-line arguments. - * However, it may be more efficient to reparse a translation + * However, it may be more efficient to reparse a translation * unit using this routine. * * \param TU The translation unit whose contents will be re-parsed. The - * translation unit must originally have been built with + * translation unit must originally have been built with * \c clang_createTranslationUnitFromSourceFile(). * * \param num_unsaved_files The number of unsaved file entries in \p @@ -1584,7 +1584,7 @@ CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); * those files. The contents and name of these files (as specified by * CXUnsavedFile) are copied when necessary, so the client only needs to * guarantee their validity until the call to this function returns. - * + * * \param options A bitset of options composed of the flags in CXReparse_Flags. * The function \c clang_defaultReparseOptions() produces a default set of * options recommended for most uses, based on the translation unit. @@ -1612,8 +1612,8 @@ enum CXTUResourceUsageKind { CXTUResourceUsage_AST_SideTables = 6, CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, - CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, - CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, + CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, + CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, CXTUResourceUsage_Preprocessor = 11, CXTUResourceUsage_PreprocessingRecord = 12, CXTUResourceUsage_SourceManager_DataStructures = 13, @@ -1635,8 +1635,8 @@ const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); typedef struct CXTUResourceUsageEntry { /* The memory usage category. */ - enum CXTUResourceUsageKind kind; - /* Amount of resources used. + enum CXTUResourceUsageKind kind; + /* Amount of resources used. The units will depend on the resource kind. */ unsigned long amount; } CXTUResourceUsageEntry; @@ -1819,7 +1819,7 @@ enum CXCursorKind { */ CXCursor_TypeRef = 43, CXCursor_CXXBaseSpecifier = 44, - /** + /** * A reference to a class template, function template, template * template parameter, or class template partial specialization. */ @@ -1829,14 +1829,14 @@ enum CXCursorKind { */ CXCursor_NamespaceRef = 46, /** - * A reference to a member of a struct, union, or class that occurs in + * A reference to a member of a struct, union, or class that occurs in * some non-expression context, e.g., a designated initializer. */ CXCursor_MemberRef = 47, /** * A reference to a labeled statement. * - * This cursor kind is used to describe the jump to "start_over" in the + * This cursor kind is used to describe the jump to "start_over" in the * goto statement in the following example: * * \code @@ -1849,7 +1849,7 @@ enum CXCursorKind { * A label reference cursor refers to a label statement. */ CXCursor_LabelRef = 48, - + /** * A reference to a set of overloaded functions or function templates * that has not yet been resolved to a specific function or function template. @@ -1882,18 +1882,18 @@ enum CXCursorKind { * argument-dependent lookup (e.g., the "swap" function at the end of the * example). * - * The functions \c clang_getNumOverloadedDecls() and + * The functions \c clang_getNumOverloadedDecls() and * \c clang_getOverloadedDecl() can be used to retrieve the definitions * referenced by this cursor. */ CXCursor_OverloadedDeclRef = 49, - + /** - * A reference to a variable that occurs in some non-expression + * A reference to a variable that occurs in some non-expression * context, e.g., a C++ lambda capture list. */ CXCursor_VariableRef = 50, - + CXCursor_LastRef = CXCursor_VariableRef, /* Error conditions */ @@ -2153,7 +2153,7 @@ enum CXCursorKind { * \endcode */ CXCursor_LambdaExpr = 144, - + /** Objective-c Boolean Literal. */ CXCursor_ObjCBoolLiteralExpr = 145, @@ -2189,10 +2189,10 @@ enum CXCursorKind { * reported. */ CXCursor_UnexposedStmt = 200, - - /** A labelled statement in a function. + + /** A labelled statement in a function. * - * This cursor kind is used to describe the "start_over:" label statement in + * This cursor kind is used to describe the "start_over:" label statement in * the following example: * * \code @@ -2650,7 +2650,7 @@ CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); * Compute a hash value for the given cursor. */ CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); - + /** * Retrieve the kind of the given cursor. */ @@ -2718,7 +2718,7 @@ CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); * element, such as a preprocessor directive or macro instantiation. */ CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); - + /*** * Determine whether the given cursor represents a currently * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). @@ -2785,7 +2785,7 @@ CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); * * \returns The availability of the cursor. */ -CINDEX_LINKAGE enum CXAvailabilityKind +CINDEX_LINKAGE enum CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor); /** @@ -2831,10 +2831,10 @@ typedef struct CXPlatformAvailability { * * \param cursor The cursor to query. * - * \param always_deprecated If non-NULL, will be set to indicate whether the + * \param always_deprecated If non-NULL, will be set to indicate whether the * entity is deprecated on all platforms. * - * \param deprecated_message If non-NULL, will be set to the message text + * \param deprecated_message If non-NULL, will be set to the message text * provided along with the unconditional deprecation of this entity. The client * is responsible for deallocating this string. * @@ -2842,7 +2842,7 @@ typedef struct CXPlatformAvailability { * entity is unavailable on all platforms. * * \param unavailable_message If non-NULL, will be set to the message text - * provided along with the unconditional unavailability of this entity. The + * provided along with the unconditional unavailability of this entity. The * client is responsible for deallocating this string. * * \param availability If non-NULL, an array of CXPlatformAvailability instances @@ -2850,15 +2850,15 @@ typedef struct CXPlatformAvailability { * the number of platforms for which availability information is available (as * returned by this function) or \c availability_size, whichever is smaller. * - * \param availability_size The number of elements available in the + * \param availability_size The number of elements available in the * \c availability array. * * \returns The number of platforms (N) for which availability information is * available (which is unrelated to \c availability_size). * - * Note that the client is responsible for calling - * \c clang_disposeCXPlatformAvailability to free each of the - * platform-availability structures returned. There are + * Note that the client is responsible for calling + * \c clang_disposeCXPlatformAvailability to free each of the + * platform-availability structures returned. There are * \c min(N, availability_size) such structures. */ CINDEX_LINKAGE int @@ -2875,7 +2875,7 @@ clang_getCursorPlatformAvailability(CXCursor cursor, */ CINDEX_LINKAGE void clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); - + /** * Describe the "language" of the entity referred to by a cursor. */ @@ -2948,7 +2948,7 @@ CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, * * The semantic parent of a cursor is the cursor that semantically contains * the given \p cursor. For many declarations, the lexical and semantic parents - * are equivalent (the lexical parent is returned by + * are equivalent (the lexical parent is returned by * \c clang_getCursorLexicalParent()). They diverge when declarations or * definitions are provided out-of-line. For example: * @@ -2983,7 +2983,7 @@ CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); * * The lexical parent of a cursor is the cursor in which the given \p cursor * was actually written. For many declarations, the lexical and semantic parents - * are equivalent (the semantic parent is returned by + * are equivalent (the semantic parent is returned by * \c clang_getCursorSemanticParent()). They diverge when declarations or * definitions are provided out-of-line. For example: * @@ -3046,18 +3046,18 @@ CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); * \param cursor A cursor representing an Objective-C or C++ * method. This routine will compute the set of methods that this * method overrides. - * + * * \param overridden A pointer whose pointee will be replaced with a * pointer to an array of cursors, representing the set of overridden * methods. If there are no overridden methods, the pointee will be - * set to NULL. The pointee must be freed via a call to + * set to NULL. The pointee must be freed via a call to * \c clang_disposeOverriddenCursors(). * * \param num_overridden A pointer to the number of overridden * functions, will be set to the number of overridden functions in the * array pointed to by \p overridden. */ -CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, +CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, CXCursor **overridden, unsigned *num_overridden); @@ -3072,7 +3072,7 @@ CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); * cursor. */ CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); - + /** * @} */ @@ -3133,7 +3133,7 @@ CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); /** * @} */ - + /** * \defgroup CINDEX_TYPES Type information for CXCursors * @@ -3582,7 +3582,7 @@ CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); /** * Returns the Objective-C type encoding for the specified CXType. */ -CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); +CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); /** * Retrieve the spelling of a given CXTypeKind. @@ -3842,7 +3842,7 @@ CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C); * CX_CXXBaseSpecifier is virtual. */ CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); - + /** * Represents the C++ access control level to a base class for a * cursor with kind CX_CXXBaseSpecifier. @@ -3887,7 +3887,7 @@ enum CX_StorageClass { CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); /** - * Determine the number of overloaded declarations referenced by a + * Determine the number of overloaded declarations referenced by a * \c CXCursor_OverloadedDeclRef cursor. * * \param cursor The cursor whose overloaded declarations are being queried. @@ -3906,18 +3906,18 @@ CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); * \param index The zero-based index into the set of overloaded declarations in * the cursor. * - * \returns A cursor representing the declaration referenced by the given - * \c cursor at the specified \c index. If the cursor does not have an + * \returns A cursor representing the declaration referenced by the given + * \c cursor at the specified \c index. If the cursor does not have an * associated set of overloaded declarations, or if the index is out of bounds, * returns \c clang_getNullCursor(); */ -CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, +CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index); - + /** * @} */ - + /** * \defgroup CINDEX_ATTRIBUTES Information for attributes * @@ -4021,7 +4021,7 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, * The visitor should return one of the \c CXChildVisitResult values * to direct clang_visitChildrenWithBlock(). */ -typedef enum CXChildVisitResult +typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent); /** @@ -4109,10 +4109,10 @@ CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); * Most of the times there is only one range for the complete spelling but for * Objective-C methods and Objective-C message expressions, there are multiple * pieces for each selector identifier. - * + * * \param pieceIndex the index of the spelling name piece. If this is greater * than the actual number of pieces, it will return a NULL (invalid) range. - * + * * \param options Reserved. */ CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor, @@ -4206,11 +4206,11 @@ CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor, * Retrieve the display name for the entity referenced by this cursor. * * The display name contains extra information that helps identify the cursor, - * such as the parameters of a function or template or the arguments of a + * such as the parameters of a function or template or the arguments of a * class template specialization. */ CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); - + /** For a cursor that is a reference, retrieve a cursor representing the * entity that it references. * @@ -4274,10 +4274,10 @@ CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); * }; * \endcode * - * The declarations and the definition of \c X are represented by three - * different cursors, all of which are declarations of the same underlying + * The declarations and the definition of \c X are represented by three + * different cursors, all of which are declarations of the same underlying * entity. One of these cursor is considered the "canonical" cursor, which - * is effectively the representative for the underlying entity. One can + * is effectively the representative for the underlying entity. One can * determine if two cursors are declarations of the same underlying entity by * comparing their canonical cursors. * @@ -4301,11 +4301,11 @@ CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); /** * Given a cursor pointing to a C++ method call or an Objective-C * message, returns non-zero if the method/message is "dynamic", meaning: - * + * * For a C++ method: the call is virtual. * For an Objective-C message: the receiver is an object instance, not 'super' * or a specific class. - * + * * If the method/message is "static" or the cursor does not point to a * method/message, it will return zero. */ @@ -4575,7 +4575,7 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C); CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C); /** - * Determine if a C++ member function or member function template is + * Determine if a C++ member function or member function template is * declared 'static'. */ CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); @@ -4622,16 +4622,16 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); * \c CXCursor_NoDeclFound. */ CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); - + /** * Given a cursor that may represent a specialization or instantiation * of a template, retrieve the cursor that represents the template that it * specializes or from which it was instantiated. * - * This routine determines the template involved both for explicit + * This routine determines the template involved both for explicit * specializations of templates and for implicit instantiations of the template, * both of which are referred to as "specializations". For a class template - * specialization (e.g., \c std::vector<bool>), this routine will return + * specialization (e.g., \c std::vector<bool>), this routine will return * either the primary template (\c std::vector) or, if the specialization was * instantiated from a class template partial specialization, the class template * partial specialization. For a class template partial specialization and a @@ -4639,7 +4639,7 @@ CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); * this routine will return the specialized template. * * For members of a class template (e.g., member functions, member classes, or - * static data members), returns the specialized or instantiated member. + * static data members), returns the specialized or instantiated member. * Although not strictly "templates" in the C++ language, members of class * templates have the same notions of specializations and instantiations that * templates do, so this routine treats them similarly. @@ -4647,7 +4647,7 @@ CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); * \param C A cursor that may be a specialization of a template or a member * of a template. * - * \returns If the given cursor is a specialization or instantiation of a + * \returns If the given cursor is a specialization or instantiation of a * template or a member thereof, the template or member that it specializes or * from which it was instantiated. Otherwise, returns a NULL cursor. */ @@ -4659,11 +4659,11 @@ CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); * * \param C A cursor pointing to a member reference, a declaration reference, or * an operator call. - * \param NameFlags A bitset with three independent flags: + * \param NameFlags A bitset with three independent flags: * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and * CXNameRange_WantSinglePiece. - * \param PieceIndex For contiguous names or when passing the flag - * CXNameRange_WantSinglePiece, only one piece with index 0 is + * \param PieceIndex For contiguous names or when passing the flag + * CXNameRange_WantSinglePiece, only one piece with index 0 is * available. When the CXNameRange_WantSinglePiece flag is not passed for a * non-contiguous names, this index can be used to retrieve the individual * pieces of the name. See also CXNameRange_WantSinglePiece. @@ -4672,7 +4672,7 @@ CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. */ CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, - unsigned NameFlags, + unsigned NameFlags, unsigned PieceIndex); enum CXNameRefFlags { @@ -4681,7 +4681,7 @@ enum CXNameRefFlags { * range. */ CXNameRange_WantQualifier = 0x1, - + /** * Include the explicit template arguments, e.g. \<int> in x.f<int>, * in the range. @@ -4700,7 +4700,7 @@ enum CXNameRefFlags { */ CXNameRange_WantSinglePiece = 0x4 }; - + /** * @} */ @@ -5153,7 +5153,7 @@ clang_getNumCompletionChunks(CXCompletionString completion_string); /** * Determine the priority of this code completion. * - * The priority of a code completion indicates how likely it is that this + * The priority of a code completion indicates how likely it is that this * particular completion is the completion that the user will select. The * priority is selected by various internal heuristics. * @@ -5164,7 +5164,7 @@ clang_getNumCompletionChunks(CXCompletionString completion_string); */ CINDEX_LINKAGE unsigned clang_getCompletionPriority(CXCompletionString completion_string); - + /** * Determine the availability of the entity that this code-completion * string refers to. @@ -5173,7 +5173,7 @@ clang_getCompletionPriority(CXCompletionString completion_string); * * \returns The availability of the completion string. */ -CINDEX_LINKAGE enum CXAvailabilityKind +CINDEX_LINKAGE enum CXAvailabilityKind clang_getCompletionAvailability(CXCompletionString completion_string); /** @@ -5206,7 +5206,7 @@ clang_getCompletionAnnotation(CXCompletionString completion_string, /** * Retrieve the parent context of the given completion string. * - * The parent context of a completion string is the semantic parent of + * The parent context of a completion string is the semantic parent of * the declaration (if any) that the code completion represents. For example, * a code completion for an Objective-C method would have the method's class * or protocol as its context. @@ -5241,7 +5241,7 @@ clang_getCompletionBriefComment(CXCompletionString completion_string); */ CINDEX_LINKAGE CXCompletionString clang_getCursorCompletionString(CXCursor cursor); - + /** * Contains the results of code-completion. * @@ -5378,12 +5378,12 @@ enum CXCompletionContext { * should be included. (This is equivalent to having no context bits set.) */ CXCompletionContext_Unexposed = 0, - + /** * Completions for any possible type should be included in the results. */ CXCompletionContext_AnyType = 1 << 0, - + /** * Completions for any possible value (variables, function calls, etc.) * should be included in the results. @@ -5404,7 +5404,7 @@ enum CXCompletionContext { * included in the results. */ CXCompletionContext_CXXClassTypeValue = 1 << 4, - + /** * Completions for fields of the member being accessed using the dot * operator should be included in the results. @@ -5420,7 +5420,7 @@ enum CXCompletionContext { * using the dot operator should be included in the results. */ CXCompletionContext_ObjCPropertyAccess = 1 << 7, - + /** * Completions for enum tags should be included in the results. */ @@ -5433,7 +5433,7 @@ enum CXCompletionContext { * Completions for struct tags should be included in the results. */ CXCompletionContext_StructTag = 1 << 10, - + /** * Completions for C++ class names should be included in the results. */ @@ -5448,7 +5448,7 @@ enum CXCompletionContext { * the results. */ CXCompletionContext_NestedNameSpecifier = 1 << 13, - + /** * Completions for Objective-C interfaces (classes) should be included * in the results. @@ -5479,27 +5479,27 @@ enum CXCompletionContext { * the results. */ CXCompletionContext_ObjCSelectorName = 1 << 19, - + /** * Completions for preprocessor macro names should be included in * the results. */ CXCompletionContext_MacroName = 1 << 20, - + /** * Natural language completions should be included in the results. */ CXCompletionContext_NaturalLanguage = 1 << 21, - + /** * The current context is unknown, so set all contexts. */ CXCompletionContext_Unknown = ((1 << 22) - 1) }; - + /** * Returns a default set of code-completion options that can be - * passed to\c clang_codeCompleteAt(). + * passed to\c clang_codeCompleteAt(). */ CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); @@ -5562,7 +5562,7 @@ CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); * * \param options Extra options that control the behavior of code * completion, expressed as a bitwise OR of the enumerators of the - * CXCodeComplete_Flags enumeration. The + * CXCodeComplete_Flags enumeration. The * \c clang_defaultCodeCompleteOptions() function returns a default set * of code-completion options. * @@ -5581,7 +5581,7 @@ CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, unsigned options); /** - * Sort the code-completion results in case-insensitive alphabetical + * Sort the code-completion results in case-insensitive alphabetical * order. * * \param Results The set of results to sort. @@ -5590,13 +5590,13 @@ CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, CINDEX_LINKAGE void clang_sortCodeCompletionResults(CXCompletionResult *Results, unsigned NumResults); - + /** * Free the given set of code-completion results. */ CINDEX_LINKAGE void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); - + /** * Determine the number of diagnostics produced prior to the * location where code completion was performed. @@ -5620,7 +5620,7 @@ CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, /** * Determines what completions are appropriate for the context * the given code completion. - * + * * \param Results the code completion results to query * * \returns the kinds of completions that are appropriate for use @@ -5676,7 +5676,7 @@ CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); */ CINDEX_LINKAGE CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); - + /** * @} */ @@ -5700,7 +5700,7 @@ CINDEX_LINKAGE CXString clang_getClangVersion(void); * value enables crash recovery, while 0 disables it. */ CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); - + /** * Visitor invoked for each file in a translation unit * (used with clang_getInclusions()). @@ -5745,7 +5745,7 @@ typedef enum { typedef void * CXEvalResult; /** - * If cursor is a statement declaration tries to evaluate the + * If cursor is a statement declaration tries to evaluate the * statement and if its variable, tries to evaluate its initializer, * into its corresponding type. */ @@ -5844,7 +5844,7 @@ CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); /** * Get the original and the associated filename from the remapping. - * + * * \param original If non-NULL, will be set to the original filename. * * \param transformed If non-NULL, will be set to the filename that the original @@ -5896,7 +5896,7 @@ typedef enum { /** * Find references of a declaration in a specific file. - * + * * \param cursor pointing to a declaration or a reference of one. * * \param file to search for references. @@ -6255,11 +6255,11 @@ typedef struct { const CXIdxEntityInfo *referencedEntity; /** * Immediate "parent" of the reference. For example: - * + * * \code * Foo *var; * \endcode - * + * * The parent of reference of type 'Foo' is the variable 'var'. * For references inside statement bodies of functions/methods, * the parentEntity will be the function/method. @@ -6294,16 +6294,16 @@ typedef struct { CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile, void *reserved); - + /** * Called when a file gets \#included/\#imported. */ CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, const CXIdxIncludedFileInfo *); - + /** * Called when a AST file (PCH or module) gets imported. - * + * * AST files will not get indexed (there will not be callbacks to index all * the entities in an AST file). The recommended action is that, if the AST * file is not already indexed, to initiate a new indexing job specific to @@ -6405,7 +6405,7 @@ typedef enum { * Used to indicate that no special indexing options are needed. */ CXIndexOpt_None = 0x0, - + /** * Used to indicate that IndexerCallbacks#indexEntityReference should * be invoked for only one reference of an entity per source file that does @@ -6492,16 +6492,16 @@ CINDEX_LINKAGE int clang_indexSourceFileFullArgv( /** * Index the given translation unit via callbacks implemented through * #IndexerCallbacks. - * + * * The order of callback invocations is not guaranteed to be the same as * when indexing a source file. The high level order will be: - * + * * -Preprocessor callbacks invocations * -Declaration/reference callbacks invocations * -Diagnostic callback invocations * * The parameters are the same as #clang_indexSourceFile. - * + * * \returns If there is a failure from which there is no recovery, returns * non-zero, otherwise returns 0. */ diff --git a/include/clang/ARCMigrate/FileRemapper.h b/include/clang/ARCMigrate/FileRemapper.h index 53b88e9eb5e52..731307f24e224 100644 --- a/include/clang/ARCMigrate/FileRemapper.h +++ b/include/clang/ARCMigrate/FileRemapper.h @@ -41,7 +41,7 @@ class FileRemapper { public: FileRemapper(); ~FileRemapper(); - + bool initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag, bool ignoreIfFilesChanged); bool initFromFile(StringRef filePath, DiagnosticsEngine &Diag, diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index c6f8e2973e8e7..a9ab687a8de9e 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -226,6 +226,12 @@ class ASTContext : public RefCountedBase<ASTContext> { using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>; mutable TypeInfoMap MemoizedTypeInfo; + /// A cache from types to unadjusted alignment information. Only ARM and + /// AArch64 targets need this information, keeping it separate prevents + /// imposing overhead on TypeInfo size. + using UnadjustedAlignMap = llvm::DenseMap<const Type *, unsigned>; + mutable UnadjustedAlignMap MemoizedUnadjustedAlign; + /// A cache mapping from CXXRecordDecls to key functions. llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions; @@ -1522,7 +1528,7 @@ public: /// The sizeof operator requires this (C99 6.5.3.4p4). CanQualType getSizeType() const; - /// Return the unique signed counterpart of + /// Return the unique signed counterpart of /// the integer type corresponding to size_t. CanQualType getSignedSizeType() const; @@ -2067,6 +2073,16 @@ public: unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; } unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; } + /// Return the ABI-specified natural alignment of a (complete) type \p T, + /// before alignment adjustments, in bits. + /// + /// This alignment is curently used only by ARM and AArch64 when passing + /// arguments of a composite type. + unsigned getTypeUnadjustedAlign(QualType T) const { + return getTypeUnadjustedAlign(T.getTypePtr()); + } + unsigned getTypeUnadjustedAlign(const Type *T) const; + /// 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). @@ -2077,6 +2093,12 @@ public: CharUnits getTypeAlignInChars(QualType T) const; CharUnits getTypeAlignInChars(const Type *T) const; + /// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type, + /// in characters, before alignment adjustments. This method does not work on + /// incomplete types. + CharUnits getTypeUnadjustedAlignInChars(QualType T) const; + CharUnits getTypeUnadjustedAlignInChars(const Type *T) const; + // getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the // type is a record, its data size is returned. std::pair<CharUnits, CharUnits> getTypeInfoDataSizeInChars(QualType T) const; diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h index b08865dde3c10..2534272da3a30 100644 --- a/include/clang/AST/ASTDiagnostic.h +++ b/include/clang/AST/ASTDiagnostic.h @@ -23,11 +23,11 @@ namespace clang { NUM_BUILTIN_AST_DIAGNOSTICS }; } // end namespace diag - + /// DiagnosticsEngine argument formatting function for diagnostics that /// involve AST nodes. /// - /// This function formats diagnostic arguments for various AST nodes, + /// This function formats diagnostic arguments for various AST nodes, /// including types, declaration names, nested name specifiers, and /// declaration contexts, into strings that can be printed as part of /// diagnostics. It is meant to be used as the argument to diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index 6e6a1926254bc..2e9a8775a8a23 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -63,7 +63,7 @@ class Attr; private: /// The contexts we're importing to and from. ASTContext &ToContext, &FromContext; - + /// The file managers we're importing to and from. FileManager &ToFileManager, &FromFileManager; @@ -72,11 +72,11 @@ class Attr; /// Whether the last diagnostic came from the "from" context. bool LastDiagFromFrom = false; - + /// Mapping from the already-imported types in the "from" context /// to the corresponding types in the "to" context. llvm::DenseMap<const Type *, const Type *> ImportedTypes; - + /// Mapping from the already-imported declarations in the "from" /// context to the corresponding declarations in the "to" context. llvm::DenseMap<Decl *, Decl *> ImportedDecls; @@ -93,11 +93,11 @@ class Attr; /// the "from" source manager to the corresponding CXXBasesSpecifier /// in the "to" source manager. ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers; - + /// Declaration (from, to) pairs that are known not to be equivalent /// (which we have already complained about). NonEquivalentDeclSet NonEquivalentDecls; - + public: /// Create a new AST importer. /// @@ -115,13 +115,13 @@ class Attr; ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport); - + virtual ~ASTImporter(); - + /// Whether the importer will perform a minimal import, creating /// to-be-completed forward declarations when possible. bool isMinimalImport() const { return Minimal; } - + /// Import the given type from the "from" context into the "to" /// context. /// @@ -142,10 +142,10 @@ class Attr; /// \returns the equivalent attribute in the "to" context. Attr *Import(const Attr *FromAttr); - /// Import the given declaration from the "from" context into the + /// Import the given declaration from the "from" context into the /// "to" context. /// - /// \returns the equivalent declaration in the "to" context, or a NULL type + /// \returns the equivalent declaration in the "to" context, or a NULL type /// if an error occurred. Decl *Import(Decl *FromD); Decl *Import(const Decl *FromD) { @@ -163,7 +163,7 @@ class Attr; /// \returns the equivalent declaration context in the "to" /// context, or a NULL type if an error occurred. DeclContext *ImportContext(DeclContext *FromDC); - + /// Import the given expression from the "from" context into the /// "to" context. /// @@ -195,7 +195,7 @@ class Attr; /// Import the goven template name from the "from" context into the /// "to" context. TemplateName Import(TemplateName From); - + /// Import the given source location from the "from" context into /// the "to" context. /// @@ -229,7 +229,7 @@ class Attr; /// \returns the equivalent selector in the "to" context. Selector Import(Selector FromSel); - /// Import the given file ID from the "from" context into the + /// Import the given file ID from the "from" context into the /// "to" context. /// /// \returns the equivalent file ID in the source manager of the "to" @@ -252,13 +252,13 @@ class Attr; /// Import the definition of the given declaration, including all of /// the declarations it contains. /// - /// This routine is intended to be used + /// This routine is intended to be used void ImportDefinition(Decl *From); /// Cope with a name conflict when importing a declaration into the /// given context. /// - /// This routine is invoked whenever there is a name conflict while + /// This routine is invoked whenever there is a name conflict while /// importing a declaration. The returned name will become the name of the /// imported declaration. By default, the returned name is the same as the /// original name, leaving the conflict unresolve such that name lookup @@ -270,7 +270,7 @@ class Attr; /// \param Name the name of the declaration being imported, which conflicts /// with other declarations. /// - /// \param DC the declaration context (in the "to" AST context) in which + /// \param DC the declaration context (in the "to" AST context) in which /// the name is being imported. /// /// \param IDNS the identifier namespace in which the name will be found. @@ -286,25 +286,25 @@ class Attr; unsigned IDNS, NamedDecl **Decls, unsigned NumDecls); - + /// Retrieve the context that AST nodes are being imported into. ASTContext &getToContext() const { return ToContext; } - + /// Retrieve the context that AST nodes are being imported from. ASTContext &getFromContext() const { return FromContext; } - + /// Retrieve the file manager that AST nodes are being imported into. FileManager &getToFileManager() const { return ToFileManager; } /// Retrieve the file manager that AST nodes are being imported from. FileManager &getFromFileManager() const { return FromFileManager; } - + /// Report a diagnostic in the "to" context. DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID); - + /// Report a diagnostic in the "from" context. DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID); - + /// Return the set of declarations that we know are not equivalent. NonEquivalentDeclSet &getNonEquivalentDecls() { return NonEquivalentDecls; } @@ -313,7 +313,7 @@ class Attr; /// /// \param D A declaration in the "to" context. virtual void CompleteDecl(Decl* D); - + /// Subclasses can override this function to observe all of the \c From -> /// \c To declaration mappings as they are imported. virtual Decl *Imported(Decl *From, Decl *To) { return To; } @@ -328,7 +328,7 @@ class Attr; /// RecordDecl can be found, we can complete it without the need for /// importation, eliminating this loop. virtual Decl *GetOriginalDecl(Decl *To) { return nullptr; } - + /// Determine whether the given types are structurally /// equivalent. bool IsStructurallyEquivalent(QualType From, QualType To, diff --git a/include/clang/AST/ASTLambda.h b/include/clang/AST/ASTLambda.h index 2fe4e2563b36f..6fedcb8d38011 100644 --- a/include/clang/AST/ASTLambda.h +++ b/include/clang/AST/ASTLambda.h @@ -40,7 +40,7 @@ inline bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD) { if (!MD) return false; const CXXRecordDecl *LambdaClass = MD->getParent(); if (LambdaClass && LambdaClass->isGenericLambda()) - return isLambdaCallOperator(MD) && + return isLambdaCallOperator(MD) && MD->isFunctionTemplateSpecialization(); return false; } @@ -51,11 +51,11 @@ inline bool isLambdaConversionOperator(CXXConversionDecl *C) { inline bool isLambdaConversionOperator(Decl *D) { if (!D) return false; - if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) - return isLambdaConversionOperator(Conv); - if (FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(D)) - if (CXXConversionDecl *Conv = - dyn_cast_or_null<CXXConversionDecl>(F->getTemplatedDecl())) + if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) + return isLambdaConversionOperator(Conv); + if (FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(D)) + if (CXXConversionDecl *Conv = + dyn_cast_or_null<CXXConversionDecl>(F->getTemplatedDecl())) return isLambdaConversionOperator(Conv); return false; } @@ -71,7 +71,7 @@ inline bool isGenericLambdaCallOperatorSpecialization(DeclContext *DC) { inline DeclContext *getLambdaAwareParentOfDeclContext(DeclContext *DC) { if (isLambdaCallOperator(DC)) return DC->getParent()->getParent(); - else + else return DC->getParent(); } diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h index 31ae2b111e013..80184e1cc7402 100644 --- a/include/clang/AST/ASTMutationListener.h +++ b/include/clang/AST/ASTMutationListener.h @@ -134,13 +134,13 @@ public: /// \param M The containing module in which the definition was made visible, /// if any. virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {} - + /// An attribute was added to a RecordDecl /// /// \param Attr The attribute that was added to the Record /// /// \param Record The RecordDecl that got a new attribute - virtual void AddedAttributeToRecord(const Attr *Attr, + virtual void AddedAttributeToRecord(const Attr *Attr, const RecordDecl *Record) {} // NOTE: If new methods are added they should also be added to diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 32a61c59d2368..20922742f687b 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -86,7 +86,7 @@ public: attr::Kind getKind() const { return static_cast<attr::Kind>(AttrKind); } - + unsigned getSpellingListIndex() const { return SpellingListIndex; } const char *getSpelling() const; diff --git a/include/clang/AST/AttrIterator.h b/include/clang/AST/AttrIterator.h index 56807b4590d37..2087ecc0e70c7 100644 --- a/include/clang/AST/AttrIterator.h +++ b/include/clang/AST/AttrIterator.h @@ -106,7 +106,7 @@ public: specific_attr_iterator Right) { assert((Left.Current == nullptr) == (Right.Current == nullptr)); if (Left.Current < Right.Current) - Left.AdvanceToNext(Right.Current); + Left.AdvanceToNext(Right.Current); else Right.AdvanceToNext(Left.Current); return Left.Current == Right.Current; diff --git a/include/clang/AST/BaseSubobject.h b/include/clang/AST/BaseSubobject.h index fdb7e718fe9e4..2b702c76b2fab 100644 --- a/include/clang/AST/BaseSubobject.h +++ b/include/clang/AST/BaseSubobject.h @@ -24,21 +24,21 @@ namespace clang { class CXXRecordDecl; -// BaseSubobject - Uniquely identifies a direct or indirect base class. +// BaseSubobject - Uniquely identifies a direct or indirect base class. // Stores both the base class decl and the offset from the most derived class to // the base class. Used for vtable and VTT generation. class BaseSubobject { /// Base - The base class declaration. const CXXRecordDecl *Base; - + /// BaseOffset - The offset from the most derived class to the base class. CharUnits BaseOffset; - + public: BaseSubobject() = default; BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset) : Base(Base), BaseOffset(BaseOffset) {} - + /// getBase - Returns the base class declaration. const CXXRecordDecl *getBase() const { return Base; } @@ -74,7 +74,7 @@ template<> struct DenseMapInfo<clang::BaseSubobject> { Base.getBaseOffset())); } - static bool isEqual(const clang::BaseSubobject &LHS, + static bool isEqual(const clang::BaseSubobject &LHS, const clang::BaseSubobject &RHS) { return LHS == RHS; } diff --git a/include/clang/AST/CXXInheritance.h b/include/clang/AST/CXXInheritance.h index 2ae1d8b25823b..f5e23f8e8505d 100644 --- a/include/clang/AST/CXXInheritance.h +++ b/include/clang/AST/CXXInheritance.h @@ -34,10 +34,10 @@ namespace clang { class ASTContext; class NamedDecl; - + /// Represents an element in a path from a derived class to a -/// base class. -/// +/// base class. +/// /// Each step in the path references the link from a /// derived class to one of its direct base classes, along with a /// base "number" that identifies which base subobject of the @@ -47,12 +47,12 @@ struct CXXBasePathElement { /// class to a base class, which will be followed by this base /// path element. const CXXBaseSpecifier *Base; - + /// The record decl of the class that the base is a base of. const CXXRecordDecl *Class; - + /// Identifies which base class subobject (of type - /// \c Base->getType()) this base path element refers to. + /// \c Base->getType()) this base path element refers to. /// /// This value is only valid if \c !Base->isVirtual(), because there /// is no base numbering for the zero or one virtual bases of a @@ -64,7 +64,7 @@ struct CXXBasePathElement { /// (which is not represented as part of the path) to a particular /// (direct or indirect) base class subobject. /// -/// Individual elements in the path are described by the \c CXXBasePathElement +/// Individual elements in the path are described by the \c CXXBasePathElement /// structure, which captures both the link from a derived class to one of its /// direct bases and identification describing which base class /// subobject is being used. @@ -121,7 +121,7 @@ class CXXBasePaths { /// The type from which this search originated. CXXRecordDecl *Origin = nullptr; - + /// Paths - The actual set of paths that can be taken from the /// derived class to the same base class. std::list<CXXBasePath> Paths; @@ -160,12 +160,12 @@ class CXXBasePaths { /// ambiguous paths while it is looking for a path from a derived /// type to a base type. bool FindAmbiguities; - + /// RecordPaths - Whether Sema::IsDerivedFrom should record paths /// while it is determining whether there are paths from a derived /// type to a base type. bool RecordPaths; - + /// DetectVirtual - Whether Sema::IsDerivedFrom should abort the search /// if it finds a path that goes across a virtual base. The virtual class /// is also recorded. @@ -181,7 +181,7 @@ public: using paths_iterator = std::list<CXXBasePath>::iterator; using const_paths_iterator = std::list<CXXBasePath>::const_iterator; using decl_iterator = NamedDecl **; - + /// BasePaths - Construct a new BasePaths structure to record the /// paths for a derived-to-base search. explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true, @@ -193,31 +193,31 @@ public: paths_iterator end() { return Paths.end(); } const_paths_iterator begin() const { return Paths.begin(); } const_paths_iterator end() const { return Paths.end(); } - + CXXBasePath& front() { return Paths.front(); } const CXXBasePath& front() const { return Paths.front(); } - + using decl_range = llvm::iterator_range<decl_iterator>; decl_range found_decls(); - + /// Determine whether the path from the most-derived type to the /// given base type is ambiguous (i.e., it refers to multiple subobjects of /// the same base type). bool isAmbiguous(CanQualType BaseType); - + /// Whether we are finding multiple paths to detect ambiguities. bool isFindingAmbiguities() const { return FindAmbiguities; } - + /// Whether we are recording paths. bool isRecordingPaths() const { return RecordPaths; } - + /// Specify whether we should be recording paths or not. void setRecordingPaths(bool RP) { RecordPaths = RP; } - + /// Whether we are detecting virtual bases. bool isDetectingVirtual() const { return DetectVirtual; } - + /// The virtual base discovered on the path (if we are merely /// detecting virtuals). const RecordType* getDetectedVirtual() const { @@ -228,11 +228,11 @@ public: /// began CXXRecordDecl *getOrigin() const { return Origin; } void setOrigin(CXXRecordDecl *Rec) { Origin = Rec; } - + /// Clear the base-paths results. void clear(); - - /// Swap this data structure's contents with another CXXBasePaths + + /// Swap this data structure's contents with another CXXBasePaths /// object. void swap(CXXBasePaths &Other); }; diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h index 63a0af66eec37..0e738da43ad41 100644 --- a/include/clang/AST/CanonicalType.h +++ b/include/clang/AST/CanonicalType.h @@ -85,8 +85,8 @@ public: /// Retrieve the underlying type pointer, which refers to a /// canonical type, or nullptr. - const T *getTypePtrOrNull() const { - return cast_or_null<T>(Stored.getTypePtrOrNull()); + const T *getTypePtrOrNull() const { + return cast_or_null<T>(Stored.getTypePtrOrNull()); } /// Implicit conversion to a qualified type. @@ -94,7 +94,7 @@ public: /// Implicit conversion to bool. explicit operator bool() const { return !isNull(); } - + bool isNull() const { return Stored.isNull(); } diff --git a/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h index ddead6046a147..0aadf06fffc98 100644 --- a/include/clang/AST/CharUnits.h +++ b/include/clang/AST/CharUnits.h @@ -61,7 +61,7 @@ namespace clang { /// fromQuantity - Construct a CharUnits quantity from a raw integer type. static CharUnits fromQuantity(QuantityType Quantity) { - return CharUnits(Quantity); + return CharUnits(Quantity); } // Compound assignment. @@ -87,7 +87,7 @@ namespace clang { CharUnits operator-- (int) { return CharUnits(Quantity--); } - + // Comparison operators. bool operator== (const CharUnits &Other) const { return Quantity == Other.Quantity; @@ -97,21 +97,21 @@ namespace clang { } // Relational operators. - bool operator< (const CharUnits &Other) const { - return Quantity < Other.Quantity; + bool operator< (const CharUnits &Other) const { + return Quantity < Other.Quantity; } - bool operator<= (const CharUnits &Other) const { + bool operator<= (const CharUnits &Other) const { return Quantity <= Other.Quantity; } - bool operator> (const CharUnits &Other) const { - return Quantity > Other.Quantity; + bool operator> (const CharUnits &Other) const { + return Quantity > Other.Quantity; } - bool operator>= (const CharUnits &Other) const { - return Quantity >= Other.Quantity; + bool operator>= (const CharUnits &Other) const { + return Quantity >= Other.Quantity; } // Other predicates. - + /// isZero - Test whether the quantity equals zero. bool isZero() const { return Quantity == 0; } @@ -172,7 +172,7 @@ namespace clang { return CharUnits(-Quantity); } - + // Conversions. /// getQuantity - Get the raw integer representation of this quantity. @@ -205,7 +205,7 @@ namespace clang { }; // class CharUnit } // namespace clang -inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale, +inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU) { return CU * Scale; } @@ -223,8 +223,8 @@ template<> struct DenseMapInfo<clang::CharUnits> { static clang::CharUnits getTombstoneKey() { clang::CharUnits::QuantityType Quantity = DenseMapInfo<clang::CharUnits::QuantityType>::getTombstoneKey(); - - return clang::CharUnits::fromQuantity(Quantity); + + return clang::CharUnits::fromQuantity(Quantity); } static unsigned getHashValue(const clang::CharUnits &CU) { @@ -232,7 +232,7 @@ template<> struct DenseMapInfo<clang::CharUnits> { return DenseMapInfo<clang::CharUnits::QuantityType>::getHashValue(Quantity); } - static bool isEqual(const clang::CharUnits &LHS, + static bool isEqual(const clang::CharUnits &LHS, const clang::CharUnits &RHS) { return LHS == RHS; } @@ -241,7 +241,7 @@ template<> struct DenseMapInfo<clang::CharUnits> { template <> struct isPodLike<clang::CharUnits> { static const bool value = true; }; - + } // end namespace llvm #endif // LLVM_CLANG_AST_CHARUNITS_H diff --git a/include/clang/AST/Comment.h b/include/clang/AST/Comment.h index e3a427d8aa0d8..f5538dec2a142 100644 --- a/include/clang/AST/Comment.h +++ b/include/clang/AST/Comment.h @@ -98,7 +98,7 @@ protected: unsigned RenderKind : 2; unsigned CommandID : CommandInfo::NumCommandIDBits; }; - enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 + + enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 + CommandInfo::NumCommandIDBits }; class HTMLTagCommentBitfields { @@ -146,7 +146,7 @@ protected: /// Contains values from CommandMarkerKind enum. unsigned CommandMarker : 1; }; - enum { NumBlockCommandCommentBits = NumCommentBits + + enum { NumBlockCommandCommentBits = NumCommentBits + CommandInfo::NumCommandIDBits + 1 }; class ParamCommandCommentBitfields { @@ -987,7 +987,7 @@ struct DeclInfo { /// Declaration the comment is actually attached to (in the source). /// Should not be NULL. const Decl *CommentDecl; - + /// CurrentDecl is the declaration with which the FullComment is associated. /// /// It can be different from \c CommentDecl. It happens when we decide @@ -997,7 +997,7 @@ struct DeclInfo { /// /// The information in the DeclInfo corresponds to CurrentDecl. const Decl *CurrentDecl; - + /// Parameters that can be referenced by \\param if \c CommentDecl is something /// that we consider a "function". ArrayRef<const ParmVarDecl *> ParamVars; @@ -1119,21 +1119,21 @@ public: } child_iterator child_end() const { - return reinterpret_cast<child_iterator>(Blocks.end()); + return reinterpret_cast<child_iterator>(Blocks.end()); } const Decl *getDecl() const LLVM_READONLY { return ThisDeclInfo->CommentDecl; } - + const DeclInfo *getDeclInfo() const LLVM_READONLY { if (!ThisDeclInfo->IsFilled) ThisDeclInfo->fill(); return ThisDeclInfo; } - + ArrayRef<BlockContentComment *> getBlocks() const { return Blocks; } - + }; } // end namespace comments } // end namespace clang diff --git a/include/clang/AST/CommentCommandTraits.h b/include/clang/AST/CommentCommandTraits.h index bac4e99dc7a4c..4fd007872c013 100644 --- a/include/clang/AST/CommentCommandTraits.h +++ b/include/clang/AST/CommentCommandTraits.h @@ -107,17 +107,17 @@ struct CommandInfo { /// \fn void f(int a); /// \endcode unsigned IsDeclarationCommand : 1; - + /// True if verbatim-like line command is a function declaration. unsigned IsFunctionDeclarationCommand : 1; /// True if block command is further describing a container API; such /// as \@coclass, \@classdesign, etc. unsigned IsRecordLikeDetailCommand : 1; - + /// True if block command is a container API; such as \@interface. unsigned IsRecordLikeDeclarationCommand : 1; - + /// True if this command is unknown. This \c CommandInfo object was /// created during parsing. unsigned IsUnknownCommand : 1; @@ -150,7 +150,7 @@ public: } const CommandInfo *getTypoCorrectCommandInfo(StringRef Typo) const; - + const CommandInfo *getCommandInfo(unsigned CommandID) const; const CommandInfo *registerUnknownCommand(StringRef CommandName); diff --git a/include/clang/AST/CommentLexer.h b/include/clang/AST/CommentLexer.h index 52c4eb9e309a1..3ef5b7c8c998c 100644 --- a/include/clang/AST/CommentLexer.h +++ b/include/clang/AST/CommentLexer.h @@ -76,7 +76,7 @@ class Token { /// unused (command spelling can be found with CommandTraits). Otherwise, /// contains the length of the string that starts at TextPtr. unsigned IntVal; - + public: SourceLocation getLocation() const LLVM_READONLY { return Loc; } void setLocation(SourceLocation SL) { Loc = SL; } @@ -228,7 +228,7 @@ private: llvm::BumpPtrAllocator &Allocator; DiagnosticsEngine &Diags; - + const CommandTraits &Traits; const char *const BufferStart; diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h index 0e94c33970caf..632eba782b924 100644 --- a/include/clang/AST/CommentSema.h +++ b/include/clang/AST/CommentSema.h @@ -191,11 +191,11 @@ public: void checkBlockCommandDuplicate(const BlockCommandComment *Command); void checkDeprecatedCommand(const BlockCommandComment *Comment); - + void checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment); - + void checkContainerDeclVerbatimLine(const BlockCommandComment *Comment); - + void checkContainerDecl(const BlockCommandComment *Comment); /// Resolve parameter names to parameter indexes in function declaration. diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index dde94599636f0..ebdb2890daf5d 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -98,7 +98,7 @@ public: /// Return the TypeLoc wrapper for the type source info. TypeLoc getTypeLoc() const; // implemented in TypeLoc.h - + /// Override the type stored in this TypeSourceInfo. Use with caution! void overrideType(QualType T) { Ty = T; } }; @@ -488,7 +488,7 @@ public: SourceLocation IdentL, IdentifierInfo *II, SourceLocation GnuLabelL); static LabelDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + LabelStmt *getStmt() const { return TheStmt; } void setStmt(LabelStmt *T) { TheStmt = T; } @@ -511,8 +511,8 @@ public: }; /// Represent a C++ namespace. -class NamespaceDecl : public NamedDecl, public DeclContext, - public Redeclarable<NamespaceDecl> +class NamespaceDecl : public NamedDecl, public DeclContext, + public Redeclarable<NamespaceDecl> { /// The starting location of the source range, pointing /// to either the namespace or the inline keyword. @@ -523,7 +523,7 @@ class NamespaceDecl : public NamedDecl, public DeclContext, /// A pointer to either the anonymous namespace that lives just inside /// this namespace or to the first namespace in the chain (the latter case - /// only when this is not the first in the chain), along with a + /// only when this is not the first in the chain), along with a /// boolean value indicating whether this is an inline namespace. llvm::PointerIntPair<NamespaceDecl *, 1, bool> AnonOrFirstNamespaceAndInline; @@ -1931,7 +1931,7 @@ public: bool isConstexprSpecified = false); static FunctionDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + DeclarationNameInfo getNameInfo() const { return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc); } @@ -2598,7 +2598,7 @@ public: InClassInitStyle InitStyle); static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// Returns the index of this field within its record, /// as appropriate for passing to ASTRecordLayout::getFieldOffset. unsigned getFieldIndex() const; @@ -2754,7 +2754,7 @@ public: QualType T, Expr *E, const llvm::APSInt &V); static EnumConstantDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + const Expr *getInitExpr() const { return (const Expr*) Init; } Expr *getInitExpr() { return (Expr*) Init; } const llvm::APSInt &getInitVal() const { return Val; } @@ -3812,7 +3812,7 @@ public: /// Finds the first data member which has a name. /// nullptr is returned if no named data member exists. - const FieldDecl *findFirstNamedDataMember() const; + const FieldDecl *findFirstNamedDataMember() const; private: /// Deserialize just the fields. @@ -3835,7 +3835,7 @@ public: SourceLocation RParenLoc); static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + SourceLocation getAsmLoc() const { return getLocation(); } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } @@ -3927,9 +3927,9 @@ protected: IsConversionFromLambda(false), DoesNotEscape(false) {} public: - static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); + static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); static BlockDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + SourceLocation getCaretLocation() const { return getLocation(); } bool isVariadic() const { return IsVariadic; } @@ -4009,7 +4009,7 @@ public: } Decl *getBlockManglingContextDecl() const { - return ManglingContextDecl; + return ManglingContextDecl; } void setBlockMangling(unsigned Number, Decl *Ctx) { @@ -4145,16 +4145,16 @@ class ImportDecl final : public Decl, /// The imported module, along with a bit that indicates whether /// we have source-location information for each identifier in the module - /// name. + /// name. /// /// When the bit is false, we only have a single source location for the /// end of the import declaration. llvm::PointerIntPair<Module *, 1, bool> ImportedAndComplete; - + /// The next import in the list of imports local to the translation /// unit being parsed (not loaded from an AST file). ImportDecl *NextLocalImport = nullptr; - + ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef<SourceLocation> IdentifierLocs); @@ -4162,26 +4162,26 @@ class ImportDecl final : public Decl, SourceLocation EndLoc); ImportDecl(EmptyShell Empty) : Decl(Import, Empty) {} - + public: /// Create a new module import declaration. - static ImportDecl *Create(ASTContext &C, DeclContext *DC, + static ImportDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef<SourceLocation> IdentifierLocs); - + /// Create a new module import declaration for an implicitly-generated /// import. - static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC, - SourceLocation StartLoc, Module *Imported, + static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC, + SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc); - + /// Create a new, deserialized module import declaration. - static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, + static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations); - + /// Retrieve the module that was imported by the import declaration. Module *getImportedModule() const { return ImportedAndComplete.getPointer(); } - + /// Retrieves the locations of each of the identifiers that make up /// the complete module name in the import declaration. /// @@ -4218,7 +4218,7 @@ 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; } diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index f99bd627877c5..d6b89d971d940 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -302,7 +302,7 @@ private: /// global variable, etc.) that is lexically inside an objc container /// definition. unsigned TopLevelDeclInObjCContainer : 1; - + /// Whether statistic collection is enabled. static bool StatisticsEnabled; @@ -629,7 +629,7 @@ protected: assert(isFromASTFile() && "Only works on a deserialized declaration"); *((unsigned*)this - 2) = ID; } - + public: /// Determine the availability of the given declaration. /// @@ -879,7 +879,7 @@ public: /// Whether this particular Decl is a canonical one. bool isCanonicalDecl() const { return getCanonicalDecl() == this; } - + protected: /// Returns the next redeclaration or itself if this is the only decl. /// @@ -956,10 +956,10 @@ public: /// Retrieve the previous declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. Decl *getPreviousDecl() { return getPreviousDeclImpl(); } - + /// Retrieve the most recent declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. - const Decl *getPreviousDecl() const { + const Decl *getPreviousDecl() const { return const_cast<Decl *>(this)->getPreviousDeclImpl(); } @@ -974,7 +974,7 @@ public: /// Retrieve the most recent declaration that declares the same entity /// as this declaration (which may be this declaration). - const Decl *getMostRecentDecl() const { + const Decl *getMostRecentDecl() const { return const_cast<Decl *>(this)->getMostRecentDeclImpl(); } @@ -1159,13 +1159,13 @@ protected: inline bool declaresSameEntity(const Decl *D1, const Decl *D2) { if (!D1 || !D2) return false; - + if (D1 == D2) return true; - + return D1->getCanonicalDecl() == D2->getCanonicalDecl(); } - + /// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when /// doing something to a specific decl. class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry { @@ -1517,7 +1517,7 @@ public: /// connected to this declaration context. /// /// For declaration contexts that have multiple semantically connected but - /// syntactically distinct contexts, such as C++ namespaces, this routine + /// syntactically distinct contexts, such as C++ namespaces, this routine /// retrieves the complete set of such declaration contexts in source order. /// For example, given: /// @@ -1921,7 +1921,7 @@ public: /// Determine whether the given declaration is stored in the list of /// declarations lexically within this context. bool isDeclInLexicalTraversal(const Decl *D) const { - return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl || + return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl || D == LastDecl); } diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 1d0489912c6bd..4353f66a34e43 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -264,7 +264,7 @@ public: return EllipsisLoc; } - /// Returns the access specifier for this base specifier. + /// Returns the access specifier for this base specifier. /// /// This is the actual base specifier as used for semantic analysis, so /// the result can never be AS_none. To retrieve the access specifier as @@ -564,7 +564,7 @@ class CXXRecordDecl : public RecordDecl { CXXRecordDecl *Definition; /// The first friend declaration in this class, or null if there - /// aren't any. + /// aren't any. /// /// This is actually currently stored in reverse order. LazyDeclPtr FirstFriend; @@ -606,14 +606,14 @@ class CXXRecordDecl : public RecordDecl { /// Whether this lambda is known to be dependent, even if its /// context isn't dependent. - /// + /// /// A lambda with a non-dependent context can be dependent if it occurs /// within the default argument of a function template, because the /// lambda will have been created with the enclosing context as its /// declaration context, rather than function. This is an unfortunate - /// artifact of having to parse the default arguments before. + /// artifact of having to parse the default arguments before. unsigned Dependent : 1; - + /// Whether this lambda is a generic lambda. unsigned IsGenericLambda : 1; @@ -626,28 +626,28 @@ class CXXRecordDecl : public RecordDecl { /// The number of explicit captures in this lambda. unsigned NumExplicitCaptures : 13; - /// The number used to indicate this lambda expression for name + /// The number used to indicate this lambda expression for name /// mangling in the Itanium C++ ABI. unsigned ManglingNumber = 0; - + /// The declaration that provides context for this lambda, if the /// 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. LazyDeclPtr ContextDecl; - - /// The list of captures, both explicit and implicit, for this + + /// The list of captures, both explicit and implicit, for this /// lambda. Capture *Captures = nullptr; /// The type of the call method. TypeSourceInfo *MethodTyInfo; - LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, - bool Dependent, bool IsGeneric, - LambdaCaptureDefault CaptureDefault) - : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric), - CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0), + LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, + bool Dependent, bool IsGeneric, + LambdaCaptureDefault CaptureDefault) + : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric), + CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0), MethodTyInfo(Info) { IsLambda = true; @@ -1205,22 +1205,22 @@ public: return DD && DD->IsLambda; } - /// Determine whether this class describes a generic + /// Determine whether this class describes a generic /// lambda function object (i.e. function call operator is - /// a template). - bool isGenericLambda() const; + /// a template). + bool isGenericLambda() const; /// Retrieve the lambda call operator of the closure type /// if this is a closure type. - CXXMethodDecl *getLambdaCallOperator() const; + CXXMethodDecl *getLambdaCallOperator() const; /// Retrieve the lambda static invoker, the address of which /// is returned by the conversion operator, and the body of which - /// is forwarded to the lambda call operator. - CXXMethodDecl *getLambdaStaticInvoker() const; + /// is forwarded to the lambda call operator. + CXXMethodDecl *getLambdaStaticInvoker() const; /// Retrieve the generic lambda's template parameter list. - /// Returns null if the class does not represent a lambda or a generic + /// Returns null if the class does not represent a lambda or a generic /// lambda. TemplateParameterList *getGenericLambdaTemplateParameterList() const; @@ -1345,11 +1345,11 @@ public: /// not overridden. bool isAbstract() const { return data().Abstract; } - /// Determine whether this class is standard-layout per + /// Determine whether this class is standard-layout per /// C++ [class]p7. bool isStandardLayout() const { return data().IsStandardLayout; } - /// Determine whether this class was standard-layout per + /// Determine whether this class was standard-layout per /// C++11 [class]p7, specifically using the C++11 rules without any DRs. bool isCXX11StandardLayout() const { return data().IsCXX11StandardLayout; } @@ -1900,25 +1900,25 @@ public: /// If this is the closure type of a lambda expression, retrieve the /// number to be used for name mangling in the Itanium C++ ABI. /// - /// Zero indicates that this closure type has internal linkage, so the + /// Zero indicates that this closure type has internal linkage, so the /// mangling number does not matter, while a non-zero value indicates which /// lambda expression this is in this particular context. unsigned getLambdaManglingNumber() const { assert(isLambda() && "Not a lambda closure type!"); return getLambdaData().ManglingNumber; } - - /// Retrieve the declaration that provides additional context for a + + /// Retrieve the declaration that provides additional context for a /// lambda, when the normal declaration context is not specific enough. /// - /// Certain contexts (default arguments of in-class function parameters and + /// Certain contexts (default arguments of in-class function parameters and /// the initializers of data members) have separate name mangling rules for /// lambdas within the Itanium C++ ABI. For these cases, this routine provides - /// the declaration in which the lambda occurs, e.g., the function parameter + /// 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; - + /// Set the mangling number and context declaration for a lambda /// class. void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl) { @@ -2799,7 +2799,7 @@ public: /// Determine whether this conversion function is a conversion from /// a lambda closure type to a block pointer. bool isLambdaToBlockPointerConversion() const; - + CXXConversionDecl *getCanonicalDecl() override { return cast<CXXConversionDecl>(FunctionDecl::getCanonicalDecl()); } @@ -2812,7 +2812,7 @@ public: static bool classofKind(Kind K) { return K == CXXConversion; } }; -/// Represents a linkage specification. +/// Represents a linkage specification. /// /// For example: /// \code @@ -2862,7 +2862,7 @@ public: SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces); static LinkageSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// Return the language specified by this linkage specification. LanguageIDs getLanguage() const { return LanguageIDs(Language); } @@ -3770,7 +3770,7 @@ public: Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed); static StaticAssertDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + Expr *getAssertExpr() { return AssertExprAndFailed.getPointer(); } const Expr *getAssertExpr() const { return AssertExprAndFailed.getPointer(); } diff --git a/include/clang/AST/DeclFriend.h b/include/clang/AST/DeclFriend.h index 47fb68bf42d3e..a8de8ed168403 100644 --- a/include/clang/AST/DeclFriend.h +++ b/include/clang/AST/DeclFriend.h @@ -254,7 +254,7 @@ inline void CXXRecordDecl::pushFriendDecl(FriendDecl *FD) { FD->NextFriend = data().FirstFriend; data().FirstFriend = FD; } - + } // namespace clang #endif // LLVM_CLANG_AST_DECLFRIEND_H diff --git a/include/clang/AST/DeclLookups.h b/include/clang/AST/DeclLookups.h index 64eb3f24b3701..9627f440d406c 100644 --- a/include/clang/AST/DeclLookups.h +++ b/include/clang/AST/DeclLookups.h @@ -54,7 +54,7 @@ public: ++It; } while (It != End && It->first == DeclarationName::getUsingDirectiveName()); - + return *this; } diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index c81a5f805fc03..c1cc726e31521 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -587,7 +587,7 @@ class ObjCTypeParamDecl : public TypedefNameDecl { /// explicitly specified. SourceLocation ColonLoc; - ObjCTypeParamDecl(ASTContext &ctx, DeclContext *dc, + ObjCTypeParamDecl(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, @@ -659,7 +659,7 @@ class ObjCTypeParamList final unsigned End; }; - union { + union { /// Location of the left and right angle brackets. PODSourceRange Brackets; @@ -1123,7 +1123,7 @@ public: ObjCPropertyDecl *>; using ProtocolPropertySet = llvm::SmallDenseSet<const ObjCProtocolDecl *, 8>; using PropertyDeclOrder = llvm::SmallVector<ObjCPropertyDecl *, 8>; - + /// This routine collects list of properties to be implemented in the class. /// This includes, class's and its conforming protocols' properties. /// Note, the superclass's properties are not included in the list. @@ -1195,15 +1195,15 @@ class ObjCInterfaceDecl : public ObjCContainerDecl /// TypeForDecl - This indicates the Type object that represents this /// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType mutable const Type *TypeForDecl = nullptr; - + struct DefinitionData { - /// The definition of this class, for quick access from any + /// The definition of this class, for quick access from any /// declaration. ObjCInterfaceDecl *Definition = nullptr; - + /// When non-null, this is always an ObjCObjectType. TypeSourceInfo *SuperClassTInfo = nullptr; - + /// Protocols referenced in the \@interface declaration ObjCProtocolList ReferencedProtocols; @@ -1247,11 +1247,11 @@ class ObjCInterfaceDecl : public ObjCContainerDecl /// One of the \c InheritedDesignatedInitializersState enumeratos. mutable unsigned InheritedDesignatedInitializers : 2; - + /// The location of the last location in this declaration, before - /// the properties/methods. For example, this will be the '>', '}', or - /// identifier, - SourceLocation EndLoc; + /// the properties/methods. For example, this will be the '>', '}', or + /// identifier, + SourceLocation EndLoc; DefinitionData() : ExternallyCompleted(false), IvarListMissingImplementation(true), @@ -1285,7 +1285,7 @@ class ObjCInterfaceDecl : public ObjCContainerDecl /// Allocate the definition data for this class. void allocateDefinitionData(); - + using redeclarable_base = Redeclarable<ObjCInterfaceDecl>; ObjCInterfaceDecl *getNextRedeclarationImpl() override { @@ -1334,7 +1334,7 @@ public: SourceRange getSourceRange() const override LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); - + return SourceRange(getAtStartLoc(), getLocation()); } @@ -1390,7 +1390,7 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return protocol_iterator(); - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1453,7 +1453,7 @@ public: if (data().ExternallyCompleted) LoadExternalDefinition(); - return data().AllReferencedProtocols.empty() + return data().AllReferencedProtocols.empty() ? protocol_begin() : data().AllReferencedProtocols.begin(); } @@ -1462,11 +1462,11 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return all_protocol_iterator(); - + if (data().ExternallyCompleted) LoadExternalDefinition(); - return data().AllReferencedProtocols.empty() + return data().AllReferencedProtocols.empty() ? protocol_end() : data().AllReferencedProtocols.end(); } @@ -1476,17 +1476,17 @@ public: ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); } - ivar_iterator ivar_begin() const { + ivar_iterator ivar_begin() const { if (const ObjCInterfaceDecl *Def = getDefinition()) - return ivar_iterator(Def->decls_begin()); - + return ivar_iterator(Def->decls_begin()); + // FIXME: Should make sure no callers ever do this. return ivar_iterator(); } - ivar_iterator ivar_end() const { + ivar_iterator ivar_end() const { if (const ObjCInterfaceDecl *Def = getDefinition()) - return ivar_iterator(Def->decls_end()); + return ivar_iterator(Def->decls_end()); // FIXME: Should make sure no callers ever do this. return ivar_iterator(); @@ -1546,10 +1546,10 @@ public: /// Determine whether this particular declaration of this class is /// actually also a definition. - bool isThisDeclarationADefinition() const { + bool isThisDeclarationADefinition() const { return getDefinition() == this; } - + /// Determine whether this class has been defined. bool hasDefinition() const { // If the name of this class is out-of-date, bring it up-to-date, which @@ -1561,16 +1561,16 @@ public: return Data.getPointer(); } - - /// Retrieve the definition of this class, or NULL if this class - /// has been forward-declared (with \@class) but not yet defined (with + + /// Retrieve the definition of this class, or NULL if this class + /// has been forward-declared (with \@class) but not yet defined (with /// \@interface). ObjCInterfaceDecl *getDefinition() { return hasDefinition()? Data.getPointer()->Definition : nullptr; } - /// Retrieve the definition of this class, or NULL if this class - /// has been forward-declared (with \@class) but not yet defined (with + /// Retrieve the definition of this class, or NULL if this class + /// has been forward-declared (with \@class) but not yet defined (with /// \@interface). const ObjCInterfaceDecl *getDefinition() const { return hasDefinition()? Data.getPointer()->Definition : nullptr; @@ -1579,7 +1579,7 @@ public: /// Starts the definition of this Objective-C class, taking it from /// a forward declaration (\@class) to a definition (\@interface). void startDefinition(); - + /// Retrieve the superclass type. const ObjCObjectType *getSuperClassType() const { if (TypeSourceInfo *TInfo = getSuperClassTInfo()) @@ -1593,7 +1593,7 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return nullptr; - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1604,7 +1604,7 @@ public: // does not include any type arguments that apply to the superclass. ObjCInterfaceDecl *getSuperClass() const; - void setSuperClass(TypeSourceInfo *superClass) { + void setSuperClass(TypeSourceInfo *superClass) { data().SuperClassTInfo = superClass; } @@ -1618,7 +1618,7 @@ public: ObjCCategoryDecl *Current = nullptr; void findAcceptableCategory(); - + public: using value_type = ObjCCategoryDecl *; using reference = value_type; @@ -1659,7 +1659,7 @@ private: /// /// Used in the \c visible_categories_iterator. static bool isVisibleCategory(ObjCCategoryDecl *Cat); - + public: /// Iterator that walks over the list of categories and extensions /// that are visible, i.e., not hidden in a non-imported submodule. @@ -1765,7 +1765,7 @@ private: /// /// Used in the \c known_extensions_iterator. static bool isKnownExtension(ObjCCategoryDecl *Cat); - + public: friend class ASTDeclReader; friend class ASTDeclWriter; @@ -1787,7 +1787,7 @@ public: known_extensions_iterator known_extensions_begin() const { return known_extensions_iterator(getCategoryListRaw()); } - + /// Retrieve an iterator to the end of the known-extensions list. known_extensions_iterator known_extensions_end() const { return known_extensions_iterator(); @@ -1804,7 +1804,7 @@ public: // FIXME: Should make sure no callers ever do this. if (!hasDefinition()) return nullptr; - + if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1831,7 +1831,7 @@ public: while (I != nullptr) { if (declaresSameEntity(this, I)) return true; - + I = I->getSuperClass(); } return false; @@ -1841,7 +1841,7 @@ public: /// to be incompatible with __weak references. Returns true if it is. bool isArcWeakrefUnavailable() const; - /// isObjCRequiresPropertyDefs - Checks that a class or one of its super + /// isObjCRequiresPropertyDefs - Checks that a class or one of its super /// classes must not be auto-synthesized. Returns class decl. if it must not /// be; 0, otherwise. const ObjCInterfaceDecl *isObjCRequiresPropertyDefs() const; @@ -1854,7 +1854,7 @@ public: } ObjCProtocolDecl *lookupNestedProtocol(IdentifierInfo *Name); - + // Lookup a method. First, we search locally. If a method isn't // found, we search referenced protocols and class categories. ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance, @@ -1893,14 +1893,14 @@ public: true /* followsSuper */, Cat); } - - SourceLocation getEndOfDefinitionLoc() const { + + SourceLocation getEndOfDefinitionLoc() const { if (!hasDefinition()) return getLocation(); - - return data().EndLoc; + + return data().EndLoc; } - + void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; } /// Retrieve the starting location of the superclass. @@ -1909,7 +1909,7 @@ public: /// isImplicitInterfaceDecl - check that this is an implicitly declared /// ObjCInterfaceDecl node. This is for legacy objective-c \@implementation /// declaration without an \@interface declaration. - bool isImplicitInterfaceDecl() const { + bool isImplicitInterfaceDecl() const { return hasDefinition() ? data().Definition->isImplicit() : isImplicit(); } @@ -1987,7 +1987,7 @@ public: bool synthesized=false); static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// Return the class interface that this ivar is logically contained /// in; this is either the interface where the ivar was declared, or the /// interface the ivar is conceptually a part of in the case of synthesized @@ -2045,7 +2045,7 @@ public: QualType T, Expr *BW); static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ObjCAtDefsField; } @@ -2087,7 +2087,7 @@ class ObjCProtocolDecl : public ObjCContainerDecl, ObjCProtocolDecl *Definition; /// Referenced protocols - ObjCProtocolList ReferencedProtocols; + ObjCProtocolList ReferencedProtocols; }; /// Contains a pointer to the data associated with this class, @@ -2107,7 +2107,7 @@ class ObjCProtocolDecl : public ObjCContainerDecl, assert(Data.getPointer() && "Objective-C protocol has no definition!"); return *Data.getPointer(); } - + void allocateDefinitionData(); using redeclarable_base = Redeclarable<ObjCProtocolDecl>; @@ -2152,15 +2152,15 @@ public: protocol_iterator protocol_begin() const { if (!hasDefinition()) return protocol_iterator(); - + return data().ReferencedProtocols.begin(); } - protocol_iterator protocol_end() const { + protocol_iterator protocol_end() const { if (!hasDefinition()) return protocol_iterator(); - - return data().ReferencedProtocols.end(); + + return data().ReferencedProtocols.end(); } using protocol_loc_iterator = ObjCProtocolList::loc_iterator; @@ -2173,22 +2173,22 @@ public: protocol_loc_iterator protocol_loc_begin() const { if (!hasDefinition()) return protocol_loc_iterator(); - + return data().ReferencedProtocols.loc_begin(); } protocol_loc_iterator protocol_loc_end() const { if (!hasDefinition()) return protocol_loc_iterator(); - + return data().ReferencedProtocols.loc_end(); } - unsigned protocol_size() const { + unsigned protocol_size() const { if (!hasDefinition()) return 0; - - return data().ReferencedProtocols.size(); + + return data().ReferencedProtocols.size(); } /// setProtocolList - Set the list of protocols that this interface @@ -2235,12 +2235,12 @@ public: return hasDefinition()? Data.getPointer()->Definition : nullptr; } - /// Determine whether this particular declaration is also the + /// Determine whether this particular declaration is also the /// definition. bool isThisDeclarationADefinition() const { return getDefinition() == this; } - + /// Starts the definition of this Objective-C protocol. void startDefinition(); @@ -2251,10 +2251,10 @@ public: SourceRange getSourceRange() const override LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); - + return SourceRange(getAtStartLoc(), getLocation()); } - + using redecl_range = redeclarable_base::redecl_range; using redecl_iterator = redeclarable_base::redecl_iterator; @@ -2316,7 +2316,7 @@ class ObjCCategoryDecl : public ObjCContainerDecl { /// class extension may have private ivars. SourceLocation IvarLBraceLoc; SourceLocation IvarRBraceLoc; - + ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, @@ -2431,7 +2431,7 @@ public: SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; } - + void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; } SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } @@ -2576,7 +2576,7 @@ class ObjCImplementationDecl : public ObjCImplDecl { /// \@implementation may have private ivars. SourceLocation IvarLBraceLoc; SourceLocation IvarRBraceLoc; - + /// Support for ivar initialization. /// The arguments used to initialize the ivars LazyCXXCtorInitializersPtr IvarInitializers; @@ -2594,7 +2594,7 @@ class ObjCImplementationDecl : public ObjCImplDecl { ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc = SourceLocation(), - SourceLocation IvarLBraceLoc=SourceLocation(), + SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation()) : ObjCImplDecl(ObjCImplementation, DC, classInterface, classInterface ? classInterface->getIdentifier() @@ -2616,7 +2616,7 @@ public: SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc = SourceLocation(), - SourceLocation IvarLBraceLoc=SourceLocation(), + SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation()); static ObjCImplementationDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -2700,7 +2700,7 @@ public: std::string getNameAsString() const { return getName(); } - + /// Produce a name to be used for class's metadata. It comes either via /// class's objc_runtime_name attribute or class name. StringRef getObjCRuntimeNameAsString() const; @@ -2715,7 +2715,7 @@ public: SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; } - + using ivar_iterator = specific_decl_iterator<ObjCIvarDecl>; using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>; @@ -2760,9 +2760,9 @@ public: SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl* aliasedClass); - static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, + static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index a2f00ec9ffa22..e0ea7cb8b1b83 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -734,8 +734,8 @@ public: }; /// Declaration of a redeclarable template. -class RedeclarableTemplateDecl : public TemplateDecl, - public Redeclarable<RedeclarableTemplateDecl> +class RedeclarableTemplateDecl : public TemplateDecl, + public Redeclarable<RedeclarableTemplateDecl> { using redeclarable_base = Redeclarable<RedeclarableTemplateDecl>; @@ -823,7 +823,7 @@ protected: /// Pointer to the common data shared by all declarations of this /// template. mutable CommonBase *Common = nullptr; - + /// Retrieves the "common" pointer shared by all (re-)declarations of /// the same template. Calling this routine may implicitly allocate memory /// for the common pointer. @@ -888,10 +888,10 @@ public: } /// Retrieve the member template from which this template was - /// instantiated, or nullptr if this template was not instantiated from a + /// instantiated, or nullptr if this template was not instantiated from a /// member template. /// - /// A template is instantiated from a member template when the member + /// A template is instantiated from a member template when the member /// template itself is part of a class template (or member thereof). For /// example, given /// @@ -1178,7 +1178,7 @@ public: unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack); - static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C, + static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C, unsigned ID); /// Whether this template type parameter was declared with @@ -1312,12 +1312,12 @@ public: QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos); - static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, + static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, unsigned ID); - static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, + static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpandedTypes); - + using TemplateParmPosition::getDepth; using TemplateParmPosition::setDepth; using TemplateParmPosition::getPosition; @@ -1495,7 +1495,7 @@ public: static TemplateTemplateParmDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions); - + using TemplateParmPosition::getDepth; using TemplateParmPosition::setDepth; using TemplateParmPosition::getPosition; @@ -2442,7 +2442,7 @@ public: static ClassScopeFunctionSpecializationDecl * CreateDeserialized(ASTContext &Context, unsigned ID); - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index 9d3dad6bbd9d2..856f3ab5720e3 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -211,14 +211,14 @@ public: /// getNameKind - Determine what kind of name this is. NameKind getNameKind() const; - /// Determines whether the name itself is dependent, e.g., because it + /// Determines whether the name itself is dependent, e.g., because it /// involves a C++ type that is itself dependent. /// /// Note that this does not capture all of the notions of "dependent name", - /// because an identifier can be a dependent name if it is used as the + /// because an identifier can be a dependent name if it is used as the /// callee in a call expression with dependent arguments. bool isDependentName() const; - + /// getNameAsString - Retrieve the human-readable string for this name. std::string getAsString() const; @@ -543,7 +543,7 @@ public: /// Determine whether this name involves a template parameter. bool isInstantiationDependent() const; - + /// Determine whether this name contains an unexpanded /// parameter pack. bool containsUnexpandedParameterPack() const; @@ -558,7 +558,7 @@ public: SourceLocation getBeginLoc() const { return NameLoc; } /// getEndLoc - Retrieve the location of the last token. - SourceLocation getEndLoc() const; + SourceLocation getEndLoc() const { return getLocEnd(); } /// getSourceRange - The range of the declaration name. SourceRange getSourceRange() const LLVM_READONLY { @@ -570,9 +570,11 @@ public: } SourceLocation getLocEnd() const LLVM_READONLY { - SourceLocation EndLoc = getEndLoc(); + SourceLocation EndLoc = getEndLocPrivate(); return EndLoc.isValid() ? EndLoc : getLocStart(); } +private: + SourceLocation getEndLocPrivate() const; }; /// Insertion operator for diagnostics. This allows sending DeclarationName's diff --git a/include/clang/AST/DependentDiagnostic.h b/include/clang/AST/DependentDiagnostic.h index a514326c6cb10..c21ef7907b8ae 100644 --- a/include/clang/AST/DependentDiagnostic.h +++ b/include/clang/AST/DependentDiagnostic.h @@ -101,9 +101,9 @@ private: friend class DependentStoredDeclsMap; DependentDiagnostic(const PartialDiagnostic &PDiag, - PartialDiagnostic::Storage *Storage) + PartialDiagnostic::Storage *Storage) : Diag(PDiag, Storage) {} - + static DependentDiagnostic *Create(ASTContext &Context, DeclContext *Parent, const PartialDiagnostic &PDiag); diff --git a/include/clang/AST/EvaluatedExprVisitor.h b/include/clang/AST/EvaluatedExprVisitor.h index e00986dbe9c86..1aec5ae842d48 100644 --- a/include/clang/AST/EvaluatedExprVisitor.h +++ b/include/clang/AST/EvaluatedExprVisitor.h @@ -21,9 +21,9 @@ #include "clang/AST/StmtVisitor.h" namespace clang { - + class ASTContext; - + /// Given a potentially-evaluated expression, this visitor visits all /// of its potentially-evaluated subexpressions, recursively. template<template <typename> class Ptr, typename ImplClass> diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 7585231e62e5c..c18fbf05df683 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -884,7 +884,7 @@ public: : Expr(OpaqueValueExprClass, T, VK, OK, T->isDependentType() || (SourceExpr && SourceExpr->isTypeDependent()), - T->isDependentType() || + T->isDependentType() || (SourceExpr && SourceExpr->isValueDependent()), T->isInstantiationDependentType() || (SourceExpr && SourceExpr->isInstantiationDependent()), @@ -2787,20 +2787,26 @@ public: /// representation in the source code (ExplicitCastExpr's derived /// classes). class CastExpr : public Expr { +public: + using BasePathSizeTy = unsigned int; + static_assert(std::numeric_limits<BasePathSizeTy>::max() >= 16384, + "[implimits] Direct and indirect base classes [16384]."); + private: Stmt *Op; bool CastConsistency() const; + BasePathSizeTy *BasePathSize(); + const CXXBaseSpecifier * const *path_buffer() const { return const_cast<CastExpr*>(this)->path_buffer(); } CXXBaseSpecifier **path_buffer(); - void setBasePathSize(unsigned basePathSize) { - CastExprBits.BasePathSize = basePathSize; - assert(CastExprBits.BasePathSize == basePathSize && - "basePathSize doesn't fit in bits of CastExprBits.BasePathSize!"); + void setBasePathSize(BasePathSizeTy basePathSize) { + assert(!path_empty() && basePathSize != 0); + *(BasePathSize()) = basePathSize; } protected: @@ -2823,7 +2829,9 @@ protected: Op(op) { CastExprBits.Kind = kind; CastExprBits.PartOfExplicitCast = false; - setBasePathSize(BasePathSize); + CastExprBits.BasePathIsEmpty = BasePathSize == 0; + if (!path_empty()) + setBasePathSize(BasePathSize); assert(CastConsistency()); } @@ -2831,7 +2839,9 @@ protected: CastExpr(StmtClass SC, EmptyShell Empty, unsigned BasePathSize) : Expr(SC, Empty) { CastExprBits.PartOfExplicitCast = false; - setBasePathSize(BasePathSize); + CastExprBits.BasePathIsEmpty = BasePathSize == 0; + if (!path_empty()) + setBasePathSize(BasePathSize); } public: @@ -2859,8 +2869,12 @@ public: typedef CXXBaseSpecifier **path_iterator; typedef const CXXBaseSpecifier * const *path_const_iterator; - bool path_empty() const { return CastExprBits.BasePathSize == 0; } - unsigned path_size() const { return CastExprBits.BasePathSize; } + bool path_empty() const { return CastExprBits.BasePathIsEmpty; } + unsigned path_size() const { + if (path_empty()) + return 0U; + return *(const_cast<CastExpr *>(this)->BasePathSize()); + } path_iterator path_begin() { return path_buffer(); } path_iterator path_end() { return path_buffer() + path_size(); } path_const_iterator path_begin() const { return path_buffer(); } @@ -2908,7 +2922,12 @@ public: /// @endcode class ImplicitCastExpr final : public CastExpr, - private llvm::TrailingObjects<ImplicitCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<ImplicitCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + private: ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, unsigned BasePathLength, ExprValueKind VK) @@ -3013,7 +3032,8 @@ public: /// (Type)expr. For example: @c (int)f. class CStyleCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects<CStyleCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<CStyleCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { SourceLocation LPLoc; // the location of the left paren SourceLocation RPLoc; // the location of the right paren @@ -3027,6 +3047,10 @@ class CStyleCastExpr final explicit CStyleCastExpr(EmptyShell Shell, unsigned PathSize) : ExplicitCastExpr(CStyleCastExprClass, Shell, PathSize) { } + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: static CStyleCastExpr *Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, @@ -5341,7 +5365,7 @@ public: SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); } SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == TypoExprClass; } diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 8206a26b2c4b5..7ab8020dec649 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -301,7 +301,8 @@ public: /// \c static_cast<int>(1.0). class CXXStaticCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects<CXXStaticCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<CXXStaticCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { CXXStaticCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, @@ -312,6 +313,10 @@ class CXXStaticCastExpr final explicit CXXStaticCastExpr(EmptyShell Empty, unsigned PathSize) : CXXNamedCastExpr(CXXStaticCastExprClass, Empty, PathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -337,7 +342,8 @@ public: /// check to determine how to perform the type conversion. class CXXDynamicCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects<CXXDynamicCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects< + CXXDynamicCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { CXXDynamicCastExpr(QualType ty, ExprValueKind VK, CastKind kind, Expr *op, unsigned pathSize, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, @@ -348,6 +354,10 @@ class CXXDynamicCastExpr final explicit CXXDynamicCastExpr(EmptyShell Empty, unsigned pathSize) : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty, pathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -380,6 +390,7 @@ public: class CXXReinterpretCastExpr final : public CXXNamedCastExpr, private llvm::TrailingObjects<CXXReinterpretCastExpr, + CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { CXXReinterpretCastExpr(QualType ty, ExprValueKind vk, CastKind kind, Expr *op, unsigned pathSize, @@ -392,6 +403,10 @@ class CXXReinterpretCastExpr final CXXReinterpretCastExpr(EmptyShell Empty, unsigned pathSize) : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty, pathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -419,7 +434,8 @@ public: /// value. class CXXConstCastExpr final : public CXXNamedCastExpr, - private llvm::TrailingObjects<CXXConstCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects<CXXConstCastExpr, CastExpr::BasePathSizeTy, + CXXBaseSpecifier *> { CXXConstCastExpr(QualType ty, ExprValueKind VK, Expr *op, TypeSourceInfo *writtenTy, SourceLocation l, SourceLocation RParenLoc, SourceRange AngleBrackets) @@ -429,6 +445,10 @@ class CXXConstCastExpr final explicit CXXConstCastExpr(EmptyShell Empty) : CXXNamedCastExpr(CXXConstCastExprClass, Empty, 0) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -721,7 +741,7 @@ public: } }; -/// A member reference to an MSPropertyDecl. +/// A member reference to an MSPropertyDecl. /// /// This expression always has pseudo-object type, and therefore it is /// typically not encountered in a fully-typechecked expression except @@ -1471,7 +1491,8 @@ public: /// \endcode class CXXFunctionalCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects<CXXFunctionalCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects< + CXXFunctionalCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { SourceLocation LParenLoc; SourceLocation RParenLoc; @@ -1486,6 +1507,10 @@ class CXXFunctionalCastExpr final explicit CXXFunctionalCastExpr(EmptyShell Shell, unsigned PathSize) : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell, PathSize) {} + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: friend class CastExpr; friend TrailingObjects; @@ -1591,7 +1616,7 @@ class LambdaExpr final : public Expr, /// The number of captures. unsigned NumCaptures : 16; - + /// The default capture kind, which is a value of type /// LambdaCaptureDefault. unsigned CaptureDefault : 2; @@ -1602,10 +1627,10 @@ class LambdaExpr final : public Expr, /// Whether this lambda had the result type explicitly specified. unsigned ExplicitResultType : 1; - + /// The location of the closing brace ('}') that completes /// the lambda. - /// + /// /// The location of the brace is also available by looking up the /// function call operator in the lambda class. However, it is /// stored here to improve the performance of getSourceRange(), and @@ -1673,7 +1698,7 @@ public: /// Retrieve this lambda's captures. capture_range captures() const; - + /// Retrieve an iterator pointing to the first lambda capture. capture_iterator capture_begin() const; @@ -1686,7 +1711,7 @@ public: /// Retrieve this lambda's explicit captures. capture_range explicit_captures() const; - + /// Retrieve an iterator pointing to the first explicit /// lambda capture. capture_iterator explicit_capture_begin() const; @@ -1754,18 +1779,18 @@ public: SourceRange getIntroducerRange() const { return IntroducerRange; } /// Retrieve the class that corresponds to the lambda. - /// + /// /// This is the "closure type" (C++1y [expr.prim.lambda]), and stores the /// captures in its fields and provides the various operations permitted /// on a lambda (copying, calling). CXXRecordDecl *getLambdaClass() const; /// Retrieve the function call operator associated with this - /// lambda expression. + /// lambda expression. CXXMethodDecl *getCallOperator() const; - /// If this is a generic lambda expression, retrieve the template - /// parameter list associated with it, or else return null. + /// If this is a generic lambda expression, retrieve the template + /// parameter list associated with it, or else return null. TemplateParameterList *getTemplateParameterList() const; /// Whether this is a generic lambda. @@ -1784,7 +1809,7 @@ public: /// Whether this lambda had its result type explicitly specified. bool hasExplicitResultType() const { return ExplicitResultType; } - + static bool classof(const Stmt *T) { return T->getStmtClass() == LambdaExprClass; } @@ -2129,7 +2154,7 @@ public: Expr *getArgument() { return cast<Expr>(Argument); } const Expr *getArgument() const { return cast<Expr>(Argument); } - /// Retrieve the type being destroyed. + /// Retrieve the type being destroyed. /// /// If the type being destroyed is a dependent type which may or may not /// be a pointer, return an invalid type. @@ -2345,13 +2370,13 @@ class TypeTraitExpr final private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> { /// The location of the type trait keyword. SourceLocation Loc; - + /// The location of the closing parenthesis. SourceLocation RParenLoc; - + // Note: The TypeSourceInfos for the arguments are allocated after the // TypeTraitExpr. - + TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef<TypeSourceInfo *> Args, SourceLocation RParenLoc, @@ -2377,26 +2402,26 @@ public: static TypeTraitExpr *CreateDeserialized(const ASTContext &C, unsigned NumArgs); - + /// Determine which type trait this expression uses. TypeTrait getTrait() const { return static_cast<TypeTrait>(TypeTraitExprBits.Kind); } - bool getValue() const { - assert(!isValueDependent()); - return TypeTraitExprBits.Value; + bool getValue() const { + assert(!isValueDependent()); + return TypeTraitExprBits.Value; } - + /// Determine the number of arguments to this type trait. unsigned getNumArgs() const { return TypeTraitExprBits.NumArgs; } - + /// Retrieve the Ith argument. TypeSourceInfo *getArg(unsigned I) const { assert(I < getNumArgs() && "Argument out-of-range"); return getArgs()[I]; } - + /// Retrieve the argument types. ArrayRef<TypeSourceInfo *> getArgs() const { return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(), @@ -2409,7 +2434,7 @@ public: static bool classof(const Stmt *T) { return T->getStmtClass() == TypeTraitExprClass; } - + // Iterators child_range children() { return child_range(child_iterator(), child_iterator()); diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index 5dac0e037da11..bb0402c270808 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -90,16 +90,16 @@ public: Value(val), Loc(l) {} explicit ObjCBoolLiteralExpr(EmptyShell Empty) : Expr(ObjCBoolLiteralExprClass, Empty) {} - + bool getValue() const { return Value; } void setValue(bool V) { Value = V; } - + SourceLocation getLocStart() const LLVM_READONLY { return Loc; } SourceLocation getLocEnd() const LLVM_READONLY { return Loc; } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - + // Iterators child_range children() { return child_range(child_iterator(), child_iterator()); @@ -124,30 +124,30 @@ public: ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R) - : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary, - E->isTypeDependent(), E->isValueDependent(), + : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary, + E->isTypeDependent(), E->isValueDependent(), E->isInstantiationDependent(), - E->containsUnexpandedParameterPack()), + E->containsUnexpandedParameterPack()), SubExpr(E), BoxingMethod(method), Range(R) {} explicit ObjCBoxedExpr(EmptyShell Empty) : Expr(ObjCBoxedExprClass, Empty) {} - + Expr *getSubExpr() { return cast<Expr>(SubExpr); } const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } - + ObjCMethodDecl *getBoxingMethod() const { - return BoxingMethod; + return BoxingMethod; } - + SourceLocation getAtLoc() const { return Range.getBegin(); } - + SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } SourceRange getSourceRange() const LLVM_READONLY { return Range; } - + // Iterators child_range children() { return child_range(&SubExpr, &SubExpr+1); } @@ -208,7 +208,7 @@ public: /// getNumElements - Return number of elements of objective-c array literal. unsigned getNumElements() const { return NumElements; } - + /// getElement - Return the Element at the specified index. Expr *getElement(unsigned Index) { assert((Index < NumElements) && "Arg access out of range!"); @@ -218,11 +218,11 @@ public: assert((Index < NumElements) && "Arg access out of range!"); return getElements()[Index]; } - + ObjCMethodDecl *getArrayWithObjectsMethod() const { - return ArrayWithObjectsMethod; + return ArrayWithObjectsMethod; } - + // Iterators child_range children() { return child_range(reinterpret_cast<Stmt **>(getElements()), @@ -239,13 +239,13 @@ public: struct ObjCDictionaryElement { /// The key for the dictionary element. Expr *Key; - + /// The value of the dictionary element. Expr *Value; - + /// The location of the ellipsis, if this is a pack expansion. SourceLocation EllipsisLoc; - + /// The number of elements this pack expansion will expand to, if /// this is a pack expansion and is known. Optional<unsigned> NumExpansions; @@ -308,7 +308,7 @@ class ObjCDictionaryLiteral final using KeyValuePair = ObjCDictionaryLiteral_KeyValuePair; using ExpansionData = ObjCDictionaryLiteral_ExpansionData; - ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK, + ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR); @@ -328,16 +328,16 @@ public: friend TrailingObjects; static ObjCDictionaryLiteral *Create(const ASTContext &C, - ArrayRef<ObjCDictionaryElement> VK, + ArrayRef<ObjCDictionaryElement> VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR); - + static ObjCDictionaryLiteral *CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions); - - /// getNumElements - Return number of elements of objective-c dictionary + + /// getNumElements - Return number of elements of objective-c dictionary /// literal. unsigned getNumElements() const { return NumElements; } @@ -354,7 +354,7 @@ public: } return Result; } - + ObjCMethodDecl *getDictWithObjectsMethod() const { return DictWithObjectsMethod; } @@ -394,7 +394,7 @@ public: EncodedType->getType()->isDependentType(), EncodedType->getType()->isDependentType(), EncodedType->getType()->isInstantiationDependentType(), - EncodedType->getType()->containsUnexpandedParameterPack()), + EncodedType->getType()->containsUnexpandedParameterPack()), EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {} explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){} @@ -408,8 +408,8 @@ public: TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; } - void setEncodedTypeSourceInfo(TypeSourceInfo *EncType) { - EncodedType = EncType; + void setEncodedTypeSourceInfo(TypeSourceInfo *EncType) { + EncodedType = EncType; } SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; } @@ -531,9 +531,9 @@ public: bool arrow = false, bool freeIvar = false) : Expr(ObjCIvarRefExprClass, t, VK_LValue, d->isBitField() ? OK_BitField : OK_Ordinary, - /*TypeDependent=*/false, base->isValueDependent(), + /*TypeDependent=*/false, base->isValueDependent(), base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), + base->containsUnexpandedParameterPack()), D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow), IsFreeIvar(freeIvar) {} @@ -560,7 +560,7 @@ public: return isFreeIvar() ? Loc : getBase()->getLocStart(); } SourceLocation getLocEnd() const LLVM_READONLY { return Loc; } - + SourceLocation getOpLoc() const { return OpLoc; } void setOpLoc(SourceLocation L) { OpLoc = L; } @@ -600,13 +600,13 @@ private: // transformation is lossy on the first character). SourceLocation IdLoc; - + /// When the receiver in property access is 'super', this is /// the location of the 'super' keyword. When it's an interface, /// this is that interface. SourceLocation ReceiverLoc; llvm::PointerUnion3<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver; - + public: ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, @@ -618,7 +618,7 @@ public: PropertyOrGetter(PD, false), IdLoc(l), Receiver(base) { assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject)); } - + ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, SourceLocation sl, QualType st) @@ -716,19 +716,19 @@ public: setMethodRefFlag(MethodRef_Setter, val); } - const Expr *getBase() const { - return cast<Expr>(Receiver.get<Stmt*>()); + const Expr *getBase() const { + return cast<Expr>(Receiver.get<Stmt*>()); } - Expr *getBase() { - return cast<Expr>(Receiver.get<Stmt*>()); + Expr *getBase() { + return cast<Expr>(Receiver.get<Stmt*>()); } SourceLocation getLocation() const { return IdLoc; } - + SourceLocation getReceiverLocation() const { return ReceiverLoc; } - QualType getSuperReceiverType() const { - return QualType(Receiver.get<const Type*>(), 0); + QualType getSuperReceiverType() const { + return QualType(Receiver.get<const Type*>(), 0); } ObjCInterfaceDecl *getClassReceiver() const { @@ -796,7 +796,7 @@ private: SetterAndMethodRefFlags.setInt(f); } }; - + /// ObjCSubscriptRefExpr - used for array and dictionary subscripting. /// array[4] = array[3]; dictionary[key] = dictionary[alt_key]; class ObjCSubscriptRefExpr : public Expr { @@ -808,20 +808,20 @@ class ObjCSubscriptRefExpr : public Expr { // an objective-c object pointer expression. enum { BASE, KEY, END_EXPR }; Stmt* SubExprs[END_EXPR]; - + ObjCMethodDecl *GetAtIndexMethodDecl; - + // For immutable objects this is null. When ObjCSubscriptRefExpr is to read // an indexed object this is null too. ObjCMethodDecl *SetAtIndexMethodDecl; - + public: ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB) - : Expr(ObjCSubscriptRefExprClass, T, VK, OK, - base->isTypeDependent() || key->isTypeDependent(), + : Expr(ObjCSubscriptRefExprClass, T, VK, OK, + base->isTypeDependent() || key->isTypeDependent(), base->isValueDependent() || key->isValueDependent(), (base->isInstantiationDependent() || key->isInstantiationDependent()), @@ -834,7 +834,7 @@ public: explicit ObjCSubscriptRefExpr(EmptyShell Empty) : Expr(ObjCSubscriptRefExprClass, Empty) {} - + SourceLocation getRBracket() const { return RBracket; } void setRBracket(SourceLocation RB) { RBracket = RB; } @@ -843,25 +843,25 @@ public: } SourceLocation getLocEnd() const LLVM_READONLY { return RBracket; } - + Expr *getBaseExpr() const { return cast<Expr>(SubExprs[BASE]); } void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; } - + Expr *getKeyExpr() const { return cast<Expr>(SubExprs[KEY]); } void setKeyExpr(Stmt *S) { SubExprs[KEY] = S; } - + ObjCMethodDecl *getAtIndexMethodDecl() const { return GetAtIndexMethodDecl; } - + ObjCMethodDecl *setAtIndexMethodDecl() const { return SetAtIndexMethodDecl; } - + bool isArraySubscriptRefExpr() const { return getKeyExpr()->getType()->isIntegralOrEnumerationType(); } - + child_range children() { return child_range(SubExprs, SubExprs+END_EXPR); } @@ -913,7 +913,7 @@ class ObjCMessageExpr final /// The number of arguments in the message send, not /// including the receiver. unsigned NumArgs : NumArgsBitWidth; - + /// The kind of message send this is, which is one of the /// ReceiverKind values. /// @@ -958,7 +958,7 @@ class ObjCMessageExpr final SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, @@ -968,7 +968,7 @@ class ObjCMessageExpr final ObjCMessageExpr(QualType T, ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, @@ -978,7 +978,7 @@ class ObjCMessageExpr final ObjCMessageExpr(QualType T, ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, @@ -1091,7 +1091,7 @@ public: SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, @@ -1125,7 +1125,7 @@ public: ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, @@ -1159,7 +1159,7 @@ public: ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, - Selector Sel, + Selector Sel, ArrayRef<SourceLocation> SeLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, @@ -1215,14 +1215,14 @@ public: /// Turn this message send into an instance message that /// computes the receiver object with the given expression. - void setInstanceReceiver(Expr *rec) { + void setInstanceReceiver(Expr *rec) { Kind = Instance; setReceiverPointer(rec); } - + /// Returns the type of a class message send, or NULL if the /// message is not a class message. - QualType getClassReceiver() const { + QualType getClassReceiver() const { if (TypeSourceInfo *TSInfo = getClassReceiverTypeInfo()) return TSInfo->getType(); @@ -1244,7 +1244,7 @@ public: /// Retrieve the location of the 'super' keyword for a class /// or instance message to 'super', otherwise an invalid source location. - SourceLocation getSuperLoc() const { + SourceLocation getSuperLoc() const { if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass) return SuperLoc; @@ -1274,7 +1274,7 @@ public: /// \returns The Objective-C interface if known, otherwise nullptr. ObjCInterfaceDecl *getReceiverInterface() const; - /// Retrieve the type referred to by 'super'. + /// Retrieve the type referred to by 'super'. /// /// The returned type will either be an ObjCInterfaceType (for an /// class message to super) or an ObjCObjectPointerType that refers @@ -1294,26 +1294,26 @@ public: Selector getSelector() const; - void setSelector(Selector S) { + void setSelector(Selector S) { HasMethod = false; SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr()); } - const ObjCMethodDecl *getMethodDecl() const { + const ObjCMethodDecl *getMethodDecl() const { if (HasMethod) return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod); return nullptr; } - ObjCMethodDecl *getMethodDecl() { + ObjCMethodDecl *getMethodDecl() { if (HasMethod) return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod); return nullptr; } - void setMethodDecl(ObjCMethodDecl *MD) { + void setMethodDecl(ObjCMethodDecl *MD) { HasMethod = true; SelectorOrMethod = reinterpret_cast<uintptr_t>(MD); } @@ -1414,16 +1414,16 @@ public: arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); } - arg_iterator arg_end() { - return reinterpret_cast<Stmt **>(getArgs() + NumArgs); + arg_iterator arg_end() { + return reinterpret_cast<Stmt **>(getArgs() + NumArgs); } - const_arg_iterator arg_begin() const { - return reinterpret_cast<Stmt const * const*>(getArgs()); + const_arg_iterator arg_begin() const { + return reinterpret_cast<Stmt const * const*>(getArgs()); } - const_arg_iterator arg_end() const { - return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs); + const_arg_iterator arg_end() const { + return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs); } static bool classof(const Stmt *T) { @@ -1439,7 +1439,7 @@ class ObjCIsaExpr : public Expr { /// IsaMemberLoc - This is the location of the 'isa'. SourceLocation IsaMemberLoc; - + /// OpLoc - This is the location of '.' or '->' SourceLocation OpLoc; @@ -1468,18 +1468,18 @@ public: /// location of 'F'. SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } - + SourceLocation getOpLoc() const { return OpLoc; } void setOpLoc(SourceLocation L) { OpLoc = L; } SourceLocation getLocStart() const LLVM_READONLY { return getBase()->getLocStart(); } - + SourceLocation getBaseLocEnd() const LLVM_READONLY { return getBase()->getLocEnd(); } - + SourceLocation getLocEnd() const LLVM_READONLY { return IsaMemberLoc; } SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; } @@ -1546,7 +1546,7 @@ public: /// copy-restore. If false, the temporary will be zero-initialized. bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; } - child_range children() { return child_range(&Operand, &Operand+1); } + child_range children() { return child_range(&Operand, &Operand+1); } // Source locations are determined by the subexpression. SourceLocation getLocStart() const LLVM_READONLY { @@ -1571,7 +1571,8 @@ public: /// \endcode class ObjCBridgedCastExpr final : public ExplicitCastExpr, - private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> { + private llvm::TrailingObjects< + ObjCBridgedCastExpr, CastExpr::BasePathSizeTy, CXXBaseSpecifier *> { friend class ASTStmtReader; friend class ASTStmtWriter; friend class CastExpr; @@ -1581,6 +1582,10 @@ class ObjCBridgedCastExpr final SourceLocation BridgeKeywordLoc; unsigned Kind : 2; + size_t numTrailingObjects(OverloadToken<CastExpr::BasePathSizeTy>) const { + return path_empty() ? 0 : 1; + } + public: ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, @@ -1588,7 +1593,7 @@ public: : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(), VK_RValue, CK, Operand, 0, TSInfo), LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {} - + /// Construct an empty Objective-C bridged cast. explicit ObjCBridgedCastExpr(EmptyShell Shell) : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0) {} @@ -1596,22 +1601,22 @@ public: SourceLocation getLParenLoc() const { return LParenLoc; } /// Determine which kind of bridge is being performed via this cast. - ObjCBridgeCastKind getBridgeKind() const { - return static_cast<ObjCBridgeCastKind>(Kind); + ObjCBridgeCastKind getBridgeKind() const { + return static_cast<ObjCBridgeCastKind>(Kind); } - + /// Retrieve the kind of bridge being performed as a string. StringRef getBridgeKindName() const; - + /// The location of the bridge keyword. SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; } - + SourceLocation getLocStart() const LLVM_READONLY { return LParenLoc; } SourceLocation getLocEnd() const LLVM_READONLY { return getSubExpr()->getLocEnd(); } - + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCBridgedCastExprClass; } diff --git a/include/clang/AST/ExternalASTMerger.h b/include/clang/AST/ExternalASTMerger.h index ae8a761e127e5..7b01fa8cbced9 100644 --- a/include/clang/AST/ExternalASTMerger.h +++ b/include/clang/AST/ExternalASTMerger.h @@ -37,7 +37,7 @@ namespace clang { /// lookup. In this case, Origins contains an entry overriding lookup and /// specifying the correct pair of DeclContext/ASTContext. /// -/// - The DeclContext of origin was determined by another ExterenalASTMerger. +/// - The DeclContext of origin was determined by another ExterenalASTMerger. /// (This is possible when the source ASTContext for one of the Importers has /// its own ExternalASTMerger). The origin must be properly forwarded in this /// case. @@ -57,7 +57,7 @@ public: typedef std::map<const DeclContext *, DCOrigin> OriginMap; typedef std::vector<std::unique_ptr<ASTImporter>> ImporterVector; private: - /// One importer exists for each source. + /// One importer exists for each source. ImporterVector Importers; /// Overrides in case name lookup would return nothing or would return /// the wrong thing. @@ -106,7 +106,7 @@ public: /// Remove a set of ASTContexts as possible origins. /// /// Sometimes an origin goes away (for example, if a source file gets - /// superseded by a newer version). + /// superseded by a newer version). /// /// The caller is responsible for ensuring that this doesn't leave /// DeclContexts that can't be completed. @@ -163,7 +163,7 @@ private: template <typename CallbackType> void ForEachMatchingDC(const DeclContext *DC, CallbackType Callback); -public: +public: /// Log something if there is a logging callback installed. llvm::raw_ostream &logs() { return *LogStream; } diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h index 82255bb1c44c8..525d4c78b3627 100644 --- a/include/clang/AST/ExternalASTSource.h +++ b/include/clang/AST/ExternalASTSource.h @@ -270,10 +270,10 @@ public: /// /// The default implementation of this method is a no-op. virtual void PrintStats(); - + /// Perform layout on the given record. /// - /// This routine allows the external AST source to provide an specific + /// This routine allows the external AST source to provide an specific /// layout for a record, overriding the layout that would normally be /// constructed. It is intended for clients who receive specific layout /// details rather than source code (such as LLDB). The client is expected @@ -290,13 +290,13 @@ public: /// expressed in bits. All of the fields must be provided with offsets. /// /// \param BaseOffsets The offset of each of the direct, non-virtual base - /// classes. If any bases are not given offsets, the bases will be laid + /// classes. If any bases are not given offsets, the bases will be laid /// out according to the ABI. /// /// \param VirtualBaseOffsets The offset of each of the virtual base classes - /// (either direct or not). If any bases are not given offsets, the bases will be laid + /// (either direct or not). If any bases are not given offsets, the bases will be laid /// out according to the ABI. - /// + /// /// \returns true if the record layout was provided, false otherwise. virtual bool layoutRecordType( const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, @@ -307,15 +307,15 @@ public: //===--------------------------------------------------------------------===// // Queries for performance analysis. //===--------------------------------------------------------------------===// - + struct MemoryBufferSizes { size_t malloc_bytes; size_t mmap_bytes; - + MemoryBufferSizes(size_t malloc_bytes, size_t mmap_bytes) : malloc_bytes(malloc_bytes), mmap_bytes(mmap_bytes) {} }; - + /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. MemoryBufferSizes getMemoryBufferSizes() const { @@ -512,10 +512,10 @@ namespace clang { /// Represents a lazily-loaded vector of data. /// /// The lazily-loaded vector of data contains data that is partially loaded -/// from an external source and partially added by local translation. The +/// from an external source and partially added by local translation. The /// items loaded from the external source are loaded lazily, when needed for /// iteration over the complete vector. -template<typename T, typename Source, +template<typename T, typename Source, void (Source::*Loader)(SmallVectorImpl<T>&), unsigned LoadedStorage = 2, unsigned LocalStorage = 4> class LazyVector { @@ -564,20 +564,20 @@ public: iterator begin(Source *source, bool LocalOnly = false) { if (LocalOnly) return iterator(this, 0); - + if (source) (source->*Loader)(Loaded); return iterator(this, -(int)Loaded.size()); } - + iterator end() { return iterator(this, Local.size()); } - + void push_back(const T& LocalValue) { Local.push_back(LocalValue); } - + void erase(iterator From, iterator To) { if (From.isLoaded() && To.isLoaded()) { Loaded.erase(&*From, &*To); diff --git a/include/clang/AST/GlobalDecl.h b/include/clang/AST/GlobalDecl.h index 3b3e4367d56c3..7f017994216fa 100644 --- a/include/clang/AST/GlobalDecl.h +++ b/include/clang/AST/GlobalDecl.h @@ -57,7 +57,7 @@ public: GlobalDecl CanonGD; CanonGD.Value.setPointer(Value.getPointer()->getCanonicalDecl()); CanonGD.Value.setInt(Value.getInt()); - + return CanonGD; } @@ -72,11 +72,11 @@ public: assert(isa<CXXDestructorDecl>(getDecl()) && "Decl is not a dtor!"); return static_cast<CXXDtorType>(Value.getInt()); } - + friend bool operator==(const GlobalDecl &LHS, const GlobalDecl &RHS) { return LHS.Value == RHS.Value; } - + void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } static GlobalDecl getFromOpaquePtr(void *P) { @@ -84,7 +84,7 @@ public: GD.Value.setFromOpaqueValue(P); return GD; } - + GlobalDecl getWithDecl(const Decl *D) { GlobalDecl Result(*this); Result.Value.setPointer(D); @@ -100,7 +100,7 @@ namespace llvm { static inline clang::GlobalDecl getEmptyKey() { return clang::GlobalDecl(); } - + static inline clang::GlobalDecl getTombstoneKey() { return clang::GlobalDecl:: getFromOpaquePtr(reinterpret_cast<void*>(-1)); @@ -109,13 +109,13 @@ namespace llvm { static unsigned getHashValue(clang::GlobalDecl GD) { return DenseMapInfo<void*>::getHashValue(GD.getAsOpaquePtr()); } - - static bool isEqual(clang::GlobalDecl LHS, + + static bool isEqual(clang::GlobalDecl LHS, clang::GlobalDecl RHS) { return LHS == RHS; } }; - + // GlobalDecl isn't *technically* a POD type. However, its copy constructor, // copy assignment operator, and destructor are all trivial. template <> diff --git a/include/clang/AST/LambdaCapture.h b/include/clang/AST/LambdaCapture.h index bcc5352c1c9dd..f246bc423bfb8 100644 --- a/include/clang/AST/LambdaCapture.h +++ b/include/clang/AST/LambdaCapture.h @@ -41,7 +41,7 @@ class LambdaCapture { }; // Decl could represent: - // - a VarDecl* that represents the variable that was captured or the + // - a VarDecl* that represents the variable that was captured or the // init-capture. // - or, is a nullptr and Capture_This is set in Bits if this represents a // capture of '*this' by value or reference. diff --git a/include/clang/AST/Mangle.h b/include/clang/AST/Mangle.h index 401574b265b0e..c42fe91b32469 100644 --- a/include/clang/AST/Mangle.h +++ b/include/clang/AST/Mangle.h @@ -73,7 +73,7 @@ public: DiagnosticsEngine &getDiags() const { return Diags; } virtual void startNewFunction() { LocalBlockIds.clear(); } - + unsigned getBlockId(const BlockDecl *BD, bool Local) { llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds = Local? LocalBlockIds : GlobalBlockIds; diff --git a/include/clang/AST/NSAPI.h b/include/clang/AST/NSAPI.h index ee07745b1242f..bf2afe38cbcab 100644 --- a/include/clang/AST/NSAPI.h +++ b/include/clang/AST/NSAPI.h @@ -113,7 +113,7 @@ public: NSMutableDict_setValueForKey }; static const unsigned NumNSDictionaryMethods = 13; - + /// The Objective-C NSDictionary selectors. Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const; diff --git a/include/clang/AST/NestedNameSpecifier.h b/include/clang/AST/NestedNameSpecifier.h index 2255d5114350e..3a7b45767dac7 100644 --- a/include/clang/AST/NestedNameSpecifier.h +++ b/include/clang/AST/NestedNameSpecifier.h @@ -44,7 +44,7 @@ class TypeLoc; /// specifier. Nested name specifiers are made up of a sequence of /// specifiers, each of which can be a namespace, type, identifier /// (for dependent names), decltype specifier, or the global specifier ('::'). -/// The last two specifiers can only appear at the start of a +/// The last two specifiers can only appear at the start of a /// nested-namespace-specifier. class NestedNameSpecifier : public llvm::FoldingSetNode { /// Enumeration describing @@ -438,7 +438,7 @@ public: /// Turn this (empty) nested-name-specifier into the global /// nested-name-specifier '::'. void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc); - + /// Turns this (empty) nested-name-specifier into '__super' /// nested-name-specifier. /// @@ -452,7 +452,7 @@ public: /// name. /// /// \param ColonColonLoc The location of the trailing '::'. - void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, + void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc); /// Make a new nested-name-specifier from incomplete source-location diff --git a/include/clang/AST/OperationKinds.def b/include/clang/AST/OperationKinds.def index 823e32424f1ee..e2d65d84880cb 100644 --- a/include/clang/AST/OperationKinds.def +++ b/include/clang/AST/OperationKinds.def @@ -307,7 +307,7 @@ CAST_OPERATION(AtomicToNonAtomic) /// Converts from T to _Atomic(T). CAST_OPERATION(NonAtomicToAtomic) -/// Causes a block literal to by copied to the heap and then +/// Causes a block literal to by copied to the heap and then /// autoreleased. /// /// This particular cast kind is used for the conversion from a C++11 @@ -391,13 +391,13 @@ BINARY_OPERATION(Comma, ",") // [C99 6.5.2.4] Postfix increment and decrement UNARY_OPERATION(PostInc, "++") UNARY_OPERATION(PostDec, "--") -// [C99 6.5.3.1] Prefix increment and decrement +// [C99 6.5.3.1] Prefix increment and decrement UNARY_OPERATION(PreInc, "++") UNARY_OPERATION(PreDec, "--") // [C99 6.5.3.2] Address and indirection UNARY_OPERATION(AddrOf, "&") UNARY_OPERATION(Deref, "*") -// [C99 6.5.3.3] Unary arithmetic +// [C99 6.5.3.3] Unary arithmetic UNARY_OPERATION(Plus, "+") UNARY_OPERATION(Minus, "-") UNARY_OPERATION(Not, "~") diff --git a/include/clang/AST/OperationKinds.h b/include/clang/AST/OperationKinds.h index c7e01fa1834e8..ac512d721e34e 100644 --- a/include/clang/AST/OperationKinds.h +++ b/include/clang/AST/OperationKinds.h @@ -16,7 +16,7 @@ #define LLVM_CLANG_AST_OPERATIONKINDS_H namespace clang { - + /// CastKind - The kind of operation required for a conversion. enum CastKind { #define CAST_OPERATION(Name) CK_##Name, diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h index 41c804486c358..b49f5be1b1e6e 100644 --- a/include/clang/AST/PrettyPrinter.h +++ b/include/clang/AST/PrettyPrinter.h @@ -109,7 +109,7 @@ struct PrintingPolicy { /// Suppress printing parts of scope specifiers that don't need /// to be written, e.g., for inline or anonymous namespaces. bool SuppressUnwrittenScope : 1; - + /// Suppress printing of variable initializers. /// /// This flag is used when printing the loop variable in a for-range @@ -140,15 +140,15 @@ struct PrintingPolicy { /// char a[9] = "A string"; /// \endcode bool ConstantArraySizeAsWritten : 1; - + /// When printing an anonymous tag name, also print the location of that /// entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just prints /// "(anonymous)" for the name. bool AnonymousTagLocations : 1; - + /// When true, suppress printing of the __strong lifetime qualifier in ARC. unsigned SuppressStrongLifetime : 1; - + /// When true, suppress printing of lifetime qualifier in ARC. unsigned SuppressLifetimeQualifiers : 1; @@ -179,7 +179,7 @@ struct PrintingPolicy { /// declarations inside namespaces etc. Effectively, this should print /// only the requested declaration. unsigned TerseOutput : 1; - + /// When true, do certain refinement needed for producing proper declaration /// tag; such as, do not print attributes attached to the declaration. /// diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h index dc60ef892b073..a546c200ffe03 100644 --- a/include/clang/AST/RecordLayout.h +++ b/include/clang/AST/RecordLayout.h @@ -71,6 +71,10 @@ private: // Alignment - Alignment of record in characters. CharUnits Alignment; + // UnadjustedAlignment - Maximum of the alignments of the record members in + // characters. + CharUnits UnadjustedAlignment; + /// RequiredAlignment - The required alignment of the object. In the MS-ABI /// the __declspec(align()) trumps #pramga pack and must always be obeyed. CharUnits RequiredAlignment; @@ -120,10 +124,10 @@ private: /// BaseSharingVBPtr - The base we share vbptr with. const CXXRecordDecl *BaseSharingVBPtr; - + /// FIXME: This should really use a SmallPtrMap, once we have one in LLVM :) using BaseOffsetsMapTy = llvm::DenseMap<const CXXRecordDecl *, CharUnits>; - + /// BaseOffsets - Contains a map from base classes to their offset. BaseOffsetsMapTy BaseOffsets; @@ -136,6 +140,7 @@ private: CXXRecordLayoutInfo *CXXInfo = nullptr; ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, + CharUnits unadjustedAlignment, CharUnits requiredAlignment, CharUnits datasize, ArrayRef<uint64_t> fieldoffsets); @@ -144,6 +149,7 @@ private: // Constructor for C++ records. ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment, + CharUnits unadjustedAlignment, CharUnits requiredAlignment, bool hasOwnVFPtr, bool hasExtendableVFPtr, CharUnits vbptroffset, @@ -162,7 +168,7 @@ private: ~ASTRecordLayout() = default; void Destroy(ASTContext &Ctx); - + public: ASTRecordLayout(const ASTRecordLayout &) = delete; ASTRecordLayout &operator=(const ASTRecordLayout &) = delete; @@ -170,6 +176,10 @@ public: /// getAlignment - Get the record alignment in characters. CharUnits getAlignment() const { return Alignment; } + /// getUnadjustedAlignment - Get the record alignment in characters, before + /// alignment adjustement. + CharUnits getUnadjustedAlignment() const { return UnadjustedAlignment; } + /// getSize - Get the record size in characters. CharUnits getSize() const { return Size; } @@ -259,7 +269,7 @@ public: assert(CXXInfo && "Record layout does not have C++ specific info!"); return CXXInfo->HasExtendableVFPtr; } - + /// hasOwnVBPtr - Does this class provide its own virtual-base /// table pointer, rather than inheriting one from a primary base /// class? diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 91dbcb71a600c..aa0f88b710237 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -204,7 +204,7 @@ protected: unsigned Kind : 6; unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr. - unsigned BasePathSize : 32 - 6 - 1 - NumExprBits; + unsigned BasePathIsEmpty : 1; }; class CallExprBitfields { @@ -271,12 +271,12 @@ protected: friend class ASTStmtReader; friend class ASTStmtWriter; friend class TypeTraitExpr; - + unsigned : NumExprBits; - + /// The kind of type trait, which is a value of a TypeTrait enumerator. unsigned Kind : 8; - + /// If this expression is not value-dependent, this indicates whether /// the trait evaluated true or false. unsigned Value : 1; @@ -1556,7 +1556,7 @@ public: /// getInputConstraint - Return the specified input constraint. Unlike output /// constraints, these can be empty. StringRef getInputConstraint(unsigned i) const; - + const Expr *getInputExpr(unsigned i) const; //===--- Other ---===// @@ -2133,7 +2133,7 @@ private: /// The number of variable captured, including 'this'. unsigned NumCaptures; - /// The pointer part is the implicit the outlined function and the + /// The pointer part is the implicit the outlined function and the /// int part is the captured region kind, 'CR_Default' etc. llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind; diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h index 33aab08bbb713..806edaa38821d 100644 --- a/include/clang/AST/StmtIterator.h +++ b/include/clang/AST/StmtIterator.h @@ -33,14 +33,14 @@ protected: DeclGroupMode = 0x2, Flags = 0x3 }; - + union { Stmt **stmt; Decl **DGI; }; uintptr_t RawVAPtr = 0; Decl **DGE; - + StmtIteratorBase(Stmt **s) : stmt(s) {} StmtIteratorBase(const VariableArrayType *t); StmtIteratorBase(Decl **dgi, Decl **dge); diff --git a/include/clang/AST/StmtObjC.h b/include/clang/AST/StmtObjC.h index 571ad76be8a9d..0b2cc78b65be9 100644 --- a/include/clang/AST/StmtObjC.h +++ b/include/clang/AST/StmtObjC.h @@ -81,7 +81,7 @@ public: ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc, VarDecl *catchVarDecl, Stmt *atCatchStmt) - : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl), + : Stmt(ObjCAtCatchStmtClass), ExceptionDecl(catchVarDecl), Body(atCatchStmt), AtCatchLoc(atCatchLoc), RParenLoc(rparenloc) { } explicit ObjCAtCatchStmt(EmptyShell Empty) : @@ -155,27 +155,27 @@ class ObjCAtTryStmt : public Stmt { private: // The location of the @ in the \@try. SourceLocation AtTryLoc; - + // The number of catch blocks in this statement. unsigned NumCatchStmts : 16; - + // Whether this statement has a \@finally statement. bool HasFinally : 1; - + /// Retrieve the statements that are stored after this \@try statement. /// /// The order of the statements in memory follows the order in the source, /// with the \@try body first, followed by the \@catch statements (if any) /// and, finally, the \@finally (if it exists). Stmt **getStmts() { return reinterpret_cast<Stmt **> (this + 1); } - const Stmt* const *getStmts() const { - return reinterpret_cast<const Stmt * const*> (this + 1); + const Stmt* const *getStmts() const { + return reinterpret_cast<const Stmt * const*> (this + 1); } - + ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt); - + explicit ObjCAtTryStmt(EmptyShell Empty, unsigned NumCatchStmts, bool HasFinally) : Stmt(ObjCAtTryStmtClass, Empty), NumCatchStmts(NumCatchStmts), @@ -188,7 +188,7 @@ public: Stmt *atFinallyStmt); static ObjCAtTryStmt *CreateEmpty(const ASTContext &Context, unsigned NumCatchStmts, bool HasFinally); - + /// Retrieve the location of the @ in the \@try. SourceLocation getAtTryLoc() const { return AtTryLoc; } void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; } @@ -201,41 +201,41 @@ public: /// Retrieve the number of \@catch statements in this try-catch-finally /// block. unsigned getNumCatchStmts() const { return NumCatchStmts; } - + /// Retrieve a \@catch statement. const ObjCAtCatchStmt *getCatchStmt(unsigned I) const { assert(I < NumCatchStmts && "Out-of-bounds @catch index"); return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]); } - + /// Retrieve a \@catch statement. ObjCAtCatchStmt *getCatchStmt(unsigned I) { assert(I < NumCatchStmts && "Out-of-bounds @catch index"); return cast_or_null<ObjCAtCatchStmt>(getStmts()[I + 1]); } - + /// Set a particular catch statement. void setCatchStmt(unsigned I, ObjCAtCatchStmt *S) { assert(I < NumCatchStmts && "Out-of-bounds @catch index"); getStmts()[I + 1] = S; } - + /// Retrieve the \@finally statement, if any. const ObjCAtFinallyStmt *getFinallyStmt() const { if (!HasFinally) return nullptr; - + return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]); } ObjCAtFinallyStmt *getFinallyStmt() { if (!HasFinally) return nullptr; - + return cast_or_null<ObjCAtFinallyStmt>(getStmts()[1 + NumCatchStmts]); } - void setFinallyStmt(Stmt *S) { + void setFinallyStmt(Stmt *S) { assert(HasFinally && "@try does not have a @finally slot!"); - getStmts()[1 + NumCatchStmts] = S; + getStmts()[1 + NumCatchStmts] = S; } SourceLocation getLocStart() const LLVM_READONLY { return AtTryLoc; } diff --git a/include/clang/AST/StmtOpenMP.h b/include/clang/AST/StmtOpenMP.h index 84a35db938b06..d23375e7606ba 100644 --- a/include/clang/AST/StmtOpenMP.h +++ b/include/clang/AST/StmtOpenMP.h @@ -2319,7 +2319,7 @@ class OMPTargetDataDirective : public OMPExecutableDirective { /// OMPTargetDataDirective(SourceLocation StartLoc, SourceLocation EndLoc, unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, + : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, OMPD_target_data, StartLoc, EndLoc, NumClauses, 1) {} @@ -2328,7 +2328,7 @@ class OMPTargetDataDirective : public OMPExecutableDirective { /// \param NumClauses Number of clauses. /// explicit OMPTargetDataDirective(unsigned NumClauses) - : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, + : OMPExecutableDirective(this, OMPTargetDataDirectiveClass, OMPD_target_data, SourceLocation(), SourceLocation(), NumClauses, 1) {} @@ -3157,7 +3157,7 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective { unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass, - OMPD_distribute_parallel_for_simd, StartLoc, + OMPD_distribute_parallel_for_simd, StartLoc, EndLoc, CollapsedNum, NumClauses) {} /// Build an empty directive. @@ -3168,7 +3168,7 @@ class OMPDistributeParallelForSimdDirective final : public OMPLoopDirective { explicit OMPDistributeParallelForSimdDirective(unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPDistributeParallelForSimdDirectiveClass, - OMPD_distribute_parallel_for_simd, + OMPD_distribute_parallel_for_simd, SourceLocation(), SourceLocation(), CollapsedNum, NumClauses) {} @@ -3232,7 +3232,7 @@ class OMPDistributeSimdDirective final : public OMPLoopDirective { /// \param CollapsedNum Number of collapsed nested loops. /// \param NumClauses Number of clauses. /// - explicit OMPDistributeSimdDirective(unsigned CollapsedNum, + explicit OMPDistributeSimdDirective(unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPDistributeSimdDirectiveClass, OMPD_distribute_simd, SourceLocation(), @@ -3369,7 +3369,7 @@ class OMPTargetSimdDirective final : public OMPLoopDirective { /// \param NumClauses Number of clauses. /// explicit OMPTargetSimdDirective(unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd, + : OMPLoopDirective(this, OMPTargetSimdDirectiveClass, OMPD_target_simd, SourceLocation(),SourceLocation(), CollapsedNum, NumClauses) {} @@ -3425,8 +3425,8 @@ class OMPTeamsDistributeDirective final : public OMPLoopDirective { /// OMPTeamsDistributeDirective(SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, unsigned NumClauses) - : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, - OMPD_teams_distribute, StartLoc, EndLoc, + : OMPLoopDirective(this, OMPTeamsDistributeDirectiveClass, + OMPD_teams_distribute, StartLoc, EndLoc, CollapsedNum, NumClauses) {} /// Build an empty directive. @@ -3567,7 +3567,7 @@ class OMPTeamsDistributeParallelForSimdDirective final unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, - OMPD_teams_distribute_parallel_for_simd, StartLoc, + OMPD_teams_distribute_parallel_for_simd, StartLoc, EndLoc, CollapsedNum, NumClauses) {} /// Build an empty directive. @@ -3578,7 +3578,7 @@ class OMPTeamsDistributeParallelForSimdDirective final explicit OMPTeamsDistributeParallelForSimdDirective(unsigned CollapsedNum, unsigned NumClauses) : OMPLoopDirective(this, OMPTeamsDistributeParallelForSimdDirectiveClass, - OMPD_teams_distribute_parallel_for_simd, + OMPD_teams_distribute_parallel_for_simd, SourceLocation(), SourceLocation(), CollapsedNum, NumClauses) {} diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h index a1920253de78a..6898ef4e1b8a4 100644 --- a/include/clang/AST/TemplateBase.h +++ b/include/clang/AST/TemplateBase.h @@ -252,7 +252,7 @@ public: /// Determine whether this template argument is a pack expansion. bool isPackExpansion() const; - + /// Retrieve the type for a type template argument. QualType getAsType() const { assert(getKind() == Type && "Unexpected kind"); @@ -288,14 +288,14 @@ public: TemplateName getAsTemplateOrTemplatePattern() const { assert((getKind() == Template || getKind() == TemplateExpansion) && "Unexpected kind"); - + return TemplateName::getFromVoidPointer(TemplateArg.Name); } /// Retrieve the number of expansions that a template template argument /// expansion will produce, if known. Optional<unsigned> getNumTemplateExpansions() const; - + /// Retrieve the template argument as an integral value. // FIXME: Provide a way to read the integral data without copying the value. llvm::APSInt getAsIntegral() const { @@ -378,13 +378,13 @@ public: /// Print this template argument to the given output stream. void print(const PrintingPolicy &Policy, raw_ostream &Out) const; - + /// Debugging aid that dumps the template argument. void dump(raw_ostream &Out) const; /// Debugging aid that dumps the template argument to standard error. void dump() const; - + /// Used to insert TemplateArguments into FoldingSets. void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const; }; @@ -411,9 +411,9 @@ public: constexpr TemplateArgumentLocInfo() : Template({nullptr, nullptr, 0, 0}) {} TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {} - + TemplateArgumentLocInfo(Expr *E) : Expression(E) {} - + TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc) { @@ -432,14 +432,14 @@ public: } NestedNameSpecifierLoc getTemplateQualifierLoc() const { - return NestedNameSpecifierLoc(Template.Qualifier, + return NestedNameSpecifierLoc(Template.Qualifier, Template.QualifierLocData); } - + SourceLocation getTemplateNameLoc() const { return SourceLocation::getFromRawEncoding(Template.TemplateNameLoc); } - + SourceLocation getTemplateEllipsisLoc() const { return SourceLocation::getFromRawEncoding(Template.EllipsisLoc); } @@ -465,10 +465,16 @@ public: TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E) : Argument(Argument), LocInfo(E) { - assert(Argument.getKind() == TemplateArgument::Expression); + + // Permit any kind of template argument that can be represented with an + // expression + assert(Argument.getKind() == TemplateArgument::NullPtr || + Argument.getKind() == TemplateArgument::Integral || + Argument.getKind() == TemplateArgument::Declaration || + Argument.getKind() == TemplateArgument::Expression); } - TemplateArgumentLoc(const TemplateArgument &Argument, + TemplateArgumentLoc(const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc = SourceLocation()) @@ -477,13 +483,13 @@ public: assert(Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion); } - + /// - Fetches the primary location of the argument. SourceLocation getLocation() const { if (Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion) return getTemplateNameLoc(); - + return getSourceRange().getBegin(); } @@ -528,13 +534,13 @@ public: Argument.getKind() == TemplateArgument::TemplateExpansion); return LocInfo.getTemplateQualifierLoc(); } - + SourceLocation getTemplateNameLoc() const { assert(Argument.getKind() == TemplateArgument::Template || Argument.getKind() == TemplateArgument::TemplateExpansion); return LocInfo.getTemplateNameLoc(); - } - + } + SourceLocation getTemplateEllipsisLoc() const { assert(Argument.getKind() == TemplateArgument::TemplateExpansion); return LocInfo.getTemplateEllipsisLoc(); @@ -689,7 +695,7 @@ inline const TemplateArgument & assert(Idx < getNumArgs() && "Template argument out of range"); return getArgs()[Idx]; } - + } // namespace clang #endif // LLVM_CLANG_AST_TEMPLATEBASE_H diff --git a/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h index 50549e1a0a6a3..d88d58d0a2aad 100644 --- a/include/clang/AST/TemplateName.h +++ b/include/clang/AST/TemplateName.h @@ -22,7 +22,7 @@ #include <cassert> namespace clang { - + class ASTContext; class DependentTemplateName; class DiagnosticBuilder; @@ -38,7 +38,7 @@ class SubstTemplateTemplateParmStorage; class TemplateArgument; class TemplateDecl; class TemplateTemplateParmDecl; - + /// Implementation class used to describe either a set of overloaded /// template names or an already-substituted template template parameter pack. class UncommonTemplateNameStorage { @@ -52,7 +52,7 @@ protected: struct BitsTag { /// A Kind. unsigned Kind : 2; - + /// The number of stored templates or template arguments, /// depending on which subclass we have. unsigned Size : 30; @@ -62,21 +62,21 @@ protected: struct BitsTag Bits; void *PointerAlignment; }; - + UncommonTemplateNameStorage(Kind kind, unsigned size) { Bits.Kind = kind; Bits.Size = size; } - + public: unsigned size() const { return Bits.Size; } - + OverloadedTemplateStorage *getAsOverloadedStorage() { return Bits.Kind == Overloaded - ? reinterpret_cast<OverloadedTemplateStorage *>(this) + ? reinterpret_cast<OverloadedTemplateStorage *>(this) : nullptr; } - + SubstTemplateTemplateParmStorage *getAsSubstTemplateTemplateParm() { return Bits.Kind == SubstTemplateTemplateParm ? reinterpret_cast<SubstTemplateTemplateParmStorage *>(this) @@ -89,13 +89,13 @@ public: : nullptr; } }; - + /// A structure for storing the information associated with an /// overloaded template name. class OverloadedTemplateStorage : public UncommonTemplateNameStorage { friend class ASTContext; - OverloadedTemplateStorage(unsigned size) + OverloadedTemplateStorage(unsigned size) : UncommonTemplateNameStorage(Overloaded, size) {} NamedDecl **getStorage() { @@ -115,7 +115,7 @@ public: /// A structure for storing an already-substituted template template /// parameter pack. /// -/// This kind of template names occurs when the parameter pack has been +/// This kind of template names occurs when the parameter pack has been /// provided with a template template argument pack in a context where its /// enclosing pack expansion could not be fully expanded. class SubstTemplateTemplateParmPackStorage @@ -123,25 +123,25 @@ class SubstTemplateTemplateParmPackStorage { TemplateTemplateParmDecl *Parameter; const TemplateArgument *Arguments; - + public: SubstTemplateTemplateParmPackStorage(TemplateTemplateParmDecl *Parameter, - unsigned Size, + unsigned Size, const TemplateArgument *Arguments) : UncommonTemplateNameStorage(SubstTemplateTemplateParmPack, Size), Parameter(Parameter), Arguments(Arguments) {} - + /// Retrieve the template template parameter pack being substituted. TemplateTemplateParmDecl *getParameterPack() const { return Parameter; } - + /// Retrieve the template template argument pack with which this /// parameter was substituted. TemplateArgument getArgumentPack() const; - + void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context); - + static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, TemplateTemplateParmDecl *Parameter, @@ -193,11 +193,11 @@ public: /// A set of overloaded template declarations. OverloadedTemplate, - /// A qualified template name, where the qualification is kept + /// A qualified template name, where the qualification is kept /// to describe the source code as written. QualifiedTemplate, - /// A dependent template name that has not been resolved to a + /// A dependent template name that has not been resolved to a /// template (or set of templates). DependentTemplate, @@ -205,7 +205,7 @@ public: /// for some other template name. SubstTemplateTemplateParm, - /// A template template parameter pack that has been substituted for + /// A template template parameter pack that has been substituted for /// a template template argument pack, but has not yet been expanded into /// individual arguments. SubstTemplateTemplateParmPack @@ -221,7 +221,7 @@ public: /// Determine whether this template name is NULL. bool isNull() const; - + // Get the kind of name that is actually stored. NameKind getKind() const; @@ -243,14 +243,14 @@ public: /// refers to a single template, returns NULL. OverloadedTemplateStorage *getAsOverloadedTemplate() const; - /// Retrieve the substituted template template parameter, if + /// Retrieve the substituted template template parameter, if /// known. /// /// \returns The storage for the substituted template template parameter, /// if known. Otherwise, returns NULL. SubstTemplateTemplateParmStorage *getAsSubstTemplateTemplateParm() const; - /// Retrieve the substituted template template parameter pack, if + /// Retrieve the substituted template template parameter pack, if /// known. /// /// \returns The storage for the substituted template template parameter pack, @@ -339,7 +339,7 @@ public: TemplateName getReplacement() const { return Replacement; } void Profile(llvm::FoldingSetNodeID &ID); - + static void Profile(llvm::FoldingSetNodeID &ID, TemplateTemplateParmDecl *parameter, TemplateName replacement); @@ -436,7 +436,7 @@ class DependentTemplateName : public llvm::FoldingSetNode { /// /// Only valid when the bit on \c Qualifier is clear. const IdentifierInfo *Identifier; - + /// The overloaded operator name. /// /// Only valid when the bit on \c Qualifier is set. @@ -453,26 +453,26 @@ class DependentTemplateName : public llvm::FoldingSetNode { DependentTemplateName(NestedNameSpecifier *Qualifier, const IdentifierInfo *Identifier) - : Qualifier(Qualifier, false), Identifier(Identifier), + : Qualifier(Qualifier, false), Identifier(Identifier), CanonicalTemplateName(this) {} DependentTemplateName(NestedNameSpecifier *Qualifier, const IdentifierInfo *Identifier, TemplateName Canon) - : Qualifier(Qualifier, false), Identifier(Identifier), + : Qualifier(Qualifier, false), Identifier(Identifier), CanonicalTemplateName(Canon) {} DependentTemplateName(NestedNameSpecifier *Qualifier, OverloadedOperatorKind Operator) - : Qualifier(Qualifier, true), Operator(Operator), + : Qualifier(Qualifier, true), Operator(Operator), CanonicalTemplateName(this) {} - + DependentTemplateName(NestedNameSpecifier *Qualifier, OverloadedOperatorKind Operator, TemplateName Canon) - : Qualifier(Qualifier, true), Operator(Operator), + : Qualifier(Qualifier, true), Operator(Operator), CanonicalTemplateName(Canon) {} - + public: /// Return the nested name specifier that qualifies this name. NestedNameSpecifier *getQualifier() const { return Qualifier.getPointer(); } @@ -481,22 +481,22 @@ public: bool isIdentifier() const { return !Qualifier.getInt(); } /// Returns the identifier to which this template name refers. - const IdentifierInfo *getIdentifier() const { + const IdentifierInfo *getIdentifier() const { assert(isIdentifier() && "Template name isn't an identifier?"); return Identifier; } - + /// Determine whether this template name refers to an overloaded /// operator. bool isOverloadedOperator() const { return Qualifier.getInt(); } - + /// Return the overloaded operator to which this template name refers. - OverloadedOperatorKind getOperator() const { + OverloadedOperatorKind getOperator() const { assert(isOverloadedOperator() && "Template name isn't an overloaded operator?"); - return Operator; + return Operator; } - + void Profile(llvm::FoldingSetNodeID &ID) { if (isIdentifier()) Profile(ID, getQualifier(), getIdentifier()); diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index c692707847a69..9a8dd6faff31c 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -992,7 +992,7 @@ public: static std::string getAsString(const Type *ty, Qualifiers qs, const PrintingPolicy &Policy); - std::string getAsString() const; + std::string getAsString() const; std::string getAsString(const PrintingPolicy &Policy) const; void print(raw_ostream &OS, const PrintingPolicy &Policy, @@ -2017,6 +2017,9 @@ public: /// type of a class template or class template partial specialization. CXXRecordDecl *getAsCXXRecordDecl() const; + /// Retrieves the RecordDecl this type refers to. + RecordDecl *getAsRecordDecl() const; + /// Retrieves the TagDecl that this type refers to, either /// because the type is a TagType or because it is the injected-class-name /// type of a class template or class template partial specialization. @@ -2926,7 +2929,7 @@ public: }; /// Represents an extended address space qualifier where the input address space -/// value is dependent. Non-dependent address spaces are not represented with a +/// value is dependent. Non-dependent address spaces are not represented with a /// special Type subclass; they are stored on an ExtQuals node as part of a QualType. /// /// For example: @@ -2945,7 +2948,7 @@ class DependentAddressSpaceType : public Type, public llvm::FoldingSetNode { SourceLocation loc; DependentAddressSpaceType(const ASTContext &Context, QualType PointeeType, - QualType can, Expr *AddrSpaceExpr, + QualType can, Expr *AddrSpaceExpr, SourceLocation loc); public: @@ -3264,7 +3267,7 @@ public: Bits = ((unsigned)cc) | (noReturn ? NoReturnMask : 0) | (producesResult ? ProducesResultMask : 0) | (noCallerSavedRegs ? NoCallerSavedRegsMask : 0) | - (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) | + (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) | (NoCfCheck ? NoCfCheckMask : 0); } @@ -4234,6 +4237,7 @@ public: attr_null_unspecified, attr_objc_kindof, attr_objc_inert_unsafe_unretained, + attr_lifetimebound, }; private: @@ -5336,7 +5340,7 @@ public: /// with base C and no protocols. /// /// 'C<P>' is an unspecialized ObjCObjectType with base C and protocol list [P]. -/// 'C<C*>' is a specialized ObjCObjectType with type arguments 'C*' and no +/// 'C<C*>' is a specialized ObjCObjectType with type arguments 'C*' and no /// protocol list. /// 'C<C*><P>' is a specialized ObjCObjectType with base C, type arguments 'C*', /// and protocol list [P]. @@ -5968,7 +5972,7 @@ inline QualType QualType::getUnqualifiedType() const { return QualType(getSplitUnqualifiedTypeImpl(*this).Ty, 0); } - + inline SplitQualType QualType::getSplitUnqualifiedType() const { if (!getTypePtr()->getCanonicalTypeInternal().hasLocalQualifiers()) return split(); @@ -6443,7 +6447,7 @@ inline bool Type::isIntegralOrEnumerationType() const { if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) return IsEnumDeclComplete(ET->getDecl()); - return false; + return false; } inline bool Type::isBooleanType() const { diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 25cd014efe5f4..c69f4aa4abcf1 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -992,7 +992,7 @@ class ObjCObjectTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, return (TypeSourceInfo**)this->getExtraLocalData(); } - // SourceLocations are stored after the type argument information, one for + // SourceLocations are stored after the type argument information, one for // each Protocol. SourceLocation *getProtocolLocArray() const { return (SourceLocation*)(getTypeArgLocArray() + getNumTypeArgs()); @@ -1131,11 +1131,11 @@ public: void setNameLoc(SourceLocation Loc) { getLocalData()->NameLoc = Loc; } - + SourceRange getLocalSourceRange() const { return SourceRange(getNameLoc(), getNameEndLoc()); } - + SourceLocation getNameEndLoc() const { return getLocalData()->NameEndLoc; } @@ -1766,10 +1766,10 @@ public: return range; } - /// Returns the type before the address space attribute application - /// area. + /// Returns the type before the address space attribute application + /// area. /// int * __attribute__((address_space(11))) * - /// ^ ^ + /// ^ ^ QualType getInnerType() const { return this->getTypePtr()->getPointeeType(); } diff --git a/include/clang/AST/TypeOrdering.h b/include/clang/AST/TypeOrdering.h index d29dd6d601247..7ea78071f5cf0 100644 --- a/include/clang/AST/TypeOrdering.h +++ b/include/clang/AST/TypeOrdering.h @@ -56,20 +56,20 @@ namespace llvm { }; template<> struct DenseMapInfo<clang::CanQualType> { - static inline clang::CanQualType getEmptyKey() { - return clang::CanQualType(); + static inline clang::CanQualType getEmptyKey() { + return clang::CanQualType(); } - + static inline clang::CanQualType getTombstoneKey() { using clang::CanQualType; return CanQualType::getFromOpaquePtr(reinterpret_cast<clang::Type *>(-1)); } - + static unsigned getHashValue(clang::CanQualType Val) { return (unsigned)((uintptr_t)Val.getAsOpaquePtr()) ^ ((unsigned)((uintptr_t)Val.getAsOpaquePtr() >> 9)); } - + static bool isEqual(clang::CanQualType LHS, clang::CanQualType RHS) { return LHS == RHS; } diff --git a/include/clang/AST/UnresolvedSet.h b/include/clang/AST/UnresolvedSet.h index d6b01cb573347..b62e9f138bb64 100644 --- a/include/clang/AST/UnresolvedSet.h +++ b/include/clang/AST/UnresolvedSet.h @@ -146,7 +146,7 @@ template <unsigned InlineCapacity> class UnresolvedSet : SmallVector<DeclAccessPair, InlineCapacity> Decls; }; - + } // namespace clang #endif // LLVM_CLANG_AST_UNRESOLVEDSET_H diff --git a/include/clang/AST/VTTBuilder.h b/include/clang/AST/VTTBuilder.h index 84661c8cc7f24..3a8a6a9c15f0e 100644 --- a/include/clang/AST/VTTBuilder.h +++ b/include/clang/AST/VTTBuilder.h @@ -76,15 +76,15 @@ class VTTBuilder { const CXXRecordDecl *MostDerivedClass; using VTTVTablesVectorTy = SmallVector<VTTVTable, 64>; - + /// The VTT vtables. VTTVTablesVectorTy VTTVTables; - + using VTTComponentsVectorTy = SmallVector<VTTComponent, 64>; - + /// The VTT components. VTTComponentsVectorTy VTTComponents; - + /// The AST record layout of the most derived class. const ASTRecordLayout &MostDerivedClassLayout; @@ -105,35 +105,35 @@ class VTTBuilder { /// Add a vtable pointer to the VTT currently being built. void AddVTablePointer(BaseSubobject Base, uint64_t VTableIndex, const CXXRecordDecl *VTableClass); - + /// Lay out the secondary VTTs of the given base subobject. void LayoutSecondaryVTTs(BaseSubobject Base); - + /// Lay out the secondary virtual pointers for the given base /// subobject. /// /// \param BaseIsMorallyVirtual whether the base subobject is a virtual base /// or a direct or indirect base of a virtual base. - void LayoutSecondaryVirtualPointers(BaseSubobject Base, + void LayoutSecondaryVirtualPointers(BaseSubobject Base, bool BaseIsMorallyVirtual, uint64_t VTableIndex, const CXXRecordDecl *VTableClass, VisitedVirtualBasesSetTy &VBases); - + /// Lay out the secondary virtual pointers for the given base /// subobject. - void LayoutSecondaryVirtualPointers(BaseSubobject Base, + void LayoutSecondaryVirtualPointers(BaseSubobject Base, uint64_t VTableIndex); /// Lay out the VTTs for the virtual base classes of the given /// record declaration. void LayoutVirtualVTTs(const CXXRecordDecl *RD, VisitedVirtualBasesSetTy &VBases); - + /// Lay out the VTT for the given subobject, including any /// secondary VTTs, secondary virtual pointers and virtual VTTs. void LayoutVTT(BaseSubobject Base, bool BaseIsVirtual); - + public: VTTBuilder(ASTContext &Ctx, const CXXRecordDecl *MostDerivedClass, bool GenerateDefinition); @@ -142,17 +142,17 @@ public: const VTTComponentsVectorTy &getVTTComponents() const { return VTTComponents; } - + // Returns a reference to the VTT vtables. const VTTVTablesVectorTy &getVTTVTables() const { return VTTVTables; } - + /// Returns a reference to the sub-VTT indices. const llvm::DenseMap<BaseSubobject, uint64_t> &getSubVTTIndicies() const { return SubVTTIndicies; } - + /// Returns a reference to the secondary virtual pointer indices. const llvm::DenseMap<BaseSubobject, uint64_t> & getSecondaryVirtualPointerIndices() const { diff --git a/include/clang/AST/VTableBuilder.h b/include/clang/AST/VTableBuilder.h index 643103916149b..4a779db01ff8b 100644 --- a/include/clang/AST/VTableBuilder.h +++ b/include/clang/AST/VTableBuilder.h @@ -394,7 +394,7 @@ public: /// Return the offset in chars (relative to the vtable address point) where /// the offset of the virtual base that contains the given base is stored, - /// otherwise, if no virtual base contains the given class, return 0. + /// otherwise, if no virtual base contains the given class, return 0. /// /// Base must be a virtual base class or an unambiguous base. CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 58f65a39fb48b..51f2ce2af75cc 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1247,7 +1247,7 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl, ObjCMethodDecl> objcMethodDecl; /// Matches block declarations. -/// +/// /// Example matches the declaration of the nameless block printing an input /// integer. /// @@ -1654,7 +1654,6 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, DeclRefExpr> /// - (void) init { /// a = @"hello"; /// } -//} /// \endcode extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCIvarRefExpr> objcIvarRefExpr; @@ -2886,7 +2885,7 @@ AST_MATCHER(ObjCMessageExpr, hasKeywordSelector) { AST_MATCHER_P(ObjCMessageExpr, numSelectorArgs, unsigned, N) { return Node.getSelector().getNumArgs() == N; } - + /// Matches if the call expression's callee expression matches. /// /// Given @@ -3679,7 +3678,7 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParam, /// \code /// b = ^(int y) { printf("%d", y) }; /// \endcode -/// +/// /// the matcher blockDecl(hasAnyParameter(hasName("y"))) /// matches the declaration of the block b with hasParameter /// matching y. @@ -5141,7 +5140,7 @@ extern const AstTypeMatcher<AutoType> autoType; /// int j = 42; /// decltype(i + j) result = i + j; /// \endcode -/// decltypeType() +/// decltypeType() /// matches "decltype(i + j)" extern const AstTypeMatcher<DecltypeType> decltypeType; @@ -6048,8 +6047,8 @@ AST_MATCHER(NamedDecl, hasExternalFormalLinkage) { /// void x(int val) {} /// void y(int val = 0) {} /// \endcode -AST_MATCHER(ParmVarDecl, hasDefaultArgument) { - return Node.hasDefaultArg(); +AST_MATCHER(ParmVarDecl, hasDefaultArgument) { + return Node.hasDefaultArg(); } /// Matches array new expressions. diff --git a/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h b/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h index da59514c4fa6e..49da6815ace9d 100644 --- a/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h +++ b/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h @@ -23,7 +23,7 @@ namespace clang { class CFG; class CFGBlock; - + // A class that performs reachability queries for CFGBlocks. Several internal // checks in this checker require reachability information. The requests all // tend to have a common destination, so we lazily do a predecessor search @@ -45,7 +45,7 @@ public: private: void mapReachability(const CFGBlock *Dst); }; - + } // namespace clang #endif // LLVM_CLANG_ANALYSIS_ANALYSES_CFGREACHABILITYANALYSIS_H diff --git a/include/clang/Analysis/Analyses/Consumed.h b/include/clang/Analysis/Analyses/Consumed.h index 6003d665fd88b..5a70989e50871 100644 --- a/include/clang/Analysis/Analyses/Consumed.h +++ b/include/clang/Analysis/Analyses/Consumed.h @@ -38,18 +38,18 @@ class Stmt; class VarDecl; namespace consumed { - + class ConsumedStmtVisitor; enum ConsumedState { // No state information for the given variable. CS_None, - + CS_Unknown, CS_Unconsumed, CS_Consumed }; - + using OptionalNotes = SmallVector<PartialDiagnosticAt, 1>; using DelayedDiag = std::pair<PartialDiagnosticAt, OptionalNotes>; using DiagList = std::list<DelayedDiag>; @@ -60,7 +60,7 @@ namespace consumed { /// Emit the warnings and notes left by the analysis. virtual void emitDiagnostics() {} - + /// Warn that a variable's state doesn't match at the entry and exit /// of a loop. /// @@ -70,7 +70,7 @@ namespace consumed { /// state. virtual void warnLoopStateMismatch(SourceLocation Loc, StringRef VariableName) {} - + /// Warn about parameter typestate mismatches upon return. /// /// \param Loc -- The SourceLocation of the return statement. @@ -84,22 +84,22 @@ namespace consumed { StringRef VariableName, StringRef ExpectedState, StringRef ObservedState) {} - + // FIXME: Add documentation. virtual void warnParamTypestateMismatch(SourceLocation LOC, StringRef ExpectedState, StringRef ObservedState) {} - + // FIXME: This can be removed when the attr propagation fix for templated // classes lands. /// Warn about return typestates set for unconsumable types. - /// + /// /// \param Loc -- The location of the attributes. /// /// \param TypeName -- The name of the unconsumable type. virtual void warnReturnTypestateForUnconsumableType(SourceLocation Loc, StringRef TypeName) {} - + /// Warn about return typestate mismatches. /// /// \param Loc -- The SourceLocation of the return statement. @@ -144,71 +144,71 @@ namespace consumed { using VarMapType = llvm::DenseMap<const VarDecl *, ConsumedState>; using TmpMapType = llvm::DenseMap<const CXXBindTemporaryExpr *, ConsumedState>; - + protected: bool Reachable = true; const Stmt *From = nullptr; VarMapType VarMap; TmpMapType TmpMap; - + public: ConsumedStateMap() = default; ConsumedStateMap(const ConsumedStateMap &Other) : Reachable(Other.Reachable), From(Other.From), VarMap(Other.VarMap), TmpMap() {} - + /// Warn if any of the parameters being tracked are not in the state /// they were declared to be in upon return from a function. void checkParamsForReturnTypestate(SourceLocation BlameLoc, ConsumedWarningsHandlerBase &WarningsHandler) const; - + /// Clear the TmpMap. void clearTemporaries(); - + /// Get the consumed state of a given variable. ConsumedState getState(const VarDecl *Var) const; - + /// Get the consumed state of a given temporary value. ConsumedState getState(const CXXBindTemporaryExpr *Tmp) const; - + /// Merge this state map with another map. void intersect(const ConsumedStateMap &Other); void intersectAtLoopHead(const CFGBlock *LoopHead, const CFGBlock *LoopBack, const ConsumedStateMap *LoopBackStates, ConsumedWarningsHandlerBase &WarningsHandler); - + /// Return true if this block is reachable. bool isReachable() const { return Reachable; } - + /// Mark the block as unreachable. void markUnreachable(); - + /// Set the source for a decision about the branching of states. /// \param Source -- The statement that was the origin of a branching /// decision. void setSource(const Stmt *Source) { this->From = Source; } - + /// Set the consumed state of a given variable. void setState(const VarDecl *Var, ConsumedState State); - + /// Set the consumed state of a given temporary value. void setState(const CXXBindTemporaryExpr *Tmp, ConsumedState State); - + /// Remove the temporary value from our state map. void remove(const CXXBindTemporaryExpr *Tmp); - + /// Tests to see if there is a mismatch in the states stored in two /// maps. /// /// \param Other -- The second map to compare against. bool operator!=(const ConsumedStateMap *Other) const; }; - + class ConsumedBlockInfo { std::vector<std::unique_ptr<ConsumedStateMap>> StateMapsArray; std::vector<unsigned int> VisitOrder; - + public: ConsumedBlockInfo() = default; @@ -218,7 +218,7 @@ namespace consumed { for (const auto BI : *SortedGraph) VisitOrder[BI->getBlockID()] = VisitOrderCounter++; } - + bool allBackEdgesVisited(const CFGBlock *CurrBlock, const CFGBlock *TargetBlock); @@ -228,7 +228,7 @@ namespace consumed { std::unique_ptr<ConsumedStateMap> StateMap); ConsumedStateMap* borrowInfo(const CFGBlock *Block); - + void discardInfo(const CFGBlock *Block); std::unique_ptr<ConsumedStateMap> getInfo(const CFGBlock *Block); @@ -243,12 +243,12 @@ namespace consumed { std::unique_ptr<ConsumedStateMap> CurrStates; ConsumedState ExpectedReturnState; - + void determineExpectedReturnState(AnalysisDeclContext &AC, const FunctionDecl *D); bool splitState(const CFGBlock *CurrBlock, const ConsumedStmtVisitor &Visitor); - + public: ConsumedWarningsHandlerBase &WarningsHandler; @@ -256,7 +256,7 @@ namespace consumed { : WarningsHandler(WarningsHandler) {} ConsumedState getExpectedReturnState() const { return ExpectedReturnState; } - + /// Check a function's CFG for consumed violations. /// /// We traverse the blocks in the CFG, keeping track of the state of each diff --git a/include/clang/Analysis/Analyses/Dominators.h b/include/clang/Analysis/Analyses/Dominators.h index a9cdc5560bc07..021e98dcd8854 100644 --- a/include/clang/Analysis/Analyses/Dominators.h +++ b/include/clang/Analysis/Analyses/Dominators.h @@ -20,7 +20,7 @@ #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" #include "llvm/Support/GenericDomTree.h" -#include "llvm/Support/GenericDomTreeConstruction.h" +#include "llvm/Support/GenericDomTreeConstruction.h" #include "llvm/Support/raw_ostream.h" // FIXME: There is no good reason for the domtree to require a print method diff --git a/include/clang/Analysis/Analyses/FormatString.h b/include/clang/Analysis/Analyses/FormatString.h index 6f8bb9b4095fa..598d341ac829d 100644 --- a/include/clang/Analysis/Analyses/FormatString.h +++ b/include/clang/Analysis/Analyses/FormatString.h @@ -236,7 +236,7 @@ public: const char *toString() const; bool isPrintfKind() const { return IsPrintf; } - + Optional<ConversionSpecifier> getStandardSpecifier() const; protected: diff --git a/include/clang/Analysis/Analyses/LiveVariables.h b/include/clang/Analysis/Analyses/LiveVariables.h index 21c3ba255c366..0cb500fffb950 100644 --- a/include/clang/Analysis/Analyses/LiveVariables.h +++ b/include/clang/Analysis/Analyses/LiveVariables.h @@ -25,7 +25,7 @@ class CFGBlock; class Stmt; class DeclRefExpr; class SourceManager; - + class LiveVariables : public ManagedAnalysis { public: class LivenessValues { @@ -34,7 +34,7 @@ public: llvm::ImmutableSet<const Stmt *> liveStmts; llvm::ImmutableSet<const VarDecl *> liveDecls; llvm::ImmutableSet<const BindingDecl *> liveBindings; - + bool equals(const LivenessValues &V) const; LivenessValues() @@ -48,21 +48,21 @@ public: bool isLive(const Stmt *S) const; bool isLive(const VarDecl *D) const; - - friend class LiveVariables; + + friend class LiveVariables; }; - + class Observer { virtual void anchor(); public: virtual ~Observer() {} - + /// A callback invoked right before invoking the /// liveness transfer function on the given statement. virtual void observeStmt(const Stmt *S, const CFGBlock *currentBlock, const LivenessValues& V) {} - + /// Called when the live variables analysis registers /// that a variable is killed. virtual void observerKill(const DeclRefExpr *DR) {} @@ -73,47 +73,47 @@ public: /// Compute the liveness information for a given CFG. static LiveVariables *computeLiveness(AnalysisDeclContext &analysisContext, bool killAtAssign); - + /// Return true if a variable is live at the end of a /// specified block. bool isLive(const CFGBlock *B, const VarDecl *D); - + /// Returns true if a variable is live at the beginning of the /// the statement. This query only works if liveness information /// has been recorded at the statement level (see runOnAllBlocks), and /// only returns liveness information for block-level expressions. bool isLive(const Stmt *S, const VarDecl *D); - + /// Returns true the block-level expression "value" is live /// before the given block-level expression (see runOnAllBlocks). bool isLive(const Stmt *Loc, const Stmt *StmtVal); - + /// Print to stderr the liveness information associated with /// each basic block. void dumpBlockLiveness(const SourceManager& M); void runOnAllBlocks(Observer &obs); - + static LiveVariables *create(AnalysisDeclContext &analysisContext) { return computeLiveness(analysisContext, true); } - + static const void *getTag(); - + private: LiveVariables(void *impl); void *impl; }; - + class RelaxedLiveVariables : public LiveVariables { public: static LiveVariables *create(AnalysisDeclContext &analysisContext) { return computeLiveness(analysisContext, false); } - + static const void *getTag(); }; - + } // end namespace clang #endif diff --git a/include/clang/Analysis/Analyses/ReachableCode.h b/include/clang/Analysis/Analyses/ReachableCode.h index 4c523bfc8b561..d79f1b03df7b5 100644 --- a/include/clang/Analysis/Analyses/ReachableCode.h +++ b/include/clang/Analysis/Analyses/ReachableCode.h @@ -57,7 +57,7 @@ public: }; /// ScanReachableFromBlock - Mark all blocks reachable from Start. -/// Returns the total number of blocks that were marked reachable. +/// Returns the total number of blocks that were marked reachable. unsigned ScanReachableFromBlock(const CFGBlock *Start, llvm::BitVector &Reachable); diff --git a/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index 580872e17ef46..599c164923cba 100644 --- a/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -500,7 +500,7 @@ private: std::vector<til::BasicBlock *> BlockMap; // Extra information per BB. Indexed by clang BlockID. - std::vector<BlockInfo> BBInfo; + std::vector<BlockInfo> BBInfo; LVarDefinitionMap CurrentLVarMap; std::vector<til::Phi *> CurrentArguments; diff --git a/include/clang/Analysis/AnalysisDeclContext.h b/include/clang/Analysis/AnalysisDeclContext.h index 8c391b5ee1e5d..19531d92e6458 100644 --- a/include/clang/Analysis/AnalysisDeclContext.h +++ b/include/clang/Analysis/AnalysisDeclContext.h @@ -111,7 +111,7 @@ public: AnalysisDeclContextManager *getManager() const { return Manager; } - + /// Return the build options used to construct the CFG. CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; @@ -190,7 +190,7 @@ public: const Stmt *S, const CFGBlock *Blk, unsigned Idx); - + const BlockInvocationContext * getBlockInvocationContext(const LocationContext *parent, const BlockDecl *BD, @@ -359,7 +359,7 @@ class BlockInvocationContext : public LocationContext { friend class LocationContextManager; const BlockDecl *BD; - + // FIXME: Come up with a more type-safe way to model context-sensitivity. const void *ContextData; @@ -372,7 +372,7 @@ public: ~BlockInvocationContext() override = default; const BlockDecl *getBlockDecl() const { return BD; } - + const void *getContextData() const { return ContextData; } void Profile(llvm::FoldingSetNodeID &ID) override; @@ -403,7 +403,7 @@ public: const ScopeContext *getScope(AnalysisDeclContext *ctx, const LocationContext *parent, const Stmt *s); - + const BlockInvocationContext * getBlockInvocationContext(AnalysisDeclContext *ctx, const LocationContext *parent, @@ -463,7 +463,7 @@ public: CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; } - + /// Return true if faux bodies should be synthesized for well-known /// functions. bool synthesizeBodies() const { return SynthesizeBodies; } diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h index f25789822d162..bf81d8358a547 100644 --- a/include/clang/Analysis/CFG.h +++ b/include/clang/Analysis/CFG.h @@ -15,9 +15,10 @@ #ifndef LLVM_CLANG_ANALYSIS_CFG_H #define LLVM_CLANG_ANALYSIS_CFG_H -#include "clang/AST/ExprCXX.h" #include "clang/Analysis/Support/BumpVector.h" #include "clang/Analysis/ConstructionContext.h" +#include "clang/AST/ExprCXX.h" +#include "clang/AST/ExprObjC.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/GraphTraits.h" @@ -51,7 +52,7 @@ class FieldDecl; class LangOptions; class VarDecl; -/// CFGElement - Represents a top-level expression in a basic block. +/// Represents a top-level expression in a basic block. class CFGElement { public: enum Kind { @@ -144,9 +145,9 @@ protected: CFGStmt() = default; }; -/// CFGConstructor - Represents C++ constructor call. Maintains information -/// necessary to figure out what memory is being initialized by the -/// constructor expression. For now this is only used by the analyzer's CFG. +/// Represents C++ constructor call. Maintains information necessary to figure +/// out what memory is being initialized by the constructor expression. For now +/// this is only used by the analyzer's CFG. class CFGConstructor : public CFGStmt { public: explicit CFGConstructor(CXXConstructExpr *CE, const ConstructionContext *C) @@ -169,30 +170,34 @@ private: } }; -/// CFGCXXRecordTypedCall - Represents a function call that returns a C++ object -/// by value. This, like constructor, requires a construction context in order -/// to understand the storage of the returned object . In C such tracking is not -/// necessary because no additional effort is required for destroying the object -/// or modeling copy elision. Like CFGConstructor, this element is for now only -/// used by the analyzer's CFG. +/// Represents a function call that returns a C++ object by value. This, like +/// constructor, requires a construction context in order to understand the +/// storage of the returned object . In C such tracking is not necessary because +/// no additional effort is required for destroying the object or modeling copy +/// elision. Like CFGConstructor, this element is for now only used by the +/// analyzer's CFG. class CFGCXXRecordTypedCall : public CFGStmt { public: /// Returns true when call expression \p CE needs to be represented /// by CFGCXXRecordTypedCall, as opposed to a regular CFGStmt. - static bool isCXXRecordTypedCall(CallExpr *CE, const ASTContext &ACtx) { - return CE->getCallReturnType(ACtx).getCanonicalType()->getAsCXXRecordDecl(); - } - - explicit CFGCXXRecordTypedCall(CallExpr *CE, const ConstructionContext *C) - : CFGStmt(CE, CXXRecordTypedCall) { - // FIXME: This is not protected against squeezing a non-record-typed-call - // into the constructor. An assertion would require passing an ASTContext - // which would mean paying for something we don't use. + static bool isCXXRecordTypedCall(Expr *E) { + assert(isa<CallExpr>(E) || isa<ObjCMessageExpr>(E)); + // There is no such thing as reference-type expression. If the function + // returns a reference, it'll return the respective lvalue or xvalue + // instead, and we're only interested in objects. + return !E->isGLValue() && + E->getType().getCanonicalType()->getAsCXXRecordDecl(); + } + + explicit CFGCXXRecordTypedCall(Expr *E, const ConstructionContext *C) + : CFGStmt(E, CXXRecordTypedCall) { + assert(isCXXRecordTypedCall(E)); assert(C && (isa<TemporaryObjectConstructionContext>(C) || // These are possible in C++17 due to mandatory copy elision. isa<ReturnedValueConstructionContext>(C) || isa<VariableConstructionContext>(C) || - isa<ConstructorInitializerConstructionContext>(C))); + isa<ConstructorInitializerConstructionContext>(C) || + isa<ArgumentConstructionContext>(C))); Data2.setPointer(const_cast<ConstructionContext *>(C)); } @@ -210,8 +215,8 @@ private: } }; -/// CFGInitializer - Represents C++ base or member initializer from -/// constructor's initialization list. +/// Represents C++ base or member initializer from constructor's initialization +/// list. class CFGInitializer : public CFGElement { public: explicit CFGInitializer(CXXCtorInitializer *initializer) @@ -231,7 +236,7 @@ private: } }; -/// CFGNewAllocator - Represents C++ allocator call. +/// Represents C++ allocator call. class CFGNewAllocator : public CFGElement { public: explicit CFGNewAllocator(const CXXNewExpr *S) @@ -349,8 +354,8 @@ private: } }; -/// CFGImplicitDtor - Represents C++ object destructor implicitly generated -/// by compiler on various occasions. +/// Represents C++ object destructor implicitly generated by compiler on various +/// occasions. class CFGImplicitDtor : public CFGElement { protected: CFGImplicitDtor() = default; @@ -373,9 +378,9 @@ private: } }; -/// CFGAutomaticObjDtor - Represents C++ object destructor implicitly generated -/// for automatic object or temporary bound to const reference at the point -/// of leaving its local scope. +/// Represents C++ object destructor implicitly generated for automatic object +/// or temporary bound to const reference at the point of leaving its local +/// scope. class CFGAutomaticObjDtor: public CFGImplicitDtor { public: CFGAutomaticObjDtor(const VarDecl *var, const Stmt *stmt) @@ -400,8 +405,7 @@ private: } }; -/// CFGDeleteDtor - Represents C++ object destructor generated -/// from a call to delete. +/// Represents C++ object destructor generated from a call to delete. class CFGDeleteDtor : public CFGImplicitDtor { public: CFGDeleteDtor(const CXXRecordDecl *RD, const CXXDeleteExpr *DE) @@ -426,8 +430,8 @@ private: } }; -/// CFGBaseDtor - Represents C++ object destructor implicitly generated for -/// base object in destructor. +/// Represents C++ object destructor implicitly generated for base object in +/// destructor. class CFGBaseDtor : public CFGImplicitDtor { public: CFGBaseDtor(const CXXBaseSpecifier *base) @@ -447,8 +451,8 @@ private: } }; -/// CFGMemberDtor - Represents C++ object destructor implicitly generated for -/// member object in destructor. +/// Represents C++ object destructor implicitly generated for member object in +/// destructor. class CFGMemberDtor : public CFGImplicitDtor { public: CFGMemberDtor(const FieldDecl *field) @@ -468,8 +472,8 @@ private: } }; -/// CFGTemporaryDtor - Represents C++ object destructor implicitly generated -/// at the end of full expression for temporary object. +/// Represents C++ object destructor implicitly generated at the end of full +/// expression for temporary object. class CFGTemporaryDtor : public CFGImplicitDtor { public: CFGTemporaryDtor(CXXBindTemporaryExpr *expr) @@ -489,7 +493,7 @@ private: } }; -/// CFGTerminator - Represents CFGBlock terminator statement. +/// Represents CFGBlock terminator statement. /// /// TemporaryDtorsBranch bit is set to true if the terminator marks a branch /// in control flow of destructors of temporaries. In this case terminator @@ -520,7 +524,7 @@ public: explicit operator bool() const { return getStmt(); } }; -/// CFGBlock - Represents a single basic block in a source-level CFG. +/// Represents a single basic block in a source-level CFG. /// It consists of: /// /// (1) A set of statements/expressions (which may contain subexpressions). @@ -588,26 +592,24 @@ class CFGBlock { bool empty() const { return Impl.empty(); } }; - /// Stmts - The set of statements in the basic block. + /// The set of statements in the basic block. ElementList Elements; - /// Label - An (optional) label that prefixes the executable - /// statements in the block. When this variable is non-NULL, it is - /// either an instance of LabelStmt, SwitchCase or CXXCatchStmt. + /// An (optional) label that prefixes the executable statements in the block. + /// When this variable is non-NULL, it is either an instance of LabelStmt, + /// SwitchCase or CXXCatchStmt. Stmt *Label = nullptr; - /// Terminator - The terminator for a basic block that - /// indicates the type of control-flow that occurs between a block - /// and its successors. + /// The terminator for a basic block that indicates the type of control-flow + /// that occurs between a block and its successors. CFGTerminator Terminator; - /// LoopTarget - Some blocks are used to represent the "loop edge" to - /// the start of a loop from within the loop body. This Stmt* will be - /// refer to the loop statement for such blocks (and be null otherwise). + /// Some blocks are used to represent the "loop edge" to the start of a loop + /// from within the loop body. This Stmt* will be refer to the loop statement + /// for such blocks (and be null otherwise). const Stmt *LoopTarget = nullptr; - /// BlockID - A numerical ID assigned to a CFGBlock during construction - /// of the CFG. + /// A numerical ID assigned to a CFGBlock during construction of the CFG. unsigned BlockID; public: @@ -629,7 +631,7 @@ public: public: /// Construct an AdjacentBlock with a possibly unreachable block. AdjacentBlock(CFGBlock *B, bool IsReachable); - + /// Construct an AdjacentBlock with a reachable block and an alternate /// unreachable block. AdjacentBlock(CFGBlock *B, CFGBlock *AlternateBlock); @@ -665,13 +667,12 @@ public: }; private: - /// Predecessors/Successors - Keep track of the predecessor / successor - /// CFG blocks. + /// Keep track of the predecessor / successor CFG blocks. using AdjacentBlocks = BumpVector<AdjacentBlock>; AdjacentBlocks Preds; AdjacentBlocks Succs; - /// NoReturn - This bit is set when the basic block contains a function call + /// This bit is set when the basic block contains a function call /// or implicit destructor that is attributed as 'noreturn'. In that case, /// control cannot technically ever proceed past this block. All such blocks /// will have a single immediate successor: the exit block. This allows them @@ -682,7 +683,7 @@ private: /// storage if the memory usage of CFGBlock becomes an issue. unsigned HasNoReturnElement : 1; - /// Parent - The parent CFG that owns this CFGBlock. + /// The parent CFG that owns this CFGBlock. CFG *Parent; public: @@ -878,10 +879,10 @@ public: Elements.push_back(CFGConstructor(CE, CC), C); } - void appendCXXRecordTypedCall(CallExpr *CE, + void appendCXXRecordTypedCall(Expr *E, const ConstructionContext *CC, BumpVectorContext &C) { - Elements.push_back(CFGCXXRecordTypedCall(CE, CC), C); + Elements.push_back(CFGCXXRecordTypedCall(E, CC), C); } void appendInitializer(CXXCtorInitializer *initializer, @@ -992,7 +993,7 @@ public: bool isAlwaysTrue) {} }; -/// CFG - Represents a source-level, intra-procedural CFG that represents the +/// Represents a source-level, intra-procedural CFG that represents the /// control-flow of a Stmt. The Stmt can represent an entire function body, /// or a single expression. A CFG will always contain one empty block that /// represents the Exit point of the CFG. A CFG will also contain a designated @@ -1044,21 +1045,21 @@ public: } }; - /// buildCFG - Builds a CFG from an AST. + /// Builds a CFG from an AST. static std::unique_ptr<CFG> buildCFG(const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO); - /// createBlock - Create a new block in the CFG. The CFG owns the block; - /// the caller should not directly free it. + /// Create a new block in the CFG. The CFG owns the block; the caller should + /// not directly free it. CFGBlock *createBlock(); - /// setEntry - Set the entry block of the CFG. This is typically used - /// only during CFG construction. Most CFG clients expect that the - /// entry block has no predecessors and contains no statements. + /// Set the entry block of the CFG. This is typically used only during CFG + /// construction. Most CFG clients expect that the entry block has no + /// predecessors and contains no statements. void setEntry(CFGBlock *B) { Entry = B; } - /// setIndirectGotoBlock - Set the block used for indirect goto jumps. - /// This is typically used only during CFG construction. + /// Set the block used for indirect goto jumps. This is typically used only + /// during CFG construction. void setIndirectGotoBlock(CFGBlock *B) { IndirectGotoBlock = B; } //===--------------------------------------------------------------------===// @@ -1152,8 +1153,8 @@ public: template <typename CALLBACK> void VisitBlockStmts(CALLBACK& O) const { - for (const_iterator I=begin(), E=end(); I != E; ++I) - for (CFGBlock::const_iterator BI=(*I)->begin(), BE=(*I)->end(); + for (const_iterator I = begin(), E = end(); I != E; ++I) + for (CFGBlock::const_iterator BI = (*I)->begin(), BE = (*I)->end(); BI != BE; ++BI) { if (Optional<CFGStmt> stmt = BI->getAs<CFGStmt>()) O(const_cast<Stmt*>(stmt->getStmt())); @@ -1164,13 +1165,12 @@ public: // CFG Introspection. //===--------------------------------------------------------------------===// - /// getNumBlockIDs - Returns the total number of BlockIDs allocated (which - /// start at 0). + /// Returns the total number of BlockIDs allocated (which start at 0). unsigned getNumBlockIDs() const { return NumBlockIDs; } - /// size - Return the total number of CFGBlocks within the CFG - /// This is simply a renaming of the getNumBlockIDs(). This is necessary - /// because the dominator implementation needs such an interface. + /// Return the total number of CFGBlocks within the CFG This is simply a + /// renaming of the getNumBlockIDs(). This is necessary because the dominator + /// implementation needs such an interface. unsigned size() const { return NumBlockIDs; } //===--------------------------------------------------------------------===// diff --git a/include/clang/Analysis/CFGStmtMap.h b/include/clang/Analysis/CFGStmtMap.h index 4dfa91df0f42c..78e637daf379a 100644 --- a/include/clang/Analysis/CFGStmtMap.h +++ b/include/clang/Analysis/CFGStmtMap.h @@ -19,20 +19,18 @@ namespace clang { -class CFG; -class CFGBlock; class ParentMap; class Stmt; class CFGStmtMap { ParentMap *PM; void *M; - + CFGStmtMap(ParentMap *pm, void *m) : PM(pm), M(m) {} - + public: ~CFGStmtMap(); - + /// Returns a new CFGMap for the given CFG. It is the caller's /// responsibility to 'delete' this object when done using it. static CFGStmtMap *Build(CFG* C, ParentMap *PM); diff --git a/include/clang/Analysis/CloneDetection.h b/include/clang/Analysis/CloneDetection.h index 955777a11a652..915ec58a5144c 100644 --- a/include/clang/Analysis/CloneDetection.h +++ b/include/clang/Analysis/CloneDetection.h @@ -332,7 +332,7 @@ struct FilenamePatternConstraint { StringRef IgnoredFilesPattern; std::shared_ptr<llvm::Regex> IgnoredFilesRegex; - FilenamePatternConstraint(StringRef IgnoredFilesPattern) + FilenamePatternConstraint(StringRef IgnoredFilesPattern) : IgnoredFilesPattern(IgnoredFilesPattern) { IgnoredFilesRegex = std::make_shared<llvm::Regex>("^(" + IgnoredFilesPattern.str() + "$)"); diff --git a/include/clang/Analysis/ConstructionContext.h b/include/clang/Analysis/ConstructionContext.h index 40cb0e7e5ddaa..aee67865df250 100644 --- a/include/clang/Analysis/ConstructionContext.h +++ b/include/clang/Analysis/ConstructionContext.h @@ -22,65 +22,200 @@ namespace clang { -/// Construction context is a linked list of multiple layers. Layers are -/// created gradually while traversing the AST, and layers that represent -/// the outmost AST nodes are built first, while the node that immediately -/// contains the constructor would be built last and capture the previous -/// layers as its parents. Construction context captures the last layer -/// (which has links to the previous layers) and classifies the seemingly -/// arbitrary chain of layers into one of the possible ways of constructing -/// an object in C++ for user-friendly experience. -class ConstructionContextLayer { +/// Represents a single point (AST node) in the program that requires attention +/// during construction of an object. ConstructionContext would be represented +/// as a list of such items. +class ConstructionContextItem { public: - typedef llvm::PointerUnion<Stmt *, CXXCtorInitializer *> TriggerTy; + enum ItemKind { + VariableKind, + NewAllocatorKind, + ReturnKind, + MaterializationKind, + TemporaryDestructorKind, + ElidedDestructorKind, + ElidableConstructorKind, + ArgumentKind, + STATEMENT_WITH_INDEX_KIND_BEGIN=ArgumentKind, + STATEMENT_WITH_INDEX_KIND_END=ArgumentKind, + STATEMENT_KIND_BEGIN = VariableKind, + STATEMENT_KIND_END = ArgumentKind, + InitializerKind, + INITIALIZER_KIND_BEGIN=InitializerKind, + INITIALIZER_KIND_END=InitializerKind + }; + + LLVM_DUMP_METHOD static StringRef getKindAsString(ItemKind K) { + switch (K) { + case VariableKind: return "construct into local variable"; + case NewAllocatorKind: return "construct into new-allocator"; + case ReturnKind: return "construct into return address"; + case MaterializationKind: return "materialize temporary"; + case TemporaryDestructorKind: return "destroy temporary"; + case ElidedDestructorKind: return "elide destructor"; + case ElidableConstructorKind: return "elide constructor"; + case ArgumentKind: return "construct into argument"; + case InitializerKind: return "construct into member variable"; + }; + llvm_unreachable("Unknown ItemKind"); + } private: + const void *const Data; + const ItemKind Kind; + const unsigned Index = 0; + + bool hasStatement() const { + return Kind >= STATEMENT_KIND_BEGIN && + Kind <= STATEMENT_KIND_END; + } + + bool hasIndex() const { + return Kind >= STATEMENT_WITH_INDEX_KIND_BEGIN && + Kind >= STATEMENT_WITH_INDEX_KIND_END; + } + + bool hasInitializer() const { + return Kind >= INITIALIZER_KIND_BEGIN && + Kind <= INITIALIZER_KIND_END; + } + +public: + // ConstructionContextItem should be simple enough so that it was easy to + // re-construct it from the AST node it captures. For that reason we provide + // simple implicit conversions from all sorts of supported AST nodes. + ConstructionContextItem(const DeclStmt *DS) + : Data(DS), Kind(VariableKind) {} + + ConstructionContextItem(const CXXNewExpr *NE) + : Data(NE), Kind(NewAllocatorKind) {} + + ConstructionContextItem(const ReturnStmt *RS) + : Data(RS), Kind(ReturnKind) {} + + ConstructionContextItem(const MaterializeTemporaryExpr *MTE) + : Data(MTE), Kind(MaterializationKind) {} + + ConstructionContextItem(const CXXBindTemporaryExpr *BTE, + bool IsElided = false) + : Data(BTE), + Kind(IsElided ? ElidedDestructorKind : TemporaryDestructorKind) {} + + ConstructionContextItem(const CXXConstructExpr *CE) + : Data(CE), Kind(ElidableConstructorKind) {} + + ConstructionContextItem(const CallExpr *CE, unsigned Index) + : Data(CE), Kind(ArgumentKind), Index(Index) {} + + ConstructionContextItem(const CXXConstructExpr *CE, unsigned Index) + : Data(CE), Kind(ArgumentKind), Index(Index) {} + + ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index) + : Data(ME), Kind(ArgumentKind), Index(Index) {} + + // A polymorphic version of the previous calls with dynamic type check. + ConstructionContextItem(const Expr *E, unsigned Index) + : Data(E), Kind(ArgumentKind), Index(Index) { + assert(isa<CallExpr>(E) || isa<CXXConstructExpr>(E) || + isa<ObjCMessageExpr>(E)); + } + + ConstructionContextItem(const CXXCtorInitializer *Init) + : Data(Init), Kind(InitializerKind), Index(0) {} + + ItemKind getKind() const { return Kind; } + + LLVM_DUMP_METHOD StringRef getKindAsString() const { + return getKindAsString(getKind()); + } + /// The construction site - the statement that triggered the construction /// for one of its parts. For instance, stack variable declaration statement /// triggers construction of itself or its elements if it's an array, /// new-expression triggers construction of the newly allocated object(s). - TriggerTy Trigger; - - /// Sometimes a single trigger is not enough to describe the construction - /// site. In this case we'd have a chain of "partial" construction context - /// layers. - /// Some examples: - /// - A constructor within in an aggregate initializer list within a variable - /// would have a construction context of the initializer list with - /// the parent construction context of a variable. - /// - A constructor for a temporary that needs to be both destroyed - /// and materialized into an elidable copy constructor would have a - /// construction context of a CXXBindTemporaryExpr with the parent - /// construction context of a MaterializeTemproraryExpr. - /// Not all of these are currently supported. - const ConstructionContextLayer *Parent = nullptr; + const Stmt *getStmt() const { + assert(hasStatement()); + return static_cast<const Stmt *>(Data); + } - ConstructionContextLayer(TriggerTy Trigger, - const ConstructionContextLayer *Parent) - : Trigger(Trigger), Parent(Parent) {} + const Stmt *getStmtOrNull() const { + return hasStatement() ? getStmt() : nullptr; + } -public: - static const ConstructionContextLayer * - create(BumpVectorContext &C, TriggerTy Trigger, - const ConstructionContextLayer *Parent = nullptr); + /// The construction site is not necessarily a statement. It may also be a + /// CXXCtorInitializer, which means that a member variable is being + /// constructed during initialization of the object that contains it. + const CXXCtorInitializer *getCXXCtorInitializer() const { + assert(hasInitializer()); + return static_cast<const CXXCtorInitializer *>(Data); + } - const ConstructionContextLayer *getParent() const { return Parent; } - bool isLast() const { return !Parent; } + /// If a single trigger statement triggers multiple constructors, they are + /// usually being enumerated. This covers function argument constructors + /// triggered by a call-expression and items in an initializer list triggered + /// by an init-list-expression. + unsigned getIndex() const { + // This is a fairly specific request. Let's make sure the user knows + // what he's doing. + assert(hasIndex()); + return Index; + } - const Stmt *getTriggerStmt() const { - return Trigger.dyn_cast<Stmt *>(); + void Profile(llvm::FoldingSetNodeID &ID) const { + ID.AddPointer(Data); + ID.AddInteger(Kind); + ID.AddInteger(Index); } - const CXXCtorInitializer *getTriggerInit() const { - return Trigger.dyn_cast<CXXCtorInitializer *>(); + bool operator==(const ConstructionContextItem &Other) const { + // For most kinds the Index comparison is trivially true, but + // checking kind separately doesn't seem to be less expensive + // than checking Index. Same in operator<(). + return std::make_tuple(Data, Kind, Index) == + std::make_tuple(Other.Data, Other.Kind, Other.Index); } - /// Returns true if these layers are equal as individual layers, even if - /// their parents are different. - bool isSameLayer(const ConstructionContextLayer *Other) const { - assert(Other); - return (Trigger == Other->Trigger); + bool operator<(const ConstructionContextItem &Other) const { + return std::make_tuple(Data, Kind, Index) < + std::make_tuple(Other.Data, Other.Kind, Other.Index); } +}; + +/// Construction context can be seen as a linked list of multiple layers. +/// Sometimes a single trigger is not enough to describe the construction +/// site. That's what causing us to have a chain of "partial" construction +/// context layers. Some examples: +/// - A constructor within in an aggregate initializer list within a variable +/// would have a construction context of the initializer list with +/// the parent construction context of a variable. +/// - A constructor for a temporary that needs to be both destroyed +/// and materialized into an elidable copy constructor would have a +/// construction context of a CXXBindTemporaryExpr with the parent +/// construction context of a MaterializeTemproraryExpr. +/// Not all of these are currently supported. +/// Layers are created gradually while traversing the AST, and layers that +/// represent the outmost AST nodes are built first, while the node that +/// immediately contains the constructor would be built last and capture the +/// previous layers as its parents. Construction context captures the last layer +/// (which has links to the previous layers) and classifies the seemingly +/// arbitrary chain of layers into one of the possible ways of constructing +/// an object in C++ for user-friendly experience. +class ConstructionContextLayer { + const ConstructionContextLayer *Parent = nullptr; + ConstructionContextItem Item; + + ConstructionContextLayer(ConstructionContextItem Item, + const ConstructionContextLayer *Parent) + : Parent(Parent), Item(Item) {} + +public: + static const ConstructionContextLayer * + create(BumpVectorContext &C, const ConstructionContextItem &Item, + const ConstructionContextLayer *Parent = nullptr); + + const ConstructionContextItem &getItem() const { return Item; } + const ConstructionContextLayer *getParent() const { return Parent; } + bool isLast() const { return !Parent; } /// See if Other is a proper initial segment of this construction context /// in terms of the parent chain - i.e. a few first parents coincide and @@ -114,7 +249,8 @@ public: SimpleReturnedValueKind, CXX17ElidedCopyReturnedValueKind, RETURNED_VALUE_BEGIN = SimpleReturnedValueKind, - RETURNED_VALUE_END = CXX17ElidedCopyReturnedValueKind + RETURNED_VALUE_END = CXX17ElidedCopyReturnedValueKind, + ArgumentKind }; protected: @@ -132,6 +268,23 @@ private: return new (CC) T(Args...); } + // A sub-routine of createFromLayers() that deals with temporary objects + // that need to be materialized. The BTE argument is for the situation when + // the object also needs to be bound for destruction. + static const ConstructionContext *createMaterializedTemporaryFromLayers( + BumpVectorContext &C, const MaterializeTemporaryExpr *MTE, + const CXXBindTemporaryExpr *BTE, + const ConstructionContextLayer *ParentLayer); + + // A sub-routine of createFromLayers() that deals with temporary objects + // that need to be bound for destruction. Automatically finds out if the + // object also needs to be materialized and delegates to + // createMaterializedTemporaryFromLayers() if necessary. + static const ConstructionContext * + createBoundTemporaryFromLayers( + BumpVectorContext &C, const CXXBindTemporaryExpr *BTE, + const ConstructionContextLayer *ParentLayer); + public: /// Consume the construction context layer, together with its parent layers, /// and wrap it up into a complete construction context. May return null @@ -469,6 +622,32 @@ public: } }; +class ArgumentConstructionContext : public ConstructionContext { + const Expr *CE; // The call of which the context is an argument. + unsigned Index; // Which argument we're constructing. + const CXXBindTemporaryExpr *BTE; // Whether the object needs to be destroyed. + + friend class ConstructionContext; // Allows to create<>() itself. + + explicit ArgumentConstructionContext(const Expr *CE, unsigned Index, + const CXXBindTemporaryExpr *BTE) + : ConstructionContext(ArgumentKind), CE(CE), + Index(Index), BTE(BTE) { + assert(isa<CallExpr>(CE) || isa<CXXConstructExpr>(CE) || + isa<ObjCMessageExpr>(CE)); + // BTE is optional. + } + +public: + const Expr *getCallLikeExpr() const { return CE; } + unsigned getIndex() const { return Index; } + const CXXBindTemporaryExpr *getCXXBindTemporaryExpr() const { return BTE; } + + static bool classof(const ConstructionContext *CC) { + return CC->getKind() == ArgumentKind; + } +}; + } // end namespace clang #endif // LLVM_CLANG_ANALYSIS_CONSTRUCTIONCONTEXT_H diff --git a/include/clang/Analysis/DomainSpecific/CocoaConventions.h b/include/clang/Analysis/DomainSpecific/CocoaConventions.h index 8b3fcff52d081..9326d1abbac1f 100644 --- a/include/clang/Analysis/DomainSpecific/CocoaConventions.h +++ b/include/clang/Analysis/DomainSpecific/CocoaConventions.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements cocoa naming convention analysis. +// This file implements cocoa naming convention analysis. // //===----------------------------------------------------------------------===// @@ -20,20 +20,20 @@ namespace clang { class FunctionDecl; class QualType; - + namespace ento { namespace cocoa { - + bool isRefType(QualType RetTy, StringRef Prefix, StringRef Name = StringRef()); - + bool isCocoaObjectRef(QualType T); } namespace coreFoundation { bool isCFObjectRef(QualType T); - + bool followsCreateRule(const FunctionDecl *FD); } diff --git a/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h b/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h index f9e800a4a412e..e304d83615d46 100644 --- a/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h +++ b/include/clang/Analysis/DomainSpecific/ObjCNoReturn.h @@ -21,7 +21,7 @@ namespace clang { class ASTContext; class ObjCMessageExpr; - + class ObjCNoReturn { /// Cached "raise" selector. Selector RaiseSel; @@ -36,7 +36,7 @@ class ObjCNoReturn { public: ObjCNoReturn(ASTContext &C); - + /// Return true if the given message expression is known to never /// return. bool isImplicitNoReturn(const ObjCMessageExpr *ME); diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index e8f0d61617eb7..25ae93fae6b84 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -33,7 +33,7 @@ namespace clang { class AnalysisDeclContext; class FunctionDecl; class LocationContext; - + /// ProgramPoints can be "tagged" as representing points specific to a given /// analysis entity. Tags are abstract annotations, with an associated /// description and potentially other information. @@ -41,12 +41,12 @@ class ProgramPointTag { public: ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {} virtual ~ProgramPointTag(); - virtual StringRef getTagDescription() const = 0; + virtual StringRef getTagDescription() const = 0; protected: /// Used to implement 'isKind' in subclasses. const void *getTagKind() { return TagKind; } - + private: const void *TagKind; }; @@ -111,7 +111,7 @@ protected: assert(getLocationContext() == l); assert(getData1() == P); } - + ProgramPoint(const void *P1, const void *P2, Kind k, @@ -223,7 +223,7 @@ class BlockEntrance : public ProgramPoint { public: BlockEntrance(const CFGBlock *B, const LocationContext *L, const ProgramPointTag *tag = nullptr) - : ProgramPoint(B, BlockEntranceKind, L, tag) { + : ProgramPoint(B, BlockEntranceKind, L, tag) { assert(B && "BlockEntrance requires non-null block"); } @@ -235,7 +235,7 @@ public: const CFGBlock *B = getBlock(); return B->empty() ? Optional<CFGElement>() : B->front(); } - + private: friend class ProgramPoint; BlockEntrance() = default; @@ -350,7 +350,7 @@ protected: LocationCheck(const Stmt *S, const LocationContext *L, ProgramPoint::Kind K, const ProgramPointTag *tag) : StmtPoint(S, nullptr, K, L, tag) {} - + private: friend class ProgramPoint; static bool isKind(const ProgramPoint &location) { @@ -358,13 +358,13 @@ private: return k == PreLoadKind || k == PreStoreKind; } }; - + class PreLoad : public LocationCheck { public: PreLoad(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag = nullptr) : LocationCheck(S, L, PreLoadKind, tag) {} - + private: friend class ProgramPoint; PreLoad() = default; @@ -378,7 +378,7 @@ public: PreStore(const Stmt *S, const LocationContext *L, const ProgramPointTag *tag = nullptr) : LocationCheck(S, L, PreStoreKind, tag) {} - + private: friend class ProgramPoint; PreStore() = default; @@ -405,7 +405,7 @@ private: class PostStore : public PostStmt { public: /// Construct the post store point. - /// \param Loc can be used to store the information about the location + /// \param Loc can be used to store the information about the location /// used in the form it was uttered in the code. PostStore(const Stmt *S, const LocationContext *L, const void *Loc, const ProgramPointTag *tag = nullptr) @@ -479,7 +479,7 @@ public: BlockEdge(const CFGBlock *B1, const CFGBlock *B2, const LocationContext *L) : ProgramPoint(B1, B2, BlockEdgeKind, L) { assert(B1 && "BlockEdge: source block must be non-null"); - assert(B2 && "BlockEdge: destination block must be non-null"); + assert(B2 && "BlockEdge: destination block must be non-null"); } const CFGBlock *getSrc() const { @@ -603,7 +603,7 @@ private: /// CallEnter uses the caller's location context. class CallEnter : public ProgramPoint { public: - CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx, + CallEnter(const Stmt *stmt, const StackFrameContext *calleeCtx, const LocationContext *callerCtx) : ProgramPoint(stmt, calleeCtx, CallEnterKind, callerCtx, nullptr) {} @@ -749,7 +749,7 @@ static bool isEqual(const clang::ProgramPoint &L, } }; - + template <> struct isPodLike<clang::ProgramPoint> { static const bool value = true; }; diff --git a/include/clang/Analysis/Support/BumpVector.h b/include/clang/Analysis/Support/BumpVector.h index 5940520855ef2..00a7417e20f92 100644 --- a/include/clang/Analysis/Support/BumpVector.h +++ b/include/clang/Analysis/Support/BumpVector.h @@ -29,7 +29,7 @@ #include <type_traits> namespace clang { - + class BumpVectorContext { llvm::PointerIntPair<llvm::BumpPtrAllocator*, 1> Alloc; @@ -47,15 +47,15 @@ public: /// BumpPtrAllocator. This BumpPtrAllocator is not destroyed when the /// BumpVectorContext object is destroyed. BumpVectorContext(llvm::BumpPtrAllocator &A) : Alloc(&A, 0) {} - + ~BumpVectorContext() { if (Alloc.getInt()) delete Alloc.getPointer(); } - + llvm::BumpPtrAllocator &getAllocator() { return *Alloc.getPointer(); } }; - + template<typename T> class BumpVector { T *Begin = nullptr; @@ -67,34 +67,34 @@ public: explicit BumpVector(BumpVectorContext &C, unsigned N) { reserve(C, N); } - + ~BumpVector() { if (std::is_class<T>::value) { // Destroy the constructed elements in the vector. destroy_range(Begin, End); } } - + using size_type = size_t; using difference_type = ptrdiff_t; using value_type = T; using iterator = T *; using const_iterator = const T *; - + using const_reverse_iterator = std::reverse_iterator<const_iterator>; using reverse_iterator = std::reverse_iterator<iterator>; - + using reference = T &; using const_reference = const T &; using pointer = T *; using const_pointer = const T *; - + // forward iterator creation methods. iterator begin() { return Begin; } const_iterator begin() const { return Begin; } iterator end() { return End; } const_iterator end() const { return End; } - + // reverse iterator creation methods. reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); } @@ -102,7 +102,7 @@ public: const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - + bool empty() const { return Begin == End; } size_type size() const { return End-Begin; } @@ -114,49 +114,49 @@ public: assert(Begin + idx < End); return Begin[idx]; } - + reference front() { return begin()[0]; } const_reference front() const { return begin()[0]; } - + reference back() { return end()[-1]; } const_reference back() const { return end()[-1]; } - + void pop_back() { --End; End->~T(); } - + T pop_back_val() { T Result = back(); pop_back(); return Result; } - + void clear() { if (std::is_class<T>::value) { destroy_range(Begin, End); } End = Begin; } - + /// data - Return a pointer to the vector's buffer, even if empty(). pointer data() { return pointer(Begin); } - + /// data - Return a pointer to the vector's buffer, even if empty(). const_pointer data() const { return const_pointer(Begin); } - + void push_back(const_reference Elt, BumpVectorContext &C) { if (End < Capacity) { Retry: @@ -165,7 +165,7 @@ public: return; } grow(C); - goto Retry; + goto Retry; } /// insert - Insert some number of copies of element into a position. Return @@ -193,18 +193,18 @@ public: /// capacity - Return the total number of elements in the currently allocated /// buffer. - size_t capacity() const { return Capacity - Begin; } - + size_t capacity() const { return Capacity - Begin; } + private: /// grow - double the size of the allocated memory, guaranteeing space for at /// least one more element or MinSize if specified. void grow(BumpVectorContext &C, size_type MinSize = 1); - + void construct_range(T *S, T *E, const T &Elt) { for (; S != E; ++S) new (S) T(Elt); } - + void destroy_range(T *S, T *E) { while (S != E) { --E; @@ -220,7 +220,7 @@ private: } } }; - + // Define this out-of-line to dissuade the C++ compiler from inlining it. template <typename T> void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) { @@ -232,7 +232,7 @@ void BumpVector<T>::grow(BumpVectorContext &C, size_t MinSize) { // Allocate the memory from the BumpPtrAllocator. T *NewElts = C.getAllocator().template Allocate<T>(NewCapacity); - + // Copy the elements over. if (Begin != End) { if (std::is_class<T>::value) { diff --git a/include/clang/Basic/ABI.h b/include/clang/Basic/ABI.h index bd919ce24f81f..dc0e49cded631 100644 --- a/include/clang/Basic/ABI.h +++ b/include/clang/Basic/ABI.h @@ -81,12 +81,12 @@ struct ReturnAdjustment { return memcmp(this, &RHS, sizeof(RHS)) < 0; } } Virtual; - + ReturnAdjustment() : NonVirtual(0) {} - + bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } - friend bool operator==(const ReturnAdjustment &LHS, + friend bool operator==(const ReturnAdjustment &LHS, const ReturnAdjustment &RHS) { return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); } @@ -103,7 +103,7 @@ struct ReturnAdjustment { return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); } }; - + /// A \c this pointer adjustment. struct ThisAdjustment { /// The non-virtual adjustment from the derived object to its @@ -149,12 +149,12 @@ struct ThisAdjustment { return memcmp(this, &RHS, sizeof(RHS)) < 0; } } Virtual; - + ThisAdjustment() : NonVirtual(0) { } bool isEmpty() const { return !NonVirtual && Virtual.isEmpty(); } - friend bool operator==(const ThisAdjustment &LHS, + friend bool operator==(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Equals(RHS.Virtual); } @@ -162,12 +162,12 @@ struct ThisAdjustment { friend bool operator!=(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { return !(LHS == RHS); } - + friend bool operator<(const ThisAdjustment &LHS, const ThisAdjustment &RHS) { if (LHS.NonVirtual < RHS.NonVirtual) return true; - + return LHS.NonVirtual == RHS.NonVirtual && LHS.Virtual.Less(RHS.Virtual); } }; @@ -179,7 +179,7 @@ class CXXMethodDecl; struct ThunkInfo { /// The \c this pointer adjustment. ThisAdjustment This; - + /// The return adjustment. ReturnAdjustment Return; @@ -204,7 +204,7 @@ struct ThunkInfo { bool isEmpty() const { return This.isEmpty() && Return.isEmpty() && Method == nullptr; } -}; +}; } // end namespace clang diff --git a/include/clang/Basic/AllDiagnostics.h b/include/clang/Basic/AllDiagnostics.h index 20c29d459d229..afec2d7e0f2f6 100644 --- a/include/clang/Basic/AllDiagnostics.h +++ b/include/clang/Basic/AllDiagnostics.h @@ -34,9 +34,9 @@ class StringSizerHelper { public: enum { Size = SizeOfStr }; }; -} // end namespace clang +} // end namespace clang #define STR_SIZE(str, fieldTy) clang::StringSizerHelper<sizeof(str)-1, \ - fieldTy>::Size + fieldTy>::Size #endif diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 0bbe52bf5f36f..fea8e129d7da6 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -141,6 +141,13 @@ def HasFunctionProto : SubsetSubject<DeclBase, isa<BlockDecl>(S)}], "non-K&R-style functions">; +// A subject that matches the implicit object parameter of a non-static member +// function. Accepted as a function type attribute on the type of such a +// member function. +// FIXME: This does not actually ever match currently. +def ImplicitObjectParameter : SubsetSubject<Function, [{false}], + "implicit object parameters">; + // A single argument to an attribute class Argument<string name, bit optional, bit fake = 0> { string Name = name; @@ -456,7 +463,7 @@ class Attr { // Set to true if all of the attribute's arguments should be parsed in an // unevaluated context. bit ParseArgumentsAsUnevaluated = 0; - // Set to true if this attribute meaningful when applied to or inherited + // Set to true if this attribute meaningful when applied to or inherited // in a class template definition. bit MeaningfulToClassTemplateDefinition = 0; // Set to true if this attribute can be used with '#pragma clang attribute'. @@ -583,7 +590,7 @@ def AlignValue : Attr { // the future (and a corresponding C++ attribute), but this can be done // later once we decide if we also want them to have slightly-different // semantics than Intel's align_value. - // + // // Does not get a [[]] spelling because the attribute is not exposed as such // by Intel. GNU<"align_value"> @@ -1211,6 +1218,13 @@ def LayoutVersion : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { let Documentation = [LayoutVersionDocs]; } +def LifetimeBound : InheritableAttr { + let Spellings = [Clang<"lifetimebound", 0>]; + let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>; + let Documentation = [LifetimeBoundDocs]; + let LangOpts = [CPlusPlus]; +} + def TrivialABI : InheritableAttr { // This attribute does not have a C [[]] spelling because it requires the // CPlusPlus language option. @@ -1703,7 +1717,7 @@ def Overloadable : Attr { let Documentation = [OverloadableDocs]; } -def Override : InheritableAttr { +def Override : InheritableAttr { let Spellings = [Keyword<"override">]; let SemaHandler = 0; let Documentation = [Undocumented]; @@ -1782,7 +1796,7 @@ def RequireConstantInit : InheritableAttr { def WorkGroupSizeHint : InheritableAttr { // Does not have a [[]] spelling because it is an OpenCL-related attribute. let Spellings = [GNU<"work_group_size_hint">]; - let Args = [UnsignedArgument<"XDim">, + let Args = [UnsignedArgument<"XDim">, UnsignedArgument<"YDim">, UnsignedArgument<"ZDim">]; let Subjects = SubjectList<[Function], ErrorDiag>; diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index 5a5ab78b49d11..bb2993eab4bc6 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -2362,6 +2362,22 @@ It is only supported when using the Microsoft C++ ABI. }]; } +def LifetimeBoundDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``lifetimebound`` attribute indicates that a resource owned by +a function parameter or implicit object parameter +is retained by the return value of the annotated function +(or, for a parameter of a constructor, in the value of the constructed object). +It is only supported in C++. + +This attribute provides an experimental implementation of the facility +described in the C++ committee paper [http://wg21.link/p0936r0](P0936R0), +and is subject to change as the design of the corresponding functionality +changes. + }]; +} + def TrivialABIDocs : Documentation { let Category = DocCatVariable; let Content = [{ diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index edd823754a374..c4d11cd827c13 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -471,6 +471,8 @@ BUILTIN(__builtin_wcslen, "zwC*", "nF") BUILTIN(__builtin_wcsncmp, "iwC*wC*z", "nF") BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF") BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF") +BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF") +BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF") BUILTIN(__builtin_return_address, "v*IUi", "n") BUILTIN(__builtin_extract_return_addr, "v*v*", "n") BUILTIN(__builtin_frame_address, "v*IUi", "n") @@ -908,6 +910,8 @@ LIBBUILTIN(wcslen, "zwC*", "f", "wchar.h", ALL_LANGUAGES) LIBBUILTIN(wcsncmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES) LIBBUILTIN(wmemchr, "w*wC*wz", "f", "wchar.h", ALL_LANGUAGES) LIBBUILTIN(wmemcmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES) +LIBBUILTIN(wmemcpy, "w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES) +LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES) // C99 // In some systems setjmp is a macro that expands to _setjmp. We undefine @@ -956,7 +960,7 @@ LIBBUILTIN(strlcpy, "zc*cC*z", "f", "string.h", ALL_GNU_LANGUAGES) LIBBUILTIN(strlcat, "zc*cC*z", "f", "string.h", ALL_GNU_LANGUAGES) // id objc_msgSend(id, SEL, ...) LIBBUILTIN(objc_msgSend, "GGH.", "f", "objc/message.h", OBJC_LANG) -// long double objc_msgSend_fpret(id self, SEL op, ...) +// long double objc_msgSend_fpret(id self, SEL op, ...) LIBBUILTIN(objc_msgSend_fpret, "LdGH.", "f", "objc/message.h", OBJC_LANG) // _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...) LIBBUILTIN(objc_msgSend_fp2ret, "XLdGH.", "f", "objc/message.h", OBJC_LANG) diff --git a/include/clang/Basic/BuiltinsAMDGPU.def b/include/clang/Basic/BuiltinsAMDGPU.def index 46cd738ae43f6..4a447eb9f6a8a 100644 --- a/include/clang/Basic/BuiltinsAMDGPU.def +++ b/include/clang/Basic/BuiltinsAMDGPU.def @@ -124,13 +124,13 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "hhhh", "nc", "gfx9-insts") // Deep learning builtins. //===----------------------------------------------------------------------===// -TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hf", "nc", "dl-insts") -TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSi", "nc", "dl-insts") -TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUi", "nc", "dl-insts") -TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSi", "nc", "dl-insts") -TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUi", "nc", "dl-insts") -TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSi", "nc", "dl-insts") -TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUi", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dl-insts") +TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dl-insts") //===----------------------------------------------------------------------===// // Special builtins. diff --git a/include/clang/Basic/BuiltinsPPC.def b/include/clang/Basic/BuiltinsPPC.def index 8cd8a2be20030..9be760853d509 100644 --- a/include/clang/Basic/BuiltinsPPC.def +++ b/include/clang/Basic/BuiltinsPPC.def @@ -58,7 +58,7 @@ BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fIi", "") BUILTIN(__builtin_altivec_dss, "vUi", "") BUILTIN(__builtin_altivec_dssall, "v", "") -BUILTIN(__builtin_altivec_dst, "vvC*iUi", "") +BUILTIN(__builtin_altivec_dst, "vvC*iUi", "") BUILTIN(__builtin_altivec_dstt, "vvC*iUi", "") BUILTIN(__builtin_altivec_dstst, "vvC*iUi", "") BUILTIN(__builtin_altivec_dststt, "vvC*iUi", "") diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 5205b4c210a6f..d30ac14e02fee 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -25,7 +25,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator_range.h" -#include "llvm/Support/Compiler.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <cstdint> #include <limits> @@ -86,7 +86,7 @@ public: bool isNull() const { return !RemoveRange.isValid(); } - + /// Create a code modification hint that inserts the given /// code string at a specific location. static FixItHint CreateInsertion(SourceLocation InsertionLoc, @@ -99,7 +99,7 @@ public: Hint.BeforePreviousInsertions = BeforePreviousInsertions; return Hint; } - + /// Create a code modification hint that inserts the given /// code from \p FromRange at a specific location. static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, @@ -123,7 +123,7 @@ public: static FixItHint CreateRemoval(SourceRange RemoveRange) { return CreateRemoval(CharSourceRange::getTokenRange(RemoveRange)); } - + /// Create a code modification hint that replaces the given /// source range with the given code string. static FixItHint CreateReplacement(CharSourceRange RemoveRange, @@ -133,7 +133,7 @@ public: Hint.CodeToInsert = Code; return Hint; } - + static FixItHint CreateReplacement(SourceRange RemoveRange, StringRef Code) { return CreateReplacement(CharSourceRange::getTokenRange(RemoveRange), Code); @@ -348,7 +348,7 @@ private: unsigned Offset; DiagStatePoint(DiagState *State, unsigned Offset) - : State(State), Offset(Offset) {} + : State(State), Offset(Offset) {} }; /// Description of the diagnostic states and state transitions for a @@ -420,7 +420,7 @@ private: /// Indicates that an unrecoverable error has occurred. bool UnrecoverableErrorOccurred; - + /// Counts for DiagnosticErrorTrap to check whether an error occurred /// during a parsing section, e.g. during parsing a function. unsigned TrapNumErrorsOccurred; @@ -556,7 +556,7 @@ public: /// /// Zero disables the limit. void setErrorLimit(unsigned Limit) { ErrorLimit = Limit; } - + /// Specify the maximum number of template instantiation /// notes to emit along with a given diagnostic. void setTemplateBacktraceLimit(unsigned Limit) { @@ -626,11 +626,11 @@ public: return GetCurDiagState()->SuppressSystemWarnings; } - /// Suppress all diagnostics, to silence the front end when we + /// Suppress all diagnostics, to silence the front end when we /// know that we don't want any more diagnostics to be passed along to the /// client - void setSuppressAllDiagnostics(bool Val = true) { - SuppressAllDiagnostics = Val; + void setSuppressAllDiagnostics(bool Val = true) { + SuppressAllDiagnostics = Val; } bool getSuppressAllDiagnostics() const { return SuppressAllDiagnostics; } @@ -638,12 +638,12 @@ public: /// template types. void setElideType(bool Val = true) { ElideType = Val; } bool getElideType() { return ElideType; } - + /// Set tree printing, to outputting the template difference in a /// tree format. void setPrintTemplateTree(bool Val = false) { PrintTemplateTree = Val; } bool getPrintTemplateTree() { return PrintTemplateTree; } - + /// Set color printing, so the type diffing will inject color markers /// into the output. void setShowColors(bool Val = false) { ShowColors = Val; } @@ -657,7 +657,7 @@ public: ShowOverloads = Val; } OverloadsShown getShowOverloads() const { return ShowOverloads; } - + /// Pretend that the last diagnostic issued was ignored, so any /// subsequent notes will be suppressed, or restore a prior ignoring /// state after ignoring some diagnostics and their notes, possibly in @@ -751,12 +751,12 @@ public: return UncompilableErrorOccurred; } bool hasFatalErrorOccurred() const { return FatalErrorOccurred; } - + /// Determine whether any kind of unrecoverable error has occurred. bool hasUnrecoverableErrorOccurred() const { return FatalErrorOccurred || UnrecoverableErrorOccurred; } - + unsigned getNumWarnings() const { return NumWarnings; } void setNumWarnings(unsigned NumWarnings) { @@ -799,10 +799,10 @@ public: LastDiagLevel = Other.LastDiagLevel; } - /// Reset the state of the diagnostic object to its initial + /// Reset the state of the diagnostic object to its initial /// configuration. void Reset(); - + //===--------------------------------------------------------------------===// // DiagnosticsEngine classification and reporting interfaces. // @@ -875,7 +875,7 @@ public: /// DiagnosticsEngine object itself. void SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1 = "", StringRef Arg2 = ""); - + /// Clear out the current diagnostic. void Clear() { CurDiagID = std::numeric_limits<unsigned>::max(); } @@ -894,7 +894,7 @@ private: friend class DiagnosticErrorTrap; friend class DiagnosticIDs; friend class PartialDiagnostic; - + /// Report the delayed diagnostic. void ReportDelayed(); @@ -1042,7 +1042,7 @@ public: class DiagnosticBuilder { friend class DiagnosticsEngine; friend class PartialDiagnostic; - + mutable DiagnosticsEngine *DiagObj = nullptr; mutable unsigned NumArgs = 0; @@ -1105,7 +1105,7 @@ protected: return Result; } - + public: /// Copy constructor. When copied, this "takes" the diagnostic info from the /// input and neuters it. @@ -1430,8 +1430,8 @@ public: }; /** - * Represents a diagnostic in a form that can be retained until its - * corresponding source manager is destroyed. + * Represents a diagnostic in a form that can be retained until its + * corresponding source manager is destroyed. */ class StoredDiagnostic { unsigned ID; @@ -1444,9 +1444,9 @@ class StoredDiagnostic { public: StoredDiagnostic() = default; StoredDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info); - StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, + StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, StringRef Message); - StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, + StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, StringRef Message, FullSourceLoc Loc, ArrayRef<CharSourceRange> Ranges, ArrayRef<FixItHint> Fixits); @@ -1466,7 +1466,7 @@ public: range_iterator range_begin() const { return Ranges.begin(); } range_iterator range_end() const { return Ranges.end(); } unsigned range_size() const { return Ranges.size(); } - + ArrayRef<CharSourceRange> getRanges() const { return llvm::makeArrayRef(Ranges); } @@ -1476,7 +1476,7 @@ public: fixit_iterator fixit_begin() const { return FixIts.begin(); } fixit_iterator fixit_end() const { return FixIts.end(); } unsigned fixit_size() const { return FixIts.size(); } - + ArrayRef<FixItHint> getFixIts() const { return llvm::makeArrayRef(FixIts); } @@ -1488,7 +1488,7 @@ class DiagnosticConsumer { protected: unsigned NumWarnings = 0; ///< Number of warnings reported unsigned NumErrors = 0; ///< Number of errors reported - + public: DiagnosticConsumer() = default; virtual ~DiagnosticConsumer(); @@ -1506,7 +1506,7 @@ public: /// in between BeginSourceFile() and EndSourceFile(). /// /// \param LangOpts The language options for the source file being processed. - /// \param PP The preprocessor object being used for the source; this is + /// \param PP The preprocessor object being used for the source; this is /// optional, e.g., it may not be present when processing AST source files. virtual void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP = nullptr) {} diff --git a/include/clang/Basic/DiagnosticASTKinds.td b/include/clang/Basic/DiagnosticASTKinds.td index 4fa1db96cb897..3358fc3d70c7a 100644 --- a/include/clang/Basic/DiagnosticASTKinds.td +++ b/include/clang/Basic/DiagnosticASTKinds.td @@ -163,12 +163,26 @@ def note_constexpr_unsupported_unsized_array : Note< def note_constexpr_unsized_array_indexed : Note< "indexing of array without known bound is not allowed " "in a constant expression">; +def note_constexpr_memcpy_type_pun : Note< + "cannot constant evaluate '%select{memcpy|memmove}0' from object of " + "type %1 to object of type %2">; +def note_constexpr_memcpy_nontrivial : Note< + "cannot constant evaluate '%select{memcpy|memmove}0' between objects of " + "non-trivially-copyable type %1">; +def note_constexpr_memcpy_overlap : Note< + "'%select{memcpy|wmemcpy}0' between overlapping memory regions">; +def note_constexpr_memcpy_unsupported : Note< + "'%select{%select{memcpy|wmemcpy}1|%select{memmove|wmemmove}1}0' " + "not supported: %select{" + "size to copy (%4) is not a multiple of size of element type %3 (%5)|" + "source is not a contiguous array of at least %4 elements of type %3|" + "destination is not a contiguous array of at least %4 elements of type %3}2">; def warn_integer_constant_overflow : Warning< "overflow in expression; result is %0 with type %1">, InGroup<DiagGroup<"integer-overflow">>; -// This is a temporary diagnostic, and shall be removed once our +// This is a temporary diagnostic, and shall be removed once our // implementation is complete, and like the preceding constexpr notes belongs // in Sema. def note_unimplemented_constexpr_lambda_feature_ast : Note< diff --git a/include/clang/Basic/DiagnosticCommentKinds.td b/include/clang/Basic/DiagnosticCommentKinds.td index ab24582c1180e..ebe62e4738f09 100644 --- a/include/clang/Basic/DiagnosticCommentKinds.td +++ b/include/clang/Basic/DiagnosticCommentKinds.td @@ -83,19 +83,19 @@ def warn_doc_function_method_decl_mismatch : Warning< "%select{a function|a function|an Objective-C method|an Objective-C method|" "a pointer to function}2 declaration">, InGroup<Documentation>, DefaultIgnore; - + def warn_doc_api_container_decl_mismatch : Warning< "'%select{\\|@}0%select{class|interface|protocol|struct|union}1' " "command should not be used in a comment attached to a " "non-%select{class|interface|protocol|struct|union}2 declaration">, InGroup<Documentation>, DefaultIgnore; - + def warn_doc_container_decl_mismatch : Warning< "'%select{\\|@}0%select{classdesign|coclass|dependency|helper" "|helperclass|helps|instancesize|ownership|performance|security|superclass}1' " "command should not be used in a comment attached to a non-container declaration">, InGroup<Documentation>, DefaultIgnore; - + def warn_doc_param_duplicate : Warning< "parameter '%0' is already documented">, InGroup<Documentation>, DefaultIgnore; diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index 61a73541d0b37..b98b183c9d6f4 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -16,7 +16,7 @@ let Component = "Common" in { // Basic. def fatal_too_many_errors - : Error<"too many errors emitted, stopping now">, DefaultFatal; + : Error<"too many errors emitted, stopping now">, DefaultFatal; def note_declared_at : Note<"declared here">; def note_previous_definition : Note<"previous definition is here">; @@ -97,11 +97,11 @@ def remark_module_lock_timeout : Remark< def err_module_shadowed : Error<"import of shadowed module '%0'">, DefaultFatal; def err_module_build_shadowed_submodule : Error< "build a shadowed submodule '%0'">, DefaultFatal; -def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, +def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, DefaultFatal; def err_module_prebuilt : Error< "error in loading module '%0' from prebuilt module path">, DefaultFatal; -def note_pragma_entered_here : Note<"#pragma entered here">; +def note_pragma_entered_here : Note<"#pragma entered here">; def note_decl_hiding_tag_type : Note< "%1 %0 is hidden by a non-type declaration of %0 here">; def err_attribute_not_type_attr : Error< @@ -115,7 +115,7 @@ let CategoryName = "Nullability Issue" in { def warn_nullability_duplicate : Warning< "duplicate nullability specifier %0">, InGroup<Nullability>; - + def warn_conflicting_nullability_attr_overriding_ret_types : Warning< "conflicting nullability specifier on return types, %0 " "conflicts with existing specifier %1">, @@ -223,7 +223,7 @@ def err_unable_to_rename_temp : Error< "unable to rename temporary '%0' to output file '%1': '%2'">; def err_unable_to_make_temp : Error< "unable to make temporary file: %0">; - + // Modules def err_module_format_unhandled : Error< "no handler registered for module format '%0'">, DefaultFatal; diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index a6be0595e1ae9..7f75f45c65781 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -208,7 +208,7 @@ def err_drv_omp_host_target_not_supported : Error< def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< "The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.">; def warn_drv_omp_offload_target_duplicate : Warning< - "The OpenMP offloading target '%0' is similar to target '%1' already specified - will be ignored.">, + "The OpenMP offloading target '%0' is similar to target '%1' already specified - will be ignored.">, InGroup<OpenMPTarget>; def warn_drv_omp_offload_target_missingbcruntime : Warning< "No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices.">, @@ -226,6 +226,9 @@ def warn_ignored_clang_option : Warning<"the flag '%0' has been deprecated and w def warn_drv_unsupported_opt_for_target : Warning< "optimization flag '%0' is not supported for target '%1'">, InGroup<IgnoredOptimizationArgument>; +def warn_drv_unsupported_debug_info_opt_for_target : Warning< + "debug information option '%0' is not supported for target '%1'">, + InGroup<UnsupportedTargetOpt>; def warn_c_kext : Warning< "ignoring -fapple-kext which is valid for C++ and Objective-C++ only">; def warn_drv_input_file_unused : Warning< diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index 6add448871fe5..66287933b7ca3 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -36,7 +36,7 @@ def remark_fe_backend_plugin: Remark<"%0">, BackendInfo, InGroup<RemarkBackendPl def note_fe_backend_plugin: Note<"%0">, BackendInfo; def warn_fe_override_module : Warning< - "overriding the module target triple with %0">, + "overriding the module target triple with %0">, InGroup<DiagGroup<"override-module">>; def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo, @@ -190,10 +190,10 @@ def err_module_interface_requires_modules_ts : Error< def warn_module_config_mismatch : Warning< "module file %0 cannot be loaded due to a configuration mismatch with the current " "compilation">, InGroup<DiagGroup<"module-file-config-mismatch">>, DefaultError; -def err_module_map_not_found : Error<"module map file '%0' not found">, +def err_module_map_not_found : Error<"module map file '%0' not found">, DefaultFatal; def err_missing_module_name : Error< - "no module name provided; specify one with -fmodule-name=">, + "no module name provided; specify one with -fmodule-name=">, DefaultFatal; def err_missing_module : Error< "no module named '%0' declared in module map file '%1'">, DefaultFatal; diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 7087db7f0fb89..2156ef93c19fe 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -72,6 +72,7 @@ def UnsupportedNan : DiagGroup<"unsupported-nan">; def UnsupportedAbs : DiagGroup<"unsupported-abs">; def UnsupportedCB : DiagGroup<"unsupported-cb">; def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">; +def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">; def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">; def NullConversion : DiagGroup<"null-conversion">; def ImplicitConversionFloatingPointToBool : @@ -287,7 +288,7 @@ def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">; def : DiagGroup<"import">; def GNUIncludeNext : DiagGroup<"gnu-include-next">; def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">; -def IncompatiblePointerTypesDiscardsQualifiers +def IncompatiblePointerTypesDiscardsQualifiers : DiagGroup<"incompatible-pointer-types-discards-qualifiers">; def IncompatibleFunctionPointerTypes : DiagGroup<"incompatible-function-pointer-types">; @@ -799,14 +800,14 @@ def Most : DiagGroup<"most", [ UserDefinedWarnings ]>; -// Thread Safety warnings +// Thread Safety warnings def ThreadSafetyAttributes : DiagGroup<"thread-safety-attributes">; def ThreadSafetyAnalysis : DiagGroup<"thread-safety-analysis">; def ThreadSafetyPrecise : DiagGroup<"thread-safety-precise">; def ThreadSafetyReference : DiagGroup<"thread-safety-reference">; def ThreadSafetyNegative : DiagGroup<"thread-safety-negative">; def ThreadSafety : DiagGroup<"thread-safety", - [ThreadSafetyAttributes, + [ThreadSafetyAttributes, ThreadSafetyAnalysis, ThreadSafetyPrecise, ThreadSafetyReference]>; diff --git a/include/clang/Basic/DiagnosticIDs.h b/include/clang/Basic/DiagnosticIDs.h index b610af953fba1..983dcb21cfdfe 100644 --- a/include/clang/Basic/DiagnosticIDs.h +++ b/include/clang/Basic/DiagnosticIDs.h @@ -214,7 +214,7 @@ public: bool ignored; return isBuiltinExtensionDiag(DiagID, ignored); } - + /// Determine whether the given built-in diagnostic ID is for an /// extension of some sort, and whether it is enabled by default. /// @@ -223,14 +223,14 @@ public: /// treated as a warning/error by default. /// static bool isBuiltinExtensionDiag(unsigned DiagID, bool &EnabledByDefault); - + /// Return the lowest-level warning option that enables the specified /// diagnostic. /// /// If there is no -Wfoo flag that controls the diagnostic, this returns null. static StringRef getWarningOptionForDiag(unsigned DiagID); - + /// Return the category number that a specified \p DiagID belongs to, /// or 0 if no category. static unsigned getCategoryNumberForDiag(unsigned DiagID); @@ -240,7 +240,7 @@ public: /// Given a category ID, return the name of the category. static StringRef getCategoryNameFromID(unsigned CategoryID); - + /// Return true if a given diagnostic falls into an ARC diagnostic /// category. static bool isARCDiagnostic(unsigned DiagID); @@ -251,26 +251,26 @@ public: /// The diagnostic should not be reported, but it should cause /// template argument deduction to fail. /// - /// The vast majority of errors that occur during template argument + /// The vast majority of errors that occur during template argument /// deduction fall into this category. SFINAE_SubstitutionFailure, - + /// The diagnostic should be suppressed entirely. /// /// Warnings generally fall into this category. SFINAE_Suppress, - + /// The diagnostic should be reported. /// - /// The diagnostic should be reported. Various fatal errors (e.g., + /// The diagnostic should be reported. Various fatal errors (e.g., /// template instantiation depth exceeded) fall into this category. SFINAE_Report, - + /// The diagnostic is an access-control diagnostic, which will be /// substitution failures in some contexts and reported in others. SFINAE_AccessControl }; - + /// Determines whether the given built-in diagnostic ID is /// for an error that is suppressed if it occurs during C++ template /// argument deduction. @@ -306,7 +306,7 @@ public: private: /// Classify the specified diagnostic ID into a Level, consumable by /// the DiagnosticClient. - /// + /// /// The classification is based on the way the client configured the /// DiagnosticsEngine object. /// diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index b5b5e8f654bca..1c960711bccb6 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -53,7 +53,7 @@ def ext_multi_line_line_comment : Extension<"multi-line // comment">, def ext_line_comment : Extension< "// comments are not allowed in this language">, InGroup<Comment>; -def ext_no_newline_eof : Extension<"no newline at end of file">, +def ext_no_newline_eof : Extension<"no newline at end of file">, InGroup<NewlineEOF>; def warn_no_newline_eof : Warning<"no newline at end of file">, InGroup<NewlineEOF>, DefaultIgnore; @@ -294,7 +294,7 @@ def pp_nonportable_path : NonportablePath, InGroup<DiagGroup<"nonportable-include-path">>; def pp_nonportable_system_path : NonportablePath, DefaultIgnore, InGroup<DiagGroup<"nonportable-system-include-path">>; - + def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">, InGroup<DiagGroup<"pragma-once-outside-header">>; def pp_pragma_sysheader_in_main_file : Warning< @@ -353,7 +353,7 @@ def ext_pp_warning_directive : Extension<"#warning is a language extension">; def ext_pp_extra_tokens_at_eol : ExtWarn< "extra tokens at end of #%0 directive">, InGroup<ExtraTokens>; - + def ext_pp_comma_expr : Extension<"comma operator in operand of #if">; def ext_pp_bad_vaargs_use : Extension< "__VA_ARGS__ can only appear in the expansion of a C99 variadic macro">; @@ -594,7 +594,7 @@ def err_pp_illegal_floating_literal : Error< def err_pp_line_requires_integer : Error< "#line directive requires a positive integer argument">; def ext_pp_line_zero : Extension< - "#line directive with zero argument is a GNU extension">, + "#line directive with zero argument is a GNU extension">, InGroup<GNUZeroLineDirective>; def err_pp_line_invalid_filename : Error< "invalid filename for #line directive">; @@ -736,7 +736,7 @@ def warn_auto_module_import : Warning< def note_implicit_top_level_module_import_here : Note< "submodule of top-level module '%0' implicitly imported here">; def warn_uncovered_module_header : Warning< - "umbrella header for module '%0' does not include header '%1'">, + "umbrella header for module '%0' does not include header '%1'">, InGroup<IncompleteUmbrella>; def warn_mmap_umbrella_dir_not_found : Warning< "umbrella directory '%0' not found">, @@ -755,7 +755,7 @@ def warn_non_modular_include_in_module : Warning< "include of non-modular header inside module '%0': '%1'">, InGroup<NonModularIncludeInModule>, DefaultIgnore; def warn_module_conflict : Warning< - "module '%0' conflicts with already-imported module '%1': %2">, + "module '%0' conflicts with already-imported module '%1': %2">, InGroup<ModuleConflict>; def warn_header_guard : Warning< diff --git a/include/clang/Basic/DiagnosticOptions.def b/include/clang/Basic/DiagnosticOptions.def index 2467b24fd909a..22645654afd81 100644 --- a/include/clang/Basic/DiagnosticOptions.def +++ b/include/clang/Basic/DiagnosticOptions.def @@ -61,9 +61,9 @@ DIAGOPT(ShowOptionNames, 1, 0) /// Show the option name for mappable DIAGOPT(ShowNoteIncludeStack, 1, 0) /// Show include stacks for notes. VALUE_DIAGOPT(ShowCategories, 2, 0) /// Show categories: 0 -> none, 1 -> Number, /// 2 -> Full Name. - -ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for diagnostics: - + +ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for diagnostics: + DIAGOPT(ShowColors, 1, 0) /// Show diagnostics with ANSI color sequences. ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1, Ovl_All) /// Overload candidates to show. diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h index 391e252eaddda..4c5bcb4e8793f 100644 --- a/include/clang/Basic/DiagnosticOptions.h +++ b/include/clang/Basic/DiagnosticOptions.h @@ -91,7 +91,7 @@ protected: public: /// The file to log diagnostic output to. std::string DiagnosticLogFile; - + /// The file to serialize diagnostics to (non-appending). std::string DiagnosticSerializationFile; diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index dd4c81922592f..609dca4f075c7 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -86,7 +86,7 @@ def err_enumerator_list_missing_comma : Error< def err_enumerator_unnamed_no_def : Error< "unnamed enumeration must be a definition">; def ext_cxx11_enum_fixed_underlying_type : Extension< - "enumeration types with a fixed underlying type are a C++11 extension">, + "enumeration types with a fixed underlying type are a C++11 extension">, InGroup<CXX11>; def ext_c_enum_fixed_underlying_type : Extension< "enumeration types with a fixed underlying type are a Microsoft extension">, @@ -101,7 +101,7 @@ def ext_alignof_expr : ExtWarn< "%0 applied to an expression is a GNU extension">, InGroup<GNUAlignofExpression>; def warn_microsoft_dependent_exists : Warning< - "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, + "dependent %select{__if_not_exists|__if_exists}0 declarations are ignored">, InGroup<DiagGroup<"microsoft-exists">>; def warn_microsoft_qualifiers_ignored : Warning< "qualifiers after comma in declarator list are ignored">, @@ -134,14 +134,14 @@ def ext_gnu_conditional_expr : Extension< "use of GNU ?: conditional expression extension, omitting middle operand">, InGroup<GNUConditionalOmittedOperand>; def ext_gnu_empty_initializer : Extension< "use of GNU empty initializer extension">, InGroup<GNUEmptyInitializer>; -def ext_gnu_array_range : Extension<"use of GNU array range extension">, +def ext_gnu_array_range : Extension<"use of GNU array range extension">, InGroup<GNUDesignator>; def ext_gnu_missing_equal_designator : ExtWarn< - "use of GNU 'missing =' extension in designator">, + "use of GNU 'missing =' extension in designator">, InGroup<GNUDesignator>; def err_expected_equal_designator : Error<"expected '=' or another designator">; def ext_gnu_old_style_field_designator : ExtWarn< - "use of GNU old-style field designator extension">, + "use of GNU old-style field designator extension">, InGroup<GNUDesignator>; def ext_gnu_case_range : Extension<"use of GNU case range extension">, InGroup<GNUCaseRange>; @@ -168,16 +168,16 @@ def err_unexpected_semi : Error<"unexpected ';' before %0">; def err_expected_fn_body : Error< "expected function body after function declarator">; def warn_attribute_on_function_definition : Warning< - "GCC does not allow %0 attribute in this position on a function definition">, + "GCC does not allow %0 attribute in this position on a function definition">, InGroup<GccCompat>; def warn_gcc_attribute_location : Warning< - "GCC does not allow an attribute in this position on a function declaration">, + "GCC does not allow an attribute in this position on a function declaration">, InGroup<GccCompat>; def warn_gcc_variable_decl_in_for_loop : Warning< "GCC does not allow variable declarations in for loop initializers before " "C99">, InGroup<GccCompat>; def warn_attribute_no_decl : Warning< - "attribute %0 ignored, because it is not attached to a declaration">, + "attribute %0 ignored, because it is not attached to a declaration">, InGroup<IgnoredAttributes>; def err_ms_attributes_not_enabled : Error< "'__declspec' attributes are not enabled; use '-fdeclspec' or " @@ -319,7 +319,7 @@ def warn_cxx98_compat_decltype : Warning< def err_unexpected_scope_on_base_decltype : Error< "unexpected namespace scope prior to decltype">; def err_expected_class_name : Error<"expected class name">; -def err_expected_class_name_not_template : +def err_expected_class_name_not_template : Error<"'typename' is redundant; base classes are implicitly types">; def err_unspecified_vla_size_with_static : Error< "'static' may not be used with an unspecified variable length array size">; @@ -395,7 +395,7 @@ def warn_arc_bridge_cast_nonarc : Warning< "'%0' casts have no effect when not using ARC">, InGroup<DiagGroup<"arc-bridge-casts-disallowed-in-nonarc">>; } - + def err_objc_illegal_visibility_spec : Error< "illegal visibility specification">; def err_objc_illegal_interface_qual : Error<"illegal interface qualifier">; @@ -687,7 +687,7 @@ def warn_cxx98_compat_extern_template : Warning< def warn_static_inline_explicit_inst_ignored : Warning< "ignoring '%select{static|inline}0' keyword on explicit template " "instantiation">, InGroup<DiagGroup<"static-inline-explicit-instantiation">>; - + // Constructor template diagnostics. def err_out_of_line_constructor_template_id : Error< "out-of-line constructor for %0 cannot have template arguments">; @@ -703,7 +703,7 @@ def err_expected_type_name_after_typename : Error< "expected an identifier or template-id after '::'">; def err_explicit_spec_non_template : Error< "explicit %select{specialization|instantiation}0 of non-template %1 %2">; - + def err_default_template_template_parameter_not_template : Error< "default template argument for a template template parameter must be a class " "template">; @@ -850,7 +850,7 @@ def err_zero_version : Error< "version number must have non-zero major, minor, or sub-minor version">; def err_availability_expected_platform : Error< "expected a platform name, e.g., 'macos'">; - + // objc_bridge_related attribute def err_objcbridge_related_expected_related_class : Error< "expected a related ObjectiveC class name, e.g., 'NSColor'">; @@ -994,7 +994,7 @@ def warn_pragma_init_seg_unsupported_target : Warning< // - #pragma fp_contract def err_pragma_fp_contract_scope : Error< "'#pragma fp_contract' can only appear at file scope or at the start of a " - "compound statement">; + "compound statement">; // - #pragma stdc unknown def ext_stdc_pragma_ignored : ExtWarn<"unknown pragma in STDC namespace">, InGroup<UnknownPragmas>; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index d0a2bec780527..586f65e9201cf 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -243,7 +243,7 @@ def err_invalid_vector_double_decl_spec : Error < "(available on POWER7 or later)">; def err_invalid_vector_long_long_decl_spec : Error < "use of 'long long' with '__vector bool' requires VSX support (available on " - "POWER7 or later) or extended Altivec support (available on POWER8 or later) " + "POWER7 or later) or extended Altivec support (available on POWER8 or later) " "to be enabled">; def err_invalid_vector_long_double_decl_spec : Error< "cannot use 'long double' with '__vector'">; @@ -388,7 +388,7 @@ def err_inline_non_function : Error< "'inline' can only appear on functions%select{| and non-local variables}0">; def err_noreturn_non_function : Error< "'_Noreturn' can only appear on functions">; -def warn_qual_return_type : Warning< +def warn_qual_return_type : Warning< "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">, InGroup<IgnoredQualifiers>, DefaultIgnore; def warn_deprecated_redundant_constexpr_static_def : Warning< @@ -640,8 +640,8 @@ def warn_dyn_class_memaccess : Warning< def note_bad_memaccess_silence : Note< "explicitly cast the pointer to silence this warning">; def warn_sizeof_pointer_expr_memaccess : Warning< - "'%0' call operates on objects of type %1 while the size is based on a " - "different type %2">, + "'%0' call operates on objects of type %1 while the size is based on a " + "different type %2">, InGroup<SizeofPointerMemaccess>; def warn_sizeof_pointer_expr_memaccess_note : Note< "did you mean to %select{dereference the argument to 'sizeof' (and multiply " @@ -679,14 +679,14 @@ def note_suspicious_bzero_size_silence : Note< "parenthesize the second argument to silence">; def warn_strncat_large_size : Warning< - "the value of the size argument in 'strncat' is too large, might lead to a " + "the value of the size argument in 'strncat' is too large, might lead to a " "buffer overflow">, InGroup<StrncatSize>; -def warn_strncat_src_size : Warning<"size argument in 'strncat' call appears " +def warn_strncat_src_size : Warning<"size argument in 'strncat' call appears " "to be size of the source">, InGroup<StrncatSize>; def warn_strncat_wrong_size : Warning< "the value of the size argument to 'strncat' is wrong">, InGroup<StrncatSize>; def note_strncat_wrong_size : Note< - "change the argument to be the free space in the destination buffer minus " + "change the argument to be the free space in the destination buffer minus " "the terminating null byte">; def warn_assume_side_effects : Warning< @@ -1030,15 +1030,15 @@ def note_property_attribute : Note<"property %0 is declared " "%select{deprecated|unavailable|partial}1 here">; def err_setter_type_void : Error<"type of setter must be void">; def err_duplicate_method_decl : Error<"duplicate declaration of method %0">; -def warn_duplicate_method_decl : - Warning<"multiple declarations of method %0 found and ignored">, +def warn_duplicate_method_decl : + Warning<"multiple declarations of method %0 found and ignored">, InGroup<MethodDuplicate>, DefaultIgnore; def warn_objc_cdirective_format_string : Warning<"using %0 directive in %select{NSString|CFString}1 " "which is being passed as a formatting argument to the formatting " "%select{method|CFfunction}2">, InGroup<ObjCCStringFormat>, DefaultIgnore; -def err_objc_var_decl_inclass : +def err_objc_var_decl_inclass : Error<"cannot declare variable inside @interface or @protocol">; def err_missing_method_context : Error< "missing context for method declaration">; @@ -1250,7 +1250,7 @@ def warn_auto_implicit_atomic_property : Warning< "property is assumed atomic when auto-synthesizing the property">, InGroup<ImplicitAtomic>, DefaultIgnore; def warn_unimplemented_selector: Warning< - "no method with selector %0 is implemented in this translation unit">, + "no method with selector %0 is implemented in this translation unit">, InGroup<Selector>, DefaultIgnore; def warn_unimplemented_protocol_method : Warning< "method %0 in protocol %1 not implemented">, InGroup<Protocol>; @@ -1379,7 +1379,7 @@ def err_capture_default_non_local : Error< "non-local lambda expression cannot have a capture-default">; def err_multiple_final_overriders : Error< - "virtual function %q0 has more than one final overrider in %1">; + "virtual function %q0 has more than one final overrider in %1">; def note_final_overrider : Note<"final overrider of %q0 in %1">; def err_type_defined_in_type_specifier : Error< @@ -1421,7 +1421,7 @@ def warn_weak_template_vtable : Warning< def ext_using_undefined_std : ExtWarn< "using directive refers to implicitly-defined namespace 'std'">; - + // C++ exception specifications def err_exception_spec_in_typedef : Error< "exception specifications are not allowed in %select{typedefs|type aliases}0">; @@ -1475,7 +1475,7 @@ def ext_ms_using_declaration_inaccessible : ExtWarn< "to accessible member '%1') is a Microsoft compatibility extension">, AccessControl, InGroup<MicrosoftUsingDecl>; def err_access_ctor : Error< - "calling a %select{private|protected}0 constructor of class %2">, + "calling a %select{private|protected}0 constructor of class %2">, AccessControl; def ext_rvalue_to_reference_access_ctor : Extension< "C++98 requires an accessible copy constructor for class %2 when binding " @@ -1498,7 +1498,7 @@ def err_access_friend_function : Error< AccessControl; def err_access_dtor : Error< - "calling a %select{private|protected}1 destructor of class %0">, + "calling a %select{private|protected}1 destructor of class %0">, AccessControl; def err_access_dtor_base : Error<"base class %0 has %select{private|protected}1 destructor">, @@ -1540,7 +1540,7 @@ def note_access_protected_restricted_object : Note< def warn_cxx98_compat_sfinae_access_control : Warning< "substitution failure due to access control is incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore, NoSFINAE; - + // C++ name lookup def err_incomplete_nested_name_spec : Error< "incomplete type %0 named in nested name specifier">; @@ -1733,6 +1733,8 @@ def warn_overriding_method_missing_noescape : Warning< "__attribute__((noescape))">, InGroup<MissingNoEscape>; def note_overridden_marked_noescape : Note< "parameter of overridden method is annotated with __attribute__((noescape))">; +def note_cat_conform_to_noescape_prot : Note< + "%select{category|class extension}0 conforms to protocol %1 which defines method %2">; def err_covariant_return_inaccessible_base : Error< "invalid covariant return for virtual function: %1 is a " @@ -1979,7 +1981,7 @@ def note_explicit_ctor_deduction_guide_here : Note< // C++11 decltype def err_decltype_in_declarator : Error< "'decltype' cannot be used to name a declaration">; - + // C++11 auto def warn_cxx98_compat_auto_type_specifier : Warning< "'auto' type specifier is incompatible with C++98">, @@ -2632,7 +2634,7 @@ def warn_objc_literal_comparison : Warning< def err_missing_atsign_prefix : Error< "string literal must be prefixed by '@' ">; def warn_objc_string_literal_comparison : Warning< - "direct comparison of a string literal has undefined behavior">, + "direct comparison of a string literal has undefined behavior">, InGroup<ObjCStringComparison>; def warn_concatenated_nsarray_literal : Warning< "concatenated NSString literal for an NSArray expression - " @@ -2746,7 +2748,7 @@ def warn_cxx11_gnu_attribute_on_type : Warning< "attribute %0 ignored, because it cannot be applied to a type">, InGroup<IgnoredAttributes>; def warn_unhandled_ms_attribute_ignored : Warning< - "__declspec attribute %0 is not supported">, + "__declspec attribute %0 is not supported">, InGroup<IgnoredAttributes>; def err_decl_attribute_invalid_on_stmt : Error< "%0 attribute cannot be applied to a statement">; @@ -3001,7 +3003,7 @@ def err_attribute_argument_out_of_range : Error< "1:can only be 1, since there is one parameter|" ":must be between 1 and %2}2">; -// Thread Safety Analysis +// Thread Safety Analysis def warn_unlock_but_no_lock : Warning<"releasing %0 '%1' that was not held">, InGroup<ThreadSafetyAnalysis>, DefaultIgnore; def warn_unlock_kind_mismatch : Warning< @@ -3015,7 +3017,7 @@ def warn_no_unlock : Warning< InGroup<ThreadSafetyAnalysis>, DefaultIgnore; def warn_expecting_locked : Warning< "expecting %0 '%1' to be held at the end of function">, - InGroup<ThreadSafetyAnalysis>, DefaultIgnore; + InGroup<ThreadSafetyAnalysis>, DefaultIgnore; // FIXME: improve the error message about locks not in scope def warn_lock_some_predecessors : Warning< "%0 '%1' is not held on every path through here">, @@ -3092,13 +3094,13 @@ def warn_fun_requires_lock_precise : def note_found_mutex_near_match : Note<"found near match '%0'">; // Verbose thread safety warnings -def warn_thread_safety_verbose : Warning<"Thread safety verbose warning.">, +def warn_thread_safety_verbose : Warning<"Thread safety verbose warning.">, InGroup<ThreadSafetyVerbose>, DefaultIgnore; def note_thread_warning_in_fun : Note<"Thread warning in function %0">; def note_guarded_by_declared_here : Note<"Guarded_by declared here.">; -// Dummy warning that will trigger "beta" warnings from the analysis if enabled. -def warn_thread_safety_beta : Warning<"Thread safety beta warning.">, +// Dummy warning that will trigger "beta" warnings from the analysis if enabled. +def warn_thread_safety_beta : Warning<"Thread safety beta warning.">, InGroup<ThreadSafetyBeta>, DefaultIgnore; // Consumed warnings @@ -3354,7 +3356,7 @@ def err_attribute_sentinel_not_zero_or_one : Error< "'sentinel' parameter 2 not 0 or 1">; def warn_cleanup_ext : Warning< "GCC does not allow the 'cleanup' attribute argument to be anything other " - "than a simple identifier">, + "than a simple identifier">, InGroup<GccCompat>; def err_attribute_cleanup_arg_not_function : Error< "'cleanup' argument %select{|%1 |%1 }0is not a %select{||single }0function">; @@ -3389,7 +3391,7 @@ def warn_iboutlet_object_type : Warning< def warn_iboutletcollection_property_assign : Warning< "IBOutletCollection properties should be copy/strong and not assign">, InGroup<ObjCInvalidIBOutletProperty>; - + def err_attribute_overloadable_mismatch : Error< "redeclaration of %0 must %select{not |}1have the 'overloadable' attribute">; def note_attribute_overloadable_prev_overload : Note< @@ -3854,7 +3856,7 @@ def note_template_param_different_kind : Note< def err_invalid_decl_specifier_in_nontype_parm : Error< "invalid declaration specifier in template non-type parameter">; - + def err_template_nontype_parm_different_type : Error< "template non-type parameter has a different type %0 in template " "%select{|template parameter }1redeclaration">; @@ -4156,7 +4158,7 @@ def err_dependent_typed_non_type_arg_in_partial_spec : Error< def err_partial_spec_args_match_primary_template : Error< "%select{class|variable}0 template partial specialization does not " "specialize any template argument; to %select{declare|define}1 the " - "primary template, remove the template argument list">; + "primary template, remove the template argument list">; def ext_partial_spec_not_more_specialized_than_primary : ExtWarn< "%select{class|variable}0 template partial specialization is not " "more specialized than the primary template">, DefaultError, @@ -4191,7 +4193,7 @@ def err_var_spec_no_template : Error< def err_var_spec_no_template_but_method : Error< "no variable template matches specialization; " "did you mean to use %0 as function template instead?">; - + // C++ Function template specializations def err_function_template_spec_no_match : Error< "no function template matches function template specialization %0">; @@ -4312,12 +4314,12 @@ def err_explicit_instantiation_out_of_scope : Error< def err_explicit_instantiation_must_be_global : Error< "explicit instantiation of %0 must occur at global scope">; def warn_explicit_instantiation_out_of_scope_0x : Warning< - "explicit instantiation of %0 not in a namespace enclosing %1">, + "explicit instantiation of %0 not in a namespace enclosing %1">, InGroup<CXX11Compat>, DefaultIgnore; def warn_explicit_instantiation_must_be_global_0x : Warning< - "explicit instantiation of %0 must occur at global scope">, + "explicit instantiation of %0 must occur at global scope">, InGroup<CXX11Compat>, DefaultIgnore; - + def err_explicit_instantiation_requires_name : Error< "explicit instantiation declaration requires a name">; def err_explicit_instantiation_of_typedef : Error< @@ -4378,7 +4380,7 @@ def err_mismatched_exception_spec_explicit_instantiation : Error< def ext_mismatched_exception_spec_explicit_instantiation : ExtWarn< err_mismatched_exception_spec_explicit_instantiation.Text>, InGroup<MicrosoftExceptionSpec>; - + // C++ typename-specifiers def err_typename_nested_not_found : Error<"no type named %0 in %1">; def err_typename_nested_not_found_enable_if : Error< @@ -4456,7 +4458,7 @@ def note_template_parameter_pack_non_pack : Note< def note_template_parameter_pack_here : Note< "previous %select{template type|non-type template|template template}0 " "parameter%select{| pack}1 declared here">; - + def err_unexpanded_parameter_pack : Error< "%select{expression|base type|declaration type|data member type|bit-field " "size|static assertion|fixed underlying type|enumerator value|" @@ -4560,7 +4562,7 @@ def warn_missing_prototype : Warning< "no previous prototype for function %0">, InGroup<DiagGroup<"missing-prototypes">>, DefaultIgnore; def note_declaration_not_a_prototype : Note< - "this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function">; + "this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function">; def warn_strict_prototypes : Warning< "this %select{function declaration is not|block declaration is not|" "old-style function definition is not preceded by}0 a prototype">, @@ -4768,7 +4770,7 @@ def ext_ms_forward_ref_enum : ExtWarn< def ext_forward_ref_enum_def : Extension< "redeclaration of already-defined enum %0 is a GNU extension">, InGroup<GNURedeclaredEnum>; - + def err_redefinition_of_enumerator : Error<"redefinition of enumerator %0">; def err_duplicate_member : Error<"duplicate member %0">; def err_misplaced_ivar : Error< @@ -4787,7 +4789,7 @@ def ext_enumerator_increment_too_large : ExtWarn< def warn_flag_enum_constant_out_of_range : Warning< "enumeration value %0 is out of range of flags in enumeration type %1">, InGroup<FlagEnum>; - + def warn_illegal_constant_array_size : Extension< "size of static array must be an integer constant expression">; def err_vm_decl_in_file_scope : Error< @@ -4892,7 +4894,7 @@ def err_illegal_initializer : Error< "illegal initializer (only variables can be initialized)">; def err_illegal_initializer_type : Error<"illegal initializer type %0">; def ext_init_list_type_narrowing : ExtWarn< - "type %0 cannot be narrowed to %1 in initializer list">, + "type %0 cannot be narrowed to %1 in initializer list">, InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure; def ext_init_list_variable_narrowing : ExtWarn< "non-constant-expression cannot be narrowed from type %0 to %1 in " @@ -5230,9 +5232,9 @@ def err_arc_illegal_method_def : Error< def warn_arc_strong_pointer_objc_pointer : Warning< "method parameter of type %0 with no explicit ownership">, InGroup<DiagGroup<"explicit-ownership-type">>, DefaultIgnore; - + } // end "ARC Restrictions" category - + def err_arc_lost_method_convention : Error< "method was declared as %select{an 'alloc'|a 'copy'|an 'init'|a 'new'}0 " "method, but its implementation doesn't match because %select{" @@ -5301,7 +5303,7 @@ def warn_receiver_forward_instance : Warning< InGroup<ForwardClassReceiver>, DefaultIgnore; def err_arc_collection_forward : Error< "collection expression type %0 is a forward declaration">; -def err_arc_multiple_method_decl : Error< +def err_arc_multiple_method_decl : Error< "multiple methods named %0 found with mismatched result, " "parameter type or attributes">; def warn_arc_lifetime_result_type : Warning< @@ -5694,7 +5696,7 @@ def warn_namespace_member_extra_qualification : Warning< "extra qualification on member %0">, InGroup<DiagGroup<"extra-qualification">>; def err_member_qualification : Error< - "non-friend class member %0 cannot have a qualified name">; + "non-friend class member %0 cannot have a qualified name">; def note_member_def_close_match : Note<"member declaration nearly matches">; def note_member_def_close_const_match : Note< "member declaration does not match because " @@ -5800,7 +5802,7 @@ def err_typecheck_invalid_lvalue_addrof_addrof_function : Error< def err_typecheck_invalid_lvalue_addrof : Error< "cannot take the address of an rvalue of type %0">; def ext_typecheck_addrof_temporary : ExtWarn< - "taking the address of a temporary object of type %0">, + "taking the address of a temporary object of type %0">, InGroup<AddressOfTemporary>, DefaultError; def err_typecheck_addrof_temporary : Error< "taking the address of a temporary object of type %0">; @@ -5911,7 +5913,7 @@ def warn_mixed_sign_comparison : Warning< "comparison of integers of different signs: %0 and %1">, InGroup<SignCompare>, DefaultIgnore; def warn_out_of_range_compare : Warning< - "result of comparison of %select{constant %0|true|false}1 with " + "result of comparison of %select{constant %0|true|false}1 with " "%select{expression of type %2|boolean expression}3 is always %4">, InGroup<TautologicalOutOfRangeCompare>; def warn_tautological_bool_compare : Warning<warn_out_of_range_compare.Text>, @@ -6069,7 +6071,7 @@ def err_no_subobject_property_setting : Error< "expression is not assignable">; def err_qualified_objc_access : Error< "%select{property|instance variable}0 access cannot be qualified with '%1'">; - + def ext_freestanding_complex : Extension< "complex numbers are an extension in a freestanding C99 implementation">; @@ -6235,13 +6237,13 @@ def warn_cxx98_compat_cast_fn_obj : Warning< def err_bad_reinterpret_cast_small_int : Error< "cast from pointer to smaller type %2 loses information">; def err_bad_cxx_cast_vector_to_scalar_different_size : Error< - "%select{||reinterpret_cast||C-style cast|}0 from vector %1 " + "%select{||reinterpret_cast||C-style cast|}0 from vector %1 " "to scalar %2 of different size">; def err_bad_cxx_cast_scalar_to_vector_different_size : Error< - "%select{||reinterpret_cast||C-style cast|}0 from scalar %1 " + "%select{||reinterpret_cast||C-style cast|}0 from scalar %1 " "to vector %2 of different size">; def err_bad_cxx_cast_vector_to_vector_different_size : Error< - "%select{||reinterpret_cast||C-style cast|}0 from vector %1 " + "%select{||reinterpret_cast||C-style cast|}0 from vector %1 " "to vector %2 of different size">; def err_bad_lvalue_to_rvalue_cast : Error< "cannot cast from lvalue of type %1 to rvalue reference type %2; types are " @@ -6643,7 +6645,7 @@ def err_typecheck_nonviable_condition_incomplete : Error< def err_typecheck_deleted_function : Error< "conversion function %diff{from $ to $|between types}0,1 " "invokes a deleted function">; - + def err_expected_class_or_namespace : Error<"%0 is not a class" "%select{ or namespace|, namespace, or enumeration}1">; def err_invalid_declarator_scope : Error<"cannot define or redeclare %0 here " @@ -7011,11 +7013,11 @@ def err_typecheck_call_too_many_args_at_most_suggest : Error< "too many %select{|||execution configuration }0arguments to " "%select{function|block|method|kernel function}0 call, " "expected at most %1, have %2; did you mean %3?">; - + def err_arc_typecheck_convert_incompatible_pointer : Error< "incompatible pointer types passing retainable parameter of type %0" "to a CF function expecting %1 type">; - + def err_builtin_fn_use : Error<"builtin functions must be directly called">; def warn_call_wrong_number_of_arguments : Warning< @@ -7129,7 +7131,8 @@ def err_shared_var_init : Error< "initialization is not supported for __shared__ variables.">; def err_device_static_local_var : Error< "within a %select{__device__|__global__|__host__|__host__ __device__}0 " - "function, only __shared__ variables may be marked 'static'">; + "function, only __shared__ variables or const variables without device " + "memory qualifier may be marked 'static'">; def err_cuda_vla : Error< "cannot use variable-length arrays in " "%select{__device__|__global__|__host__|__host__ __device__}0 functions">; @@ -7505,8 +7508,8 @@ def err_reference_to_local_in_enclosing_context : Error< "%select{%3|block literal|lambda expression|context}2">; def err_static_data_member_not_allowed_in_local_class : Error< - "static data member %0 not allowed in local class %1">; - + "static data member %0 not allowed in local class %1">; + // C++ derived classes def err_base_clause_on_union : Error<"unions cannot have base classes">; def err_base_must_be_class : Error<"base specifier must name a class">; @@ -7851,6 +7854,13 @@ def warn_null_ret : Warning< "null returned from %select{function|method}0 that requires a non-null return value">, InGroup<NonNull>; +def err_lifetimebound_no_object_param : Error< + "'lifetimebound' attribute cannot be applied; %select{static |non-}0member " + "function has no implicit object parameter">; +def err_lifetimebound_ctor_dtor : Error< + "'lifetimebound' attribute cannot be applied to a " + "%select{constructor|destructor}0">; + // CHECK: returning address/reference of stack memory def warn_ret_stack_addr_ref : Warning< "%select{address of|reference to}0 stack memory associated with " @@ -7865,7 +7875,8 @@ def warn_ret_addr_label : Warning< def err_ret_local_block : Error< "returning block that lives on the local stack">; def note_local_var_initializer : Note< - "%select{via initialization of|binding reference}0 variable %1 here">; + "%select{via initialization of|binding reference}0 variable " + "%select{%2 |}1here">; def note_init_with_default_member_initalizer : Note< "initializing field %0 with default member initializer">; @@ -7897,13 +7908,14 @@ def note_lifetime_extending_member_declared_here : Note< "member with %select{reference|'std::initializer_list'}0 subobject}1 " "declared here">; def warn_dangling_variable : Warning< - "%select{temporary %select{whose address is used as value of|bound to}3 " - "%select{%select{|reference }3member of local variable|" - "local %select{variable|reference}3}1|" + "%select{temporary %select{whose address is used as value of|" + "%select{|implicitly }2bound to}4 " + "%select{%select{|reference }4member of local variable|" + "local %select{variable|reference}4}1|" "array backing " "%select{initializer list subobject of local variable|" "local initializer list}1}0 " - "%2 will be destroyed at the end of the full-expression">, + "%select{%3 |}2will be destroyed at the end of the full-expression">, InGroup<Dangling>; def warn_new_dangling_reference : Warning< "temporary bound to reference member of allocated object " @@ -8219,7 +8231,7 @@ def err_vector_incorrect_num_initializers : Error< def err_altivec_empty_initializer : Error<"expected initializer">; def err_invalid_neon_type_code : Error< - "incompatible constant for this __builtin_neon function">; + "incompatible constant for this __builtin_neon function">; def err_argument_invalid_range : Error< "argument value %0 is outside the valid range [%1, %2]">; def warn_argument_invalid_range : Warning< @@ -8275,7 +8287,7 @@ def err_constant_integer_arg_type : Error< def ext_mixed_decls_code : Extension< "ISO C90 forbids mixing declarations and code">, InGroup<DiagGroup<"declaration-after-statement">>; - + def err_non_local_variable_decl_in_for : Error< "declaration of non-local variable in 'for' loop">; def err_non_variable_decl_in_for : Error< @@ -8343,7 +8355,7 @@ def warn_nsconsumed_attribute_mismatch : Warning< err_nsconsumed_attribute_mismatch.Text>, InGroup<NSConsumedMismatch>; def warn_nsreturns_retained_attribute_mismatch : Warning< err_nsreturns_retained_attribute_mismatch.Text>, InGroup<NSReturnsMismatch>; - + def note_getter_unavailable : Note< "or because setter is declared here, but no getter method %0 is found">; def err_invalid_protocol_qualifiers : Error< @@ -8599,7 +8611,7 @@ def err_opencl_extern_block_declaration : Error< def err_opencl_block_ref_block : Error< "cannot refer to a block inside block">; -// OpenCL v2.0 s6.13.9 - Address space qualifier functions. +// OpenCL v2.0 s6.13.9 - Address space qualifier functions. def err_opencl_builtin_to_addr_arg_num : Error< "invalid number of arguments to function: %0">; def err_opencl_builtin_to_addr_invalid_arg : Error< diff --git a/include/clang/Basic/DiagnosticSerializationKinds.td b/include/clang/Basic/DiagnosticSerializationKinds.td index 3a552e2f3db42..54237d16f5c10 100644 --- a/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/include/clang/Basic/DiagnosticSerializationKinds.td @@ -49,7 +49,7 @@ def err_pch_diagopt_mismatch : Error<"%0 is currently enabled, but was not in " "the PCH file">; def err_pch_modulecache_mismatch : Error<"PCH was compiled with module cache " "path '%0', but the path is currently '%1'">; - + def err_pch_version_too_old : Error< "PCH file uses an older PCH format that is no longer supported">; def err_pch_version_too_new : Error< diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h index 45aded527c1bd..1ec344623a0dc 100644 --- a/include/clang/Basic/FileSystemStatCache.h +++ b/include/clang/Basic/FileSystemStatCache.h @@ -62,7 +62,7 @@ protected: public: virtual ~FileSystemStatCache() = default; - + enum LookupResult { /// We know the file exists and its cached stat data. CacheExists, @@ -90,10 +90,10 @@ public: void setNextStatCache(std::unique_ptr<FileSystemStatCache> Cache) { NextStatCache = std::move(Cache); } - + /// Retrieve the next stat call cache in the chain. FileSystemStatCache *getNextStatCache() { return NextStatCache.get(); } - + /// Retrieve the next stat call cache in the chain, transferring /// ownership of this cache (and, transitively, all of the remaining caches) /// to the caller. diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index f43df5c64829d..c2e9c71b0f0d2 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -63,7 +63,7 @@ class IdentifierInfo { bool IsPoisoned : 1; // True if identifier is poisoned. bool IsCPPOperatorKeyword : 1; // True if ident is a C++ operator keyword. bool NeedsHandleIdentifier : 1; // See "RecomputeNeedsHandleIdentifier". - bool IsFromAST : 1; // True if identifier was loaded (at least + bool IsFromAST : 1; // True if identifier was loaded (at least // partially) from an AST file. bool ChangedAfterLoad : 1; // True if identifier has changed from the // definition loaded from an AST file. @@ -308,7 +308,7 @@ public: bool hasChangedSinceDeserialization() const { return ChangedAfterLoad; } - + /// Note that this identifier has changed since it was loaded from /// an AST file. void setChangedSinceDeserialization() { @@ -320,7 +320,7 @@ public: bool hasFETokenInfoChangedSinceDeserialization() const { return FEChangedAfterLoad; } - + /// Note that the frontend token information for this identifier has /// changed since it was loaded from an AST file. void setFETokenInfoChangedSinceDeserialization() { @@ -330,7 +330,7 @@ public: /// Determine whether the information for this identifier is out of /// date with respect to the external source. bool isOutOfDate() const { return OutOfDate; } - + /// Set whether the information for this identifier is out of /// date with respect to the external source. void setOutOfDate(bool OOD) { @@ -340,10 +340,10 @@ public: else RecomputeNeedsHandleIdentifier(); } - + /// Determine whether this is the contextual keyword \c import. bool isModulesImport() const { return IsModulesImport; } - + /// Set whether this identifier is the contextual keyword \c import. void setModulesImport(bool I) { IsModulesImport = I; @@ -419,7 +419,7 @@ public: class IdentifierIterator { protected: IdentifierIterator() = default; - + public: IdentifierIterator(const IdentifierIterator &) = delete; IdentifierIterator &operator=(const IdentifierIterator &) = delete; @@ -490,7 +490,7 @@ public: IdentifierInfoLookup *getExternalIdentifierLookup() const { return ExternalLookup; } - + llvm::BumpPtrAllocator& getAllocator() { return HashTable.getAllocator(); } @@ -572,7 +572,7 @@ public: void AddKeywords(const LangOptions &LangOpts); }; -/// A family of Objective-C methods. +/// A family of Objective-C methods. /// /// These families have no inherent meaning in the language, but are /// nonetheless central enough in the existing implementations to @@ -687,13 +687,13 @@ class Selector { MultiKeywordSelector *getMultiKeywordSelector() const { return reinterpret_cast<MultiKeywordSelector *>(InfoPtr & ~ArgFlags); } - + unsigned getIdentifierInfoFlag() const { return InfoPtr & ArgFlags; } static ObjCMethodFamily getMethodFamilyImpl(Selector sel); - + static ObjCStringFormatFamily getStringFormatFamilyImpl(Selector sel); public: @@ -730,11 +730,11 @@ public: } unsigned getNumArgs() const; - + /// Retrieve the identifier at a given position in the selector. /// /// Note that the identifier pointer returned may be NULL. Clients that only - /// care about the text of the identifier string, and not the specific, + /// care about the text of the identifier string, and not the specific, /// uniqued identifier pointer, should use \c getNameForSlot(), which returns /// an empty string when the identifier pointer would be NULL. /// @@ -745,7 +745,7 @@ public: /// \returns the uniqued identifier for this slot, or NULL if this slot has /// no corresponding identifier. IdentifierInfo *getIdentifierInfoForSlot(unsigned argIndex) const; - + /// Retrieve the name at a given position in the selector. /// /// \param argIndex The index for which we want to retrieve the name. @@ -755,7 +755,7 @@ public: /// \returns the name for this slot, which may be the empty string if no /// name was supplied. StringRef getNameForSlot(unsigned argIndex) const; - + /// Derive the full selector name (e.g. "foo:bar:") and return /// it as an std::string. std::string getAsString() const; @@ -769,11 +769,11 @@ public: ObjCMethodFamily getMethodFamily() const { return getMethodFamilyImpl(*this); } - + ObjCStringFormatFamily getStringFormatFamily() const { return getStringFormatFamilyImpl(*this); } - + static Selector getEmptyMarker() { return Selector(uintptr_t(-1)); } @@ -781,7 +781,7 @@ public: static Selector getTombstoneMarker() { return Selector(uintptr_t(-2)); } - + static ObjCInstanceTypeFamily getInstTypeMethodFamily(Selector sel); }; @@ -901,7 +901,7 @@ struct PointerLikeTypeTraits<clang::Selector> { return clang::Selector(reinterpret_cast<uintptr_t>(P)); } - enum { NumLowBitsAvailable = 0 }; + enum { NumLowBitsAvailable = 0 }; }; // Provide PointerLikeTypeTraits for IdentifierInfo pointers, which diff --git a/include/clang/Basic/LLVM.h b/include/clang/Basic/LLVM.h index 8a432db911daf..3f833c62c0a8c 100644 --- a/include/clang/Basic/LLVM.h +++ b/include/clang/Basic/LLVM.h @@ -59,7 +59,7 @@ namespace clang { using llvm::dyn_cast; using llvm::dyn_cast_or_null; using llvm::cast_or_null; - + // ADT's. using llvm::ArrayRef; using llvm::MutableArrayRef; diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index f3a6292e5adea..a1396f84352fc 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -50,10 +50,10 @@ protected: class LangOptions : public LangOptionsBase { public: using Visibility = clang::Visibility; - + enum GCMode { NonGC, GCOnly, HybridGC }; enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq }; - + enum SignedOverflowBehaviorTy { // Default C standard behavior. SOB_Undefined, @@ -165,7 +165,7 @@ public: clang::ObjCRuntime ObjCRuntime; std::string ObjCConstantStringClass; - + /// The name of the handler function to be called when -ftrapv is /// specified. /// @@ -209,10 +209,10 @@ public: LangOptions(); // Define accessors/mutators for language options of enumeration type. -#define LANGOPT(Name, Bits, Default, Description) +#define LANGOPT(Name, Bits, Default, Description) #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ Type get##Name() const { return static_cast<Type>(Name); } \ - void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } + void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } #include "clang/Basic/LangOptions.def" /// Are we compiling a module interface (.cppm or module map)? @@ -228,7 +228,7 @@ public: bool isSignedOverflowDefined() const { return getSignedOverflowBehavior() == SOB_Defined; } - + bool isSubscriptPointerArithmetic() const { return ObjCRuntime.isSubscriptPointerArithmetic() && !ObjCSubscriptingLegacyRuntime; @@ -309,7 +309,7 @@ enum TranslationUnitKind { /// The translation unit is a module. TU_Module }; - + } // namespace clang #endif // LLVM_CLANG_BASIC_LANGOPTIONS_H diff --git a/include/clang/Basic/Linkage.h b/include/clang/Basic/Linkage.h index 94dcfd445b0b7..529cfa9f3f8d7 100644 --- a/include/clang/Basic/Linkage.h +++ b/include/clang/Basic/Linkage.h @@ -19,7 +19,7 @@ namespace clang { -/// Describes the different kinds of linkage +/// Describes the different kinds of linkage /// (C++ [basic.link], C99 6.2.2) that an entity may have. enum Linkage : unsigned char { /// No linkage, which means that the entity is unique and @@ -31,7 +31,7 @@ enum Linkage : unsigned char { /// translation units). InternalLinkage, - /// External linkage within a unique namespace. + /// External linkage within a unique namespace. /// /// From the language perspective, these entities have external /// linkage. However, since they reside in an anonymous namespace, diff --git a/include/clang/Basic/Module.h b/include/clang/Basic/Module.h index 4aebda1887c45..02a4ef610b64d 100644 --- a/include/clang/Basic/Module.h +++ b/include/clang/Basic/Module.h @@ -44,7 +44,7 @@ class raw_ostream; } // namespace llvm namespace clang { - + class LangOptions; class TargetInfo; @@ -66,7 +66,7 @@ class Module { public: /// The name of this module. std::string Name; - + /// The location of the module definition. SourceLocation DefinitionLoc; @@ -111,12 +111,12 @@ public: /// The module through which entities defined in this module will /// eventually be exposed, for use in "private" modules. std::string ExportAsModule; - + private: /// The submodules of this module, indexed by name. std::vector<Module *> SubModules; - - /// A mapping from the submodule name to the index into the + + /// A mapping from the submodule name to the index into the /// \c SubModules vector at which that submodule resides. llvm::StringMap<unsigned> SubModuleIndex; @@ -214,13 +214,13 @@ public: /// Whether this module was loaded from a module file. unsigned IsFromModuleFile : 1; - + /// Whether this is a framework module. unsigned IsFramework : 1; - + /// Whether this is an explicit submodule. unsigned IsExplicit : 1; - + /// Whether this is a "system" module (which assumes that all /// headers in it are system headers). unsigned IsSystem : 1; @@ -233,16 +233,16 @@ public: /// Whether this is an inferred submodule (module * { ... }). unsigned IsInferred : 1; - /// Whether we should infer submodules for this module based on + /// Whether we should infer submodules for this module based on /// the headers. /// /// Submodules can only be inferred for modules with an umbrella header. unsigned InferSubmodules : 1; - + /// Whether, when inferring submodules, the inferred submodules /// should be explicit. unsigned InferExplicitSubmodules : 1; - + /// Whether, when inferring submodules, the inferr submodules should /// export all modules they import (e.g., the equivalent of "export *"). unsigned InferExportWildcard : 1; @@ -280,31 +280,31 @@ public: /// The set of modules imported by this module, and on which this /// module depends. llvm::SmallSetVector<Module *, 2> Imports; - + /// Describes an exported module. /// /// The pointer is the module being re-exported, while the bit will be true /// to indicate that this is a wildcard export. using ExportDecl = llvm::PointerIntPair<Module *, 1, bool>; - + /// The set of export declarations. SmallVector<ExportDecl, 2> Exports; - + /// Describes an exported module that has not yet been resolved /// (perhaps because the module it refers to has not yet been loaded). struct UnresolvedExportDecl { /// The location of the 'export' keyword in the module map file. SourceLocation ExportLoc; - + /// The name of the module. ModuleId Id; - + /// Whether this export declaration ends in a wildcard, indicating /// that all of its submodules should be exported (rather than the named /// module itself). bool Wildcard; }; - + /// The set of export declarations that have yet to be resolved. SmallVector<UnresolvedExportDecl, 2> UnresolvedExports; @@ -320,7 +320,7 @@ public: LinkLibrary() = default; LinkLibrary(const std::string &Library, bool IsFramework) : Library(Library), IsFramework(IsFramework) {} - + /// The library to link against. /// /// This will typically be a library or framework name, but can also @@ -371,9 +371,9 @@ public: /// Construct a new module or submodule. Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, bool IsFramework, bool IsExplicit, unsigned VisibilityID); - + ~Module(); - + /// Determine whether this module is available for use within the /// current translation unit. bool isAvailable() const { return IsAvailable; } @@ -395,7 +395,7 @@ public: /// /// \param ShadowingModule If this module is unavailable because it is /// shadowed, this parameter will be set to the shadowing module. - bool isAvailable(const LangOptions &LangOpts, + bool isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, Requirement &Req, UnresolvedHeaderDirective &MissingHeader, @@ -403,19 +403,19 @@ public: /// Determine whether this module is a submodule. bool isSubModule() const { return Parent != nullptr; } - + /// Determine whether this module is a submodule of the given other /// module. bool isSubModuleOf(const Module *Other) const; - + /// Determine whether this module is a part of a framework, /// either because it is a framework module or because it is a submodule /// of a framework module. bool isPartOfFramework() const { - for (const Module *Mod = this; Mod; Mod = Mod->Parent) + for (const Module *Mod = this; Mod; Mod = Mod->Parent) if (Mod->IsFramework) return true; - + return false; } @@ -456,7 +456,7 @@ public: /// Retrieve the top-level module for this (sub)module, which may /// be this module. const Module *getTopLevelModule() const; - + /// Retrieve the name of the top-level module. StringRef getTopLevelModuleName() const { return getTopLevelModule()->Name; @@ -552,7 +552,7 @@ public: using submodule_iterator = std::vector<Module *>::iterator; using submodule_const_iterator = std::vector<Module *>::const_iterator; - + submodule_iterator submodule_begin() { return SubModules.begin(); } submodule_const_iterator submodule_begin() const {return SubModules.begin();} submodule_iterator submodule_end() { return SubModules.end(); } @@ -575,9 +575,9 @@ public: return "<module-includes>"; } - /// Print the module map for this module to the given stream. + /// Print the module map for this module to the given stream. void print(raw_ostream &OS, unsigned Indent = 0) const; - + /// Dump the contents of this module to the given output stream. void dump() const; diff --git a/include/clang/Basic/ObjCRuntime.h b/include/clang/Basic/ObjCRuntime.h index d5f4f50fe36f5..c307c96433909 100644 --- a/include/clang/Basic/ObjCRuntime.h +++ b/include/clang/Basic/ObjCRuntime.h @@ -154,7 +154,7 @@ public: llvm_unreachable("bad kind"); } - /// Does this runtime natively provide the ARC entrypoints? + /// Does this runtime natively provide the ARC entrypoints? /// /// ARC cannot be directly supported on a platform that does not provide /// these entrypoints, although it may be supportable via a stub diff --git a/include/clang/Basic/OperatorKinds.h b/include/clang/Basic/OperatorKinds.h index b0064cfb4e5a7..3096f835e66b8 100644 --- a/include/clang/Basic/OperatorKinds.h +++ b/include/clang/Basic/OperatorKinds.h @@ -27,7 +27,7 @@ enum OverloadedOperatorKind : int { NUM_OVERLOADED_OPERATORS }; -/// Retrieve the spelling of the given overloaded operator, without +/// Retrieve the spelling of the given overloaded operator, without /// the preceding "operator" keyword. const char *getOperatorSpelling(OverloadedOperatorKind Operator); diff --git a/include/clang/Basic/Sanitizers.def b/include/clang/Basic/Sanitizers.def index 5a36822a63035..ae5c75fc5bbd5 100644 --- a/include/clang/Basic/Sanitizers.def +++ b/include/clang/Basic/Sanitizers.def @@ -131,9 +131,14 @@ SANITIZER_GROUP("undefined", Undefined, // -fsanitize=undefined-trap is an alias for -fsanitize=undefined. SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined) +// ImplicitConversionSanitizer +SANITIZER("implicit-integer-truncation", ImplicitIntegerTruncation) +SANITIZER_GROUP("implicit-conversion", ImplicitConversion, + ImplicitIntegerTruncation) + SANITIZER_GROUP("integer", Integer, - SignedIntegerOverflow | UnsignedIntegerOverflow | Shift | - IntegerDivideByZero) + ImplicitIntegerTruncation | IntegerDivideByZero | Shift | + SignedIntegerOverflow | UnsignedIntegerOverflow) SANITIZER("local-bounds", LocalBounds) SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds) diff --git a/include/clang/Basic/Sanitizers.h b/include/clang/Basic/Sanitizers.h index 469d9e2e95917..2ecbde821599d 100644 --- a/include/clang/Basic/Sanitizers.h +++ b/include/clang/Basic/Sanitizers.h @@ -84,7 +84,8 @@ SanitizerMask expandSanitizerGroups(SanitizerMask Kinds); /// Return the sanitizers which do not affect preprocessing. inline SanitizerMask getPPTransparentSanitizers() { return SanitizerKind::CFI | SanitizerKind::Integer | - SanitizerKind::Nullability | SanitizerKind::Undefined; + SanitizerKind::ImplicitConversion | SanitizerKind::Nullability | + SanitizerKind::Undefined; } } // namespace clang diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index f174f83abf4a0..488a604a452f7 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/include/clang/Basic/SourceLocation.h @@ -38,7 +38,7 @@ class SourceManager; /// source file (MemoryBuffer) along with its \#include path and \#line data. /// class FileID { - /// A mostly-opaque identifier, where 0 is "invalid", >0 is + /// A mostly-opaque identifier, where 0 is "invalid", >0 is /// this module, and <-1 is something loaded from another module. int ID = 0; @@ -60,7 +60,7 @@ private: friend class ASTWriter; friend class ASTReader; friend class SourceManager; - + static FileID get(int V) { FileID F; F.ID = V; @@ -221,7 +221,7 @@ public: return B != X.B || E != X.E; } }; - + /// Represents a character-granular source range. /// /// The underlying SourceRange can either specify the starting/ending character @@ -229,7 +229,7 @@ public: /// last token of the range (a "token range"). In the token range case, the /// size of the last token must be measured to determine the actual end of the /// range. -class CharSourceRange { +class CharSourceRange { SourceRange Range; bool IsTokenRange = false; @@ -244,7 +244,7 @@ public: static CharSourceRange getCharRange(SourceRange R) { return CharSourceRange(R, false); } - + static CharSourceRange getTokenRange(SourceLocation B, SourceLocation E) { return getTokenRange(SourceRange(B, E)); } @@ -252,21 +252,21 @@ public: static CharSourceRange getCharRange(SourceLocation B, SourceLocation E) { return getCharRange(SourceRange(B, E)); } - + /// Return true if the end of this range specifies the start of /// the last token. Return false if the end of this range specifies the last /// character in the range. bool isTokenRange() const { return IsTokenRange; } bool isCharRange() const { return !IsTokenRange; } - + SourceLocation getBegin() const { return Range.getBegin(); } SourceLocation getEnd() const { return Range.getEnd(); } SourceRange getAsRange() const { return Range; } - + void setBegin(SourceLocation b) { Range.setBegin(b); } void setEnd(SourceLocation e) { Range.setEnd(e); } void setTokenRange(bool TR) { IsTokenRange = TR; } - + bool isValid() const { return Range.isValid(); } bool isInvalid() const { return !isValid(); } }; @@ -453,7 +453,7 @@ namespace llvm { return LHS == RHS; } }; - + template <> struct isPodLike<clang::SourceLocation> { static const bool value = true; }; template <> diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h index 99c36f4cdfcc8..af7dbbc13ca7b 100644 --- a/include/clang/Basic/SourceManager.h +++ b/include/clang/Basic/SourceManager.h @@ -155,7 +155,7 @@ namespace SrcMgr { ContentCache(const FileEntry *Ent, const FileEntry *contentEnt) : Buffer(nullptr, false), OrigEntry(Ent), ContentsEntry(contentEnt), BufferOverridden(false), IsSystemFile(false), IsTransient(false) {} - + /// The copy ctor does not allow copies where source object has either /// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory /// is not transferred, so this is a logical error. @@ -1072,7 +1072,7 @@ public: unsigned FileOffset = Entry.getOffset(); return SourceLocation::getFileLoc(FileOffset); } - + /// Return the source location corresponding to the last byte of the /// specified file. SourceLocation getLocForEndOfFile(FileID FID) const { @@ -1080,7 +1080,7 @@ public: const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, &Invalid); if (Invalid || !Entry.isFile()) return SourceLocation(); - + unsigned FileOffset = Entry.getOffset(); return SourceLocation::getFileLoc(FileOffset + getFileIDSize(FID)); } @@ -1403,7 +1403,7 @@ public: PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives = true) const; - /// Returns whether the PresumedLoc for a given SourceLocation is + /// Returns whether the PresumedLoc for a given SourceLocation is /// in the main file. /// /// This computes the "presumed" location for a SourceLocation, then checks diff --git a/include/clang/Basic/SourceManagerInternals.h b/include/clang/Basic/SourceManagerInternals.h index 68873be594d4b..ddc58ffb6969d 100644 --- a/include/clang/Basic/SourceManagerInternals.h +++ b/include/clang/Basic/SourceManagerInternals.h @@ -79,7 +79,7 @@ inline bool operator<(unsigned Offset, const LineEntry &E) { /// Used to hold and unique data used to represent \#line information. class LineTableInfo { - /// Map used to assign unique IDs to filenames in \#line directives. + /// Map used to assign unique IDs to filenames in \#line directives. /// /// This allows us to unique the filenames that /// frequently reoccur and reference them with indices. FilenameIDs holds diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h index 303b77e448053..cd8213f6cfd4b 100644 --- a/include/clang/Basic/Specifiers.h +++ b/include/clang/Basic/Specifiers.h @@ -28,14 +28,14 @@ namespace clang { TSW_long, TSW_longlong }; - + /// Specifies the signedness of a type, e.g., signed or unsigned. enum TypeSpecifierSign { TSS_unspecified, TSS_signed, TSS_unsigned }; - + enum TypeSpecifiersPipe { TSP_unspecified, TSP_pipe @@ -134,7 +134,7 @@ namespace clang { /// An Objective-C property is a logical field of an Objective-C /// object which is read and written via Objective-C method calls. OK_ObjCProperty, - + /// An Objective-C array/dictionary subscripting which reads an /// object or writes at the subscripted array/dictionary element via /// Objective-C method calls. diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td index 506da07203385..1517d741cb3ce 100644 --- a/include/clang/Basic/StmtNodes.td +++ b/include/clang/Basic/StmtNodes.td @@ -187,7 +187,7 @@ def TypoExpr : DStmt<Expr>; // Microsoft Extensions. def MSPropertyRefExpr : DStmt<Expr>; def MSPropertySubscriptExpr : DStmt<Expr>; -def CXXUuidofExpr : DStmt<Expr>; +def CXXUuidofExpr : DStmt<Expr>; def SEHTryStmt : Stmt; def SEHExceptStmt : Stmt; def SEHFinallyStmt : Stmt; diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index ec5c59b239069..958b9106bc99a 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -1139,7 +1139,8 @@ public: bool isSEHTrySupported() const { return getTriple().isOSWindows() && (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64); + getTriple().getArch() == llvm::Triple::x86_64 || + getTriple().getArch() == llvm::Triple::aarch64); } /// Return true if {|} are normal characters in the asm string. diff --git a/include/clang/Basic/TemplateKinds.h b/include/clang/Basic/TemplateKinds.h index 3b68cba73655b..a0bc362e7a443 100644 --- a/include/clang/Basic/TemplateKinds.h +++ b/include/clang/Basic/TemplateKinds.h @@ -31,7 +31,7 @@ enum TemplateNameKind { /// The name refers to a variable template whose specialization produces a /// variable. TNK_Var_template, - /// The name refers to a dependent template name: + /// The name refers to a dependent template name: /// \code /// template<typename MetaFun, typename T1, typename T2> struct apply2 { /// typedef typename MetaFun::template apply<T1, T2>::type type; @@ -39,7 +39,7 @@ enum TemplateNameKind { /// \endcode /// /// Here, "apply" is a dependent template name within the typename - /// specifier in the typedef. "apply" is a nested template, and + /// specifier in the typedef. "apply" is a nested template, and /// whether the template name is assumed to refer to a type template or a /// function template depends on the context in which the template /// name occurs. diff --git a/include/clang/Basic/arm_neon.td b/include/clang/Basic/arm_neon.td index d405aac106504..c35336166c39f 100644 --- a/include/clang/Basic/arm_neon.td +++ b/include/clang/Basic/arm_neon.td @@ -772,9 +772,9 @@ def RSHRN_HIGH_N : IOpInst<"vrshrn_high_n", "hmdi", "HsHiHlHUsHUiHUl", OP_NARROW_HI>; def QRSHRUN_HIGH_N : SOpInst<"vqrshrun_high_n", "hmdi", "HsHiHl", OP_NARROW_HI>; -def QSHRN_HIGH_N : SOpInst<"vqshrn_high_n", "hmdi", +def QSHRN_HIGH_N : SOpInst<"vqshrn_high_n", "hmdi", "HsHiHlHUsHUiHUl", OP_NARROW_HI>; -def QRSHRN_HIGH_N : SOpInst<"vqrshrn_high_n", "hmdi", +def QRSHRN_HIGH_N : SOpInst<"vqrshrn_high_n", "hmdi", "HsHiHlHUsHUiHUl", OP_NARROW_HI>; } @@ -927,7 +927,7 @@ def VMINV : SInst<"vminv", "sd", "csifUcUsUiQcQsQiQUcQUsQUiQfQd">; def VADDV : SInst<"vaddv", "sd", "csifUcUsUiQcQsQiQUcQUsQUiQfQdQlQUl">; def FMAXNMV : SInst<"vmaxnmv", "sd", "fQfQd">; def FMINNMV : SInst<"vminnmv", "sd", "fQfQd">; - + //////////////////////////////////////////////////////////////////////////////// // Newly added Vector Extract for f64 def VEXT_A64 : WInst<"vext", "dddi", "dQdPlQPl">; diff --git a/include/clang/Basic/arm_neon_incl.td b/include/clang/Basic/arm_neon_incl.td index 46708a52aa3a6..5f3aa6fc02213 100644 --- a/include/clang/Basic/arm_neon_incl.td +++ b/include/clang/Basic/arm_neon_incl.td @@ -9,7 +9,7 @@ // // This file defines data structures shared by arm_neon.td and arm_fp16.td. // It constains base operation classes, operations, instructions, instruction -// modifiers, etc. +// modifiers, etc. // //===----------------------------------------------------------------------===// // diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 7cb9724a57e19..672231e70fad8 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -87,16 +87,16 @@ def analyzer_viz_egraph_ubigraph : Flag<["-"], "analyzer-viz-egraph-ubigraph">, def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">, HelpText<"Bound on stack depth while inlining (4 by default)">; -def analyzer_inline_max_stack_depth_EQ : Joined<["-"], "analyzer-inline-max-stack-depth=">, +def analyzer_inline_max_stack_depth_EQ : Joined<["-"], "analyzer-inline-max-stack-depth=">, Alias<analyzer_inline_max_stack_depth>; - + def analyzer_inlining_mode : Separate<["-"], "analyzer-inlining-mode">, HelpText<"Specify the function selection heuristic used during inlining">; def analyzer_inlining_mode_EQ : Joined<["-"], "analyzer-inlining-mode=">, Alias<analyzer_inlining_mode>; def analyzer_disable_retry_exhausted : Flag<["-"], "analyzer-disable-retry-exhausted">, HelpText<"Do not re-analyze paths leading to exhausted nodes with a different strategy (may decrease code coverage)">; - + def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">, HelpText<"The maximum number of times the analyzer will go through a loop">; def analyzer_stats : Flag<["-"], "analyzer-stats">, @@ -815,7 +815,7 @@ def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">, HelpText<"Generate code only for an OpenMP target device.">; def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, HelpText<"Path to the IR file produced by the frontend for the host.">; - + } // let Flags = [CC1Option] diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index 017248c3690f1..b7b8022211802 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -256,7 +256,7 @@ private: llvm::opt::DerivedArgList * TranslateInputArgs(const llvm::opt::InputArgList &Args) const; - // getFinalPhase - Determine which compilation mode we are in and record + // getFinalPhase - Determine which compilation mode we are in and record // which option we used to determine the final phase. phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, llvm::opt::Arg **FinalPhaseArg = nullptr) const; @@ -365,12 +365,12 @@ public: llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args, bool &ContainsError); - /// BuildInputs - Construct the list of inputs and their types from + /// BuildInputs - Construct the list of inputs and their types from /// the given arguments. /// /// \param TC - The default host tool chain. /// \param Args - The input arguments. - /// \param Inputs - The list to store the resulting compilation + /// \param Inputs - The list to store the resulting compilation /// inputs onto. void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args, InputList &Inputs) const; @@ -493,7 +493,7 @@ public: /// \param JA - The action of interest. /// \param BaseInput - The original input file that this action was /// triggered by. - /// \param BoundArch - The bound architecture. + /// \param BoundArch - The bound architecture. /// \param AtTopLevel - Whether this is a "top-level" action. /// \param MultipleArchs - Whether multiple -arch options were supplied. /// \param NormalizedTriple - The normalized triple of the relevant target. @@ -502,7 +502,7 @@ public: bool AtTopLevel, bool MultipleArchs, StringRef NormalizedTriple) const; - /// GetTemporaryPath - Return the pathname of a temporary file to use + /// GetTemporaryPath - Return the pathname of a temporary file to use /// as part of compilation; the file will have the given prefix and suffix. /// /// GCC goes to extra lengths here to be a bit more robust. diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index addf7aa6a9c8d..2f9c2c190e32d 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -413,6 +413,11 @@ public: return llvm::DebuggerKind::GDB; } + /// Does this toolchain supports given debug info option or not. + virtual bool supportsDebugInfoOption(const llvm::opt::Arg *) const { + return true; + } + /// GetExceptionModel - Return the tool chain exception model. virtual llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const; diff --git a/include/clang/Edit/Commit.h b/include/clang/Edit/Commit.h index a574b8ef4cd24..d6eb6cd84f93d 100644 --- a/include/clang/Edit/Commit.h +++ b/include/clang/Edit/Commit.h @@ -57,7 +57,7 @@ private: bool IsCommitable = true; SmallVector<Edit, 8> CachedEdits; - + llvm::BumpPtrAllocator StrAlloc; public: diff --git a/include/clang/Edit/EditedSource.h b/include/clang/Edit/EditedSource.h index 3d33688f5f737..52873c3c3841c 100644 --- a/include/clang/Edit/EditedSource.h +++ b/include/clang/Edit/EditedSource.h @@ -85,7 +85,7 @@ public: bool canInsertInOffset(SourceLocation OrigLoc, FileOffset Offs); bool commit(const Commit &commit); - + void applyRewrites(EditsReceiver &receiver, bool adjustRemovals = true); void clearRewrites(); diff --git a/include/clang/Edit/Rewriters.h b/include/clang/Edit/Rewriters.h index 980ed1d3363f1..8338d71b3e525 100644 --- a/include/clang/Edit/Rewriters.h +++ b/include/clang/Edit/Rewriters.h @@ -29,7 +29,7 @@ bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, bool rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit, const ParentMap *PMap); - + bool rewriteToObjCSubscriptSyntax(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit); diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 9f529ba0e0e85..ba145965462f2 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -159,7 +159,7 @@ private: /// Whether the ASTUnit should delete the remapped buffers. bool OwnsRemappedFileBuffers = true; - + /// Track the top-level decls which appeared in an ASTUnit which was loaded /// from a source file. // @@ -176,7 +176,7 @@ private: /// Map from FileID to the file-level declarations that it contains. /// The files and decls are only local (and non-preamble) ones. FileDeclsTy FileDecls; - + /// The name of the original source file used to generate this ASTUnit. std::string OriginalSourceFile; @@ -197,7 +197,7 @@ private: /// Diagnostics that come from the driver are retained from one parse to /// the next. unsigned NumStoredDiagnosticsFromDriver = 0; - + /// Counter that determines when we want to try building a /// precompiled preamble. /// @@ -236,7 +236,7 @@ private: /// A list of the serialization ID numbers for each of the top-level /// declarations parsed within the precompiled preamble. std::vector<serialization::DeclID> TopLevelDeclsInPreamble; - + /// Whether we should be caching code-completion results. bool ShouldCacheCodeCompletionResults : 1; @@ -247,7 +247,7 @@ private: /// True if non-system source files should be treated as volatile /// (likely to change while trying to use them). bool UserFilesAreVolatile : 1; - + static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags, ASTUnit &AST, bool CaptureDiagnostics); @@ -265,7 +265,7 @@ public: /// The code-completion string corresponding to this completion /// result. CodeCompletionString *Completion; - + /// A bitmask that indicates which code-completion contexts should /// contain this completion result. /// @@ -274,20 +274,20 @@ public: /// bit, shift 1 by that number of bits. Many completions can occur in /// several different contexts. uint64_t ShowInContexts; - + /// The priority given to this code-completion result. unsigned Priority; - - /// The libclang cursor kind corresponding to this code-completion + + /// The libclang cursor kind corresponding to this code-completion /// result. CXCursorKind Kind; - + /// The availability of this code-completion result. CXAvailabilityKind Availability; - + /// The simplified type class for a non-macro completion result. SimplifiedTypeClass TypeClass; - + /// The type of a non-macro completion result, stored as a unique /// integer used by the string map of cached completion types. /// @@ -296,13 +296,13 @@ public: /// for more information. unsigned Type; }; - + /// Retrieve the mapping from formatted type names to unique type /// identifiers. llvm::StringMap<unsigned> &getCachedCompletionTypes() { - return CachedCompletionTypes; + return CachedCompletionTypes; } - + /// Retrieve the allocator used to cache global code completions. std::shared_ptr<GlobalCodeCompletionAllocator> getCachedCompletionAllocator() { @@ -324,29 +324,29 @@ private: /// The set of cached code-completion results. std::vector<CachedCodeCompletionResult> CachedCompletionResults; - + /// A mapping from the formatted type name to a unique number for that /// type, which is used for type equality comparisons. llvm::StringMap<unsigned> CachedCompletionTypes; - - /// A string hash of the top-level declaration and macro definition + + /// A string hash of the top-level declaration and macro definition /// names processed the last time that we reparsed the file. /// - /// This hash value is used to determine when we need to refresh the + /// This hash value is used to determine when we need to refresh the /// global code-completion cache. unsigned CompletionCacheTopLevelHashValue = 0; - /// A string hash of the top-level declaration and macro definition + /// A string hash of the top-level declaration and macro definition /// names processed the last time that we reparsed the precompiled preamble. /// - /// This hash value is used to determine when we need to refresh the + /// This hash value is used to determine when we need to refresh the /// global code-completion cache after a rebuild of the precompiled preamble. unsigned PreambleTopLevelHashValue = 0; /// The current hash value for the top-level declaration and macro /// definition names unsigned CurrentTopLevelHashValue = 0; - + /// Bit used by CIndex to mark when a translation unit may be in an /// inconsistent state, and is not safe to free. unsigned UnsafeToFree : 1; @@ -357,10 +357,10 @@ private: /// Cache any "global" code-completion results, so that we can avoid /// recomputing them with each completion. void CacheCodeCompletionResults(); - - /// Clear out and deallocate + + /// Clear out and deallocate void ClearCachedCompletionResults(); - + explicit ASTUnit(bool MainFileIsAST); bool Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps, @@ -402,9 +402,9 @@ public: class ConcurrencyCheck { ASTUnit &Self; - + public: - explicit ConcurrencyCheck(ASTUnit &Self) : Self(Self) { + explicit ConcurrencyCheck(ASTUnit &Self) : Self(Self) { Self.ConcurrencyCheckValue.start(); } @@ -424,7 +424,7 @@ public: const DiagnosticsEngine &getDiagnostics() const { return *Diagnostics; } DiagnosticsEngine &getDiagnostics() { return *Diagnostics; } - + const SourceManager &getSourceManager() const { return *SourceMgr; } SourceManager &getSourceManager() { return *SourceMgr; } @@ -449,7 +449,7 @@ public: bool hasSema() const { return (bool)TheSema; } - Sema &getSema() const { + Sema &getSema() const { assert(TheSema && "ASTUnit does not have a Sema object!"); return *TheSema; } @@ -463,12 +463,12 @@ public: assert(HSOpts && "ASTUnit does not have header search options"); return *HSOpts; } - + const PreprocessorOptions &getPreprocessorOpts() const { assert(PPOpts && "ASTUnit does not have preprocessor options"); return *PPOpts; } - + const FileManager &getFileManager() const { return *FileMgr; } FileManager &getFileManager() { return *FileMgr; } @@ -529,7 +529,7 @@ public: /// Get the decls that are contained in a file in the Offset/Length /// range. \p Length can be 0 to indicate a point at \p Offset instead of - /// a range. + /// a range. void findFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl<Decl *> &Decls); @@ -575,25 +575,25 @@ public: return SourceRange(mapLocationToPreamble(R.getBegin()), mapLocationToPreamble(R.getEnd())); } - + // Retrieve the diagnostics associated with this AST using stored_diag_iterator = StoredDiagnostic *; using stored_diag_const_iterator = const StoredDiagnostic *; - stored_diag_const_iterator stored_diag_begin() const { - return StoredDiagnostics.begin(); + stored_diag_const_iterator stored_diag_begin() const { + return StoredDiagnostics.begin(); } - stored_diag_iterator stored_diag_begin() { - return StoredDiagnostics.begin(); + stored_diag_iterator stored_diag_begin() { + return StoredDiagnostics.begin(); } - stored_diag_const_iterator stored_diag_end() const { - return StoredDiagnostics.end(); + stored_diag_const_iterator stored_diag_end() const { + return StoredDiagnostics.end(); } - stored_diag_iterator stored_diag_end() { - return StoredDiagnostics.end(); + stored_diag_iterator stored_diag_end() { + return StoredDiagnostics.end(); } unsigned stored_diag_size() const { return StoredDiagnostics.size(); } @@ -601,12 +601,12 @@ public: stored_diag_iterator stored_diag_afterDriver_begin() { if (NumStoredDiagnosticsFromDriver > StoredDiagnostics.size()) NumStoredDiagnosticsFromDriver = 0; - return StoredDiagnostics.begin() + NumStoredDiagnosticsFromDriver; + return StoredDiagnostics.begin() + NumStoredDiagnosticsFromDriver; } using cached_completion_iterator = std::vector<CachedCodeCompletionResult>::iterator; - + cached_completion_iterator cached_completion_begin() { return CachedCompletionResults.begin(); } @@ -615,8 +615,8 @@ public: return CachedCompletionResults.end(); } - unsigned cached_completion_size() const { - return CachedCompletionResults.size(); + unsigned cached_completion_size() const { + return CachedCompletionResults.size(); } /// Returns an iterator range for the local preprocessing entities @@ -712,7 +712,7 @@ private: public: /// Create an ASTUnit from a source file, via a CompilerInvocation - /// object, by invoking the optionally provided ASTFrontendAction. + /// object, by invoking the optionally provided ASTFrontendAction. /// /// \param CI - The compiler invocation to use; it must have exactly one input /// source file. The ASTUnit takes ownership of the CompilerInvocation object. @@ -854,10 +854,10 @@ public: /// /// \param Column The column at which code completion will occur. /// - /// \param IncludeMacros Whether to include macros in the code-completion + /// \param IncludeMacros Whether to include macros in the code-completion /// results. /// - /// \param IncludeCodePatterns Whether to include code patterns (such as a + /// \param IncludeCodePatterns Whether to include code patterns (such as a /// for loop) in the code-completion results. /// /// \param IncludeBriefComments Whether to include brief documentation within diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 977d1b2ed65f5..818c733982d97 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -144,9 +144,9 @@ class CompilerInstance : public ModuleLoader { bool DeleteBuiltModules = true; /// The location of the module-import keyword for the last module - /// import. + /// import. SourceLocation LastModuleImportLoc; - + /// The result of the last module import. /// ModuleLoadResult LastModuleImportResult; @@ -246,7 +246,7 @@ public: /// Indicates whether we should (re)build the global module index. bool shouldBuildGlobalModuleIndex() const; - + /// Set the flag indicating whether we should (re)build the global /// module index. void setBuildGlobalModuleIndex(bool Build) { @@ -350,7 +350,7 @@ public: void setDiagnostics(DiagnosticsEngine *Value); DiagnosticConsumer &getDiagnosticClient() const { - assert(Diagnostics && Diagnostics->getClient() && + assert(Diagnostics && Diagnostics->getClient() && "Compiler instance has no diagnostic client!"); return *Diagnostics->getClient(); } @@ -409,7 +409,7 @@ public: assert(FileMgr && "Compiler instance has no file manager!"); return *FileMgr; } - + void resetAndLeakFileManager() { BuryPointer(FileMgr.get()); FileMgr.resetWithoutRelease(); @@ -429,7 +429,7 @@ public: assert(SourceMgr && "Compiler instance has no source manager!"); return *SourceMgr; } - + void resetAndLeakSourceManager() { BuryPointer(SourceMgr.get()); SourceMgr.resetWithoutRelease(); @@ -469,7 +469,7 @@ public: assert(Context && "Compiler instance has no AST context!"); return *Context; } - + void resetAndLeakASTContext() { BuryPointer(Context.get()); Context.resetWithoutRelease(); @@ -481,7 +481,7 @@ public: /// Replace the current Sema; the compiler instance takes ownership /// of S. void setSema(Sema *S); - + /// } /// @name ASTConsumer /// { @@ -506,7 +506,7 @@ public: /// { bool hasSema() const { return (bool)TheSema; } - Sema &getSema() const { + Sema &getSema() const { assert(TheSema && "Compiler instance has no Sema object!"); return *TheSema; } @@ -613,7 +613,7 @@ public: /// attached to (and, then, owned by) the DiagnosticsEngine inside this AST /// unit. /// - /// \param ShouldOwnClient If Client is non-NULL, specifies whether + /// \param ShouldOwnClient If Client is non-NULL, specifies whether /// the diagnostic object should take ownership of the client. void createDiagnostics(DiagnosticConsumer *Client = nullptr, bool ShouldOwnClient = true); @@ -693,7 +693,7 @@ public: /// Create the Sema object to be used for parsing. void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer); - + /// Create the frontend timer and replace any existing one with it. void createFrontendTimer(); diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h index 3d302051d2988..1d421f09fdcc6 100644 --- a/include/clang/Frontend/CompilerInvocation.h +++ b/include/clang/Frontend/CompilerInvocation.h @@ -106,7 +106,7 @@ public: return *PreprocessorOpts; } }; - + /// Helper class for holding the data necessary to invoke the compiler. /// /// This class is designed to represent an abstract "invocation" of the @@ -117,7 +117,7 @@ class CompilerInvocation : public CompilerInvocationBase { AnalyzerOptionsRef AnalyzerOpts; MigratorOptions MigratorOpts; - + /// Options controlling IRgen and the backend. CodeGenOptions CodeGenOpts; @@ -172,11 +172,11 @@ public: static void setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T, PreprocessorOptions &PPOpts, LangStandard::Kind LangStd = LangStandard::lang_unspecified); - - /// Retrieve a module hash string that is suitable for uniquely + + /// Retrieve a module hash string that is suitable for uniquely /// identifying the conditions under which the module was built. std::string getModuleHash() const; - + /// @} /// @name Option Subgroups /// @{ @@ -185,7 +185,7 @@ public: MigratorOptions &getMigratorOpts() { return MigratorOpts; } const MigratorOptions &getMigratorOpts() const { return MigratorOpts; } - + CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; } const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } diff --git a/include/clang/Frontend/DiagnosticRenderer.h b/include/clang/Frontend/DiagnosticRenderer.h index 191d32accf2ff..3bbf37946d0b3 100644 --- a/include/clang/Frontend/DiagnosticRenderer.h +++ b/include/clang/Frontend/DiagnosticRenderer.h @@ -32,7 +32,7 @@ class SourceManager; using DiagOrStoredDiag = llvm::PointerUnion<const Diagnostic *, const StoredDiagnostic *>; - + /// Class to encapsulate the logic for formatting a diagnostic message. /// /// Actual "printing" logic is implemented by subclasses. @@ -49,20 +49,20 @@ class DiagnosticRenderer { protected: const LangOptions &LangOpts; IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; - + /// The location of the previous diagnostic if known. /// /// This will be invalid in cases where there is no (known) previous /// diagnostic location, or that location itself is invalid or comes from /// a different source manager than SM. SourceLocation LastLoc; - + /// The location of the last include whose stack was printed if known. /// /// Same restriction as LastLoc essentially, but tracking include stack /// root locations rather than diagnostic locations. SourceLocation LastIncludeLoc; - + /// The level of the last diagnostic emitted. /// /// The level of the last diagnostic emitted. Used to detect level changes @@ -71,7 +71,7 @@ protected: DiagnosticRenderer(const LangOptions &LangOpts, DiagnosticOptions *DiagOpts); - + virtual ~DiagnosticRenderer(); virtual void emitDiagnosticMessage(FullSourceLoc Loc, PresumedLoc PLoc, @@ -137,7 +137,7 @@ public: void emitStoredDiagnostic(StoredDiagnostic &Diag); }; - + /// Subclass of DiagnosticRender that turns all subdiagostics into explicit /// notes. It is up to subclasses to further define the behavior. class DiagnosticNoteRenderer : public DiagnosticRenderer { diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h index 20f1b3e11bdb7..54539a5b3cee7 100644 --- a/include/clang/Frontend/FrontendActions.h +++ b/include/clang/Frontend/FrontendActions.h @@ -18,7 +18,7 @@ namespace clang { class Module; class FileEntry; - + //===----------------------------------------------------------------------===// // Custom Consumer Actions //===----------------------------------------------------------------------===// @@ -198,7 +198,7 @@ protected: class ASTMergeAction : public FrontendAction { /// The action that the merge action adapts. std::unique_ptr<FrontendAction> AdaptedAction; - + /// The set of AST files to merge. std::vector<std::string> ASTFiles; @@ -233,7 +233,7 @@ protected: bool usesPreprocessorOnly() const override { return true; } }; - + //===----------------------------------------------------------------------===// // Preprocessor Actions //===----------------------------------------------------------------------===// @@ -264,7 +264,7 @@ protected: bool hasPCHSupport() const override { return true; } }; - + } // end namespace clang #endif diff --git a/include/clang/Frontend/LayoutOverrideSource.h b/include/clang/Frontend/LayoutOverrideSource.h index 0b7f7dc7a7d67..28e3cf005b30f 100644 --- a/include/clang/Frontend/LayoutOverrideSource.h +++ b/include/clang/Frontend/LayoutOverrideSource.h @@ -27,24 +27,24 @@ namespace clang { struct Layout { /// The size of the record. uint64_t Size; - + /// The alignment of the record. uint64_t Align; - + /// The offsets of the fields, in source order. SmallVector<uint64_t, 8> FieldOffsets; }; - + /// The set of layouts that will be overridden. llvm::StringMap<Layout> Layouts; - + public: /// Create a new AST source that overrides the layout of some /// set of record types. /// /// The file is the result of passing -fdump-record-layouts to a file. explicit LayoutOverrideSource(StringRef Filename); - + /// If this particular record type has an overridden layout, /// return that layout. bool @@ -54,7 +54,7 @@ namespace clang { llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) override; - + /// Dump the overridden layouts. void dump(); }; diff --git a/include/clang/Frontend/LogDiagnosticPrinter.h b/include/clang/Frontend/LogDiagnosticPrinter.h index 98adf655fcf12..3286ecf2cdd32 100644 --- a/include/clang/Frontend/LogDiagnosticPrinter.h +++ b/include/clang/Frontend/LogDiagnosticPrinter.h @@ -23,22 +23,22 @@ class LogDiagnosticPrinter : public DiagnosticConsumer { struct DiagEntry { /// The primary message line of the diagnostic. std::string Message; - + /// The source file name, if available. std::string Filename; - + /// The source file line number, if available. unsigned Line; - + /// The source file column number, if available. unsigned Column; - + /// The ID of the diagnostic. unsigned DiagnosticID; /// The Option Flag for the diagnostic std::string WarningOption; - + /// The level of the diagnostic. DiagnosticsEngine::Level DiagnosticLevel; }; diff --git a/include/clang/Frontend/PCHContainerOperations.h b/include/clang/Frontend/PCHContainerOperations.h index f9a73508d7003..7a12ebc862e7d 100644 --- a/include/clang/Frontend/PCHContainerOperations.h +++ b/include/clang/Frontend/PCHContainerOperations.h @@ -34,12 +34,12 @@ struct PCHBuffer { llvm::SmallVector<char, 0> Data; bool IsComplete; }; - + /// This abstract interface provides operations for creating /// containers for serialized ASTs (precompiled headers and clang /// modules). class PCHContainerWriter { -public: +public: virtual ~PCHContainerWriter() = 0; virtual StringRef getFormat() const = 0; @@ -58,7 +58,7 @@ public: /// containers for serialized ASTs (precompiled headers and clang /// modules). class PCHContainerReader { -public: +public: virtual ~PCHContainerReader() = 0; /// Equivalent to the format passed to -fmodule-format= virtual StringRef getFormat() const = 0; @@ -102,7 +102,7 @@ public: } void registerReader(std::unique_ptr<PCHContainerReader> Reader) { Readers[Reader->getFormat()] = std::move(Reader); - } + } const PCHContainerWriter *getWriterOrNull(StringRef Format) { return Writers[Format].get(); } diff --git a/include/clang/Frontend/VerifyDiagnosticConsumer.h b/include/clang/Frontend/VerifyDiagnosticConsumer.h index 9d985bc4955f8..f36970f1eb392 100644 --- a/include/clang/Frontend/VerifyDiagnosticConsumer.h +++ b/include/clang/Frontend/VerifyDiagnosticConsumer.h @@ -252,7 +252,7 @@ private: public: /// Create a new verifying diagnostic client, which will issue errors to - /// the currently-attached diagnostic client when a diagnostic does not match + /// the currently-attached diagnostic client when a diagnostic does not match /// what is expected (as indicated in the source file). VerifyDiagnosticConsumer(DiagnosticsEngine &Diags); ~VerifyDiagnosticConsumer() override; diff --git a/include/clang/Lex/CodeCompletionHandler.h b/include/clang/Lex/CodeCompletionHandler.h index be153cc1ad508..87089fd7d50b0 100644 --- a/include/clang/Lex/CodeCompletionHandler.h +++ b/include/clang/Lex/CodeCompletionHandler.h @@ -18,13 +18,13 @@ namespace clang { class IdentifierInfo; class MacroInfo; - -/// Callback handler that receives notifications when performing code + +/// Callback handler that receives notifications when performing code /// completion within the preprocessor. class CodeCompletionHandler { public: virtual ~CodeCompletionHandler(); - + /// Callback invoked when performing code completion for a preprocessor /// directive. /// @@ -34,23 +34,23 @@ public: /// \param InConditional Whether we're inside a preprocessor conditional /// already. virtual void CodeCompleteDirective(bool InConditional) { } - + /// Callback invoked when performing code completion within a block of /// code that was excluded due to preprocessor conditionals. virtual void CodeCompleteInConditionalExclusion() { } - + /// Callback invoked when performing code completion in a context /// where the name of a macro is expected. /// /// \param IsDefinition Whether this is the definition of a macro, e.g., /// in a \#define. virtual void CodeCompleteMacroName(bool IsDefinition) { } - + /// Callback invoked when performing code completion in a preprocessor /// expression, such as the condition of an \#if or \#elif directive. virtual void CodeCompletePreprocessorExpression() { } - - /// Callback invoked when performing code completion inside a + + /// Callback invoked when performing code completion inside a /// function-like macro argument. /// /// There will be another callback invocation after the macro arguments are @@ -61,11 +61,11 @@ public: unsigned ArgumentIndex) { } /// Callback invoked when performing code completion in a part of the - /// file where we expect natural language, e.g., a comment, string, or + /// file where we expect natural language, e.g., a comment, string, or /// \#error directive. virtual void CodeCompleteNaturalLanguage() { } }; - + } #endif // LLVM_CLANG_LEX_CODECOMPLETIONHANDLER_H diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h index 222ebf025ac04..55065b7d8547d 100644 --- a/include/clang/Lex/DirectoryLookup.h +++ b/include/clang/Lex/DirectoryLookup.h @@ -24,7 +24,7 @@ class DirectoryEntry; class FileEntry; class HeaderSearch; class Module; - + /// DirectoryLookup - This class represents one entry in the search list that /// specifies the search order for directories in \#include directives. It /// represents either a directory, a framework, or a headermap. @@ -54,14 +54,14 @@ private: /// LookupType - This indicates whether this DirectoryLookup object is a /// normal directory, a framework, or a headermap. unsigned LookupType : 2; - + /// Whether this is a header map used when building a framework. unsigned IsIndexHeaderMap : 1; /// Whether we've performed an exhaustive search for module maps /// within the subdirectories of this directory. unsigned SearchedAllModuleMaps : 1; - + public: /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of /// 'dir'. @@ -140,10 +140,10 @@ public: } /// Whether this header map is building a framework or not. - bool isIndexHeaderMap() const { - return isHeaderMap() && IsIndexHeaderMap; + bool isIndexHeaderMap() const { + return isHeaderMap() && IsIndexHeaderMap; } - + /// LookupFile - Lookup the specified file in this search path, returning it /// if it exists or returning null if not. /// diff --git a/include/clang/Lex/ExternalPreprocessorSource.h b/include/clang/Lex/ExternalPreprocessorSource.h index f34be682617cd..d849bbd76188c 100644 --- a/include/clang/Lex/ExternalPreprocessorSource.h +++ b/include/clang/Lex/ExternalPreprocessorSource.h @@ -19,18 +19,18 @@ namespace clang { class IdentifierInfo; class Module; -/// Abstract interface for external sources of preprocessor +/// Abstract interface for external sources of preprocessor /// information. /// -/// This abstract class allows an external sources (such as the \c ASTReader) +/// This abstract class allows an external sources (such as the \c ASTReader) /// to provide additional preprocessing information. class ExternalPreprocessorSource { public: virtual ~ExternalPreprocessorSource(); - + /// Read the set of macros defined by this external macro source. virtual void ReadDefinedMacros() = 0; - + /// Update an out-of-date identifier. virtual void updateOutOfDateIdentifier(IdentifierInfo &II) = 0; @@ -42,7 +42,7 @@ public: /// Map a module ID to a module. virtual Module *getModule(unsigned ModuleID) = 0; }; - + } #endif diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index b7147c54faacd..6bb0f58f2db9d 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -74,9 +74,9 @@ struct HeaderFileInfo { /// Whether this structure is considered to already have been /// "resolved", meaning that it was loaded from the external source. unsigned Resolved : 1; - + /// Whether this is a header inside a framework that is currently - /// being built. + /// being built. /// /// When a framework is being built, the headers have not yet been placed /// into the appropriate framework subdirectories, and therefore are @@ -86,7 +86,7 @@ struct HeaderFileInfo { /// Whether this file has been looked up as a header. unsigned IsValid : 1; - + /// The number of times the file has been included already. unsigned short NumIncludes = 0; @@ -110,9 +110,9 @@ struct HeaderFileInfo { /// If this header came from a framework include, this is the name /// of the framework. StringRef Framework; - + HeaderFileInfo() - : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), + : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), External(false), isModuleHeader(false), isCompilingModuleHeader(false), Resolved(false), IndexHeaderMapHeader(false), IsValid(false) {} @@ -124,7 +124,7 @@ struct HeaderFileInfo { /// Determine whether this is a non-default header file info, e.g., /// it corresponds to an actual header we've included or tried to include. bool isNonDefault() const { - return isImport || isPragmaOnce || NumIncludes || ControllingMacro || + return isImport || isPragmaOnce || NumIncludes || ControllingMacro || ControllingMacroID; } }; @@ -134,15 +134,15 @@ struct HeaderFileInfo { class ExternalHeaderFileInfoSource { public: virtual ~ExternalHeaderFileInfoSource(); - + /// Retrieve the header file information for the given file entry. /// /// \returns Header file information for the given file entry, with the - /// \c External bit set. If the file entry is not known, return a + /// \c External bit set. If the file entry is not known, return a /// default-constructed \c HeaderFileInfo. virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0; }; - + /// Encapsulates the information needed to find the file referenced /// by a \#include or \#include_next, (sub-)framework lookup, etc. class HeaderSearch { @@ -186,7 +186,7 @@ class HeaderSearch { /// The path to the module cache. std::string ModuleCachePath; - + /// All of the preprocessor-specific data about files that are /// included, indexed by the FileEntry's UID. mutable std::vector<HeaderFileInfo> FileInfo; @@ -232,7 +232,7 @@ class HeaderSearch { /// The mapping between modules and headers. mutable ModuleMap ModMap; - + /// Describes whether a given directory has a module map in it. llvm::DenseMap<const DirectoryEntry *, bool> DirectoryHasModuleMap; @@ -240,10 +240,10 @@ class HeaderSearch { /// whether they were valid or not. llvm::DenseMap<const FileEntry *, bool> LoadedModuleMaps; - /// Uniqued set of framework names, which is used to track which + /// Uniqued set of framework names, which is used to track which /// headers were included as framework headers. llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames; - + /// Entity used to resolve the identifier IDs of controlling /// macros into IdentifierInfo pointers, and keep the identifire up to date, /// as needed. @@ -251,7 +251,7 @@ class HeaderSearch { /// Entity used to look up stored header file information. ExternalHeaderFileInfoSource *ExternalSource = nullptr; - + // Various statistics we track for performance analysis. unsigned NumIncluded = 0; unsigned NumMultiIncludeFileOptzn = 0; @@ -269,7 +269,7 @@ public: /// Retrieve the header-search options with which this header search /// was initialized. HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; } - + FileManager &getFileMgr() const { return FileMgr; } DiagnosticsEngine &getDiags() const { return Diags; } @@ -306,7 +306,7 @@ public: /// Map the source include name to the dest include name. /// - /// The Source should include the angle brackets or quotes, the dest + /// The Source should include the angle brackets or quotes, the dest /// should not. This allows for distinction between <> and "" headers. void AddIncludeAlias(StringRef Source, StringRef Dest) { if (!IncludeAliases) @@ -332,7 +332,7 @@ public: void setModuleCachePath(StringRef CachePath) { ModuleCachePath = CachePath; } - + /// Retrieve the path to the module cache. StringRef getModuleCachePath() const { return ModuleCachePath; } @@ -340,7 +340,7 @@ public: void setDirectoryHasModuleMap(const DirectoryEntry* Dir) { DirectoryHasModuleMap[Dir] = true; } - + /// Forget everything we know about headers so far. void ClearFileInfo() { FileInfo.clear(); @@ -353,16 +353,16 @@ public: ExternalPreprocessorSource *getExternalLookup() const { return ExternalLookup; } - + /// Set the external source of header information. void SetExternalSource(ExternalHeaderFileInfoSource *ES) { ExternalSource = ES; } - + /// Set the target information for the header search, if not /// already known. void setTarget(const TargetInfo &Target); - + /// Given a "foo" or \<foo> reference, look up the indicated file, /// return null on failure. /// @@ -540,7 +540,7 @@ public: /// \c nullptr if none is found. const FileEntry *lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework); - + void IncrementFrameworkLookupCount() { ++NumFrameworkLookups; } /// Determine whether there is a module map that may map the header @@ -556,7 +556,7 @@ public: /// header directories. bool hasModuleMap(StringRef Filename, const DirectoryEntry *Root, bool IsSystem); - + /// Retrieve the module that corresponds to the given file, if any. /// /// \param File The header that we wish to map to a module. @@ -617,7 +617,7 @@ private: /// frameworks. /// /// \returns The module, if found; otherwise, null. - Module *loadFrameworkModule(StringRef Name, + Module *loadFrameworkModule(StringRef Name, const DirectoryEntry *Dir, bool IsSystem); @@ -655,10 +655,10 @@ private: public: /// Retrieve the module map. ModuleMap &getModuleMap() { return ModMap; } - + /// Retrieve the module map. const ModuleMap &getModuleMap() const { return ModMap; } - + unsigned header_file_size() const { return FileInfo.size(); } /// Return the HeaderFileInfo structure for the specified FileEntry, @@ -722,7 +722,7 @@ public: bool *IsSystem = nullptr); void PrintStats(); - + size_t getTotalMemory() const; private: diff --git a/include/clang/Lex/HeaderSearchOptions.h b/include/clang/Lex/HeaderSearchOptions.h index 298179e91a6fd..e5b52b30323fa 100644 --- a/include/clang/Lex/HeaderSearchOptions.h +++ b/include/clang/Lex/HeaderSearchOptions.h @@ -14,7 +14,7 @@ #include "llvm/ADT/CachedHashString.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" -#include <cstdint> +#include <cstdint> #include <string> #include <vector> #include <map> @@ -36,7 +36,7 @@ enum IncludeDirGroup { Angled, /// Like Angled, but marks header maps used when building frameworks. - IndexHeaderMap, + IndexHeaderMap, /// Like Angled, but marks system directories. System, @@ -70,7 +70,7 @@ public: std::string Path; frontend::IncludeDirGroup Group; unsigned IsFramework : 1; - + /// IgnoreSysRoot - This is false if an absolute path should be treated /// relative to the sysroot, or true if it should always be the absolute /// path. diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h index 1b6bf6bcffb0e..3843a5afd2b0e 100644 --- a/include/clang/Lex/LiteralSupport.h +++ b/include/clang/Lex/LiteralSupport.h @@ -208,7 +208,7 @@ class StringLiteralParser { const LangOptions &Features; const TargetInfo &Target; DiagnosticsEngine *Diags; - + unsigned MaxTokenLength; unsigned SizeBound; unsigned CharByteWidth; @@ -230,7 +230,7 @@ public: ResultPtr(ResultBuf.data()), hadError(false), Pascal(false) { init(StringToks); } - + bool hadError; bool Pascal; diff --git a/include/clang/Lex/MacroArgs.h b/include/clang/Lex/MacroArgs.h index a202550da3b3c..853eee2fd7792 100644 --- a/include/clang/Lex/MacroArgs.h +++ b/include/clang/Lex/MacroArgs.h @@ -27,7 +27,7 @@ namespace clang { /// MacroArgs - An instance of this class captures information about /// the formal arguments specified to a function-like macro invocation. -class MacroArgs final +class MacroArgs final : private llvm::TrailingObjects<MacroArgs, Token> { friend TrailingObjects; @@ -43,7 +43,7 @@ class MacroArgs final /// if in strict mode and the C99 varargs macro had only a ... argument, this /// is false. bool VarargsElided; - + /// PreExpArgTokens - Pre-expanded tokens for arguments that need them. Empty /// if not yet computed. This includes the EOF marker at the end of the /// stream. @@ -115,7 +115,7 @@ public: /// Returns true if the macro was defined with a variadic (ellipsis) parameter /// AND was invoked with at least one token supplied as a variadic argument. /// - /// \code + /// \code /// #define F(a) a /// #define V(a, ...) __VA_OPT__(a) /// F() <-- returns false on this invocation. @@ -123,7 +123,7 @@ public: /// V(,) <-- returns false on this invocation. /// \endcode /// - + bool invokedWithVariadicArgument(const MacroInfo *const MI) const; /// StringifyArgument - Implement C99 6.10.3.2p2, converting a sequence of @@ -135,8 +135,8 @@ public: Preprocessor &PP, bool Charify, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd); - - + + /// deallocate - This should only be called by the Preprocessor when managing /// its freelist. MacroArgs *deallocate(); diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h index 13e5313a9c301..0cc1cb92e67e7 100644 --- a/include/clang/Lex/MacroInfo.h +++ b/include/clang/Lex/MacroInfo.h @@ -174,7 +174,7 @@ public: std::copy(List.begin(), List.end(), ParameterList); } - /// Parameters - The list of parameters for a function-like macro. This can + /// Parameters - The list of parameters for a function-like macro. This can /// be empty, for, e.g. "#define X()". using param_iterator = IdentifierInfo *const *; bool param_empty() const { return NumParameters == 0; } diff --git a/include/clang/Lex/ModuleLoader.h b/include/clang/Lex/ModuleLoader.h index a2766fa35984f..05396dd205970 100644 --- a/include/clang/Lex/ModuleLoader.h +++ b/include/clang/Lex/ModuleLoader.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines the ModuleLoader interface, which is responsible for +// This file defines the ModuleLoader interface, which is responsible for // loading named modules. // //===----------------------------------------------------------------------===// @@ -80,7 +80,7 @@ public: : BuildingModule(BuildingModule) {} virtual ~ModuleLoader(); - + /// Returns true if this instance is building a module. bool buildingModule() const { return BuildingModule; @@ -90,17 +90,17 @@ public: void setBuildingModule(bool BuildingModuleFlag) { BuildingModule = BuildingModuleFlag; } - + /// Attempt to load the given module. /// - /// This routine attempts to load the module described by the given + /// This routine attempts to load the module described by the given /// parameters. /// /// \param ImportLoc The location of the 'import' keyword. /// /// \param Path The identifiers (and their locations) of the module /// "path", e.g., "std.vector" would be split into "std" and "vector". - /// + /// /// \param Visibility The visibility provided for the names in the loaded /// module. /// @@ -108,7 +108,7 @@ public: /// implicitly, due to the presence of an inclusion directive. Otherwise, /// it is being loaded due to an import declaration. /// - /// \returns If successful, returns the loaded module. Otherwise, returns + /// \returns If successful, returns the loaded module. Otherwise, returns /// NULL to indicate that the module could not be loaded. virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, @@ -177,7 +177,7 @@ public: return false; } }; - + } // namespace clang #endif // LLVM_CLANG_LEX_MODULELOADER_H diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index 577f4008978ea..aa519891c1ce8 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -69,7 +69,7 @@ public: virtual void moduleMapAddUmbrellaHeader(FileManager *FileMgr, const FileEntry *Header) {} }; - + class ModuleMap { SourceManager &SourceMgr; DiagnosticsEngine &Diags; @@ -78,11 +78,11 @@ class ModuleMap { HeaderSearch &HeaderInfo; llvm::SmallVector<std::unique_ptr<ModuleMapCallbacks>, 1> Callbacks; - + /// The directory used for Clang-supplied, builtin include headers, /// such as "stdint.h". const DirectoryEntry *BuiltinIncludeDir = nullptr; - + /// Language options used to parse the module map itself. /// /// These are always simple C language options. @@ -285,7 +285,7 @@ private: /// /// \returns The resolved export declaration, which will have a NULL pointer /// if the export could not be resolved. - Module::ExportDecl + Module::ExportDecl resolveExport(Module *Mod, const Module::UnresolvedExportDecl &Unresolved, bool Complain) const; @@ -494,13 +494,13 @@ public: /// using direct (qualified) name lookup. /// /// \param Name The name of the module to look up. - /// + /// /// \param Context The module for which we will look for a submodule. If /// null, we will look for a top-level module. /// /// \returns The named submodule, if known; otherwose, returns null. Module *lookupModuleQualified(StringRef Name, Module *Context) const; - + /// Find a new module or submodule, or create it if it does not already /// exist. /// @@ -645,7 +645,7 @@ public: /// Marks this header as being excluded from the given module. void excludeHeader(Module *Mod, Module::Header Header); - /// Parse the given module map file, and record any modules we + /// Parse the given module map file, and record any modules we /// encounter. /// /// \param File The file to be parsed. @@ -672,13 +672,13 @@ public: /// Dump the contents of the module map, for debugging purposes. void dump(); - + using module_iterator = llvm::StringMap<Module *>::const_iterator; module_iterator module_begin() const { return Modules.begin(); } module_iterator module_end() const { return Modules.end(); } }; - + } // namespace clang #endif // LLVM_CLANG_LEX_MODULEMAP_H diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index eb85bda840afe..45c2d18da6e2b 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -66,10 +66,10 @@ public: /// Callback invoked whenever an inclusion directive results in a /// file-not-found error. /// - /// \param FileName The name of the file being included, as written in the + /// \param FileName The name of the file being included, as written in the /// source code. /// - /// \param RecoveryPath If this client indicates that it can recover from + /// \param RecoveryPath If this client indicates that it can recover from /// this missing file, the client should set this as an additional header /// search patch. /// @@ -84,13 +84,13 @@ public: /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless /// of whether the inclusion will actually result in an inclusion. /// - /// \param HashLoc The location of the '#' that starts the inclusion + /// \param HashLoc The location of the '#' that starts the inclusion /// directive. /// - /// \param IncludeTok The token that indicates the kind of inclusion + /// \param IncludeTok The token that indicates the kind of inclusion /// directive, e.g., 'include' or 'import'. /// - /// \param FileName The name of the file being included, as written in the + /// \param FileName The name of the file being included, as written in the /// source code. /// /// \param IsAngled Whether the file name was enclosed in angle brackets; @@ -99,7 +99,7 @@ public: /// \param FilenameRange The character range of the quotes or angle brackets /// for the written file name. /// - /// \param File The actual file that may be included by this inclusion + /// \param File The actual file that may be included by this inclusion /// directive. /// /// \param SearchPath Contains the search path which was used to find the file @@ -222,7 +222,7 @@ public: /// Called when an OpenCL extension is either disabled or /// enabled with a pragma. - virtual void PragmaOpenCLExtension(SourceLocation NameLoc, + virtual void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) { } @@ -269,13 +269,13 @@ public: const MacroDefinition &MD, const MacroDirective *Undef) { } - + /// Hook called whenever the 'defined' operator is seen. /// \param MD The MacroDirective if the name was a macro, null otherwise. virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) { } - + /// Hook called when a source range is skipped. /// \param Range The SourceRange that was skipped. The range begins at the /// \#if/\#else directive and ends after the \#endif/\#else directive. diff --git a/include/clang/Lex/PPConditionalDirectiveRecord.h b/include/clang/Lex/PPConditionalDirectiveRecord.h index a653b8339948d..a2ccf1407f79c 100644 --- a/include/clang/Lex/PPConditionalDirectiveRecord.h +++ b/include/clang/Lex/PPConditionalDirectiveRecord.h @@ -20,12 +20,12 @@ #include <vector> namespace clang { - + /// Records preprocessor conditional directive regions and allows /// querying in which region source locations belong to. class PPConditionalDirectiveRecord : public PPCallbacks { SourceManager &SourceMgr; - + SmallVector<SourceLocation, 6> CondDirectiveStack; class CondDirectiveLoc { diff --git a/include/clang/Lex/PTHLexer.h b/include/clang/Lex/PTHLexer.h index f122a008e4aa1..0b84df1434aec 100644 --- a/include/clang/Lex/PTHLexer.h +++ b/include/clang/Lex/PTHLexer.h @@ -49,7 +49,7 @@ class PTHLexer : public PreprocessorLexer { /// ReadToken - Used by PTHLexer to read tokens TokBuf. void ReadToken(Token &T); - + bool LexEndOfFile(Token &Result); /// PTHMgr - The PTHManager object that created this PTHLexer. diff --git a/include/clang/Lex/Pragma.h b/include/clang/Lex/Pragma.h index 9348388bc28cf..4d74face52756 100644 --- a/include/clang/Lex/Pragma.h +++ b/include/clang/Lex/Pragma.h @@ -34,19 +34,19 @@ class Token; * The pragma was introduced via \#pragma. */ PIK_HashPragma, - + /** * The pragma was introduced via the C99 _Pragma(string-literal). */ PIK__Pragma, - + /** - * The pragma was introduced via the Microsoft + * The pragma was introduced via the Microsoft * __pragma(token-string). */ PIK___pragma }; - + /// PragmaHandler - Instances of this interface defined to handle the various /// pragmas that the language front-end uses. Each handler optionally has a /// name (e.g. "pack") and the HandlePragma method is invoked when a pragma with diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h index 54e28a52f5b36..44d79d9b62290 100644 --- a/include/clang/Lex/PreprocessingRecord.h +++ b/include/clang/Lex/PreprocessingRecord.h @@ -66,13 +66,13 @@ class Token; /// A macro expansion. MacroExpansionKind, - + /// \defgroup Preprocessing directives /// @{ - + /// A macro definition. MacroDefinitionKind, - + /// An inclusion directive, such as \c \#include, \c /// \#import, or \c \#include_next. InclusionDirectiveKind, @@ -86,10 +86,10 @@ class Token; private: /// The kind of preprocessed entity that this object describes. EntityKind Kind; - + /// The source range that covers this preprocessed entity. SourceRange Range; - + protected: friend class PreprocessingRecord; @@ -99,8 +99,8 @@ class Token; public: /// Retrieve the kind of preprocessed entity stored in this object. EntityKind getKind() const { return Kind; } - - /// Retrieve the source range that covers this entire preprocessed + + /// Retrieve the source range that covers this entire preprocessed /// entity. SourceRange getSourceRange() const LLVM_READONLY { return Range; } @@ -108,7 +108,7 @@ class Token; /// entity. bool isInvalid() const { return Kind == InvalidKind; } - // Only allow allocation of preprocessed entities using the allocator + // Only allow allocation of preprocessed entities using the allocator // in PreprocessingRecord or by doing a placement new. void *operator new(size_t bytes, PreprocessingRecord &PR, unsigned alignment = 8) noexcept { @@ -130,15 +130,15 @@ class Token; void *operator new(size_t bytes) noexcept; void operator delete(void *data) noexcept; }; - + /// Records the presence of a preprocessor directive. class PreprocessingDirective : public PreprocessedEntity { public: - PreprocessingDirective(EntityKind Kind, SourceRange Range) + PreprocessingDirective(EntityKind Kind, SourceRange Range) : PreprocessedEntity(Kind, Range) {} - + // Implement isa/cast/dyncast/etc. - static bool classof(const PreprocessedEntity *PD) { + static bool classof(const PreprocessedEntity *PD) { return PD->getKind() >= FirstPreprocessingDirective && PD->getKind() <= LastPreprocessingDirective; } @@ -159,13 +159,13 @@ class Token; /// Retrieve the location of the macro name in the definition. SourceLocation getLocation() const { return getSourceRange().getBegin(); } - + // Implement isa/cast/dyncast/etc. static bool classof(const PreprocessedEntity *PE) { return PE->getKind() == MacroDefinitionKind; } }; - + /// Records the location of a macro expansion. class MacroExpansion : public PreprocessedEntity { /// The definition of this macro or the name of the macro if it is @@ -246,16 +246,16 @@ class Token; public: InclusionDirective(PreprocessingRecord &PPRec, - InclusionKind Kind, StringRef FileName, + InclusionKind Kind, StringRef FileName, bool InQuotes, bool ImportedModule, const FileEntry *File, SourceRange Range); - + /// Determine what kind of inclusion directive this is. InclusionKind getKind() const { return static_cast<InclusionKind>(Kind); } - + /// Retrieve the included file name as it was written in the source. StringRef getFileName() const { return FileName; } - + /// Determine whether the included file name was written in quotes; /// otherwise, it was written in angle brackets. bool wasInQuotes() const { return InQuotes; } @@ -263,23 +263,23 @@ class Token; /// Determine whether the inclusion directive was automatically /// turned into a module import. bool importedModule() const { return ImportedModule; } - + /// Retrieve the file entry for the actual file that was included /// by this directive. const FileEntry *getFile() const { return File; } - + // Implement isa/cast/dyncast/etc. static bool classof(const PreprocessedEntity *PE) { return PE->getKind() == InclusionDirectiveKind; } }; - + /// An abstract class that should be subclassed by any external source /// of preprocessing record entries. class ExternalPreprocessingRecordSource { public: virtual ~ExternalPreprocessingRecordSource(); - + /// Read a preallocated preprocessed entity from the external source. /// /// \returns null if an error occurred that prevented the preprocessed @@ -301,20 +301,20 @@ class Token; /// Read a preallocated skipped range from the external source. virtual SourceRange ReadSkippedRange(unsigned Index) = 0; }; - + /// A record of the steps taken while preprocessing a source file, - /// including the various preprocessing directives processed, macros + /// including the various preprocessing directives processed, macros /// expanded, etc. class PreprocessingRecord : public PPCallbacks { SourceManager &SourceMgr; - + /// Allocator used to store preprocessing objects. llvm::BumpPtrAllocator BumpAlloc; /// The set of preprocessed entities in this record, in order they /// were seen. std::vector<PreprocessedEntity *> PreprocessedEntities; - + /// The set of preprocessed entities in this record that have been /// loaded from external sources. /// @@ -362,7 +362,7 @@ class Token; /// Retrieve the loaded preprocessed entity at the given index. PreprocessedEntity *getLoadedPreprocessedEntity(unsigned Index); - + /// Determine the number of preprocessed entities that were /// loaded (or can be loaded) from an external source. unsigned getNumLoadedPreprocessedEntities() const { @@ -403,7 +403,7 @@ class Token; void *Allocate(unsigned Size, unsigned Align = 8) { return BumpAlloc.Allocate(Size, Align); } - + /// Deallocate memory in the preprocessing record. void Deallocate(void *Ptr) {} @@ -518,7 +518,7 @@ class Token; ensureSkippedRangesLoaded(); return SkippedRanges; } - + private: friend class ASTReader; friend class ASTWriter; diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 4ec29fe8f331c..e718f5b6bbd00 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -255,7 +255,7 @@ class Preprocessor { /// with this preprocessor. std::vector<CommentHandler *> CommentHandlers; - /// True if we want to ignore EOF token and continue later on (thus + /// True if we want to ignore EOF token and continue later on (thus /// avoid tearing the Lexer and etc. down). bool IncrementalProcessing = false; @@ -281,7 +281,7 @@ class Preprocessor { /// for preprocessing. SourceLocation CodeCompletionFileLoc; - /// The source location of the \c import contextual keyword we just + /// The source location of the \c import contextual keyword we just /// lexed, if any. SourceLocation ModuleImportLoc; @@ -294,7 +294,7 @@ class Preprocessor { /// Whether the module import expects an identifier next. Otherwise, /// it expects a '.' or ';'. bool ModuleImportExpectsIdentifier = false; - + /// The source location of the currently-active /// \#pragma clang arc_cf_code_audited begin. SourceLocation PragmaARCCFCodeAuditedLoc; @@ -814,7 +814,7 @@ public: /// Retrieve the preprocessor options used to initialize this /// preprocessor. PreprocessorOptions &getPreprocessorOpts() const { return *PPOpts; } - + DiagnosticsEngine &getDiagnostics() const { return *Diags; } void setDiagnostics(DiagnosticsEngine &D) { Diags = &D; } @@ -852,7 +852,7 @@ public: } /// True if we are currently preprocessing a #if or #elif directive - bool isParsingIfOrElifDirective() const { + bool isParsingIfOrElifDirective() const { return ParsingIfOrElifDirective; } @@ -1439,7 +1439,7 @@ public: void enableIncrementalProcessing(bool value = true) { IncrementalProcessing = value; } - + /// Specify the point at which code-completion will be performed. /// /// \param File the file in which code completion should occur. If @@ -1630,7 +1630,7 @@ public: } /// Plop the specified string into a scratch buffer and set the - /// specified token's location and length to it. + /// specified token's location and length to it. /// /// If specified, the source location provides a location of the expansion /// point of the token. @@ -1769,7 +1769,7 @@ public: void PoisonSEHIdentifiers(bool Poison = true); // Borland /// Callback invoked when the lexer reads an identifier and has - /// filled in the tokens IdentifierInfo member. + /// filled in the tokens IdentifierInfo member. /// /// This callback potentially macro expands it or turns it into a named /// token (like 'for'). @@ -1817,12 +1817,12 @@ public: /// Retrieves the module that we're currently building, if any. Module *getCurrentModule(); - + /// Allocate a new MacroInfo object with the provided SourceLocation. MacroInfo *AllocateMacroInfo(SourceLocation L); /// Turn the specified lexer token into a fully checked and spelled - /// filename, e.g. as an operand of \#include. + /// filename, e.g. as an operand of \#include. /// /// The caller is expected to provide a buffer that is large enough to hold /// the spelling of the filename, but is also expected to handle the case @@ -1846,7 +1846,7 @@ public: bool *IsMapped, bool SkipCache = false); /// Get the DirectoryLookup structure used to find the current - /// FileEntry, if CurLexer is non-null and if applicable. + /// FileEntry, if CurLexer is non-null and if applicable. /// /// This allows us to implement \#include_next and find directory-specific /// properties. @@ -1856,7 +1856,7 @@ public: bool isInPrimaryFile() const; /// Handle cases where the \#include name is expanded - /// from a macro as multiple tokens, which need to be glued together. + /// from a macro as multiple tokens, which need to be glued together. /// /// This occurs for code like: /// \code @@ -1939,7 +1939,7 @@ private: /// - # (stringization) is followed by a macro parameter /// \param MacroNameTok - Token that represents the macro name /// \param ImmediatelyAfterHeaderGuard - Macro follows an #ifdef header guard - /// + /// /// Either returns a pointer to a MacroInfo object OR emits a diagnostic and /// returns a nullptr if an invalid sequence of tokens is encountered. MacroInfo *ReadOptionalMacroParameterListAndBody( diff --git a/include/clang/Lex/PreprocessorLexer.h b/include/clang/Lex/PreprocessorLexer.h index bb02725b116f0..b619f192f5306 100644 --- a/include/clang/Lex/PreprocessorLexer.h +++ b/include/clang/Lex/PreprocessorLexer.h @@ -169,12 +169,12 @@ public: using conditional_iterator = SmallVectorImpl<PPConditionalInfo>::const_iterator; - conditional_iterator conditional_begin() const { - return ConditionalStack.begin(); + conditional_iterator conditional_begin() const { + return ConditionalStack.begin(); } - conditional_iterator conditional_end() const { - return ConditionalStack.end(); + conditional_iterator conditional_end() const { + return ConditionalStack.end(); } void setConditionalLevels(ArrayRef<PPConditionalInfo> CL) { diff --git a/include/clang/Lex/PreprocessorOptions.h b/include/clang/Lex/PreprocessorOptions.h index 3d7e5ab4a8dc7..5134aeaa6a297 100644 --- a/include/clang/Lex/PreprocessorOptions.h +++ b/include/clang/Lex/PreprocessorOptions.h @@ -13,7 +13,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" -#include <memory> +#include <memory> #include <set> #include <string> #include <utility> @@ -27,7 +27,7 @@ class MemoryBuffer; namespace clang { -/// Enumerate the kinds of standard library that +/// Enumerate the kinds of standard library that enum ObjCXXARCStandardLibraryKind { ARCXX_nolib, @@ -37,7 +37,7 @@ enum ObjCXXARCStandardLibraryKind { /// libstdc++ ARCXX_libstdcxx }; - + /// PreprocessorOptions - This class is used for passing the various options /// used in preprocessor initialization to InitializePreprocessor(). class PreprocessorOptions { @@ -136,15 +136,15 @@ public: /// the buffers associated with remapped files. /// /// This flag defaults to false; it can be set true only through direct - /// manipulation of the compiler invocation object, in cases where the + /// manipulation of the compiler invocation object, in cases where the /// compiler invocation and its buffers will be reused. bool RetainRemappedFileBuffers = false; - + /// The Objective-C++ ARC standard library that we should support, /// by providing appropriate definitions to retrofit the standard library /// with support for lifetime-qualified pointers. ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary = ARCXX_nolib; - + /// Records the set of modules class FailedModulesSet { llvm::StringSet<> Failed; @@ -158,7 +158,7 @@ public: Failed.insert(module); } }; - + /// The set of modules that failed to build. /// /// This pointer will be shared among all of the compiler instances created @@ -185,7 +185,7 @@ public: RemappedFiles.clear(); RemappedFileBuffers.clear(); } - + /// Reset any options that are not considered when building a /// module. void resetNonModularOptions() { diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h index 633e1d15697b9..85bef728197d8 100644 --- a/include/clang/Lex/Token.h +++ b/include/clang/Lex/Token.h @@ -73,7 +73,7 @@ public: enum TokenFlags { StartOfLine = 0x01, // At start of line or only after whitespace // (considering the line after macro expansion). - LeadingSpace = 0x02, // Whitespace exists before this token (considering + LeadingSpace = 0x02, // Whitespace exists before this token (considering // whitespace after macro expansion). DisableExpand = 0x04, // This identifier may never be macro expanded. NeedsCleaning = 0x08, // Contained an escaped newline or trigraph. diff --git a/include/clang/Lex/TokenConcatenation.h b/include/clang/Lex/TokenConcatenation.h index a2d98b0d473a3..60c182b509a4d 100644 --- a/include/clang/Lex/TokenConcatenation.h +++ b/include/clang/Lex/TokenConcatenation.h @@ -58,8 +58,8 @@ namespace clang { public: TokenConcatenation(Preprocessor &PP); - bool AvoidConcat(const Token &PrevPrevTok, - const Token &PrevTok, + bool AvoidConcat(const Token &PrevPrevTok, + const Token &PrevTok, const Token &Tok) const; private: diff --git a/include/clang/Lex/TokenLexer.h b/include/clang/Lex/TokenLexer.h index e616d497eec69..98935ad9c4fa2 100644 --- a/include/clang/Lex/TokenLexer.h +++ b/include/clang/Lex/TokenLexer.h @@ -65,7 +65,7 @@ class TokenLexer { /// Source location pointing at the source location entry chunk that /// was reserved for the current macro expansion. SourceLocation MacroExpansionStart; - + /// The offset of the macro expansion in the /// "source location address space". unsigned MacroStartSLocOffset; diff --git a/include/clang/Lex/VariadicMacroSupport.h b/include/clang/Lex/VariadicMacroSupport.h index 55202ffc34d75..3a7a955953f4f 100644 --- a/include/clang/Lex/VariadicMacroSupport.h +++ b/include/clang/Lex/VariadicMacroSupport.h @@ -71,10 +71,10 @@ namespace clang { class VAOptDefinitionContext { /// Contains all the locations of so far unmatched lparens. SmallVector<SourceLocation, 8> UnmatchedOpeningParens; - + const IdentifierInfo *const Ident__VA_OPT__; - - + + public: VAOptDefinitionContext(Preprocessor &PP) : Ident__VA_OPT__(PP.Ident__VA_OPT__) {} @@ -86,12 +86,12 @@ namespace clang { /// Returns true if we have seen the __VA_OPT__ and '(' but before having /// seen the matching ')'. bool isInVAOpt() const { return UnmatchedOpeningParens.size(); } - + /// Call this function as soon as you see __VA_OPT__ and '('. void sawVAOptFollowedByOpeningParens(const SourceLocation LParenLoc) { assert(!isInVAOpt() && "Must NOT be within VAOPT context to call this"); UnmatchedOpeningParens.push_back(LParenLoc); - + } SourceLocation getUnmatchedOpeningParenLoc() const { @@ -107,13 +107,13 @@ namespace clang { UnmatchedOpeningParens.pop_back(); return !UnmatchedOpeningParens.size(); } - + /// Call this function each time an lparen is seen. void sawOpeningParen(SourceLocation LParenLoc) { assert(isInVAOpt() && "Must be within VAOPT context to call this"); UnmatchedOpeningParens.push_back(LParenLoc); } - + }; /// A class for tracking whether we're inside a VA_OPT during a @@ -133,11 +133,11 @@ namespace clang { int NumOfTokensPriorToVAOpt = -1; unsigned LeadingSpaceForStringifiedToken : 1; - + unsigned StringifyBefore : 1; unsigned CharifyBefore : 1; - - + + bool hasStringifyBefore() const { assert(!isReset() && "Must only be called if the state has not been reset"); @@ -169,14 +169,14 @@ namespace clang { void sawHashOrHashAtBefore(const bool HasLeadingSpace, const bool IsHashAt) { - + StringifyBefore = !IsHashAt; CharifyBefore = IsHashAt; LeadingSpaceForStringifiedToken = HasLeadingSpace; } - - + + bool hasCharifyBefore() const { assert(!isReset() && "Must only be called if the state has not been reset"); @@ -185,13 +185,13 @@ namespace clang { bool hasStringifyOrCharifyBefore() const { return hasStringifyBefore() || hasCharifyBefore(); } - + unsigned int getNumberOfTokensPriorToVAOpt() const { assert(!isReset() && "Must only be called if the state has not been reset"); return NumOfTokensPriorToVAOpt; } - + bool getLeadingSpaceForStringifiedToken() const { assert(hasStringifyBefore() && "Must only be called if this has been marked for stringification"); @@ -219,7 +219,7 @@ namespace clang { using VAOptDefinitionContext::isInVAOpt; using VAOptDefinitionContext::sawClosingParen; using VAOptDefinitionContext::sawOpeningParen; - + }; } // end namespace clang diff --git a/include/clang/Parse/ParseAST.h b/include/clang/Parse/ParseAST.h index 34b04060346f8..f6e78ac2ca56d 100644 --- a/include/clang/Parse/ParseAST.h +++ b/include/clang/Parse/ParseAST.h @@ -42,7 +42,7 @@ namespace clang { CodeCompleteConsumer *CompletionConsumer = nullptr, bool SkipFunctionBodies = false); - /// Parse the main file known to the preprocessor, producing an + /// Parse the main file known to the preprocessor, producing an /// abstract syntax tree. void ParseAST(Sema &S, bool PrintStats = false, bool SkipFunctionBodies = false); diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index d7b83803af202..69bf88a371db9 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -132,7 +132,7 @@ class Parser : public CodeCompletionHandler { /// Identifier for "unavailable". IdentifierInfo *Ident_unavailable; - + /// Identifier for "message". IdentifierInfo *Ident_message; @@ -1196,7 +1196,7 @@ private: /// method will be stored so that they can be reintroduced into /// scope at the appropriate times. SmallVector<LateParsedDefaultArgument, 8> DefaultArgs; - + /// The set of tokens that make up an exception-specification that /// has not yet been parsed. CachedTokens *ExceptionSpecTokens; @@ -1225,7 +1225,7 @@ private: /// C++ class, its method declarations that contain parts that won't be /// parsed until after the definition is completed (C++ [class.mem]p2), /// the method declarations and possibly attached inline definitions - /// will be stored here with the tokens that will be parsed to create those + /// will be stored here with the tokens that will be parsed to create those /// entities. typedef SmallVector<LateParsedDeclaration*,2> LateParsedDeclarationsContainer; @@ -1653,6 +1653,7 @@ private: /// ParenParseOption - Control what ParseParenExpression will parse. enum ParenParseOption { SimpleExpr, // Only parse '(' expression ')' + FoldExpr, // Also allow fold-expression <anything> CompoundStmt, // Also allow '(' compound-statement ')' CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}' CastExpr // Also allow '(' type-name ')' <anything> @@ -1673,7 +1674,7 @@ private: ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral = false); ExprResult ParseGenericSelectionExpression(); - + ExprResult ParseObjCBoolLiteral(); ExprResult ParseFoldExpression(ExprResult LHS, BalancedDelimiterTracker &T); @@ -1835,7 +1836,7 @@ private: SourceLocation LBracloc, SourceLocation SuperLoc, ParsedType ReceiverType, Expr *ReceiverExpr); bool ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr); - + //===--------------------------------------------------------------------===// // C99 6.8: Statements and Blocks. @@ -2064,7 +2065,7 @@ private: bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, const ParsedTemplateInfo &TemplateInfo, - AccessSpecifier AS, DeclSpecContext DSC, + AccessSpecifier AS, DeclSpecContext DSC, ParsedAttributesWithRange &Attrs); DeclSpecContext getDeclSpecContextFromDeclaratorContext(DeclaratorContext Context); @@ -2192,7 +2193,7 @@ private: /// isCXXFunctionDeclarator - Disambiguates between a function declarator or /// a constructor-style initializer, when parsing declaration statements. /// Returns true for function declarator and false for constructor-style - /// initializer. Sets 'IsAmbiguous' to true to indicate that this declaration + /// initializer. Sets 'IsAmbiguous' to true to indicate that this declaration /// might be a constructor-style initializer. /// If during the disambiguation process a parsing error is encountered, /// the function returns true to let the declaration parsing code handle it. @@ -2319,7 +2320,7 @@ private: void stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, DeclSpec &DS, Sema::TagUseKind TUK); - + // FixItLoc = possible correct location for the attributes void ProhibitAttributes(ParsedAttributesWithRange &Attrs, SourceLocation FixItLoc = SourceLocation()) { @@ -2689,7 +2690,7 @@ private: void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc, DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, bool EnteringContext, - DeclSpecContext DSC, + DeclSpecContext DSC, ParsedAttributesWithRange &Attributes); void SkipCXXMemberSpecification(SourceLocation StartLoc, SourceLocation AttrFixitLoc, @@ -2943,7 +2944,7 @@ private: //===--------------------------------------------------------------------===// // C++11/G++: Type Traits [Type-Traits.html in the GCC manual] ExprResult ParseTypeTrait(); - + //===--------------------------------------------------------------------===// // Embarcadero: Arary and Expression Traits ExprResult ParseArrayTypeTrait(); diff --git a/include/clang/Parse/RAIIObjectsForParser.h b/include/clang/Parse/RAIIObjectsForParser.h index f45d6434833ea..ba5e5fe3c8fb8 100644 --- a/include/clang/Parse/RAIIObjectsForParser.h +++ b/include/clang/Parse/RAIIObjectsForParser.h @@ -49,7 +49,7 @@ namespace clang { bool Active; public: - /// Begin suppressing access-like checks + /// Begin suppressing access-like checks SuppressAccessChecks(Parser &P, bool activate = true) : S(P.getActions()), DiagnosticPool(nullptr) { if (activate) { @@ -264,7 +264,7 @@ namespace clang { Diags.DecrementAllExtensionsSilenced(); } }; - + /// ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and /// restores it when destroyed. This says that "foo:" should not be /// considered a possible typo for "foo::" for error recovery purposes. @@ -276,18 +276,18 @@ namespace clang { : P(p), OldVal(P.ColonIsSacred) { P.ColonIsSacred = Value; } - + /// restore - This can be used to restore the state early, before the dtor /// is run. void restore() { P.ColonIsSacred = OldVal; } - + ~ColonProtectionRAIIObject() { restore(); } }; - + /// RAII object that makes '>' behave either as an operator /// or as the closing angle bracket for a template argument list. class GreaterThanIsOperatorScope { @@ -298,28 +298,28 @@ namespace clang { : GreaterThanIsOperator(GTIO), OldGreaterThanIsOperator(GTIO) { GreaterThanIsOperator = Val; } - + ~GreaterThanIsOperatorScope() { GreaterThanIsOperator = OldGreaterThanIsOperator; } }; - + class InMessageExpressionRAIIObject { bool &InMessageExpression; bool OldValue; - + public: InMessageExpressionRAIIObject(Parser &P, bool Value) - : InMessageExpression(P.InMessageExpression), + : InMessageExpression(P.InMessageExpression), OldValue(P.InMessageExpression) { InMessageExpression = Value; } - + ~InMessageExpressionRAIIObject() { InMessageExpression = OldValue; } }; - + /// RAII object that makes sure paren/bracket/brace count is correct /// after declaration/statement parsing, even when there's a parsing error. class ParenBraceBracketBalancer { @@ -329,7 +329,7 @@ namespace clang { ParenBraceBracketBalancer(Parser &p) : P(p), ParenCount(p.ParenCount), BracketCount(p.BracketCount), BraceCount(p.BraceCount) { } - + ~ParenBraceBracketBalancer() { P.AngleBrackets.clear(P); P.ParenCount = ParenCount; @@ -369,7 +369,7 @@ namespace clang { tok::TokenKind Kind, Close, FinalToken; SourceLocation (Parser::*Consumer)(); SourceLocation LOpen, LClose; - + unsigned short &getDepth() { switch (Kind) { case tok::l_brace: return P.BraceCount; @@ -378,10 +378,10 @@ namespace clang { default: llvm_unreachable("Wrong token kind"); } } - + bool diagnoseOverflow(); bool diagnoseMissingClose(); - + public: BalancedDelimiterTracker(Parser& p, tok::TokenKind k, tok::TokenKind FinalToken = tok::semi) @@ -391,34 +391,34 @@ namespace clang { switch (Kind) { default: llvm_unreachable("Unexpected balanced token"); case tok::l_brace: - Close = tok::r_brace; + Close = tok::r_brace; Consumer = &Parser::ConsumeBrace; break; case tok::l_paren: - Close = tok::r_paren; + Close = tok::r_paren; Consumer = &Parser::ConsumeParen; break; - + case tok::l_square: - Close = tok::r_square; + Close = tok::r_square; Consumer = &Parser::ConsumeBracket; break; - } + } } - + SourceLocation getOpenLocation() const { return LOpen; } SourceLocation getCloseLocation() const { return LClose; } SourceRange getRange() const { return SourceRange(LOpen, LClose); } - + bool consumeOpen() { if (!P.Tok.is(Kind)) return true; - + if (getDepth() < P.getLangOpts().BracketDepth) { LOpen = (P.*Consumer)(); return false; } - + return diagnoseOverflow(); } @@ -436,7 +436,7 @@ namespace clang { LClose = (P.*Consumer)(); return false; } - + return diagnoseMissingClose(); } void skipToEnd(); diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 83d5ab2cff85d..2e70203c6cc08 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -61,7 +61,7 @@ namespace clang { /// /// The actual scope is described by getScopeRep(). class CXXScopeSpec { - SourceRange Range; + SourceRange Range; NestedNameSpecifierLocBuilder Builder; public: @@ -73,8 +73,8 @@ public: SourceLocation getEndLoc() const { return Range.getEnd(); } /// Retrieve the representation of the nested-name-specifier. - NestedNameSpecifier *getScopeRep() const { - return Builder.getRepresentation(); + NestedNameSpecifier *getScopeRep() const { + return Builder.getRepresentation(); } /// Extend the current nested-name-specifier by another @@ -91,7 +91,7 @@ public: void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc); - /// Extend the current nested-name-specifier by another + /// Extend the current nested-name-specifier by another /// nested-name-specifier component of the form 'identifier::'. /// /// \param Context The AST context in which this nested-name-specifier @@ -105,7 +105,7 @@ public: void Extend(ASTContext &Context, IdentifierInfo *Identifier, SourceLocation IdentifierLoc, SourceLocation ColonColonLoc); - /// Extend the current nested-name-specifier by another + /// Extend the current nested-name-specifier by another /// nested-name-specifier component of the form 'namespace::'. /// /// \param Context The AST context in which this nested-name-specifier @@ -119,7 +119,7 @@ public: void Extend(ASTContext &Context, NamespaceDecl *Namespace, SourceLocation NamespaceLoc, SourceLocation ColonColonLoc); - /// Extend the current nested-name-specifier by another + /// Extend the current nested-name-specifier by another /// nested-name-specifier component of the form 'namespace-alias::'. /// /// \param Context The AST context in which this nested-name-specifier @@ -127,7 +127,7 @@ public: /// /// \param Alias The namespace alias. /// - /// \param AliasLoc The location of the namespace alias + /// \param AliasLoc The location of the namespace alias /// name. /// /// \param ColonColonLoc The location of the trailing '::'. @@ -137,7 +137,7 @@ public: /// Turn this (empty) nested-name-specifier into the global /// nested-name-specifier '::'. void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc); - + /// Turns this (empty) nested-name-specifier into '__super' /// nested-name-specifier. /// @@ -160,13 +160,13 @@ public: /// FIXME: This routine should be used very, very rarely, in cases where we /// need to synthesize a nested-name-specifier. Most code should instead use /// \c Adopt() with a proper \c NestedNameSpecifierLoc. - void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, + void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R); - - /// Adopt an existing nested-name-specifier (with source-range + + /// Adopt an existing nested-name-specifier (with source-range /// information). void Adopt(NestedNameSpecifierLoc Other); - + /// Retrieve a nested-name-specifier with location information, copied /// into the given AST context. /// @@ -196,14 +196,14 @@ public: bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; } /// Indicate that this nested-name-specifier is invalid. - void SetInvalid(SourceRange R) { + void SetInvalid(SourceRange R) { assert(R.isValid() && "Must have a valid source range"); if (Range.getBegin().isInvalid()) Range.setBegin(R.getBegin()); Range.setEnd(R.getEnd()); Builder.Clear(); } - + /// Deprecated. Some call sites intend isNotEmpty() while others intend /// isValid(). bool isSet() const { return getScopeRep() != nullptr; } @@ -215,8 +215,8 @@ public: /// Retrieve the data associated with the source-location information. char *location_data() const { return Builder.getBuffer().first; } - - /// Retrieve the size of the data associated with source-location + + /// Retrieve the size of the data associated with source-location /// information. unsigned location_size() const { return Builder.getBuffer().second; } }; @@ -254,7 +254,7 @@ public: static const TSW TSW_short = clang::TSW_short; static const TSW TSW_long = clang::TSW_long; static const TSW TSW_longlong = clang::TSW_longlong; - + enum TSC { TSC_unspecified, TSC_imaginary, @@ -709,7 +709,7 @@ public: bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); } SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; } - + bool isConstexprSpecified() const { return Constexpr_specified; } SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } @@ -916,7 +916,7 @@ enum class UnqualifiedIdKind { IK_DeductionGuideName }; -/// Represents a C++ unqualified-id that has been parsed. +/// Represents a C++ unqualified-id that has been parsed. class UnqualifiedId { private: UnqualifiedId(const UnqualifiedId &Other) = delete; @@ -931,8 +931,8 @@ public: OverloadedOperatorKind Operator; /// The source locations of the individual tokens that name - /// the operator, e.g., the "new", "[", and "]" tokens in - /// operator new []. + /// the operator, e.g., the "new", "[", and "]" tokens in + /// operator new []. /// /// Different operators have different numbers of tokens in their name, /// up to three. Any remaining source locations in this array will be @@ -946,44 +946,44 @@ public: /// When Kind == IK_Identifier, the parsed identifier, or when /// Kind == IK_UserLiteralId, the identifier suffix. IdentifierInfo *Identifier; - + /// When Kind == IK_OperatorFunctionId, the overloaded operator /// that we parsed. struct OFI OperatorFunctionId; - - /// When Kind == IK_ConversionFunctionId, the type that the + + /// When Kind == IK_ConversionFunctionId, the type that the /// conversion function names. UnionParsedType ConversionFunctionId; /// When Kind == IK_ConstructorName, the class-name of the type /// whose constructor is being referenced. UnionParsedType ConstructorName; - + /// When Kind == IK_DestructorName, the type referred to by the /// class-name. UnionParsedType DestructorName; /// When Kind == IK_DeductionGuideName, the parsed template-name. UnionParsedTemplateTy TemplateName; - + /// When Kind == IK_TemplateId or IK_ConstructorTemplateId, /// the template-id annotation that contains the template name and /// template arguments. TemplateIdAnnotation *TemplateId; }; - + /// The location of the first token that describes this unqualified-id, /// which will be the location of the identifier, "operator" keyword, /// tilde (for a destructor), or the template name of a template-id. SourceLocation StartLocation; - + /// The location of the last token that describes this unqualified-id. SourceLocation EndLocation; UnqualifiedId() : Kind(UnqualifiedIdKind::IK_Identifier), Identifier(nullptr) {} - /// Clear out this unqualified-id, setting it to default (invalid) + /// Clear out this unqualified-id, setting it to default (invalid) /// state. void clear() { Kind = UnqualifiedIdKind::IK_Identifier; @@ -991,17 +991,17 @@ public: StartLocation = SourceLocation(); EndLocation = SourceLocation(); } - + /// Determine whether this unqualified-id refers to a valid name. bool isValid() const { return StartLocation.isValid(); } /// Determine whether this unqualified-id refers to an invalid name. bool isInvalid() const { return !isValid(); } - + /// Determine what kind of name we have. UnqualifiedIdKind getKind() const { return Kind; } - void setKind(UnqualifiedIdKind kind) { Kind = kind; } - + void setKind(UnqualifiedIdKind kind) { Kind = kind; } + /// Specify that this unqualified-id was parsed as an identifier. /// /// \param Id the parsed identifier. @@ -1011,8 +1011,8 @@ public: Identifier = const_cast<IdentifierInfo *>(Id); StartLocation = EndLocation = IdLoc; } - - /// Specify that this unqualified-id was parsed as an + + /// Specify that this unqualified-id was parsed as an /// operator-function-id. /// /// \param OperatorLoc the location of the 'operator' keyword. @@ -1021,11 +1021,11 @@ public: /// /// \param SymbolLocations the locations of the individual operator symbols /// in the operator. - void setOperatorFunctionId(SourceLocation OperatorLoc, + void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3]); - - /// Specify that this unqualified-id was parsed as a + + /// Specify that this unqualified-id was parsed as a /// conversion-function-id. /// /// \param OperatorLoc the location of the 'operator' keyword. @@ -1033,7 +1033,7 @@ public: /// \param Ty the type to which this conversion function is converting. /// /// \param EndLoc the location of the last token that makes up the type name. - void setConversionFunctionId(SourceLocation OperatorLoc, + void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc) { Kind = UnqualifiedIdKind::IK_ConversionFunctionId; @@ -1057,7 +1057,7 @@ public: StartLocation = OpLoc; EndLocation = IdLoc; } - + /// Specify that this unqualified-id was parsed as a constructor name. /// /// \param ClassType the class type referred to by the constructor name. @@ -1065,7 +1065,7 @@ public: /// \param ClassNameLoc the location of the class name. /// /// \param EndLoc the location of the last token that makes up the type name. - void setConstructorName(ParsedType ClassType, + void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc) { Kind = UnqualifiedIdKind::IK_ConstructorName; @@ -1096,7 +1096,7 @@ public: EndLocation = EndLoc; DestructorName = ClassType; } - + /// Specify that this unqualified-id was parsed as a template-id. /// /// \param TemplateId the template-id annotation that describes the parsed @@ -1115,10 +1115,10 @@ public: TemplateName = Template; StartLocation = EndLocation = TemplateLoc; } - + /// Return the source range that covers this unqualified-id. - SourceRange getSourceRange() const LLVM_READONLY { - return SourceRange(StartLocation, EndLocation); + SourceRange getSourceRange() const LLVM_READONLY { + return SourceRange(StartLocation, EndLocation); } SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; } SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; } @@ -1326,7 +1326,7 @@ struct DeclaratorChunk { /// Pointer to the expression in the noexcept-specifier of this /// function, if it has one. Expr *NoexceptExpr; - + /// Pointer to the cached tokens for an exception-specification /// that has not yet been parsed. CachedTokens *ExceptionSpecTokens; @@ -1426,7 +1426,7 @@ struct DeclaratorChunk { return SourceLocation::getFromRawEncoding(MutableLoc); } - /// Determine whether this function declaration contains a + /// Determine whether this function declaration contains a /// ref-qualifier. bool hasRefQualifier() const { return getRefQualifierLoc().isValid(); } @@ -1746,7 +1746,7 @@ enum class DeclaratorContext { /// Instances of this class should be a transient object that lives on the /// stack, not objects that are allocated in large quantities on the heap. class Declarator { - + private: const DeclSpec &DS; CXXScopeSpec SS; @@ -1771,7 +1771,7 @@ private: /// GroupingParens - Set by Parser::ParseParenDeclarator(). unsigned GroupingParens : 1; - /// FunctionDefinition - Is this Declarator for a function or member + /// FunctionDefinition - Is this Declarator for a function or member /// definition and, if so, what kind? /// /// Actually a FunctionDefinitionKind. @@ -1785,7 +1785,7 @@ private: /// Indicates whether this is an Objective-C instance variable. unsigned ObjCIvar : 1; - + /// Indicates whether this is an Objective-C 'weak' property. unsigned ObjCWeakProperty : 1; @@ -1817,7 +1817,7 @@ private: /// If provided, the source location of the ellipsis used to describe /// this declarator as a parameter pack. SourceLocation EllipsisLoc; - + friend struct DeclaratorChunk; public: @@ -1858,7 +1858,7 @@ public: const DecompositionDeclarator &getDecompositionDeclarator() const { return BindingGroup; } - + DeclaratorContext getContext() const { return Context; } bool isPrototypeContext() const { @@ -2107,10 +2107,10 @@ public: return BindingGroup.isSet(); } - IdentifierInfo *getIdentifier() const { + IdentifierInfo *getIdentifier() const { if (Name.getKind() == UnqualifiedIdKind::IK_Identifier) return Name.Identifier; - + return nullptr; } SourceLocation getIdentifierLoc() const { return Name.StartLocation; } @@ -2261,9 +2261,9 @@ public: return const_cast<Declarator*>(this)->getFunctionTypeInfo(); } - /// Determine whether the declaration that will be produced from + /// Determine whether the declaration that will be produced from /// this declaration will be a function. - /// + /// /// A declaration can declare a function even if the declarator itself /// isn't a function declarator, if the type specifier refers to a function /// type. This routine checks for both cases. @@ -2318,8 +2318,8 @@ public: case DeclaratorContext::MemberContext: // FIXME: sizeof(...) permits an expression. - case DeclaratorContext::TypeNameContext: - + case DeclaratorContext::TypeNameContext: + case DeclaratorContext::FunctionalCastContext: case DeclaratorContext::AliasDeclContext: case DeclaratorContext::AliasTemplateContext: @@ -2349,7 +2349,7 @@ public: llvm_unreachable("unknown context kind!"); } - + /// Return true if a function declarator at this position would be a /// function declaration. bool isFunctionDeclaratorAFunctionDeclaration() const { @@ -2418,7 +2418,7 @@ public: void setObjCIvar(bool Val = true) { ObjCIvar = Val; } bool isObjCIvar() const { return ObjCIvar; } - + void setObjCWeakProperty(bool Val = true) { ObjCWeakProperty = Val; } bool isObjCWeakProperty() const { return ObjCWeakProperty; } @@ -2438,16 +2438,16 @@ public: SourceLocation getEllipsisLoc() const { return EllipsisLoc; } void setEllipsisLoc(SourceLocation EL) { EllipsisLoc = EL; } - void setFunctionDefinitionKind(FunctionDefinitionKind Val) { - FunctionDefinition = Val; + void setFunctionDefinitionKind(FunctionDefinitionKind Val) { + FunctionDefinition = Val; } - + bool isFunctionDefinition() const { return getFunctionDefinitionKind() != FDK_Declaration; } - - FunctionDefinitionKind getFunctionDefinitionKind() const { - return (FunctionDefinitionKind)FunctionDefinition; + + FunctionDefinitionKind getFunctionDefinitionKind() const { + return (FunctionDefinitionKind)FunctionDefinition; } /// Returns true if this declares a real member and not a friend. @@ -2511,7 +2511,7 @@ public: SourceLocation getFirstLocation() const { return FirstLocation; } SourceLocation getLastLocation() const { return LastLocation; } Specifier getLastSpecifier() const { return LastSpecifier; } - + private: unsigned Specifiers; Specifier LastSpecifier; @@ -2565,7 +2565,7 @@ struct LambdaIntroducer { IdentifierInfo* Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, - ExprResult Init, + ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange) { Captures.push_back(LambdaCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init, diff --git a/include/clang/Sema/DelayedDiagnostic.h b/include/clang/Sema/DelayedDiagnostic.h index 76aa4546d749a..a26b6ff070f6f 100644 --- a/include/clang/Sema/DelayedDiagnostic.h +++ b/include/clang/Sema/DelayedDiagnostic.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // /// \file -/// Defines the classes clang::DelayedDiagnostic and +/// Defines the classes clang::DelayedDiagnostic and /// clang::AccessedEntity. /// /// DelayedDiangostic is used to record diagnostics that are being diff --git a/include/clang/Sema/ExternalSemaSource.h b/include/clang/Sema/ExternalSemaSource.h index 42754b33e2df2..00f80e27415d4 100644 --- a/include/clang/Sema/ExternalSemaSource.h +++ b/include/clang/Sema/ExternalSemaSource.h @@ -46,7 +46,7 @@ struct ExternalVTableUse { SourceLocation Location; bool DefinitionRequired; }; - + /// An abstract interface that should be implemented by /// external AST sources that also provide information for semantic /// analysis. @@ -106,7 +106,7 @@ public: /// introduce the same declarations repeatedly. virtual void ReadTentativeDefinitions( SmallVectorImpl<VarDecl *> &TentativeDefs) {} - + /// Read the set of unused file-scope declarations known to the /// external Sema source. /// @@ -116,7 +116,7 @@ public: /// introduce the same declarations repeatedly. virtual void ReadUnusedFileScopedDecls( SmallVectorImpl<const DeclaratorDecl *> &Decls) {} - + /// Read the set of delegating constructors known to the /// external Sema source. /// @@ -148,9 +148,9 @@ public: /// Read the set of referenced selectors known to the /// external Sema source. /// - /// The external source should append its own referenced selectors to the - /// given vector of selectors. Note that this routine - /// may be invoked multiple times; the external source should take care not + /// The external source should append its own referenced selectors to the + /// given vector of selectors. Note that this routine + /// may be invoked multiple times; the external source should take care not /// to introduce the same selectors repeatedly. virtual void ReadReferencedSelectors( SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {} @@ -159,7 +159,7 @@ public: /// external Sema source. /// /// The external source should append its own weak, undeclared identifiers to - /// the given vector. Note that this routine may be invoked multiple times; + /// the given vector. Note that this routine may be invoked multiple times; /// the external source should take care not to introduce the same identifiers /// repeatedly. virtual void ReadWeakUndeclaredIdentifiers( @@ -180,7 +180,7 @@ public: /// external source should take care not to introduce the same instantiations /// repeatedly. virtual void ReadPendingInstantiations( - SmallVectorImpl<std::pair<ValueDecl *, + SmallVectorImpl<std::pair<ValueDecl *, SourceLocation> > &Pending) {} /// Read the set of late parsed template functions for this source. @@ -227,7 +227,7 @@ public: static bool classof(const ExternalASTSource *Source) { return Source->SemaSource; } -}; +}; } // end namespace clang diff --git a/include/clang/Sema/IdentifierResolver.h b/include/clang/Sema/IdentifierResolver.h index ea6c3df74af0b..1c46e1d0e3d2c 100644 --- a/include/clang/Sema/IdentifierResolver.h +++ b/include/clang/Sema/IdentifierResolver.h @@ -32,7 +32,7 @@ class LangOptions; class NamedDecl; class Preprocessor; class Scope; - + /// IdentifierResolver - Keeps track of shadowed decls on enclosing /// scopes. It manages the shadowing chains of declaration names and /// implements efficient decl lookup based on a declaration name. @@ -58,7 +58,7 @@ class IdentifierResolver { void InsertDecl(DeclsTy::iterator Pos, NamedDecl *D) { Decls.insert(Pos, D); } - + private: DeclsTy Decls; }; @@ -176,17 +176,17 @@ public: /// /// \returns true if the declaration was added, false otherwise. bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name); - + private: const LangOptions &LangOpt; Preprocessor &PP; - + class IdDeclInfoMap; IdDeclInfoMap *IdDeclInfos; void updatingIdentifier(IdentifierInfo &II); void readingIdentifier(IdentifierInfo &II); - + /// FETokenInfo contains a Decl pointer if lower bit == 0. static inline bool isDeclPtr(void *Ptr) { return (reinterpret_cast<uintptr_t>(Ptr) & 0x1) == 0; diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h index 7a510f391bda4..8582e971d0b6c 100644 --- a/include/clang/Sema/Initialization.h +++ b/include/clang/Sema/Initialization.h @@ -102,7 +102,7 @@ public: /// complex number. EK_ComplexElement, - /// The entity being initialized is the field that captures a + /// The entity being initialized is the field that captures a /// variable in a lambda. EK_LambdaCapture, @@ -178,7 +178,7 @@ private: union { /// When Kind == EK_Variable, EK_Member or EK_Binding, the variable. VD Variable; - + /// When Kind == EK_RelatedResult, the ObjectiveC method where /// result type was implicitly changed to accommodate ARC semantics. ObjCMethodDecl *MethodDecl; @@ -186,21 +186,21 @@ private: /// When Kind == EK_Parameter, the ParmVarDecl, with the /// low bit indicating whether the parameter is "consumed". uintptr_t Parameter; - + /// When Kind == EK_Temporary or EK_CompoundLiteralInit, the type /// source information for the temporary. TypeSourceInfo *TypeInfo; struct LN LocAndNRVO; - - /// When Kind == EK_Base, the base specifier that provides the + + /// When Kind == EK_Base, the base specifier that provides the /// base class. The lower bit specifies whether the base is an inherited /// virtual base. uintptr_t Base; /// When Kind == EK_ArrayElement, EK_VectorElement, or /// EK_ComplexElement, the index of the array or vector element being - /// initialized. + /// initialized. unsigned Index; struct C Capture; @@ -211,7 +211,7 @@ private: /// Create the initialization entity for a variable. InitializedEntity(VarDecl *Var, EntityKind EK = EK_Variable) : Kind(EK), Type(Var->getType()), Variable{Var, false, false} {} - + /// Create the initialization entity for the result of a /// function, throwing an object, performing an explicit cast, or /// initializing a parameter for which there is no declaration. @@ -221,15 +221,15 @@ private: LocAndNRVO.Location = Loc.getRawEncoding(); LocAndNRVO.NRVO = NRVO; } - + /// Create the initialization entity for a member subobject. InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent, bool Implicit, bool DefaultMemberInit) : Kind(EK_Member), Parent(Parent), Type(Member->getType()), Variable{Member, Implicit, DefaultMemberInit} {} - + /// Create the initialization entity for an array element. - InitializedEntity(ASTContext &Context, unsigned Index, + InitializedEntity(ASTContext &Context, unsigned Index, const InitializedEntity &Parent); /// Create the initialization entity for a lambda capture. @@ -238,7 +238,7 @@ private: Capture.VarID = VarID; Capture.Location = Loc.getRawEncoding(); } - + public: /// Create the initialization entity for a variable. static InitializedEntity InitializeVariable(VarDecl *Var) { @@ -314,7 +314,7 @@ public: static InitializedEntity InitializeNew(SourceLocation NewLoc, QualType Type) { return InitializedEntity(EK_New, NewLoc, Type); } - + /// Create the initialization entity for a temporary. static InitializedEntity InitializeTemporary(QualType Type) { return InitializeTemporary(nullptr, Type); @@ -324,7 +324,7 @@ public: static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo) { return InitializeTemporary(TypeInfo, TypeInfo->getType()); } - + /// Create the initialization entity for a temporary. static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo, QualType Type) { @@ -332,7 +332,7 @@ public: Result.TypeInfo = TypeInfo; return Result; } - + /// Create the initialization entity for a related result. static InitializedEntity InitializeRelatedResult(ObjCMethodDecl *MD, QualType Type) { @@ -375,8 +375,8 @@ public: } /// Create the initialization entity for an array element. - static InitializedEntity InitializeElement(ASTContext &Context, - unsigned Index, + static InitializedEntity InitializeElement(ASTContext &Context, + unsigned Index, const InitializedEntity &Parent) { return InitializedEntity(Context, Index, Parent); } @@ -403,7 +403,7 @@ public: /// Determine the kind of initialization. EntityKind getKind() const { return Kind; } - + /// Retrieve the parent of the entity being initialized, when /// the initialization itself is occurring within the context of a /// larger initialization. @@ -411,27 +411,27 @@ public: /// Retrieve type being initialized. QualType getType() const { return Type; } - - /// Retrieve complete type-source information for the object being + + /// Retrieve complete type-source information for the object being /// constructed, if known. TypeSourceInfo *getTypeSourceInfo() const { if (Kind == EK_Temporary || Kind == EK_CompoundLiteralInit) return TypeInfo; - + return nullptr; } - + /// Retrieve the name of the entity being initialized. DeclarationName getName() const; /// Retrieve the variable, parameter, or field being /// initialized. ValueDecl *getDecl() const; - + /// Retrieve the ObjectiveC method being initialized. ObjCMethodDecl *getMethodDecl() const { return MethodDecl; } - /// Determine whether this initialization allows the named return + /// Determine whether this initialization allows the named return /// value optimization, which also applies to thrown objects. bool allowsNRVO() const; @@ -446,7 +446,7 @@ public: assert(isParameterKind() && "Not a parameter"); return (Parameter & 1); } - + /// Retrieve the base specifier. const CXXBaseSpecifier *getBaseSpecifier() const { assert(getKind() == EK_Base && "Not a base specifier"); @@ -519,7 +519,7 @@ public: assert(getKind() == EK_LambdaCapture && "Not a lambda capture!"); return SourceLocation::getFromRawEncoding(Capture.Location); } - + void setParameterCFAudited() { Kind = EK_Parameter_CF_Audited; } @@ -533,8 +533,8 @@ public: private: unsigned dumpImpl(raw_ostream &OS) const; }; - -/// Describes the kind of initialization being performed, along with + +/// Describes the kind of initialization being performed, along with /// location information for tokens related to the initialization (equal sign, /// parentheses). class InitializationKind { @@ -556,7 +556,7 @@ public: /// Value initialization IK_Value }; - + private: /// The context of the initialization. enum InitContext { @@ -578,24 +578,24 @@ private: /// Functional cast context IC_FunctionalCast }; - + /// The kind of initialization being performed. InitKind Kind : 8; /// The context of the initialization. InitContext Context : 8; - + /// The source locations involved in the initialization. SourceLocation Locations[3]; - - InitializationKind(InitKind Kind, InitContext Context, SourceLocation Loc1, + + InitializationKind(InitKind Kind, InitContext Context, SourceLocation Loc1, SourceLocation Loc2, SourceLocation Loc3) : Kind(Kind), Context(Context) { Locations[0] = Loc1; Locations[1] = Loc2; Locations[2] = Loc3; } - + public: /// Create a direct initialization. static InitializationKind CreateDirect(SourceLocation InitLoc, @@ -617,13 +617,13 @@ public: RBraceLoc); } - /// Create a direct initialization due to a cast that isn't a C-style + /// Create a direct initialization due to a cast that isn't a C-style /// or functional cast. static InitializationKind CreateCast(SourceRange TypeRange) { return InitializationKind(IK_Direct, IC_StaticCast, TypeRange.getBegin(), TypeRange.getBegin(), TypeRange.getEnd()); } - + /// Create a direct initialization for a C-style cast. static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, @@ -647,16 +647,16 @@ public: static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs = false) { - return InitializationKind(IK_Copy, + return InitializationKind(IK_Copy, AllowExplicitConvs? IC_ExplicitConvs : IC_Normal, InitLoc, EqualLoc, EqualLoc); } - + /// Create a default initialization. static InitializationKind CreateDefault(SourceLocation InitLoc) { return InitializationKind(IK_Default, IC_Normal, InitLoc, InitLoc, InitLoc); } - + /// Create a value initialization. static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, @@ -676,20 +676,20 @@ public: return CreateDirectList(Loc, Init->getLocStart(), Init->getLocEnd()); return CreateDirect(Loc, Init->getLocStart(), Init->getLocEnd()); } - + /// Determine the initialization kind. InitKind getKind() const { return Kind; } - + /// Determine whether this initialization is an explicit cast. bool isExplicitCast() const { return Context >= IC_StaticCast; } - + /// Determine whether this initialization is a C-style cast. - bool isCStyleOrFunctionalCast() const { - return Context >= IC_CStyleCast; + bool isCStyleOrFunctionalCast() const { + return Context >= IC_CStyleCast; } /// Determine whether this is a C-style cast. @@ -709,12 +709,12 @@ public: /// Retrieve the location at which initialization is occurring. SourceLocation getLocation() const { return Locations[0]; } - + /// Retrieve the source range that covers the initialization. - SourceRange getRange() const { + SourceRange getRange() const { return SourceRange(Locations[0], Locations[2]); } - + /// Retrieve the location of the equal sign for copy initialization /// (if present). SourceLocation getEqualLoc() const { @@ -741,7 +741,7 @@ public: bool hasParenOrBraceRange() const { return Kind == IK_Direct || Kind == IK_Value || Kind == IK_DirectList; } - + /// Retrieve the source range containing the locations of the open /// and closing parentheses or braces for value, direct, and direct list /// initializations. @@ -771,7 +771,7 @@ public: /// A normal sequence. NormalSequence }; - + /// Describes the kind of a particular step in an initialization /// sequence. enum StepKind { @@ -898,13 +898,13 @@ public: /// Passing zero to a function where OpenCL event_t is expected. SK_OCLZeroEvent }; - + /// A single step in the initialization sequence. class Step { public: /// The kind of conversion or initialization step we are taking. StepKind Kind; - + // The type that results from this initialization. QualType Type; @@ -916,7 +916,7 @@ public: union { /// When Kind == SK_ResolvedOverloadedFunction or Kind == - /// SK_UserConversion, the function that the expression should be + /// SK_UserConversion, the function that the expression should be /// resolved to or the conversion function to call, respectively. /// When Kind == SK_ConstructorInitialization or SK_ListConstruction, /// the constructor to be called. @@ -938,14 +938,14 @@ public: void Destroy(); }; - + private: /// The kind of initialization sequence computed. enum SequenceKind SequenceKind; - + /// Steps taken by this initialization. SmallVector<Step, 4> Steps; - + public: /// Describes why initialization failed. enum FailureKind { @@ -958,7 +958,7 @@ public: /// Array must be initialized with an initializer list. FK_ArrayNeedsInitList, - /// Array must be initialized with an initializer list or a + /// Array must be initialized with an initializer list or a /// string literal. FK_ArrayNeedsInitListOrStringLiteral, @@ -1067,14 +1067,14 @@ public: /// List-copy-initialization chose an explicit constructor. FK_ExplicitConstructor, }; - + private: /// The reason why initialization failed. FailureKind Failure; /// The failed result of overload resolution. OverloadingResult FailedOverloadResult; - + /// The candidate set created when initialization failed. OverloadCandidateSet FailedCandidateSet; @@ -1100,11 +1100,11 @@ private: void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity); public: - /// Try to perform initialization of the given entity, creating a + /// Try to perform initialization of the given entity, creating a /// record of the steps required to perform the initialization. /// /// The generated initialization sequence will either contain enough - /// information to diagnose + /// information to diagnose /// /// \param S the semantic analysis object. /// @@ -1119,7 +1119,7 @@ public: /// narrowing conversions in C++11 onwards. /// \param TreatUnavailableAsInvalid true if we want to treat unavailable /// as invalid. - InitializationSequence(Sema &S, + InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, @@ -1130,7 +1130,7 @@ public: bool TopLevelOfInitList, bool TreatUnavailableAsInvalid); ~InitializationSequence(); - + /// Perform the actual initialization of the given entity based on /// the computed initialization sequence. /// @@ -1157,22 +1157,22 @@ public: const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType = nullptr); - + /// Diagnose an potentially-invalid initialization sequence. /// - /// \returns true if the initialization sequence was ill-formed, + /// \returns true if the initialization sequence was ill-formed, /// false otherwise. - bool Diagnose(Sema &S, + bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef<Expr *> Args); - + /// Determine the kind of initialization sequence computed. enum SequenceKind getKind() const { return SequenceKind; } - + /// Set the kind of sequence computed. void setSequenceKind(enum SequenceKind SK) { SequenceKind = SK; } - + /// Determine whether the initialization sequence is valid. explicit operator bool() const { return !Failed(); } @@ -1188,14 +1188,14 @@ public: step_range steps() const { return {step_begin(), step_end()}; } - /// Determine whether this initialization is a direct reference + /// Determine whether this initialization is a direct reference /// binding (C++ [dcl.init.ref]). bool isDirectReferenceBinding() const; - + /// Determine whether this initialization failed due to an ambiguity. bool isAmbiguous() const; - - /// Determine whether this initialization is direct call to a + + /// Determine whether this initialization is direct call to a /// constructor. bool isConstructorInitialization() const; @@ -1228,7 +1228,7 @@ public: /// rvalue, an xvalue, or an lvalue. void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category); - + /// Add a new step binding a reference to an object. /// /// \param BindingTemporary True if we are binding a reference to a temporary @@ -1351,11 +1351,11 @@ public: assert((Failure != FK_Incomplete || !FailedIncompleteType.isNull()) && "Incomplete type failure requires a type!"); } - + /// Note that this initialization sequence failed due to failed /// overload resolution. void SetOverloadFailure(FailureKind Failure, OverloadingResult Result); - + /// Retrieve a reference to the candidate set when overload /// resolution fails. OverloadCandidateSet &getFailedCandidateSet() { @@ -1381,15 +1381,15 @@ public: return Failure; } - /// Dump a representation of this initialization sequence to + /// Dump a representation of this initialization sequence to /// the given stream, for debugging purposes. void dump(raw_ostream &OS) const; - - /// Dump a representation of this initialization sequence to + + /// Dump a representation of this initialization sequence to /// standard error, for debugging purposes. void dump() const; }; - + } // namespace clang #endif // LLVM_CLANG_SEMA_INITIALIZATION_H diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index c06952064dd9e..e28b847f4ae5a 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -50,11 +50,11 @@ public: /// No entity found met the criteria. NotFound = 0, - /// No entity found met the criteria within the current - /// instantiation,, but there were dependent base classes of the + /// No entity found met the criteria within the current + /// instantiation,, but there were dependent base classes of the /// current instantiation that could not be searched. NotFoundInCurrentInstantiation, - + /// Name lookup found a single declaration that met the /// criteria. getFoundDecl() will return this declaration. Found, @@ -435,7 +435,7 @@ public: bool wasNotFoundInCurrentInstantiation() const { return ResultKind == NotFoundInCurrentInstantiation; } - + /// Note that while no result was found in the current instantiation, /// there were dependent base classes that could not be searched. void setNotFoundInCurrentInstantiation() { @@ -610,7 +610,7 @@ public: LookupResult::iterator I; bool Changed = false; bool CalledDone = false; - + Filter(LookupResult &Results) : Results(Results), I(Results.begin()) {} public: diff --git a/include/clang/Sema/MultiplexExternalSemaSource.h b/include/clang/Sema/MultiplexExternalSemaSource.h index 4c242c89f3f4b..86bddebcef691 100644 --- a/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/include/clang/Sema/MultiplexExternalSemaSource.h @@ -42,7 +42,7 @@ private: SmallVector<ExternalSemaSource *, 2> Sources; // doesn't own them. public: - + ///Constructs a new multiplexing external sema source and appends the /// given element to it. /// @@ -113,7 +113,7 @@ public: /// Get the decls that are contained in a file in the Offset/Length /// range. \p Length can be 0 to indicate a point at \p Offset instead of - /// a range. + /// a range. void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, SmallVectorImpl<Decl *> &Decls) override; @@ -125,7 +125,7 @@ public: /// incomplete Objective-C class. /// /// This routine will only be invoked if the "externally completed" bit is - /// set on the ObjCInterfaceDecl via the function + /// set on the ObjCInterfaceDecl via the function /// \c ObjCInterfaceDecl::setExternallyCompleted(). void CompleteType(ObjCInterfaceDecl *Class) override; @@ -156,7 +156,7 @@ public: /// Perform layout on the given record. /// - /// This routine allows the external AST source to provide an specific + /// This routine allows the external AST source to provide an specific /// layout for a record, overriding the layout that would normally be /// constructed. It is intended for clients who receive specific layout /// details rather than source code (such as LLDB). The client is expected @@ -173,13 +173,13 @@ public: /// expressed in bits. All of the fields must be provided with offsets. /// /// \param BaseOffsets The offset of each of the direct, non-virtual base - /// classes. If any bases are not given offsets, the bases will be laid + /// classes. If any bases are not given offsets, the bases will be laid /// out according to the ABI. /// /// \param VirtualBaseOffsets The offset of each of the virtual base classes - /// (either direct or not). If any bases are not given offsets, the bases will + /// (either direct or not). If any bases are not given offsets, the bases will /// be laid out according to the ABI. - /// + /// /// \returns true if the record layout was provided, false otherwise. bool layoutRecordType(const RecordDecl *Record, @@ -287,9 +287,9 @@ public: /// Read the set of referenced selectors known to the /// external Sema source. /// - /// The external source should append its own referenced selectors to the - /// given vector of selectors. Note that this routine - /// may be invoked multiple times; the external source should take care not + /// The external source should append its own referenced selectors to the + /// given vector of selectors. Note that this routine + /// may be invoked multiple times; the external source should take care not /// to introduce the same selectors repeatedly. void ReadReferencedSelectors(SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override; @@ -298,7 +298,7 @@ public: /// external Sema source. /// /// The external source should append its own weak, undeclared identifiers to - /// the given vector. Note that this routine may be invoked multiple times; + /// the given vector. Note that this routine may be invoked multiple times; /// the external source should take care not to introduce the same identifiers /// repeatedly. void ReadWeakUndeclaredIdentifiers( @@ -356,7 +356,7 @@ public: // isa/cast/dyn_cast support static bool classof(const MultiplexExternalSemaSource*) { return true; } //static bool classof(const ExternalSemaSource*) { return true; } -}; +}; } // end namespace clang diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index f75faf049625d..6ded010ee8ed7 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -62,7 +62,7 @@ class Sema; /// Succeeded, but refers to a deleted function. OR_Deleted }; - + enum OverloadCandidateDisplayKind { /// Requests that all candidates be shown. Viable candidates will /// be printed first. @@ -107,7 +107,7 @@ class Sema; /// Integral conversions (C++ [conv.integral]) ICK_Integral_Conversion, - /// Floating point conversions (C++ [conv.double] + /// Floating point conversions (C++ [conv.double] ICK_Floating_Conversion, /// Complex conversions (C99 6.3.1.6) @@ -252,7 +252,7 @@ class Sema; /// Whether the qualification conversion involves a change in the /// Objective-C lifetime (for automatic reference counting). unsigned QualificationIncludesObjCLifetime : 1; - + /// IncompatibleObjC - Whether this is an Objective-C conversion /// that we should warn about (if we actually use it). unsigned IncompatibleObjC : 1; @@ -268,21 +268,21 @@ class Sema; /// Whether this is an lvalue reference binding (otherwise, it's /// an rvalue reference binding). unsigned IsLvalueReference : 1; - + /// Whether we're binding to a function lvalue. unsigned BindsToFunctionLvalue : 1; - + /// Whether we're binding to an rvalue. unsigned BindsToRvalue : 1; - - /// Whether this binds an implicit object argument to a + + /// Whether this binds an implicit object argument to a /// non-static member function without a ref-qualifier. unsigned BindsImplicitObjectArgumentWithoutRefQualifier : 1; - + /// Whether this binds a reference to an object with a different /// Objective-C lifetime qualifier. unsigned ObjCLifetimeConversionBinding : 1; - + /// FromType - The type that this conversion is converting /// from. This is an opaque pointer that can be translated into a /// QualType. @@ -303,13 +303,13 @@ class Sema; void setFromType(QualType T) { FromTypePtr = T.getAsOpaquePtr(); } - void setToType(unsigned Idx, QualType T) { + void setToType(unsigned Idx, QualType T) { assert(Idx < 3 && "To type index is out of range"); - ToTypePtrs[Idx] = T.getAsOpaquePtr(); + ToTypePtrs[Idx] = T.getAsOpaquePtr(); } void setAllToTypes(QualType T) { - ToTypePtrs[0] = T.getAsOpaquePtr(); + ToTypePtrs[0] = T.getAsOpaquePtr(); ToTypePtrs[1] = ToTypePtrs[0]; ToTypePtrs[2] = ToTypePtrs[0]; } @@ -324,11 +324,11 @@ class Sema; } void setAsIdentityConversion(); - + bool isIdentityConversion() const { return Second == ICK_Identity && Third == ICK_Identity; } - + ImplicitConversionRank getRank() const; NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, @@ -562,7 +562,7 @@ class Sema; new (this) ImplicitConversionSequence(Other); return *this; } - + ~ImplicitConversionSequence() { destruct(); } @@ -571,7 +571,7 @@ class Sema; assert(isInitialized() && "querying uninitialized conversion"); return Kind(ConversionKind); } - + /// Return a ranking of the implicit conversion sequence /// kind, where smaller ranks represent better conversion /// sequences. @@ -581,11 +581,11 @@ class Sema; /// per C++ [over.best.ics]p10. unsigned getKindRank() const { switch (getKind()) { - case StandardConversion: + case StandardConversion: return 0; case UserDefinedConversion: - case AmbiguousConversion: + case AmbiguousConversion: return 1; case EllipsisConversion: @@ -781,7 +781,7 @@ class Sema; union { DeductionFailureInfo DeductionFailure; - + /// FinalConversion - For a conversion function (where Function is /// a CXXConversionDecl), the standard conversion that occurs /// after the call to the overload candidate to convert the result diff --git a/include/clang/Sema/ParsedAttr.h b/include/clang/Sema/ParsedAttr.h index 3f293247787ca..cfb91af78370f 100644 --- a/include/clang/Sema/ParsedAttr.h +++ b/include/clang/Sema/ParsedAttr.h @@ -179,7 +179,7 @@ private: /// The location of the 'unavailable' keyword in an /// availability attribute. SourceLocation UnavailableLoc; - + const Expr *MessageExpr; /// Arguments, if any, are stored immediately following the object. @@ -265,7 +265,7 @@ private: Args[2] = Parm3; AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } - + /// Constructor for type_tag_for_datatype attribute. ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, @@ -352,7 +352,7 @@ public: void operator delete(void *) = delete; - enum Kind { + enum Kind { #define PARSED_ATTR(NAME) AT_##NAME, #include "clang/Sema/AttrParsedAttrList.inc" #undef PARSED_ATTR @@ -363,11 +363,11 @@ public: IdentifierInfo *getName() const { return AttrName; } SourceLocation getLoc() const { return AttrRange.getBegin(); } SourceRange getRange() const { return AttrRange; } - + bool hasScope() const { return ScopeName; } IdentifierInfo *getScopeName() const { return ScopeName; } SourceLocation getScopeLoc() const { return ScopeLoc; } - + bool hasParsedType() const { return HasParsedType; } /// Is this the Microsoft __declspec(property) attribute? @@ -473,7 +473,7 @@ public: assert(getKind() == AT_Availability && "Not an availability attribute"); return UnavailableLoc; } - + const Expr * getMessageExpr() const { assert(getKind() == AT_Availability && "Not an availability attribute"); return MessageExpr; diff --git a/include/clang/Sema/ParsedTemplate.h b/include/clang/Sema/ParsedTemplate.h index f79157ba813e6..258b2291d2602 100644 --- a/include/clang/Sema/ParsedTemplate.h +++ b/include/clang/Sema/ParsedTemplate.h @@ -25,7 +25,7 @@ #include <cstdlib> #include <new> -namespace clang { +namespace clang { /// Represents the parsed form of a C++ template argument. class ParsedTemplateArgument { public: @@ -39,87 +39,87 @@ namespace clang { Template }; - /// Build an empty template argument. + /// Build an empty template argument. /// /// This template argument is invalid. ParsedTemplateArgument() : Kind(Type), Arg(nullptr) { } - + /// Create a template type argument or non-type template argument. /// /// \param Arg the template type argument or non-type template argument. /// \param Loc the location of the type. ParsedTemplateArgument(KindType Kind, void *Arg, SourceLocation Loc) : Kind(Kind), Arg(Arg), Loc(Loc) { } - + /// Create a template template argument. /// /// \param SS the C++ scope specifier that precedes the template name, if /// any. /// - /// \param Template the template to which this template template + /// \param Template the template to which this template template /// argument refers. /// /// \param TemplateLoc the location of the template name. ParsedTemplateArgument(const CXXScopeSpec &SS, - ParsedTemplateTy Template, - SourceLocation TemplateLoc) + ParsedTemplateTy Template, + SourceLocation TemplateLoc) : Kind(ParsedTemplateArgument::Template), - Arg(Template.getAsOpaquePtr()), + Arg(Template.getAsOpaquePtr()), SS(SS), Loc(TemplateLoc), EllipsisLoc() { } - + /// Determine whether the given template argument is invalid. bool isInvalid() const { return Arg == nullptr; } - + /// Determine what kind of template argument we have. KindType getKind() const { return Kind; } - + /// Retrieve the template type argument's type. ParsedType getAsType() const { assert(Kind == Type && "Not a template type argument"); return ParsedType::getFromOpaquePtr(Arg); } - + /// Retrieve the non-type template argument's expression. Expr *getAsExpr() const { assert(Kind == NonType && "Not a non-type template argument"); return static_cast<Expr*>(Arg); } - + /// Retrieve the template template argument's template name. ParsedTemplateTy getAsTemplate() const { assert(Kind == Template && "Not a template template argument"); return ParsedTemplateTy::getFromOpaquePtr(Arg); } - + /// Retrieve the location of the template argument. SourceLocation getLocation() const { return Loc; } - + /// Retrieve the nested-name-specifier that precedes the template /// name in a template template argument. const CXXScopeSpec &getScopeSpec() const { - assert(Kind == Template && + assert(Kind == Template && "Only template template arguments can have a scope specifier"); return SS; } - + /// Retrieve the location of the ellipsis that makes a template /// template argument into a pack expansion. SourceLocation getEllipsisLoc() const { - assert(Kind == Template && + assert(Kind == Template && "Only template template arguments can have an ellipsis"); return EllipsisLoc; } - + /// Retrieve a pack expansion of the given template template /// argument. /// /// \param EllipsisLoc The location of the ellipsis. ParsedTemplateArgument getTemplatePackExpansion( SourceLocation EllipsisLoc) const; - + private: KindType Kind; - + /// The actual template argument representation, which may be /// an \c Sema::TypeTy* (for a type), an Expr* (for an /// expression), or an Sema::TemplateTy (for a template). @@ -136,14 +136,14 @@ namespace clang { /// argument (turning it into a template template argument expansion). SourceLocation EllipsisLoc; }; - + /// Information about a template-id annotation /// token. /// - /// A template-id annotation token contains the template declaration, - /// template arguments, whether those template arguments were types, - /// expressions, or template names, and the source locations for important - /// tokens. All of the information about template arguments is allocated + /// A template-id annotation token contains the template declaration, + /// template arguments, whether those template arguments were types, + /// expressions, or template names, and the source locations for important + /// tokens. All of the information about template arguments is allocated /// directly after this structure. struct TemplateIdAnnotation final : private llvm::TrailingObjects<TemplateIdAnnotation, @@ -159,34 +159,34 @@ namespace clang { /// TemplateNameLoc - The location of the template name within the /// source. SourceLocation TemplateNameLoc; - + /// FIXME: Temporarily stores the name of a specialization IdentifierInfo *Name; - + /// FIXME: Temporarily stores the overloaded operator kind. OverloadedOperatorKind Operator; - + /// The declaration of the template corresponding to the /// template-name. ParsedTemplateTy Template; - + /// The kind of template that Template refers to. TemplateNameKind Kind; - + /// The location of the '<' before the template argument /// list. SourceLocation LAngleLoc; - + /// The location of the '>' after the template argument /// list. SourceLocation RAngleLoc; - + /// NumArgs - The number of template arguments. unsigned NumArgs; - + /// Retrieves a pointer to the template arguments - ParsedTemplateArgument *getTemplateArgs() { - return getTrailingObjects<ParsedTemplateArgument>(); + ParsedTemplateArgument *getTemplateArgs() { + return getTrailingObjects<ParsedTemplateArgument>(); } /// Creates a new TemplateIdAnnotation with NumArgs arguments and @@ -213,7 +213,7 @@ namespace clang { getTemplateArgs(), getTemplateArgs() + NumArgs, [](ParsedTemplateArgument &A) { A.~ParsedTemplateArgument(); }); this->~TemplateIdAnnotation(); - free(this); + free(this); } private: TemplateIdAnnotation(const TemplateIdAnnotation &) = delete; @@ -239,7 +239,7 @@ namespace clang { /// Retrieves the range of the given template parameter lists. SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, - unsigned NumParams); + unsigned NumParams); } // end namespace clang #endif // LLVM_CLANG_SEMA_PARSEDTEMPLATE_H diff --git a/include/clang/Sema/Scope.h b/include/clang/Sema/Scope.h index a3379ff34f123..11fa0362124b9 100644 --- a/include/clang/Sema/Scope.h +++ b/include/clang/Sema/Scope.h @@ -89,7 +89,7 @@ public: /// This is a scope that corresponds to the Objective-C /// \@catch statement. AtCatchScope = 0x400, - + /// This scope corresponds to an Objective-C method body. /// It always has FnScope and DeclScope set as well. ObjCMethodScope = 0x800, @@ -347,7 +347,7 @@ public: } return false; } - + /// isInObjcMethodScope - Return true if this scope is, or is contained in, an /// Objective-C method body. Note that this method is not constant time. bool isInObjcMethodScope() const { diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h index 5eac2845fd33e..5925fd6ccead9 100644 --- a/include/clang/Sema/ScopeInfo.h +++ b/include/clang/Sema/ScopeInfo.h @@ -85,12 +85,12 @@ public: PartialDiagnostic PD; SourceLocation Loc; const Stmt *stmt; - + PossiblyUnreachableDiag(const PartialDiagnostic &PD, SourceLocation Loc, const Stmt *stmt) : PD(PD), Loc(Loc), stmt(stmt) {} }; - + /// Retains information about a function, method, or block that is /// currently being parsed. class FunctionScopeInfo { @@ -101,7 +101,7 @@ protected: SK_Lambda, SK_CapturedRegion }; - + public: /// What kind of scope we are describing. ScopeKind Kind : 3; @@ -206,7 +206,7 @@ public: /// current function scope. These diagnostics are vetted for reachability /// prior to being emitted. SmallVector<PossiblyUnreachableDiag, 4> PossiblyUnreachableDiags; - + /// A list of parameters which have the nonnull attribute and are /// modified in the function. llvm::SmallPtrSet<const ParmVarDecl *, 8> ModifiedNonNullParams; @@ -633,9 +633,9 @@ public: QualType ReturnType; void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, - SourceLocation Loc, SourceLocation EllipsisLoc, + SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy) { - Captures.push_back(Capture(Var, isBlock, isByref, isNested, Loc, + Captures.push_back(Capture(Var, isBlock, isByref, isNested, Loc, EllipsisLoc, CaptureType, Cpy)); CaptureMap[Var] = Captures.size(); } @@ -655,13 +655,13 @@ public: /// Determine whether the C++ 'this' is captured. bool isCXXThisCaptured() const { return CXXThisCaptureIndex != 0; } - + /// Retrieve the capture of C++ 'this', if it has been captured. Capture &getCXXThisCapture() { assert(isCXXThisCaptured() && "this has not been captured"); return Captures[CXXThisCaptureIndex - 1]; } - + /// Determine whether the given variable has been captured. bool isCaptured(VarDecl *Var) const { return CaptureMap.count(Var); @@ -684,7 +684,7 @@ public: return Captures[Known->second - 1]; } - static bool classof(const FunctionScopeInfo *FSI) { + static bool classof(const FunctionScopeInfo *FSI) { return FSI->Kind == SK_Block || FSI->Kind == SK_Lambda || FSI->Kind == SK_CapturedRegion; } @@ -694,7 +694,7 @@ public: class BlockScopeInfo final : public CapturingScopeInfo { public: BlockDecl *TheDecl; - + /// TheScope - This is the scope for the block itself, which contains /// arguments etc. Scope *TheScope; @@ -711,8 +711,8 @@ public: ~BlockScopeInfo() override; - static bool classof(const FunctionScopeInfo *FSI) { - return FSI->Kind == SK_Block; + static bool classof(const FunctionScopeInfo *FSI) { + return FSI->Kind == SK_Block; } }; @@ -796,12 +796,12 @@ public: /// Whether the lambda contains an unexpanded parameter pack. bool ContainsUnexpandedParameterPack = false; - /// If this is a generic lambda, use this as the depth of + /// If this is a generic lambda, use this as the depth of /// each 'auto' parameter, during initial AST construction. unsigned AutoTemplateParameterDepth = 0; /// Store the list of the auto parameters for a generic lambda. - /// If this is a generic lambda, store the list of the auto + /// If this is a generic lambda, store the list of the auto /// parameters converted into TemplateTypeParmDecls into a vector /// that can be used to construct the generic lambda's template /// parameter list, during initial AST construction. @@ -811,19 +811,19 @@ public: /// list has been created (from the AutoTemplateParams) then /// store a reference to it (cache it to avoid reconstructing it). TemplateParameterList *GLTemplateParameterList = nullptr; - + /// Contains all variable-referring-expressions (i.e. DeclRefExprs /// or MemberExprs) that refer to local variables in a generic lambda /// or a lambda in a potentially-evaluated-if-used context. - /// - /// Potentially capturable variables of a nested lambda that might need - /// to be captured by the lambda are housed here. + /// + /// Potentially capturable variables of a nested lambda that might need + /// to be captured by the lambda are housed here. /// This is specifically useful for generic lambdas or /// lambdas within a potentially evaluated-if-used context. /// If an enclosing variable is named in an expression of a lambda nested - /// within a generic lambda, we don't always know know whether the variable + /// within a generic lambda, we don't always know know whether the variable /// will truly be odr-used (i.e. need to be captured) by that nested lambda, - /// until its instantiation. But we still need to capture it in the + /// until its instantiation. But we still need to capture it in the /// enclosing lambda if all intervening lambdas can capture the variable. llvm::SmallVector<Expr*, 4> PotentiallyCapturingExprs; @@ -867,10 +867,10 @@ public: return !AutoTemplateParams.empty() || GLTemplateParameterList; } - /// Add a variable that might potentially be captured by the - /// lambda and therefore the enclosing lambdas. - /// - /// This is also used by enclosing lambda's to speculatively capture + /// Add a variable that might potentially be captured by the + /// lambda and therefore the enclosing lambdas. + /// + /// This is also used by enclosing lambda's to speculatively capture /// variables that nested lambda's - depending on their enclosing /// specialization - might need to capture. /// Consider: @@ -879,7 +879,7 @@ public: /// void foo() { /// const int x = 10; /// auto L = [=](auto a) { // capture 'x' - /// return [=](auto b) { + /// return [=](auto b) { /// f(x, a); // we may or may not need to capture 'x' /// }; /// }; @@ -888,46 +888,46 @@ public: assert(isa<DeclRefExpr>(VarExpr) || isa<MemberExpr>(VarExpr)); PotentiallyCapturingExprs.push_back(VarExpr); } - + void addPotentialThisCapture(SourceLocation Loc) { PotentialThisCaptureLocation = Loc; } - bool hasPotentialThisCapture() const { - return PotentialThisCaptureLocation.isValid(); + bool hasPotentialThisCapture() const { + return PotentialThisCaptureLocation.isValid(); } /// Mark a variable's reference in a lambda as non-odr using. /// - /// For generic lambdas, if a variable is named in a potentially evaluated - /// expression, where the enclosing full expression is dependent then we + /// For generic lambdas, if a variable is named in a potentially evaluated + /// expression, where the enclosing full expression is dependent then we /// must capture the variable (given a default capture). - /// This is accomplished by recording all references to variables - /// (DeclRefExprs or MemberExprs) within said nested lambda in its array of + /// This is accomplished by recording all references to variables + /// (DeclRefExprs or MemberExprs) within said nested lambda in its array of /// PotentialCaptures. All such variables have to be captured by that lambda, /// except for as described below. - /// If that variable is usable as a constant expression and is named in a - /// manner that does not involve its odr-use (e.g. undergoes + /// If that variable is usable as a constant expression and is named in a + /// manner that does not involve its odr-use (e.g. undergoes /// lvalue-to-rvalue conversion, or discarded) record that it is so. Upon the /// act of analyzing the enclosing full expression (ActOnFinishFullExpr) /// if we can determine that the full expression is not instantiation- - /// dependent, then we can entirely avoid its capture. + /// dependent, then we can entirely avoid its capture. /// /// const int n = 0; /// [&] (auto x) { /// (void)+n + x; /// }; - /// Interestingly, this strategy would involve a capture of n, even though - /// it's obviously not odr-used here, because the full-expression is + /// Interestingly, this strategy would involve a capture of n, even though + /// it's obviously not odr-used here, because the full-expression is /// instantiation-dependent. It could be useful to avoid capturing such /// variables, even when they are referred to in an instantiation-dependent /// expression, if we can unambiguously determine that they shall never be /// odr-used. This would involve removal of the variable-referring-expression - /// from the array of PotentialCaptures during the lvalue-to-rvalue + /// from the array of PotentialCaptures during the lvalue-to-rvalue /// conversions. But per the working draft N3797, (post-chicago 2013) we must - /// capture such variables. + /// capture such variables. /// Before anyone is tempted to implement a strategy for not-capturing 'n', - /// consider the insightful warning in: + /// consider the insightful warning in: /// /cfe-commits/Week-of-Mon-20131104/092596.html /// "The problem is that the set of captures for a lambda is part of the ABI /// (since lambda layout can be made visible through inline functions and the @@ -937,32 +937,32 @@ public: /// building such a node. So we need a rule that anyone can implement and get /// exactly the same result". void markVariableExprAsNonODRUsed(Expr *CapturingVarExpr) { - assert(isa<DeclRefExpr>(CapturingVarExpr) + assert(isa<DeclRefExpr>(CapturingVarExpr) || isa<MemberExpr>(CapturingVarExpr)); NonODRUsedCapturingExprs.insert(CapturingVarExpr); } bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const { - assert(isa<DeclRefExpr>(CapturingVarExpr) + assert(isa<DeclRefExpr>(CapturingVarExpr) || isa<MemberExpr>(CapturingVarExpr)); return NonODRUsedCapturingExprs.count(CapturingVarExpr); } void removePotentialCapture(Expr *E) { PotentiallyCapturingExprs.erase( - std::remove(PotentiallyCapturingExprs.begin(), - PotentiallyCapturingExprs.end(), E), + std::remove(PotentiallyCapturingExprs.begin(), + PotentiallyCapturingExprs.end(), E), PotentiallyCapturingExprs.end()); } void clearPotentialCaptures() { PotentiallyCapturingExprs.clear(); PotentialThisCaptureLocation = SourceLocation(); } - unsigned getNumPotentialVariableCaptures() const { - return PotentiallyCapturingExprs.size(); + unsigned getNumPotentialVariableCaptures() const { + return PotentiallyCapturingExprs.size(); } - bool hasPotentialCaptures() const { - return getNumPotentialVariableCaptures() || - PotentialThisCaptureLocation.isValid(); + bool hasPotentialCaptures() const { + return getNumPotentialVariableCaptures() || + PotentialThisCaptureLocation.isValid(); } // When passed the index, returns the VarDecl and Expr associated diff --git a/include/clang/Sema/SemaInternal.h b/include/clang/Sema/SemaInternal.h index 86ab703a5b3af..c55e16a27cd30 100644 --- a/include/clang/Sema/SemaInternal.h +++ b/include/clang/Sema/SemaInternal.h @@ -45,7 +45,7 @@ inline bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context) { const VarDecl *DefVD = nullptr; return !isa<ParmVarDecl>(Var) && Var->isUsableInConstantExpressions(Context) && - Var->getAnyInitializer(DefVD) && DefVD->checkInitIsICE(); + Var->getAnyInitializer(DefVD) && DefVD->checkInitIsICE(); } // Helper function to check whether D's attributes match current CUDA mode. @@ -60,13 +60,13 @@ inline bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D) { return isDeviceSideDecl == LangOpts.CUDAIsDevice; } -// Directly mark a variable odr-used. Given a choice, prefer to use -// MarkVariableReferenced since it does additional checks and then +// Directly mark a variable odr-used. Given a choice, prefer to use +// MarkVariableReferenced since it does additional checks and then // calls MarkVarDeclODRUsed. // If the variable must be captured: // - if FunctionScopeIndexToStopAt is null, capture it in the CurContext -// - else capture it in the DeclContext that maps to the -// *FunctionScopeIndexToStopAt on the FunctionScopeInfo stack. +// - else capture it in the DeclContext that maps to the +// *FunctionScopeIndexToStopAt on the FunctionScopeInfo stack. inline void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt) { @@ -81,10 +81,10 @@ inline void MarkVarDeclODRUsed(VarDecl *Var, old = Loc; } QualType CaptureType, DeclRefType; - SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit, + SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit, /*EllipsisLoc*/ SourceLocation(), - /*BuildAndDiagnose*/ true, - CaptureType, DeclRefType, + /*BuildAndDiagnose*/ true, + CaptureType, DeclRefType, FunctionScopeIndexToStopAt); Var->markUsed(SemaRef.Context); diff --git a/include/clang/Sema/SemaLambda.h b/include/clang/Sema/SemaLambda.h index dfdc4ebc3643d..8edb9b5c613d2 100644 --- a/include/clang/Sema/SemaLambda.h +++ b/include/clang/Sema/SemaLambda.h @@ -25,11 +25,11 @@ class FunctionScopeInfo; class Sema; /// Examines the FunctionScopeInfo stack to determine the nearest -/// enclosing lambda (to the current lambda) that is 'capture-capable' for +/// enclosing lambda (to the current lambda) that is 'capture-capable' for /// the variable referenced in the current lambda (i.e. \p VarToCapture). /// If successful, returns the index into Sema's FunctionScopeInfo stack -/// of the capture-capable lambda's LambdaScopeInfo. -/// See Implementation for more detailed comments. +/// of the capture-capable lambda's LambdaScopeInfo. +/// See Implementation for more detailed comments. Optional<unsigned> getStackIndexOfNearestEnclosingCaptureCapableLambda( ArrayRef<const sema::FunctionScopeInfo *> FunctionScopes, diff --git a/include/clang/Sema/Template.h b/include/clang/Sema/Template.h index c0dee3e82d58a..39b08e934be4d 100644 --- a/include/clang/Sema/Template.h +++ b/include/clang/Sema/Template.h @@ -46,7 +46,7 @@ class VarDecl; /// Data structure that captures multiple levels of template argument /// lists for use in template instantiation. /// - /// Multiple levels of template arguments occur when instantiating the + /// Multiple levels of template arguments occur when instantiating the /// definitions of member templates. For example: /// /// \code @@ -63,7 +63,7 @@ class VarDecl; /// list will contain a template argument list (int) at depth 0 and a /// template argument list (17) at depth 1. class MultiLevelTemplateArgumentList { - /// The template argument list at a certain template depth + /// The template argument list at a certain template depth using ArgList = ArrayRef<TemplateArgument>; /// The template argument lists, stored from the innermost template @@ -73,17 +73,17 @@ class VarDecl; /// The number of outer levels of template arguments that are not /// being substituted. unsigned NumRetainedOuterLevels = 0; - + public: /// Construct an empty set of template argument lists. MultiLevelTemplateArgumentList() = default; - + /// Construct a single-level template argument list. - explicit + explicit MultiLevelTemplateArgumentList(const TemplateArgumentList &TemplateArgs) { addOuterTemplateArguments(&TemplateArgs); } - + /// Determine the number of levels in this template argument /// list. unsigned getNumLevels() const { @@ -102,7 +102,7 @@ class VarDecl; assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].size()); return TemplateArgumentLists[getNumLevels() - Depth - 1][Index]; } - + /// Determine whether there is a non-NULL template argument at the /// given depth and index. /// @@ -112,13 +112,13 @@ class VarDecl; if (Depth < NumRetainedOuterLevels) return false; - + if (Index >= TemplateArgumentLists[getNumLevels() - Depth - 1].size()) return false; - + return !(*this)(Depth, Index).isNull(); } - + /// Clear out a specific template argument. void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg) { @@ -128,8 +128,8 @@ class VarDecl; TemplateArgumentLists[getNumLevels() - Depth - 1][Index]) = Arg; } - - /// Add a new outermost level to the multi-level template argument + + /// Add a new outermost level to the multi-level template argument /// list. void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs) { addOuterTemplateArguments(ArgList(TemplateArgs->data(), @@ -153,21 +153,21 @@ class VarDecl; /// Retrieve the innermost template argument list. const ArgList &getInnermost() const { - return TemplateArgumentLists.front(); + return TemplateArgumentLists.front(); } }; - + /// The context in which partial ordering of function templates occurs. enum TPOC { /// Partial ordering of function templates for a function call. TPOC_Call, - /// Partial ordering of function templates for a call to a + /// Partial ordering of function templates for a call to a /// conversion function. TPOC_Conversion, /// Partial ordering of function templates in other contexts, e.g., - /// taking the address of a function template or matching a function + /// taking the address of a function template or matching a function /// template specialization to a function template. TPOC_Other }; @@ -261,7 +261,7 @@ class VarDecl; /// The set of argument packs we've allocated. SmallVector<DeclArgumentPack *, 1> ArgumentPacks; - + /// The outer scope, which contains local variable /// definitions from some other instantiation (that may not be /// relevant to this particular scope). @@ -273,17 +273,17 @@ class VarDecl; /// Whether to combine this scope with the outer scope, such that /// lookup will search our outer scope. bool CombineWithOuterScope; - + /// If non-NULL, the template parameter pack that has been /// partially substituted per C++0x [temp.arg.explicit]p9. NamedDecl *PartiallySubstitutedPack = nullptr; - + /// If \c PartiallySubstitutedPack is non-null, the set of /// explicitly-specified template arguments in that pack. - const TemplateArgument *ArgsInPartiallySubstitutedPack; - - /// If \c PartiallySubstitutedPack, the number of - /// explicitly-specified template arguments in + const TemplateArgument *ArgsInPartiallySubstitutedPack; + + /// If \c PartiallySubstitutedPack, the number of + /// explicitly-specified template arguments in /// ArgsInPartiallySubstitutedPack. unsigned NumArgsInPartiallySubstitutedPack; @@ -301,17 +301,17 @@ class VarDecl; ~LocalInstantiationScope() { Exit(); } - + const Sema &getSema() const { return SemaRef; } /// Exit this local instantiation scope early. void Exit() { if (Exited) return; - + for (unsigned I = 0, N = ArgumentPacks.size(); I != N; ++I) delete ArgumentPacks[I]; - + SemaRef.CurrentInstantiationScope = Outer; Exited = true; } @@ -381,9 +381,9 @@ class VarDecl; void InstantiatedLocal(const Decl *D, Decl *Inst); void InstantiatedLocalPackArg(const Decl *D, ParmVarDecl *Inst); void MakeInstantiatedLocalArgPack(const Decl *D); - + /// Note that the given parameter pack has been partially substituted - /// via explicit specification of template arguments + /// via explicit specification of template arguments /// (C++0x [temp.arg.explicit]p9). /// /// \param Pack The parameter pack, which will always be a template @@ -394,7 +394,7 @@ class VarDecl; /// /// \param NumExplicitArgs The number of explicitly-specified template /// arguments provided for this parameter pack. - void SetPartiallySubstitutedPack(NamedDecl *Pack, + void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs); @@ -416,7 +416,7 @@ class VarDecl; }; class TemplateDeclInstantiator - : public DeclVisitor<TemplateDeclInstantiator, Decl *> + : public DeclVisitor<TemplateDeclInstantiator, Decl *> { Sema &SemaRef; Sema::ArgumentPackSubstitutionIndexRAII SubstIndex; @@ -562,7 +562,7 @@ class VarDecl; template<typename T> Decl *instantiateUnresolvedUsingDecl(T *D, bool InstantiatingPackElement = false); - }; + }; } // namespace clang diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 76bc818557a96..430fc48379fef 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -55,16 +55,16 @@ namespace serialization { const unsigned VERSION_MINOR = 0; /// An ID number that refers to an identifier in an AST file. - /// + /// /// The ID numbers of identifiers are consecutive (in order of discovery) /// and start at 1. 0 is reserved for NULL. using IdentifierID = uint32_t; - + /// An ID number that refers to a declaration in an AST file. /// /// The ID numbers of declarations are consecutive (in order of - /// discovery), with values below NUM_PREDEF_DECL_IDS being reserved. - /// At the start of a chain of precompiled headers, declaration ID 1 is + /// discovery), with values below NUM_PREDEF_DECL_IDS being reserved. + /// At the start of a chain of precompiled headers, declaration ID 1 is /// used for the translation unit declaration. using DeclID = uint32_t; @@ -98,14 +98,14 @@ namespace serialization { TypeID asTypeID(unsigned FastQuals) const { if (Idx == uint32_t(-1)) return TypeID(-1); - + return (Idx << Qualifiers::FastWidth) | FastQuals; } static TypeIdx fromTypeID(TypeID ID) { if (ID == TypeID(-1)) return TypeIdx(-1); - + return TypeIdx(ID >> Qualifiers::FastWidth); } }; @@ -124,7 +124,7 @@ namespace serialization { } static unsigned getHashValue(QualType T) { - assert(!T.getLocalFastQualifiers() && + assert(!T.getLocalFastQualifiers() && "hash invalid for types with fast quals"); uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()); return (unsigned(v) >> 4) ^ (unsigned(v) >> 9); @@ -155,8 +155,8 @@ namespace serialization { /// The number of predefined selector IDs. const unsigned int NUM_PREDEF_SELECTOR_IDS = 1; - - /// An ID number that refers to a set of CXXBaseSpecifiers in an + + /// An ID number that refers to a set of CXXBaseSpecifiers in an /// AST file. using CXXBaseSpecifiersID = uint32_t; @@ -170,7 +170,7 @@ namespace serialization { /// An ID number that refers to a submodule in a module file. using SubmoduleID = uint32_t; - + /// The number of predefined submodule IDs. const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; @@ -311,7 +311,7 @@ namespace serialization { /// generate the AST file, including both its file ID and its /// name. ORIGINAL_FILE, - + /// The directory that the PCH was originally created in. ORIGINAL_PCH_DIR, @@ -706,15 +706,15 @@ namespace serialization { enum PreprocessorDetailRecordTypes { /// Describes a macro expansion within the preprocessing record. PPD_MACRO_EXPANSION = 0, - + /// Describes a macro definition within the preprocessing record. PPD_MACRO_DEFINITION = 1, - + /// Describes an inclusion directive within the preprocessing /// record. PPD_INCLUSION_DIRECTIVE = 2 }; - + /// Record types used within a submodule description block. enum SubmoduleRecordTypes { /// Metadata for submodules as a whole. @@ -737,11 +737,11 @@ namespace serialization { /// Specifies an umbrella directory. SUBMODULE_UMBRELLA_DIR = 5, - /// Specifies the submodules that are imported by this + /// Specifies the submodules that are imported by this /// submodule. SUBMODULE_IMPORTS = 6, - /// Specifies the submodules that are re-exported from this + /// Specifies the submodules that are re-exported from this /// submodule. SUBMODULE_EXPORTS = 7, @@ -1203,7 +1203,7 @@ namespace serialization { /// C ucontext_t typedef type SPECIAL_TYPE_UCONTEXT_T = 7 }; - + /// The number of special type IDs. const unsigned NumSpecialTypeIDs = 8; @@ -1211,7 +1211,7 @@ namespace serialization { /// /// These declaration IDs correspond to predefined declarations in the AST /// context, such as the NULL declaration ID. Such declarations are never - /// actually serialized, since they will be built by the AST context when + /// actually serialized, since they will be built by the AST context when /// it is created. enum PredefinedDeclIDs { /// The NULL declaration. @@ -1279,7 +1279,7 @@ namespace serialization { /// Record code for a list of local redeclarations of a declaration. /// This can occur within DECLTYPES_BLOCK_ID. const unsigned int LOCAL_REDECLARATIONS = 50; - + /// Record codes for each kind of declaration. /// /// These constants describe the declaration records that can occur within @@ -1539,7 +1539,7 @@ namespace serialization { /// /// These constants describe the records that describe statements /// or expressions. These records occur within type and declarations - /// block, so they begin with record values of 128. Each constant + /// block, so they begin with record values of 128. Each constant /// describes a record for a specific statement or expression class in the /// AST. enum StmtCode { @@ -1741,7 +1741,7 @@ namespace serialization { EXPR_OBJC_BOXED_EXPRESSION, EXPR_OBJC_ARRAY_LITERAL, EXPR_OBJC_DICTIONARY_LITERAL, - + /// An ObjCEncodeExpr record. EXPR_OBJC_ENCODE, @@ -1800,7 +1800,7 @@ namespace serialization { EXPR_OBJC_AVAILABILITY_CHECK, // C++ - + /// A CXXCatchStmt record. STMT_CXX_CATCH, @@ -1862,9 +1862,9 @@ namespace serialization { EXPR_CXX_NEW, // CXXNewExpr EXPR_CXX_DELETE, // CXXDeleteExpr EXPR_CXX_PSEUDO_DESTRUCTOR, // CXXPseudoDestructorExpr - + EXPR_EXPR_WITH_CLEANUPS, // ExprWithCleanups - + EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr @@ -1878,7 +1878,7 @@ namespace serialization { EXPR_BINARY_CONDITIONAL_OPERATOR, // BinaryConditionalOperator EXPR_TYPE_TRAIT, // TypeTraitExpr EXPR_ARRAY_TYPE_TRAIT, // ArrayTypeTraitIntExpr - + EXPR_PACK_EXPANSION, // PackExpansionExpr EXPR_SIZEOF_PACK, // SizeOfPackExpr EXPR_SUBST_NON_TYPE_TEMPLATE_PARM, // SubstNonTypeTemplateParmExpr @@ -1888,7 +1888,7 @@ namespace serialization { EXPR_CXX_FOLD, // CXXFoldExpr // CUDA - EXPR_CUDA_KERNEL_CALL, // CUDAKernelCallExpr + EXPR_CUDA_KERNEL_CALL, // CUDAKernelCallExpr // OpenCL EXPR_ASTYPE, // AsTypeExpr @@ -1998,22 +1998,22 @@ namespace serialization { // Offset into the array of redeclaration chains. unsigned Offset; - + friend bool operator<(const LocalRedeclarationsInfo &X, const LocalRedeclarationsInfo &Y) { return X.FirstID < Y.FirstID; } - + friend bool operator>(const LocalRedeclarationsInfo &X, const LocalRedeclarationsInfo &Y) { return X.FirstID > Y.FirstID; } - + friend bool operator<=(const LocalRedeclarationsInfo &X, const LocalRedeclarationsInfo &Y) { return X.FirstID <= Y.FirstID; } - + friend bool operator>=(const LocalRedeclarationsInfo &X, const LocalRedeclarationsInfo &Y) { return X.FirstID >= Y.FirstID; @@ -2027,22 +2027,22 @@ namespace serialization { // Offset into the array of category lists. unsigned Offset; - + friend bool operator<(const ObjCCategoriesInfo &X, const ObjCCategoriesInfo &Y) { return X.DefinitionID < Y.DefinitionID; } - + friend bool operator>(const ObjCCategoriesInfo &X, const ObjCCategoriesInfo &Y) { return X.DefinitionID > Y.DefinitionID; } - + friend bool operator<=(const ObjCCategoriesInfo &X, const ObjCCategoriesInfo &Y) { return X.DefinitionID <= Y.DefinitionID; } - + friend bool operator>=(const ObjCCategoriesInfo &X, const ObjCCategoriesInfo &Y) { return X.DefinitionID >= Y.DefinitionID; diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 82a74a64443d6..0eecb6f5d65ac 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -591,7 +591,7 @@ private: llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> PendingVisibleUpdates; - /// The set of C++ or Objective-C classes that have forward + /// The set of C++ or Objective-C classes that have forward /// declarations that have not yet been linked to their definitions. llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; @@ -662,10 +662,10 @@ private: /// This vector is indexed by the Submodule ID (-1). NULL submodule entries /// indicate that the particular submodule ID has not yet been loaded. SmallVector<Module *, 2> SubmodulesLoaded; - + using GlobalSubmoduleMapType = ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>; - + /// Mapping from global submodule IDs to the module file in which the /// submodule resides along with the offset that should be added to the /// global submodule ID to produce a local ID. @@ -678,12 +678,12 @@ private: /// A mapping from each of the hidden submodules to the deserialized /// declarations in that submodule that could be made visible. HiddenNamesMapType HiddenNamesMap; - + /// A module import, export, or conflict that hasn't yet been resolved. struct UnresolvedModuleRef { /// The file in which this module resides. ModuleFile *File; - + /// The module that is importing or exporting. Module *Mod; @@ -699,11 +699,11 @@ private: /// String data. StringRef String; }; - - /// The set of module imports and exports that still need to be + + /// The set of module imports and exports that still need to be /// resolved. SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs; - + /// A vector containing selectors that have already been loaded. /// /// This vector is indexed by the Selector ID (-1). NULL selector @@ -1056,7 +1056,7 @@ private: /// Objective-C protocols. std::deque<InterestingDecl> PotentiallyInterestingDecls; - /// The list of redeclaration chains that still need to be + /// The list of redeclaration chains that still need to be /// reconstructed, and the local offset to the corresponding list /// of redeclarations. SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains; @@ -1117,14 +1117,14 @@ private: using KeyDeclsMap = llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>; - + /// A mapping from canonical declarations to the set of global /// declaration IDs for key declaration that have been merged with that /// canonical declaration. A key declaration is a formerly-canonical /// declaration whose module did not import any other key declaration for that /// entity. These are the IDs that we use as keys when finding redecl chains. KeyDeclsMap KeyDecls; - + /// A mapping from DeclContexts to the semantic DeclContext that we /// are treating as the definition of the entity. This is used, for instance, /// when merging implicit instantiations of class templates across modules. @@ -1625,7 +1625,7 @@ public: /// Determine whether we tried to load the global index, but failed, /// e.g., because it is out-of-date or does not exist. bool isGlobalIndexUnavailable() const; - + /// Initializes the ASTContext void InitializeContext(); @@ -1654,7 +1654,7 @@ public: /// Retrieve the name of the original source file name for the primary /// module file. StringRef getOriginalSourceFile() { - return ModuleMgr.getPrimaryModule().OriginalSourceFileName; + return ModuleMgr.getPrimaryModule().OriginalSourceFileName; } /// Retrieve the name of the original source file name directly from @@ -1741,7 +1741,7 @@ public: unsigned getTotalNumSubmodules() const { return static_cast<unsigned>(SubmodulesLoaded.size()); } - + /// Returns the number of selectors found in the chain. unsigned getTotalNumSelectors() const { return static_cast<unsigned>(SelectorsLoaded.size()); @@ -1839,15 +1839,15 @@ public: return cast_or_null<T>(GetLocalDecl(F, LocalID)); } - /// Map a global declaration ID into the declaration ID used to + /// Map a global declaration ID into the declaration ID used to /// refer to this declaration within the given module fule. /// /// \returns the global ID of the given declaration as known in the given /// module file. - serialization::DeclID + serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID); - + /// Reads a declaration ID from the given position in a record in the /// given module. /// @@ -2067,7 +2067,7 @@ public: /// Retrieve the global submodule ID given a module and its local ID /// number. - serialization::SubmoduleID + serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); /// Retrieve the submodule that corresponds to a global submodule ID. diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index a93579930ff52..7ff5d65bd7d0e 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -416,7 +416,7 @@ private: /// The set of Objective-C class that have categories we /// should serialize. llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories; - + /// The set of declarations that may have redeclaration chains that /// need to be serialized. llvm::SmallVector<const Decl *, 16> Redeclarations; @@ -424,7 +424,7 @@ private: /// A cache of the first local declaration for "interesting" /// redeclaration chains. llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache; - + /// Mapping from SwitchCase statements to IDs. llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs; @@ -475,7 +475,7 @@ private: void WriteHeaderSearch(const HeaderSearch &HS); void WritePreprocessorDetail(PreprocessingRecord &PPRec); void WriteSubmodules(Module *WritingModule); - + void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag, bool isModule); diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h index 2f909965db7ef..73bf2ed10f044 100644 --- a/include/clang/Serialization/ContinuousRangeMap.h +++ b/include/clang/Serialization/ContinuousRangeMap.h @@ -72,14 +72,14 @@ public: "Must insert keys in order."); Rep.push_back(Val); } - + void insertOrReplace(const value_type &Val) { iterator I = std::lower_bound(Rep.begin(), Rep.end(), Val, Compare()); if (I != Rep.end() && I->first == Val.first) { I->second = Val.second; return; } - + Rep.insert(I, Val); } @@ -106,7 +106,7 @@ public: reference back() { return Rep.back(); } const_reference back() const { return Rep.back(); } - + /// An object that helps properly build a continuous range map /// from a set of values. class Builder { @@ -116,7 +116,7 @@ public: explicit Builder(ContinuousRangeMap &Self) : Self(Self) {} Builder(const Builder&) = delete; Builder &operator=(const Builder&) = delete; - + ~Builder() { llvm::sort(Self.Rep.begin(), Self.Rep.end(), Compare()); std::unique(Self.Rep.begin(), Self.Rep.end(), @@ -128,7 +128,7 @@ public: return A == B; }); } - + void insert(const value_type &Val) { Self.Rep.push_back(Val); } diff --git a/include/clang/Serialization/GlobalModuleIndex.h b/include/clang/Serialization/GlobalModuleIndex.h index f48d0cf17c493..d47fe9517d762 100644 --- a/include/clang/Serialization/GlobalModuleIndex.h +++ b/include/clang/Serialization/GlobalModuleIndex.h @@ -115,7 +115,7 @@ class GlobalModuleIndex { /// The number of identifier lookup hits, where we recognize the /// identifier. unsigned NumIdentifierLookupHits; - + /// Internal constructor. Use \c readIndex() to read an index. explicit GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer, llvm::BitstreamCursor Cursor); @@ -167,7 +167,7 @@ public: /// A set of module files in which we found a result. typedef llvm::SmallPtrSet<ModuleFile *, 4> HitSet; - + /// Look for all of the module files with information about the given /// identifier, e.g., a global function, variable, or type with that name. /// diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 653981b1427ca..d6e78e693109e 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -173,7 +173,7 @@ public: /// The generation of which this module file is a part. unsigned Generation; - + /// The memory buffer that stores the data associated with /// this AST file, owned by the PCMCache in the ModuleManager. llvm::MemoryBuffer *Buffer; @@ -358,17 +358,17 @@ public: /// the header files. void *HeaderFileInfoTable = nullptr; - // === Submodule information === + // === Submodule information === /// The number of submodules in this module. unsigned LocalNumSubmodules = 0; - + /// Base submodule ID for submodules local to this module. serialization::SubmoduleID BaseSubmoduleID = 0; - + /// Remapping table for submodule IDs in this module. ContinuousRangeMap<uint32_t, int, 2> SubmoduleRemap; - + // === Selectors === /// The number of selectors new to this file. @@ -431,13 +431,13 @@ public: const serialization::DeclID *FileSortedDecls = nullptr; unsigned NumFileSortedDecls = 0; - /// Array of category list location information within this + /// Array of category list location information within this /// module file, sorted by the definition ID. const serialization::ObjCCategoriesInfo *ObjCCategoriesMap = nullptr; - + /// The number of redeclaration info entries in ObjCCategoriesMap. unsigned LocalNumObjCCategoriesInMap = 0; - + /// The Objective-C category lists for categories known to this /// module. SmallVector<uint64_t, 1> ObjCCategories; diff --git a/include/clang/Serialization/ModuleFileExtension.h b/include/clang/Serialization/ModuleFileExtension.h index f7bdcec598f16..f70218e329af1 100644 --- a/include/clang/Serialization/ModuleFileExtension.h +++ b/include/clang/Serialization/ModuleFileExtension.h @@ -26,7 +26,7 @@ namespace clang { class ASTReader; class ASTWriter; class Sema; - + namespace serialization { class ModuleFile; } // end namespace serialization @@ -128,7 +128,7 @@ public: /// Abstract base class that reads a module file extension block from /// a module file. /// -/// Subclasses +/// Subclasses class ModuleFileExtensionReader { ModuleFileExtension *Extension; diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h index e101e60b21a3d..cfc9a2ef112c2 100644 --- a/include/clang/Serialization/ModuleManager.h +++ b/include/clang/Serialization/ModuleManager.h @@ -82,7 +82,7 @@ class ModuleManager { /// The visitation order. SmallVector<ModuleFile *, 4> VisitOrder; - + /// The list of module files that both we and the global module index /// know about. /// @@ -150,13 +150,13 @@ public: /// Forward iterator end-point to traverse all loaded modules ModuleIterator end() { return Chain.end(); } - + /// Const forward iterator to traverse all loaded modules. ModuleConstIterator begin() const { return Chain.begin(); } /// Const forward iterator end-point to traverse all loaded modules ModuleConstIterator end() const { return Chain.end(); } - + /// Reverse iterator to traverse all loaded modules. ModuleReverseIterator rbegin() { return Chain.rbegin(); } @@ -172,14 +172,14 @@ public: /// Returns the primary module associated with the manager, that is, /// the first module loaded ModuleFile &getPrimaryModule() { return *Chain[0]; } - + /// Returns the primary module associated with the manager, that is, /// the first module loaded. ModuleFile &getPrimaryModule() const { return *Chain[0]; } - + /// Returns the module associated with the given index ModuleFile &operator[](unsigned Index) const { return *Chain[Index]; } - + /// Returns the module associated with the given file name. ModuleFile *lookupByFileName(StringRef FileName) const; @@ -191,7 +191,7 @@ public: /// Returns the in-memory (virtual file) buffer with the given name std::unique_ptr<llvm::MemoryBuffer> lookupBuffer(StringRef Name); - + /// Number of modules loaded unsigned size() const { return Chain.size(); } diff --git a/include/clang/StaticAnalyzer/Checkers/Checkers.td b/include/clang/StaticAnalyzer/Checkers/Checkers.td index ab0e4af1361b9..9e53460f6e934 100644 --- a/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -276,6 +276,10 @@ def ReturnUndefChecker : Checker<"UndefReturn">, let ParentPackage = Cplusplus in { +def InnerPointerChecker : Checker<"InnerPointer">, + HelpText<"Check for inner pointers of C++ containers used after re/deallocation">, + DescFile<"InnerPointerChecker.cpp">; + def NewDeleteChecker : Checker<"NewDelete">, HelpText<"Check for double-free and use-after-free problems. Traces memory managed by new/delete.">, DescFile<"MallocChecker.cpp">; @@ -305,10 +309,6 @@ def DeleteWithNonVirtualDtorChecker : Checker<"DeleteWithNonVirtualDtor">, "destructor in their base class">, DescFile<"DeleteWithNonVirtualDtorChecker.cpp">; -def InnerPointerChecker : Checker<"InnerPointer">, - HelpText<"Check for inner pointers of C++ containers used after re/deallocation">, - DescFile<"InnerPointerChecker.cpp">; - def IteratorRangeChecker : Checker<"IteratorRange">, HelpText<"Check for iterators used outside their valid ranges">, DescFile<"IteratorChecker.cpp">; @@ -440,7 +440,7 @@ def MallocOverflowSecurityChecker : Checker<"MallocOverflow">, DescFile<"MallocOverflowSecurityChecker.cpp">; // Operating systems specific PROT_READ/PROT_WRITE values is not implemented, -// the defaults are correct for several common operating systems though, +// the defaults are correct for several common operating systems though, // but may need to be overridden via the related analyzer-config flags. def MmapWriteExecChecker : Checker<"MmapWriteExec">, HelpText<"Warn on mmap() calls that are both writable and executable">, diff --git a/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h b/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h index e5e857e970297..f5a06394b1874 100644 --- a/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h +++ b/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h @@ -136,7 +136,7 @@ public: // by inlining the function NoRetHard }; - + /// Determines the object kind of a tracked object. enum ObjKind { /// Indicates that the tracked object is a CF object. This is @@ -153,30 +153,30 @@ public: private: Kind K; ObjKind O; - + RetEffect(Kind k, ObjKind o = AnyObj) : K(k), O(o) {} - + public: Kind getKind() const { return K; } - + ObjKind getObjKind() const { return O; } - + bool isOwned() const { return K == OwnedSymbol || K == OwnedWhenTrackedReceiver; } - + bool notOwned() const { return K == NotOwnedSymbol; } - + bool operator==(const RetEffect &Other) const { return K == Other.K && O == Other.O; } - + static RetEffect MakeOwnedWhenTrackedReceiver() { return RetEffect(OwnedWhenTrackedReceiver, ObjC); } - + static RetEffect MakeOwned(ObjKind o) { return RetEffect(OwnedSymbol, o); } diff --git a/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h index 9d292cfddb0c8..7586f7e0835bd 100644 --- a/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -130,23 +130,23 @@ public: /// Pair of checker name and enable/disable. std::vector<std::pair<std::string, bool>> CheckersControlList; - + /// A key-value table of use-specified configuration values. ConfigTable Config; AnalysisStores AnalysisStoreOpt = RegionStoreModel; AnalysisConstraints AnalysisConstraintsOpt = RangeConstraintsModel; AnalysisDiagClients AnalysisDiagOpt = PD_HTML; AnalysisPurgeMode AnalysisPurgeOpt = PurgeStmt; - + std::string AnalyzeSpecificFunction; /// Store full compiler invocation for reproducible instructions in the /// generated report. std::string FullCompilerInvocation; - + /// The maximum number of times the analyzer visits a block. unsigned maxBlockVisitOnPath; - + /// Disable all analyzer checks. /// /// This flag allows one to disable analyzer checks on the code processed by @@ -170,21 +170,21 @@ public: /// precision until we have a better way to lazily evaluate such logic. The /// downside is that it eagerly bifurcates paths. unsigned eagerlyAssumeBinOpBifurcation : 1; - + unsigned TrimGraph : 1; unsigned visualizeExplodedGraphWithGraphViz : 1; unsigned visualizeExplodedGraphWithUbiGraph : 1; unsigned UnoptimizedCFG : 1; unsigned PrintStats : 1; - + /// Do not re-analyze paths leading to exhausted nodes with a different /// strategy. We get better code coverage when retry is enabled. unsigned NoRetryExhausted : 1; - + /// The inlining stack depth limit. // Cap the stack depth at 4 calls (5 stack frames, base + 4 calls). unsigned InlineMaxStackDepth = 5; - + /// The mode of function selection used during inlining. AnalysisInliningMode InliningMode = NoRedundancy; @@ -211,7 +211,7 @@ private: UMK_Deep = 2 }; - /// Controls the high-level analyzer mode, which influences the default + /// Controls the high-level analyzer mode, which influences the default /// settings for some of the lower-level config options (such as IPAMode). /// \sa getUserMode UserModeKind UserMode = UMK_NotSet; @@ -221,7 +221,7 @@ private: /// Controls which C++ member functions will be considered for inlining. CXXInlineableMemberKind CXXMemberInliningMode; - + /// \sa includeImplicitDtorsInCFG Optional<bool> IncludeImplicitDtorsInCFG; @@ -239,7 +239,7 @@ private: /// \sa mayInlineCXXStandardLibrary Optional<bool> InlineCXXStandardLibrary; - + /// \sa includeScopesInCFG Optional<bool> IncludeScopesInCFG; @@ -722,9 +722,9 @@ public: /// the option will be ignored. bool shouldElideConstructors(); }; - + using AnalyzerOptionsRef = IntrusiveRefCntPtr<AnalyzerOptions>; - + } // namespace clang #endif // LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 111e1d1e8e20a..9041f4c1afbd4 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -74,7 +74,7 @@ using DiagnosticForConsumerMapTy = /// This class provides an interface through which checkers can create /// individual bug reports. class BugReport : public llvm::ilist_node<BugReport> { -public: +public: class NodeResolver { virtual void anchor(); @@ -102,7 +102,7 @@ protected: PathDiagnosticLocation Location; PathDiagnosticLocation UniqueingLocation; const Decl *UniqueingDecl; - + const ExplodedNode *ErrorNode = nullptr; SmallVector<SourceRange, 4> Ranges; ExtraTextList ExtraText; @@ -220,12 +220,12 @@ public: /// Disable all path pruning when generating a PathDiagnostic. void disablePathPruning() { DoNotPrunePath = true; } - + void markInteresting(SymbolRef sym); void markInteresting(const MemRegion *R); void markInteresting(SVal V); void markInteresting(const LocationContext *LC); - + bool isInteresting(SymbolRef sym); bool isInteresting(const MemRegion *R); bool isInteresting(SVal V); @@ -251,11 +251,11 @@ public: void markInvalid(const void *Tag, const void *Data) { Invalidations.insert(std::make_pair(Tag, Data)); } - + /// Return the canonical declaration, be it a method or class, where /// this issue semantically occurred. const Decl *getDeclWithIssue() const; - + /// Specifically set the Decl where an issue occurred. This isn't necessary /// for BugReports that cover a path as it will be automatically inferred. void setDeclWithIssue(const Decl *declWithIssue) { @@ -290,7 +290,7 @@ public: /// This allows for addition of meta data to the diagnostic. /// - /// Currently, only the HTMLDiagnosticClient knows how to display it. + /// Currently, only the HTMLDiagnosticClient knows how to display it. void addExtraText(StringRef S) { ExtraText.push_back(S); } @@ -310,7 +310,7 @@ public: PathDiagnosticLocation getUniqueingLocation() const { return UniqueingLocation; } - + /// Get the declaration containing the uniqueing location. const Decl *getUniqueingDecl() const { return UniqueingDecl; diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h index 92118b0fbee25..da019f83c214b 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -246,7 +246,7 @@ public: BugReport &BR) override; }; -/// When a region containing undefined value or '0' value is passed +/// When a region containing undefined value or '0' value is passed /// as an argument in a call, marks the call as interesting. /// /// As a result, BugReporter will not prune the path through the function even diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h index c723f31aec266..3c1f8f718a3bf 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h @@ -52,7 +52,7 @@ public: // FIXME: This is a workaround to ensure that the correct check name is used // The check names are set after the constructors are run. // In case the BugType object is initialized in the checker's ctor - // the Check field will be empty. To circumvent this problem we use + // the Check field will be empty. To circumvent this problem we use // CheckerBase whenever it is possible. StringRef CheckName = Checker ? Checker->getCheckName().getName() : Check.getName(); diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h index b18d3c9b3031c..b0bb12feba20b 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -71,17 +71,17 @@ public: PDFileEntry(llvm::FoldingSetNodeID &NodeID) : NodeID(NodeID) {} using ConsumerFiles = std::vector<std::pair<StringRef, StringRef>>; - + /// A vector of <consumer,file> pairs. ConsumerFiles files; - + /// A precomputed hash tag used for uniquing PDFileEntry objects. const llvm::FoldingSetNodeID NodeID; /// Used for profiling in the FoldingSet. void Profile(llvm::FoldingSetNodeID &ID) { ID = NodeID; } }; - + class FilesMade { llvm::BumpPtrAllocator Alloc; llvm::FoldingSet<PDFileEntry> Set; @@ -94,7 +94,7 @@ public: void addDiagnostic(const PathDiagnostic &PD, StringRef ConsumerName, StringRef fileName); - + PDFileEntry::ConsumerFiles *getFiles(const PathDiagnostic &PD); }; @@ -127,7 +127,7 @@ public: virtual PathGenerationScheme getGenerationScheme() const { return Minimal; } virtual bool supportsLogicalOpControlFlow() const { return false; } - + /// Return true if the PathDiagnosticConsumer supports individual /// PathDiagnostics that span multiple files. virtual bool supportsCrossFileDiagnostics() const { return false; } @@ -322,12 +322,12 @@ public: void flatten(); const SourceManager& getManager() const { assert(isValid()); return *SM; } - + void Profile(llvm::FoldingSetNodeID &ID) const; void dump() const; - /// Given an exploded node, retrieve the statement that should be used + /// Given an exploded node, retrieve the statement that should be used /// for the diagnostic location. static const Stmt *getStmt(const ExplodedNode *N); @@ -354,7 +354,7 @@ public: Start.flatten(); End.flatten(); } - + void Profile(llvm::FoldingSetNodeID &ID) const { Start.Profile(ID); End.Profile(ID); @@ -378,7 +378,7 @@ private: /// In the containing bug report, this piece is the last piece from /// the main source file. bool LastInMainSourceFile = false; - + /// A constant string that can be used to tag the PathDiagnosticPiece, /// typically with the identification of the creator. The actual pointer /// value is meant to be an identifier; the string itself is useful for @@ -401,14 +401,14 @@ public: /// Tag this PathDiagnosticPiece with the given C-string. void setTag(const char *tag) { Tag = tag; } - + /// Return the opaque tag (if any) on the PathDiagnosticPiece. const void *getTag() const { return Tag.data(); } - + /// Return the string representation of the tag. This is useful /// for debugging. StringRef getTagStr() const { return Tag; } - + /// getDisplayHint - Return a hint indicating where the diagnostic should /// be displayed by the PathDiagnosticConsumer. DisplayHint getDisplayHint() const { return Hint; } @@ -488,7 +488,7 @@ public: /// Interface for classes constructing Stack hints. /// -/// If a PathDiagnosticEvent occurs in a different frame than the final +/// If a PathDiagnosticEvent occurs in a different frame than the final /// diagnostic the hints can be used to summarize the effect of the call. class StackHintGenerator { public: @@ -563,12 +563,12 @@ public: bool hasCallStackHint() { return (bool)CallStackHint; } - /// Produce the hint for the given node. The node contains + /// Produce the hint for the given node. The node contains /// information about the call for which the diagnostic can be generated. std::string getCallStackMessage(const ExplodedNode *N) { if (CallStackHint) return CallStackHint->getMessage(N); - return {}; + return {}; } void dump() const override; @@ -605,16 +605,16 @@ class PathDiagnosticCallPiece : public PathDiagnosticPiece { public: PathDiagnosticLocation callEnter; PathDiagnosticLocation callEnterWithin; - PathDiagnosticLocation callReturn; + PathDiagnosticLocation callReturn; PathPieces path; ~PathDiagnosticCallPiece() override; const Decl *getCaller() const { return Caller; } - + const Decl *getCallee() const { return Callee; } void setCallee(const CallEnter &CE, const SourceManager &SM); - + bool hasCallStackMessage() { return !CallStackMessage.empty(); } void setCallStackMessage(StringRef st) { CallStackMessage = st; } @@ -725,7 +725,7 @@ public: ~PathDiagnosticMacroPiece() override; PathPieces subPieces; - + bool containsEvent() const; void flattenLocations() override { @@ -779,7 +779,7 @@ class PathDiagnostic : public llvm::FoldingSetNode { PathPieces pathImpl; SmallVector<PathPieces *, 3> pathStack; - + /// Important bug uniqueing location. /// The location info is useful to differentiate between bugs. PathDiagnosticLocation UniqueingLoc; @@ -796,22 +796,22 @@ public: const Decl *DeclToUnique, std::unique_ptr<FilesToLineNumsMap> ExecutedLines); ~PathDiagnostic(); - + const PathPieces &path; - /// Return the path currently used by builders for constructing the + /// Return the path currently used by builders for constructing the /// PathDiagnostic. PathPieces &getActivePath() { if (pathStack.empty()) return pathImpl; return *pathStack.back(); } - + /// Return a mutable version of 'path'. PathPieces &getMutablePieces() { return pathImpl; } - + /// Return the unrolled size of the path. unsigned full_size(); @@ -898,7 +898,7 @@ public: /// Two diagnostics with the same issue along different paths will generate /// different profiles. void FullProfile(llvm::FoldingSetNodeID &ID) const; -}; +}; } // namespace ento diff --git a/include/clang/StaticAnalyzer/Core/Checker.h b/include/clang/StaticAnalyzer/Core/Checker.h index 45b7a61139ea7..8484cfe4c9560 100644 --- a/include/clang/StaticAnalyzer/Core/Checker.h +++ b/include/clang/StaticAnalyzer/Core/Checker.h @@ -63,7 +63,7 @@ public: class EndOfTranslationUnit { template <typename CHECKER> static void _checkEndOfTranslationUnit(void *checker, - const TranslationUnitDecl *TU, + const TranslationUnitDecl *TU, AnalysisManager& mgr, BugReporter &BR) { ((const CHECKER *)checker)->checkEndOfTranslationUnit(TU, mgr, BR); @@ -331,7 +331,7 @@ public: class RegionChanges { template <typename CHECKER> - static ProgramStateRef + static ProgramStateRef _checkRegionChanges(void *checker, ProgramStateRef state, const InvalidatedSymbols *invalidated, @@ -370,7 +370,7 @@ class PointerEscape { Kind); InvalidatedSymbols RegularEscape; - for (InvalidatedSymbols::const_iterator I = Escaped.begin(), + for (InvalidatedSymbols::const_iterator I = Escaped.begin(), E = Escaped.end(); I != E; ++I) if (!ETraits->hasTrait(*I, RegionAndSymbolInvalidationTraits::TK_PreserveContents) && @@ -410,7 +410,7 @@ class ConstPointerEscape { return State; InvalidatedSymbols ConstEscape; - for (InvalidatedSymbols::const_iterator I = Escaped.begin(), + for (InvalidatedSymbols::const_iterator I = Escaped.begin(), E = Escaped.end(); I != E; ++I) if (ETraits->hasTrait(*I, RegionAndSymbolInvalidationTraits::TK_PreserveContents) && @@ -436,7 +436,7 @@ public: } }; - + template <typename EVENT> class Event { template <typename CHECKER> @@ -504,7 +504,7 @@ public: /// Dump checker name to stream. raw_ostream& operator<<(raw_ostream &Out, const CheckerBase &Checker); -/// Tag that can use a checker name as a message provider +/// Tag that can use a checker name as a message provider /// (see SimpleProgramPointTag). class CheckerProgramPointTag : public SimpleProgramPointTag { public: diff --git a/include/clang/StaticAnalyzer/Core/CheckerManager.h b/include/clang/StaticAnalyzer/Core/CheckerManager.h index 33a794061a384..7c353326be46e 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerManager.h +++ b/include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -86,7 +86,7 @@ enum PointerEscapeKind { /// argument to a function. PSK_IndirectEscapeOnCall, - /// The reason for pointer escape is unknown. For example, + /// The reason for pointer escape is unknown. For example, /// a region containing this pointer is invalidated. PSK_EscapeOther }; @@ -353,18 +353,18 @@ public: /// /// This notifies the checkers about pointer escape, which occurs whenever /// the analyzer cannot track the symbol any more. For example, as a - /// result of assigning a pointer into a global or when it's passed to a + /// result of assigning a pointer into a global or when it's passed to a /// function call the analyzer cannot model. - /// + /// /// \param State The state at the point of escape. /// \param Escaped The list of escaped symbols. - /// \param Call The corresponding CallEvent, if the symbols escape as + /// \param Call The corresponding CallEvent, if the symbols escape as /// parameters to the given call. /// \param Kind The reason of pointer escape. - /// \param ITraits Information about invalidation for a particular + /// \param ITraits Information about invalidation for a particular /// region/symbol. /// \returns Checkers can modify the state by returning a new one. - ProgramStateRef + ProgramStateRef runCheckersForPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, const CallEvent *Call, @@ -381,7 +381,7 @@ public: void runCheckersForEvalCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &CE, ExprEngine &Eng); - + /// Run checkers for the entire Translation Unit. void runCheckersOnEndOfTranslationUnit(const TranslationUnitDecl *TU, AnalysisManager &mgr, @@ -419,21 +419,21 @@ public: //===----------------------------------------------------------------------===// using CheckStmtFunc = CheckerFn<void (const Stmt *, CheckerContext &)>; - + using CheckObjCMessageFunc = CheckerFn<void (const ObjCMethodCall &, CheckerContext &)>; using CheckCallFunc = CheckerFn<void (const CallEvent &, CheckerContext &)>; - + using CheckLocationFunc = CheckerFn<void (const SVal &location, bool isLoad, const Stmt *S, CheckerContext &)>; - + using CheckBindFunc = CheckerFn<void (const SVal &location, const SVal &val, const Stmt *S, CheckerContext &)>; - + using CheckEndAnalysisFunc = CheckerFn<void (ExplodedGraph &, BugReporter &, ExprEngine &)>; @@ -441,18 +441,18 @@ public: using CheckEndFunctionFunc = CheckerFn<void (const ReturnStmt *, CheckerContext &)>; - + using CheckBranchConditionFunc = CheckerFn<void (const Stmt *, CheckerContext &)>; using CheckNewAllocatorFunc = CheckerFn<void (const CXXNewExpr *, SVal, CheckerContext &)>; - + using CheckDeadSymbolsFunc = CheckerFn<void (SymbolReaper &, CheckerContext &)>; - + using CheckLiveSymbolsFunc = CheckerFn<void (ProgramStateRef,SymbolReaper &)>; - + using CheckRegionChangesFunc = CheckerFn<ProgramStateRef (ProgramStateRef, const InvalidatedSymbols *symbols, @@ -460,17 +460,17 @@ public: ArrayRef<const MemRegion *> Regions, const LocationContext *LCtx, const CallEvent *Call)>; - + using CheckPointerEscapeFunc = CheckerFn<ProgramStateRef (ProgramStateRef, const InvalidatedSymbols &Escaped, const CallEvent *Call, PointerEscapeKind Kind, RegionAndSymbolInvalidationTraits *ITraits)>; - + using EvalAssumeFunc = CheckerFn<ProgramStateRef (ProgramStateRef, const SVal &cond, bool assumption)>; - + using EvalCallFunc = CheckerFn<bool (const CallExpr *, CheckerContext &)>; using CheckEndOfTranslationUnit = @@ -531,7 +531,7 @@ public: template <typename EVENT> void _registerListenerForEvent(CheckEventFunc checkfn) { EventInfo &info = Events[getTag<EVENT>()]; - info.Checkers.push_back(checkfn); + info.Checkers.push_back(checkfn); } template <typename EVENT> @@ -636,7 +636,7 @@ private: EventInfo() = default; }; - + using EventsTy = llvm::DenseMap<EventTag, EventInfo>; EventsTy Events; }; diff --git a/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h b/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h index e981871ae4e08..2d13bf34cd15c 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h +++ b/include/clang/StaticAnalyzer/Core/CheckerOptInfo.h @@ -28,7 +28,7 @@ class CheckerOptInfo { public: CheckerOptInfo(StringRef name, bool enable) : Name(name), Enable(enable), Claimed(false) { } - + StringRef getName() const { return Name; } bool isEnabled() const { return Enable; } bool isDisabled() const { return !isEnabled(); } diff --git a/include/clang/StaticAnalyzer/Core/CheckerRegistry.h b/include/clang/StaticAnalyzer/Core/CheckerRegistry.h index 912a601b61c49..d580dda73488d 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerRegistry.h +++ b/include/clang/StaticAnalyzer/Core/CheckerRegistry.h @@ -47,7 +47,7 @@ // The clang_registerCheckers function may add any number of checkers to the // registry. If any checkers require additional initialization, use the three- // argument form of CheckerRegistry::addChecker. -// +// // To load a checker plugin, specify the full path to the dynamic library as // the argument to the -load option in the cc1 frontend. You can then enable // your custom checker using the -analyzer-checker: diff --git a/include/clang/StaticAnalyzer/Core/IssueHash.h b/include/clang/StaticAnalyzer/Core/IssueHash.h index 8cb6631fae747..03997aae79ae6 100644 --- a/include/clang/StaticAnalyzer/Core/IssueHash.h +++ b/include/clang/StaticAnalyzer/Core/IssueHash.h @@ -29,7 +29,7 @@ class LangOptions; /// location. The bugtype and the name of the checker is also part of the hash. /// The last component is the string representation of the enclosing declaration /// of the associated location. -/// +/// /// In case a new hash is introduced, the old one should still be maintained for /// a while. One should not introduce a new hash for every change, it is /// possible to introduce experimental hashes that may change in the future. diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h b/include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h index 93edfcef2d5aa..243795e720f61 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h @@ -88,7 +88,7 @@ public: /// for 'unsigned char' (u8). RangeTestResultKind testInRange(const llvm::APSInt &Val, bool AllowMixedSign) const LLVM_READONLY; - + bool operator==(const APSIntType &Other) const { return BitWidth == Other.BitWidth && IsUnsigned == Other.IsUnsigned; } @@ -102,7 +102,7 @@ public: std::tie(Other.BitWidth, Other.IsUnsigned); } }; - + } // end ento namespace } // end clang namespace diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h b/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h index 02b335761e708..85369509efcd5 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h @@ -45,12 +45,12 @@ class AnalysisManager : public BugReporterData { public: AnalyzerOptions &options; - + AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags, const LangOptions &lang, const PathDiagnosticConsumers &Consumers, StoreManagerCreator storemgr, - ConstraintManagerCreator constraintmgr, + ConstraintManagerCreator constraintmgr, CheckerManager *checkerMgr, AnalyzerOptions &Options, CodeInjector* injector = nullptr); @@ -60,7 +60,7 @@ public: void ClearContexts() { AnaCtxMgr.clear(); } - + AnalysisDeclContextManager& getAnalysisDeclContextManager() { return AnaCtxMgr; } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h b/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h index 0bbc6500d6ec3..b72b158194c73 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h @@ -155,12 +155,12 @@ public: return getValue(TargetType.convert(From)); } - + const llvm::APSInt &Convert(QualType T, const llvm::APSInt &From) { APSIntType TargetType = getAPSIntType(T); if (TargetType == APSIntType(From)) return From; - + return getValue(TargetType.convert(From)); } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h b/include/clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h index b94dadff23427..5e831095abc75 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/BlockCounter.h @@ -35,7 +35,7 @@ class BlockCounter { public: BlockCounter() : Data(nullptr) {} - unsigned getNumVisited(const StackFrameContext *CallSite, + unsigned getNumVisited(const StackFrameContext *CallSite, unsigned BlockID) const; class Factory { @@ -45,7 +45,7 @@ public: ~Factory(); BlockCounter GetEmptyCounter(); - BlockCounter IncrementCount(BlockCounter BC, + BlockCounter IncrementCount(BlockCounter BC, const StackFrameContext *CallSite, unsigned BlockID); }; diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index 9c667f912e9fd..9078fb94d2821 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -29,6 +29,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h" #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h" @@ -117,12 +118,12 @@ public: } }; -/// \class RuntimeDefinition +/// \class RuntimeDefinition /// Defines the runtime definition of the called function. -/// -/// Encapsulates the information we have about which Decl will be used +/// +/// Encapsulates the information we have about which Decl will be used /// when the call is executed on the given path. When dealing with dynamic -/// dispatch, the information is based on DynamicTypeInfo and might not be +/// dispatch, the information is based on DynamicTypeInfo and might not be /// precise. class RuntimeDefinition { /// The Declaration of the function which could be called at runtime. @@ -141,13 +142,13 @@ public: RuntimeDefinition(const Decl *InD, const MemRegion *InR): D(InD), R(InR) {} const Decl *getDecl() { return D; } - - /// Check if the definition we have is precise. - /// If not, it is possible that the call dispatches to another definition at + + /// Check if the definition we have is precise. + /// If not, it is possible that the call dispatches to another definition at /// execution time. bool mayHaveOtherDefinitions() { return R != nullptr; } - - /// When other definitions are possible, returns the region whose runtime type + + /// When other definitions are possible, returns the region whose runtime type /// determines the method definition. const MemRegion *getDispatchRegion() { return R; } }; @@ -404,6 +405,46 @@ public: /// \p D must not be null. static bool isVariadic(const Decl *D); + /// Returns AnalysisDeclContext for the callee stack frame. + /// Currently may fail; returns null on failure. + AnalysisDeclContext *getCalleeAnalysisDeclContext() const; + + /// Returns the callee stack frame. That stack frame will only be entered + /// during analysis if the call is inlined, but it may still be useful + /// in intermediate calculations even if the call isn't inlined. + /// May fail; returns null on failure. + const StackFrameContext *getCalleeStackFrame() const; + + /// Returns memory location for a parameter variable within the callee stack + /// frame. May fail; returns null on failure. + const VarRegion *getParameterLocation(unsigned Index) const; + + /// Returns true if on the current path, the argument was constructed by + /// calling a C++ constructor over it. This is an internal detail of the + /// analysis which doesn't necessarily represent the program semantics: + /// if we are supposed to construct an argument directly, we may still + /// not do that because we don't know how (i.e., construction context is + /// unavailable in the CFG or not supported by the analyzer). + bool isArgumentConstructedDirectly(unsigned Index) const { + // This assumes that the object was not yet removed from the state. + return ExprEngine::getObjectUnderConstruction( + getState(), {getOriginExpr(), Index}, getCalleeStackFrame()).hasValue(); + } + + /// Some calls have parameter numbering mismatched from argument numbering. + /// This function converts an argument index to the corresponding + /// parameter index. Returns None is the argument doesn't correspond + /// to any parameter variable. + Optional<unsigned> getAdjustedParameterIndex(unsigned ArgumentIndex) const { + if (dyn_cast_or_null<CXXOperatorCallExpr>(getOriginExpr()) && + dyn_cast_or_null<CXXMethodDecl>(getDecl())) { + // For member operator calls argument 0 on the expression corresponds + // to implicit this-parameter on the declaration. + return (ArgumentIndex > 0) ? Optional<unsigned>(ArgumentIndex - 1) : None; + } + return ArgumentIndex; + } + // Iterator access to formal parameters and their types. private: struct GetTypeFn { @@ -628,7 +669,7 @@ protected: : AnyFunctionCall(D, St, LCtx) {} CXXInstanceCall(const CXXInstanceCall &Other) = default; - void getExtraInvalidatedValues(ValueList &Values, + void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override; public: diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index f3a0ca7b66081..ce2b711a4a1b9 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -51,7 +51,7 @@ namespace ento { /// be accessible from more than one translation unit. #define REGISTER_SET_WITH_PROGRAMSTATE(Name, Elem) \ REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, llvm::ImmutableSet<Elem>) - + /// Declares an immutable list of type \p NameTy, suitable for placement into /// the ProgramState. This is implementing using llvm::ImmutableList. /// @@ -83,7 +83,7 @@ public: /// If we are post visiting a call, this flag will be set if the /// call was inlined. In all other cases it will be false. const bool wasInlined; - + CheckerContext(NodeBuilder &builder, ExprEngine &eng, ExplodedNode *pred, @@ -110,7 +110,7 @@ public: StoreManager &getStoreManager() { return Eng.getStoreManager(); } - + /// Returns the previous node in the exploded graph, which includes /// the state of the program before the checker ran. Note, checkers should /// not retain the node in their state since the nodes might get invalidated. @@ -149,7 +149,7 @@ public: BugReporter &getBugReporter() { return Eng.getBugReporter(); } - + SourceManager &getSourceManager() { return getBugReporter().getSourceManager(); } @@ -308,7 +308,7 @@ public: static bool isCLibraryFunction(const FunctionDecl *FD, StringRef Name = StringRef()); - /// Depending on wither the location corresponds to a macro, return + /// Depending on wither the location corresponds to a macro, return /// either the macro name or the token spelling. /// /// This could be useful when checkers' logic depends on whether a function diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index 5755818cd9716..17369a85bfa30 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -64,7 +64,7 @@ class CoreEngine { public: using BlocksExhausted = std::vector<std::pair<BlockEdge, const ExplodedNode *>>; - + using BlocksAborted = std::vector<std::pair<const CFGBlock *, const ExplodedNode *>>; @@ -87,7 +87,7 @@ private: /// The locations where we stopped doing work because we visited a location /// too many times. BlocksExhausted blocksExhausted; - + /// The locations where we stopped because the engine aborted analysis, /// usually because it could not reason about something. BlocksAborted blocksAborted; @@ -141,7 +141,7 @@ public: /// Returns true if there is still simulation state on the worklist. bool ExecuteWorkListWithInitialState(const LocationContext *L, unsigned Steps, - ProgramStateRef InitState, + ProgramStateRef InitState, ExplodedNodeSet &Dst); /// Dispatch the work list item based on the given location information. @@ -152,8 +152,8 @@ public: // Functions for external checking of whether we have unfinished work bool wasBlockAborted() const { return !blocksAborted.empty(); } bool wasBlocksExhausted() const { return !blocksExhausted.empty(); } - bool hasWorkRemaining() const { return wasBlocksExhausted() || - WList->hasWork() || + bool hasWorkRemaining() const { return wasBlocksExhausted() || + WList->hasWork() || wasBlockAborted(); } /// Inform the CoreEngine that a basic block was aborted because @@ -161,7 +161,7 @@ public: void addAbortedBlock(const ExplodedNode *node, const CFGBlock *block) { blocksAborted.push_back(std::make_pair(block, node)); } - + WorkList *getWorkList() const { return WList.get(); } BlocksExhausted::const_iterator blocks_exhausted_begin() const { @@ -255,7 +255,7 @@ protected: /// Allow subclasses to finalize results before result_begin() is executed. virtual void finalizeResults() {} - + ExplodedNode *generateNodeImpl(const ProgramPoint &PP, ProgramStateRef State, ExplodedNode *Pred, @@ -474,7 +474,7 @@ class IndirectGotoNodeBuilder { ExplodedNode *Pred; public: - IndirectGotoNodeBuilder(ExplodedNode *pred, const CFGBlock *src, + IndirectGotoNodeBuilder(ExplodedNode *pred, const CFGBlock *src, const Expr *e, const CFGBlock *dispatch, CoreEngine* eng) : Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {} @@ -508,7 +508,7 @@ public: const Expr *getTarget() const { return E; } ProgramStateRef getState() const { return Pred->State; } - + const LocationContext *getLocationContext() const { return Pred->getLocationContext(); } @@ -562,7 +562,7 @@ public: const Expr *getCondition() const { return Condition; } ProgramStateRef getState() const { return Pred->State; } - + const LocationContext *getLocationContext() const { return Pred->getLocationContext(); } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h b/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h index d49aa81bc9585..77e35398077c7 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h @@ -40,14 +40,14 @@ public: const Stmt *getStmt() const { return first; } const LocationContext *getLocationContext() const { return second; } - + /// Profile an EnvironmentEntry for inclusion in a FoldingSet. static void Profile(llvm::FoldingSetNodeID &ID, const EnvironmentEntry &E) { ID.AddPointer(E.getStmt()); ID.AddPointer(E.getLocationContext()); } - + void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, *this); } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h index c12198db6598d..4e0c02e6d65b3 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -87,7 +87,7 @@ class ExplodedNode : public llvm::FoldingSetNode { // for the nodes in the group. // This is not a PointerIntPair in order to keep the storage type opaque. uintptr_t P; - + public: NodeGroup(bool Flag = false) : P(Flag) { assert(getFlag() == Flag); @@ -251,7 +251,7 @@ public: }; static void SetAuditor(Auditor* A); - + private: void replaceSuccessor(ExplodedNode *node) { Succs.replaceNode(node); } void replacePredecessor(ExplodedNode *node) { Preds.replaceNode(node); } @@ -286,18 +286,18 @@ protected: /// NumNodes - The number of nodes in the graph. unsigned NumNodes = 0; - + /// A list of recently allocated nodes that can potentially be recycled. NodeVector ChangedNodes; - + /// A list of nodes that can be reused. NodeVector FreeNodes; - + /// Determines how often nodes are reclaimed. /// /// If this is 0, nodes will never be reclaimed. unsigned ReclaimNodeInterval = 0; - + /// Counter to determine when to reclaim nodes. unsigned ReclaimCounter; diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 25849e94c8ff1..06a90fa847a6f 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -69,7 +69,7 @@ namespace cross_tu { class CrossTranslationUnitContext; } // namespace cross_tu - + namespace ento { class BasicValueFactory; @@ -117,7 +117,7 @@ private: cross_tu::CrossTranslationUnitContext &CTU; AnalysisManager &AMgr; - + AnalysisDeclContextManager &AnalysisDeclContexts; CoreEngine Engine; @@ -136,11 +136,11 @@ private: unsigned int currStmtIdx = 0; const NodeBuilderContext *currBldrCtx = nullptr; - + /// Helper object to determine if an Objective-C message expression /// implicitly never returns. ObjCNoReturn ObjCNoRet; - + /// Whether or not GC is enabled in this analysis. bool ObjCGCEnabled; @@ -173,7 +173,7 @@ public: /// state of the function call. Returns true if there is still simulation /// state on the worklist. bool ExecuteWorkListWithInitialState(const LocationContext *L, unsigned Steps, - ProgramStateRef InitState, + ProgramStateRef InitState, ExplodedNodeSet &Dst) { return Engine.ExecuteWorkListWithInitialState(L, Steps, InitState, Dst); } @@ -276,17 +276,17 @@ public: ExplodedNode *Pred, ExplodedNodeSet &Dst); void ProcessMemberDtor(const CFGMemberDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst); - void ProcessTemporaryDtor(const CFGTemporaryDtor D, + void ProcessTemporaryDtor(const CFGTemporaryDtor D, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// Called by CoreEngine when processing the entrance of a CFGBlock. void processCFGBlockEntrance(const BlockEdge &L, NodeBuilderWithSinks &nodeBuilder, ExplodedNode *Pred) override; - + /// ProcessBranch - Called by CoreEngine. Used to generate successor /// nodes by processing the 'effects' of a branch condition. - void processBranch(const Stmt *Condition, const Stmt *Term, + void processBranch(const Stmt *Condition, const Stmt *Term, NodeBuilderContext& BuilderCtx, ExplodedNode *Pred, ExplodedNodeSet &Dst, @@ -354,7 +354,7 @@ public: /// processRegionChanges - Called by ProgramStateManager whenever a change is made /// to the store. Used to update checkers that track region values. - ProgramStateRef + ProgramStateRef processRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef<const MemRegion *> ExplicitRegions, @@ -410,15 +410,15 @@ public: ExplodedNodeSet &Dst); /// VisitBlockExpr - Transfer function logic for BlockExprs. - void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, + void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// VisitLambdaExpr - Transfer function logic for LambdaExprs. - void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, + void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// VisitBinaryOperator - Transfer function logic for binary operators. - void VisitBinaryOperator(const BinaryOperator* B, ExplodedNode *Pred, + void VisitBinaryOperator(const BinaryOperator* B, ExplodedNode *Pred, ExplodedNodeSet &Dst); @@ -431,21 +431,21 @@ public: ExplodedNodeSet &Dst); /// VisitCompoundLiteralExpr - Transfer function logic for compound literals. - void VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, + void VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// Transfer function logic for DeclRefExprs and BlockDeclRefExprs. void VisitCommonDeclRefExpr(const Expr *DR, const NamedDecl *D, ExplodedNode *Pred, ExplodedNodeSet &Dst); - + /// VisitDeclStmt - Transfer function logic for DeclStmts. - void VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred, + void VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// VisitGuardedExpr - Transfer function logic for ?, __builtin_choose - void VisitGuardedExpr(const Expr *Ex, const Expr *L, const Expr *R, + void VisitGuardedExpr(const Expr *Ex, const Expr *L, const Expr *R, ExplodedNode *Pred, ExplodedNodeSet &Dst); - + void VisitInitListExpr(const InitListExpr *E, ExplodedNode *Pred, ExplodedNodeSet &Dst); @@ -454,7 +454,7 @@ public: ExplodedNodeSet &Dst); /// VisitMemberExpr - Transfer function for member expressions. - void VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred, + void VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// VisitAtomicExpr - Transfer function for builtin atomic expressions @@ -471,16 +471,16 @@ public: /// VisitObjCForCollectionStmt - Transfer function logic for /// ObjCForCollectionStmt. - void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S, + void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S, ExplodedNode *Pred, ExplodedNodeSet &Dst); void VisitObjCMessage(const ObjCMessageExpr *ME, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// VisitReturnStmt - Transfer function logic for return statements. - void VisitReturnStmt(const ReturnStmt *R, ExplodedNode *Pred, + void VisitReturnStmt(const ReturnStmt *R, ExplodedNode *Pred, ExplodedNodeSet &Dst); - + /// VisitOffsetOfExpr - Transfer function for offsetof. void VisitOffsetOfExpr(const OffsetOfExpr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst); @@ -490,7 +490,7 @@ public: ExplodedNode *Pred, ExplodedNodeSet &Dst); /// VisitUnaryOperator - Transfer function logic for unary operators. - void VisitUnaryOperator(const UnaryOperator* B, ExplodedNode *Pred, + void VisitUnaryOperator(const UnaryOperator* B, ExplodedNode *Pred, ExplodedNodeSet &Dst); /// Handle ++ and -- (both pre- and post-increment). @@ -505,7 +505,7 @@ public: void VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred, ExplodedNodeSet &Dst); - void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred, + void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred, ExplodedNodeSet & Dst); void VisitCXXConstructExpr(const CXXConstructExpr *E, ExplodedNode *Pred, @@ -528,15 +528,15 @@ public: /// Create a C++ temporary object for an rvalue. void CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, - ExplodedNode *Pred, + ExplodedNode *Pred, ExplodedNodeSet &Dst); - + /// evalEagerlyAssumeBinOpBifurcation - Given the nodes in 'Src', eagerly assume symbolic /// expressions of the form 'x != 0' and generate new nodes (stored in Dst) /// with those assumptions. - void evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, + void evalEagerlyAssumeBinOpBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, const Expr *Ex); - + static std::pair<const ProgramPointTag *, const ProgramPointTag *> geteagerlyAssumeBinOpBifurcationTags(); @@ -580,7 +580,15 @@ public: SVal LHS, SVal RHS, QualType T) { return svalBuilder.evalBinOp(ST, Op, LHS, RHS, T); } - + + /// By looking at a certain item that may be potentially part of an object's + /// ConstructionContext, retrieve such object's location. A particular + /// statement can be transparently passed as \p Item in most cases. + static Optional<SVal> + getObjectUnderConstruction(ProgramStateRef State, + const ConstructionContextItem &Item, + const LocationContext *LC); + protected: /// evalBind - Handle the semantics of binding a value to a specific location. /// This method is used by evalStore, VisitDeclStmt, and others. @@ -761,24 +769,17 @@ private: /// This allows, among other things, to keep bindings to variable's fields /// made within the constructor alive until its declaration actually /// goes into scope. - static ProgramStateRef addObjectUnderConstruction( - ProgramStateRef State, - llvm::PointerUnion<const Stmt *, const CXXCtorInitializer *> P, - const LocationContext *LC, SVal V); + static ProgramStateRef + addObjectUnderConstruction(ProgramStateRef State, + const ConstructionContextItem &Item, + const LocationContext *LC, SVal V); /// Mark the object sa fully constructed, cleaning up the state trait /// that tracks objects under construction. - static ProgramStateRef finishObjectConstruction( - ProgramStateRef State, - llvm::PointerUnion<const Stmt *, const CXXCtorInitializer *> P, - const LocationContext *LC); - - /// If the given statement corresponds to an object under construction, - /// being part of its construciton context, retrieve that object's location. - static Optional<SVal> getObjectUnderConstruction( - ProgramStateRef State, - llvm::PointerUnion<const Stmt *, const CXXCtorInitializer *> P, - const LocationContext *LC); + static ProgramStateRef + finishObjectConstruction(ProgramStateRef State, + const ConstructionContextItem &Item, + const LocationContext *LC); /// If the given expression corresponds to a temporary that was used for /// passing into an elidable copy/move constructor and that constructor diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h index f3846eba6b963..3a93aae5a9bc6 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -131,9 +131,9 @@ public: bool hasGlobalsOrParametersStorage() const; bool hasStackStorage() const; - + bool hasStackNonParametersStorage() const; - + bool hasStackParametersStorage() const; /// Compute the offset within the top level memory object. @@ -253,7 +253,7 @@ class StaticGlobalSpaceRegion : public GlobalsSpaceRegion { friend class MemRegionManager; const CodeTextRegion *CR; - + StaticGlobalSpaceRegion(MemRegionManager *mgr, const CodeTextRegion *cr) : GlobalsSpaceRegion(mgr, StaticGlobalSpaceRegionKind), CR(cr) { assert(cr); @@ -348,7 +348,7 @@ public: class HeapSpaceRegion : public MemSpaceRegion { friend class MemRegionManager; - + HeapSpaceRegion(MemRegionManager *mgr) : MemSpaceRegion(mgr, HeapSpaceRegionKind) {} @@ -359,7 +359,7 @@ public: return R->getKind() == HeapSpaceRegionKind; } }; - + class UnknownSpaceRegion : public MemSpaceRegion { friend class MemRegionManager; @@ -613,7 +613,7 @@ public: return R->getKind() == FunctionCodeRegionKind; } }; - + /// BlockCodeRegion - A region that represents code texts of blocks (closures). /// Blocks are represented with two kinds of regions. BlockCodeRegions /// represent the "code", while BlockDataRegions represent instances of blocks, @@ -643,7 +643,7 @@ public: QualType getLocationType() const override { return locTy; } - + const BlockDecl *getDecl() const { return BD; } @@ -658,7 +658,7 @@ public: return R->getKind() == BlockCodeRegionKind; } }; - + /// BlockDataRegion - A region that represents a block instance. /// Blocks are represented with two kinds of regions. BlockCodeRegions /// represent the "code", while BlockDataRegions represent instances of blocks, @@ -733,9 +733,9 @@ public: /// Return the original region for a captured region, if /// one exists. const VarRegion *getOriginalRegion(const VarRegion *VR) const; - + referenced_vars_iterator referenced_vars_begin() const; - referenced_vars_iterator referenced_vars_end() const; + referenced_vars_iterator referenced_vars_end() const; void dumpToStream(raw_ostream &os) const override; @@ -824,7 +824,7 @@ public: return R->getKind() == StringRegionKind; } }; - + /// The region associated with an ObjCStringLiteral. class ObjCStringRegion : public TypedValueRegion { friend class MemRegionManager; @@ -840,7 +840,7 @@ class ObjCStringRegion : public TypedValueRegion { static void ProfileRegion(llvm::FoldingSetNodeID &ID, const ObjCStringLiteral *Str, const MemRegion *superRegion); - + public: const ObjCStringLiteral *getObjCStringLiteral() const { return Str; } @@ -897,9 +897,9 @@ public: class DeclRegion : public TypedValueRegion { protected: - const Decl *D; + const ValueDecl *D; - DeclRegion(const Decl *d, const MemRegion *sReg, Kind k) + DeclRegion(const ValueDecl *d, const MemRegion *sReg, Kind k) : TypedValueRegion(sReg, k), D(d) { assert(classof(this)); assert(d); @@ -909,7 +909,7 @@ protected: const MemRegion* superRegion, Kind k); public: - const Decl *getDecl() const { return D; } + const ValueDecl *getDecl() const { return D; } void Profile(llvm::FoldingSetNodeID& ID) const override; static bool classof(const MemRegion* R) { @@ -959,7 +959,7 @@ public: return R->getKind() == VarRegionKind; } }; - + /// CXXThisRegion - Represents the region for the implicit 'this' parameter /// in a call to a C++ method. This region doesn't represent the object /// referred to by 'this', but rather 'this' itself. @@ -1141,7 +1141,7 @@ public: } }; -// CXXBaseObjectRegion represents a base object within a C++ object. It is +// CXXBaseObjectRegion represents a base object within a C++ object. It is // identified by the base class declaration and the region of its parent object. class CXXBaseObjectRegion : public TypedValueRegion { friend class MemRegionManager; @@ -1197,7 +1197,7 @@ class MemRegionManager { GlobalSystemSpaceRegion *SystemGlobals = nullptr; GlobalImmutableSpaceRegion *ImmutableGlobals = nullptr; - llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *> + llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *> StackLocalsSpaceRegions; llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *> StackArgumentsSpaceRegions; @@ -1213,7 +1213,7 @@ public: ~MemRegionManager(); ASTContext &getContext() { return C; } - + llvm::BumpPtrAllocator &getAllocator() { return A; } /// getStackLocalsRegion - Retrieve the memory region associated with the @@ -1251,7 +1251,7 @@ public: const CompoundLiteralRegion* getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC); - + /// getCXXThisRegion - Retrieve the [artificial] region associated with the /// parameter 'this'. const CXXThisRegion *getCXXThisRegion(QualType thisPointerTy, @@ -1320,7 +1320,7 @@ public: /// Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different /// super region. const CXXBaseObjectRegion * - getCXXBaseObjectRegionWithSuper(const CXXBaseObjectRegion *baseReg, + getCXXBaseObjectRegionWithSuper(const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion) { return getCXXBaseObjectRegion(baseReg->getDecl(), superRegion, baseReg->isVirtual()); @@ -1330,7 +1330,7 @@ public: const BlockCodeRegion *getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC); - + /// getBlockDataRegion - Get the memory region associated with an instance /// of a block. Unlike many other MemRegions, the LocationContext* /// argument is allowed to be NULL for cases where we have no known @@ -1363,7 +1363,7 @@ private: template <typename REG> const REG* LazyAllocate(REG*& region); - + template <typename REG, typename ARG> const REG* LazyAllocate(REG*& region, ARG a); }; @@ -1408,7 +1408,7 @@ public: /// should be invalidated. TK_EntireMemSpace = 0x8 - // Do not forget to extend StorageTypeForKinds if number of traits exceed + // Do not forget to extend StorageTypeForKinds if number of traits exceed // the number of bits StorageTypeForKinds can store. }; diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index 17ab7379fdba9..b86301a03470c 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -36,6 +36,7 @@ class ASTContext; namespace ento { +class AnalysisManager; class CallEvent; class CallEventManager; @@ -111,6 +112,8 @@ public: return *stateMgr; } + AnalysisManager &getAnalysisManager() const; + /// Return the ConstraintManager. ConstraintManager &getConstraintManager() const; diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h index 31300d69f2ff7..865014b22830e 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h @@ -55,7 +55,7 @@ class SValBuilder { protected: ASTContext &Context; - + /// Manager of APSInt values. BasicValueFactory BasicVals; @@ -69,7 +69,7 @@ protected: /// The scalar type to use for array indices. const QualType ArrayIndexTy; - + /// The width of the scalar type used for array indices. const unsigned ArrayIndexWidth; @@ -137,7 +137,7 @@ public: /// that represents the same value, but is hopefully easier to work with /// than the original SVal. virtual SVal simplifySVal(ProgramStateRef State, SVal Val) = 0; - + /// Constructs a symbolic expression for two non-location values. SVal makeSymExprValNN(ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy); @@ -157,11 +157,11 @@ public: const ASTContext &getContext() const { return Context; } ProgramStateManager &getStateManager() { return StateMgr; } - + QualType getConditionType() const { return Context.getLangOpts().CPlusPlus ? Context.BoolTy : Context.IntTy; } - + QualType getArrayIndexType() const { return ArrayIndexTy; } @@ -237,7 +237,7 @@ public: DefinedSVal getMemberPointer(const DeclaratorDecl *DD); DefinedSVal getFunctionPointer(const FunctionDecl *func); - + DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy, const LocationContext *locContext, unsigned blockCount); @@ -252,7 +252,7 @@ public: return nonloc::CompoundVal(BasicVals.getCompoundValData(type, vals)); } - NonLoc makeLazyCompoundVal(const StoreRef &store, + NonLoc makeLazyCompoundVal(const StoreRef &store, const TypedValueRegion *region) { return nonloc::LazyCompoundVal( BasicVals.getLazyCompoundValData(store, region)); diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index 0fde63e9eb09b..1b79bfc3f8cf1 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -202,7 +202,7 @@ public: return SymExpr::symbol_iterator(); } - SymExpr::symbol_iterator symbol_end() const { + SymExpr::symbol_iterator symbol_end() const { return SymExpr::symbol_end(); } }; @@ -230,13 +230,13 @@ public: // tautologically false. bool isUndef() const = delete; bool isValid() const = delete; - + protected: DefinedOrUnknownSVal() = default; explicit DefinedOrUnknownSVal(const void *d, bool isLoc, unsigned ValKind) : SVal(d, isLoc, ValKind) {} explicit DefinedOrUnknownSVal(BaseKind k, void *D = nullptr) : SVal(k, D) {} - + private: friend class SVal; @@ -244,11 +244,11 @@ private: return !V.isUndef(); } }; - + class UnknownVal : public DefinedOrUnknownSVal { public: explicit UnknownVal() : DefinedOrUnknownSVal(UnknownValKind) {} - + private: friend class SVal; @@ -325,7 +325,7 @@ public: void dumpToStream(raw_ostream &Out) const; static bool isLocType(QualType T) { - return T->isAnyPointerType() || T->isBlockPointerType() || + return T->isAnyPointerType() || T->isBlockPointerType() || T->isReferenceType() || T->isNullPtrType(); } @@ -664,7 +664,7 @@ private: } }; -} // namespace loc +} // namespace loc } // namespace ento diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h b/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h index dc0644df8aabe..fc072a3800749 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h @@ -149,7 +149,7 @@ public: // FIXME: This should soon be eliminated altogether; clients should deal with // region extents directly. - virtual DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state, + virtual DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state, const MemRegion *region, QualType EleTy) { return UnknownVal(); @@ -176,8 +176,8 @@ public: /// - Successful cast (ex: derived is subclass of base). /// - Failed cast (ex: derived is definitely not a subclass of base). /// The distinction of this case from the next one is necessary to model - /// dynamic_cast. - /// - We don't know (base is a symbolic region and we don't have + /// dynamic_cast. + /// - We don't know (base is a symbolic region and we don't have /// enough info to determine if the cast will succeed at run time). /// The function returns an SVal representing the derived class; it's /// valid only if Failed flag is set to false. @@ -195,7 +195,7 @@ public: virtual bool includedInBindings(Store store, const MemRegion *region) const = 0; - + /// If the StoreManager supports it, increment the reference count of /// the specified Store object. virtual void incrementReferenceCount(Store store) {} @@ -221,7 +221,7 @@ public: /// globals should get invalidated. /// \param[in,out] IS A set to fill with any symbols that are no longer /// accessible. Pass \c NULL if this information will not be used. - /// \param[in] ITraits Information about invalidation for a particular + /// \param[in] ITraits Information about invalidation for a particular /// region/symbol. /// \param[in,out] InvalidatedTopLevel A vector to fill with regions //// explicitly being invalidated. Pass \c NULL if this @@ -305,16 +305,16 @@ inline StoreRef::StoreRef(Store store, StoreManager & smgr) inline StoreRef::StoreRef(const StoreRef &sr) : store(sr.store), mgr(sr.mgr) -{ +{ if (store) mgr.incrementReferenceCount(store); } - + inline StoreRef::~StoreRef() { if (store) mgr.decrementReferenceCount(store); } - + inline StoreRef &StoreRef::operator=(StoreRef const &newStore) { assert(&newStore.mgr == &mgr); if (store != newStore.store) { diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h b/include/clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h index c5b4e5036bdf4..22259a239cf68 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h @@ -18,15 +18,15 @@ namespace clang { namespace ento { - + class StoreManager; - + /// Store - This opaque type encapsulates an immutable mapping from /// locations to values. At a high-level, it represents the symbolic /// memory model. Different subclasses of StoreManager may choose /// different types to represent the locations and values. using Store = const void *; - + class StoreRef { Store store; StoreManager &mgr; @@ -36,14 +36,14 @@ public: StoreRef(const StoreRef &sr); StoreRef &operator=(StoreRef const &newStore); ~StoreRef(); - + bool operator==(const StoreRef &x) const { assert(&mgr == &x.mgr); return x.store == store; } bool operator!=(const StoreRef &x) const { return !operator==(x); } - + Store getStore() const { return store; } const StoreManager &getStoreManager() const { return mgr; } }; diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h index e574ffdd6a159..d6aa4feddff2c 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h @@ -29,7 +29,7 @@ class CrossTranslationUnitContext; } namespace ento { - + struct NodeBuilderContext; class AnalysisManager; class ExplodedNodeSet; @@ -133,7 +133,7 @@ public: /// processRegionChanges - Called by ProgramStateManager whenever a change is /// made to the store. Used to update checkers that track region values. - virtual ProgramStateRef + virtual ProgramStateRef processRegionChanges(ProgramStateRef state, const InvalidatedSymbols *invalidated, ArrayRef<const MemRegion *> ExplicitRegions, @@ -142,7 +142,7 @@ public: const CallEvent *Call) = 0; - inline ProgramStateRef + inline ProgramStateRef processRegionChange(ProgramStateRef state, const MemRegion* MR, const LocationContext *LCtx) { diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SummaryManager.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SummaryManager.h index 52d78b6a3c82a..0a75eeb3ea53d 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SummaryManager.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SummaryManager.h @@ -21,9 +21,9 @@ namespace ento { namespace summMgr { - + /* Key kinds: - + - C functions - C++ functions (name + parameter types) - ObjC methods: @@ -34,21 +34,21 @@ namespace summMgr { - C++ methods - Class, function name + parameter types + const */ - + class SummaryKey { - + }; } // end namespace clang::summMgr - + class SummaryManagerImpl { - + }; - + template <typename T> class SummaryManager : SummaryManagerImpl { - + }; } // end GR namespace diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h index cc3ce72f9e569..0745519626074 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h @@ -167,7 +167,7 @@ public: /// SubRegion::getExtent instead -- the value returned may not be a symbol. class SymbolExtent : public SymbolData { const SubRegion *R; - + public: SymbolExtent(SymbolID sym, const SubRegion *r) : SymbolData(SymbolExtentKind, sym), R(r) { @@ -300,7 +300,7 @@ public: } }; -/// Represents a symbolic expression involving a binary operator +/// Represents a symbolic expression involving a binary operator class BinarySymExpr : public SymExpr { BinaryOperator::Opcode Op; QualType T; @@ -558,7 +558,7 @@ class SymbolReaper { SymbolSetTy TheDead; RegionSetTy RegionRoots; - + const StackFrameContext *LCtx; const Stmt *Loc; SymbolManager& SymMgr; @@ -614,7 +614,7 @@ public: bool hasDeadSymbols() const { return !TheDead.empty(); } - + using region_iterator = RegionSetTy::const_iterator; region_iterator region_begin() const { return RegionRoots.begin(); } @@ -627,10 +627,10 @@ public: bool isDead(SymbolRef sym) const { return TheDead.count(sym); } - + void markLive(const MemRegion *region); void markElementIndicesLive(const MemRegion *region); - + /// Set to the value of the symbolic store after /// StoreManager::removeDeadBindings has been called. void setReapedStore(StoreRef st) { reapedStore = st; } diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/WorkList.h b/include/clang/StaticAnalyzer/Core/PathSensitive/WorkList.h index 7df8f373b3663..07edd35ff9440 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/WorkList.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/WorkList.h @@ -20,7 +20,7 @@ #include <cassert> namespace clang { - + class CFGBlock; namespace ento { @@ -47,13 +47,13 @@ public: /// Returns the node associated with the worklist unit. ExplodedNode *getNode() const { return node; } - + /// Returns the block counter map associated with the worklist unit. BlockCounter getBlockCounter() const { return counter; } /// Returns the CFGblock associated with the worklist unit. const CFGBlock *getBlock() const { return block; } - + /// Return the index within the CFGBlock for the worklist unit. unsigned getIndex() const { return blockIdx; } }; |