diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:01 +0000 |
commit | 486754660bb926339aefcf012a3f848592babb8b (patch) | |
tree | ecdbc446c9876f4f120f701c243373cd3cb43db3 /include | |
parent | 55e6d896ad333f07bb3b1ba487df214fc268a4ab (diff) | |
download | src-486754660bb926339aefcf012a3f848592babb8b.tar.gz src-486754660bb926339aefcf012a3f848592babb8b.zip |
Vendor import of clang trunk r338150:vendor/clang/clang-trunk-r338150
Notes
Notes:
svn path=/vendor/clang/dist/; revision=336815
svn path=/vendor/clang/clang-trunk-r338150/; revision=336816; tag=vendor/clang/clang-trunk-r338150
Diffstat (limited to 'include')
411 files changed, 28926 insertions, 19352 deletions
diff --git a/include/clang-c/BuildSystem.h b/include/clang-c/BuildSystem.h index 8d323a4e6cae..3cfec388308c 100644 --- a/include/clang-c/BuildSystem.h +++ b/include/clang-c/BuildSystem.h @@ -28,19 +28,19 @@ extern "C" { */ /** - * \brief Return the timestamp for use with Clang's + * Return the timestamp for use with Clang's * \c -fbuild-session-timestamp= option. */ CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void); /** - * \brief Object encapsulating information about overlaying virtual + * Object encapsulating information about overlaying virtual * file/directories over the real file system. */ typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay; /** - * \brief Create a \c CXVirtualFileOverlay object. + * Create a \c CXVirtualFileOverlay object. * Must be disposed with \c clang_VirtualFileOverlay_dispose(). * * \param options is reserved, always pass 0. @@ -49,7 +49,7 @@ CINDEX_LINKAGE CXVirtualFileOverlay clang_VirtualFileOverlay_create(unsigned options); /** - * \brief Map an absolute virtual file path to an absolute real one. + * Map an absolute virtual file path to an absolute real one. * The virtual path must be canonicalized (not contain "."/".."). * \returns 0 for success, non-zero to indicate an error. */ @@ -59,17 +59,17 @@ clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay, const char *realPath); /** - * \brief Set the case sensitivity for the \c CXVirtualFileOverlay object. + * Set the case sensitivity for the \c CXVirtualFileOverlay object. * The \c CXVirtualFileOverlay object is case-sensitive by default, this * option can be used to override the default. * \returns 0 for success, non-zero to indicate an error. */ CINDEX_LINKAGE enum CXErrorCode clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay, - int caseSensitive); + int caseSensitive); /** - * \brief Write out the \c CXVirtualFileOverlay object to a char buffer. + * Write out the \c CXVirtualFileOverlay object to a char buffer. * * \param options is reserved, always pass 0. * \param out_buffer_ptr pointer to receive the buffer pointer, which should be @@ -83,7 +83,7 @@ clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options, unsigned *out_buffer_size); /** - * \brief free memory allocated by libclang, such as the buffer returned by + * free memory allocated by libclang, such as the buffer returned by * \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer(). * * \param buffer memory pointer to free. @@ -91,17 +91,17 @@ clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options, CINDEX_LINKAGE void clang_free(void *buffer); /** - * \brief Dispose a \c CXVirtualFileOverlay object. + * Dispose a \c CXVirtualFileOverlay object. */ CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay); /** - * \brief Object encapsulating information about a module.map file. + * Object encapsulating information about a module.map file. */ typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor; /** - * \brief Create a \c CXModuleMapDescriptor object. + * Create a \c CXModuleMapDescriptor object. * Must be disposed with \c clang_ModuleMapDescriptor_dispose(). * * \param options is reserved, always pass 0. @@ -110,7 +110,7 @@ CINDEX_LINKAGE CXModuleMapDescriptor clang_ModuleMapDescriptor_create(unsigned options); /** - * \brief Sets the framework module name that the module.map describes. + * Sets the framework module name that the module.map describes. * \returns 0 for success, non-zero to indicate an error. */ CINDEX_LINKAGE enum CXErrorCode @@ -118,7 +118,7 @@ clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor, const char *name); /** - * \brief Sets the umbrealla header name that the module.map describes. + * Sets the umbrealla header name that the module.map describes. * \returns 0 for success, non-zero to indicate an error. */ CINDEX_LINKAGE enum CXErrorCode @@ -126,7 +126,7 @@ clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor, const char *name); /** - * \brief Write out the \c CXModuleMapDescriptor object to a char buffer. + * Write out the \c CXModuleMapDescriptor object to a char buffer. * * \param options is reserved, always pass 0. * \param out_buffer_ptr pointer to receive the buffer pointer, which should be @@ -140,7 +140,7 @@ clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options, unsigned *out_buffer_size); /** - * \brief Dispose a \c CXModuleMapDescriptor object. + * Dispose a \c CXModuleMapDescriptor object. */ CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor); diff --git a/include/clang-c/CXCompilationDatabase.h b/include/clang-c/CXCompilationDatabase.h index 29f89e52a6e3..6f483ee28b56 100644 --- a/include/clang-c/CXCompilationDatabase.h +++ b/include/clang-c/CXCompilationDatabase.h @@ -38,7 +38,7 @@ extern "C" { typedef void * CXCompilationDatabase; /** - * \brief Contains the results of a search in the compilation database + * Contains the results of a search in the compilation database * * When searching for the compile command for a file, the compilation db can * return several commands, as the file may have been compiled with @@ -49,28 +49,28 @@ typedef void * CXCompilationDatabase; typedef void * CXCompileCommands; /** - * \brief Represents the command line invocation to compile a specific file. + * Represents the command line invocation to compile a specific file. */ typedef void * CXCompileCommand; /** - * \brief Error codes for Compilation Database + * Error codes for Compilation Database */ typedef enum { /* - * \brief No error occurred + * No error occurred */ CXCompilationDatabase_NoError = 0, /* - * \brief Database can not be loaded + * Database can not be loaded */ CXCompilationDatabase_CanNotLoadDatabase = 1 } CXCompilationDatabase_Error; /** - * \brief Creates a compilation database from the database found in directory + * Creates a compilation database from the database found in directory * buildDir. For example, CMake can output a compile_commands.json which can * be used to build the database. * @@ -81,13 +81,13 @@ clang_CompilationDatabase_fromDirectory(const char *BuildDir, CXCompilationDatabase_Error *ErrorCode); /** - * \brief Free the given compilation database + * Free the given compilation database */ CINDEX_LINKAGE void clang_CompilationDatabase_dispose(CXCompilationDatabase); /** - * \brief Find the compile commands used for a file. The compile commands + * Find the compile commands used for a file. The compile commands * must be freed by \c clang_CompileCommands_dispose. */ CINDEX_LINKAGE CXCompileCommands @@ -95,24 +95,24 @@ clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase, const char *CompleteFileName); /** - * \brief Get all the compile commands in the given compilation database. + * Get all the compile commands in the given compilation database. */ CINDEX_LINKAGE CXCompileCommands clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase); /** - * \brief Free the given CompileCommands + * Free the given CompileCommands */ CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands); /** - * \brief Get the number of CompileCommand we have for a file + * Get the number of CompileCommand we have for a file */ CINDEX_LINKAGE unsigned clang_CompileCommands_getSize(CXCompileCommands); /** - * \brief Get the I'th CompileCommand for a file + * Get the I'th CompileCommand for a file * * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands) */ @@ -120,26 +120,26 @@ CINDEX_LINKAGE CXCompileCommand clang_CompileCommands_getCommand(CXCompileCommands, unsigned I); /** - * \brief Get the working directory where the CompileCommand was executed from + * Get the working directory where the CompileCommand was executed from */ CINDEX_LINKAGE CXString clang_CompileCommand_getDirectory(CXCompileCommand); /** - * \brief Get the filename associated with the CompileCommand. + * Get the filename associated with the CompileCommand. */ CINDEX_LINKAGE CXString clang_CompileCommand_getFilename(CXCompileCommand); /** - * \brief Get the number of arguments in the compiler invocation. + * Get the number of arguments in the compiler invocation. * */ CINDEX_LINKAGE unsigned clang_CompileCommand_getNumArgs(CXCompileCommand); /** - * \brief Get the I'th argument value in the compiler invocations + * Get the I'th argument value in the compiler invocations * * Invariant : * - argument 0 is the compiler executable @@ -148,19 +148,19 @@ CINDEX_LINKAGE CXString clang_CompileCommand_getArg(CXCompileCommand, unsigned I); /** - * \brief Get the number of source mappings for the compiler invocation. + * Get the number of source mappings for the compiler invocation. */ CINDEX_LINKAGE unsigned clang_CompileCommand_getNumMappedSources(CXCompileCommand); /** - * \brief Get the I'th mapped source path for the compiler invocation. + * Get the I'th mapped source path for the compiler invocation. */ CINDEX_LINKAGE CXString clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I); /** - * \brief Get the I'th mapped source content for the compiler invocation. + * Get the I'th mapped source content for the compiler invocation. */ CINDEX_LINKAGE CXString clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I); diff --git a/include/clang-c/CXErrorCode.h b/include/clang-c/CXErrorCode.h index aff73b746763..caee48d76832 100644 --- a/include/clang-c/CXErrorCode.h +++ b/include/clang-c/CXErrorCode.h @@ -21,19 +21,19 @@ extern "C" { #endif /** - * \brief Error codes returned by libclang routines. + * Error codes returned by libclang routines. * * Zero (\c CXError_Success) is the only error code indicating success. Other * error codes, including not yet assigned non-zero values, indicate errors. */ enum CXErrorCode { /** - * \brief No error. + * No error. */ CXError_Success = 0, /** - * \brief A generic error code, no further details are available. + * A generic error code, no further details are available. * * Errors of this kind can get their own specific error codes in future * libclang versions. @@ -41,18 +41,18 @@ enum CXErrorCode { CXError_Failure = 1, /** - * \brief libclang crashed while performing the requested operation. + * libclang crashed while performing the requested operation. */ CXError_Crashed = 2, /** - * \brief The function detected that the arguments violate the function + * The function detected that the arguments violate the function * contract. */ CXError_InvalidArguments = 3, /** - * \brief An AST deserialization error has occurred. + * An AST deserialization error has occurred. */ CXError_ASTReadError = 4 }; diff --git a/include/clang-c/CXString.h b/include/clang-c/CXString.h index 68ab7bc5244c..76eeda180109 100644 --- a/include/clang-c/CXString.h +++ b/include/clang-c/CXString.h @@ -28,7 +28,7 @@ extern "C" { */ /** - * \brief A character string. + * A character string. * * The \c CXString type is used to return strings from the interface when * the ownership of that string might differ from one call to the next. @@ -46,17 +46,17 @@ typedef struct { } CXStringSet; /** - * \brief Retrieve the character data associated with the given string. + * Retrieve the character data associated with the given string. */ CINDEX_LINKAGE const char *clang_getCString(CXString string); /** - * \brief Free the given string. + * Free the given string. */ CINDEX_LINKAGE void clang_disposeString(CXString string); /** - * \brief Free the given string set. + * Free the given string set. */ CINDEX_LINKAGE void clang_disposeStringSet(CXStringSet *set); diff --git a/include/clang-c/Documentation.h b/include/clang-c/Documentation.h index 89373b11457d..58c8af5aa47c 100644 --- a/include/clang-c/Documentation.h +++ b/include/clang-c/Documentation.h @@ -32,7 +32,7 @@ extern "C" { */ /** - * \brief A parsed comment. + * A parsed comment. */ typedef struct { const void *ASTNode; @@ -40,38 +40,38 @@ typedef struct { } CXComment; /** - * \brief Given a cursor that represents a documentable entity (e.g., + * Given a cursor that represents a documentable entity (e.g., * declaration), return the associated parsed comment as a * \c CXComment_FullComment AST node. */ CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C); /** - * \brief Describes the type of the comment AST node (\c CXComment). A comment + * Describes the type of the comment AST node (\c CXComment). A comment * node can be considered block content (e. g., paragraph), inline content * (plain text) or neither (the root AST node). */ enum CXCommentKind { /** - * \brief Null comment. No AST node is constructed at the requested location + * Null comment. No AST node is constructed at the requested location * because there is no text or a syntax error. */ CXComment_Null = 0, /** - * \brief Plain text. Inline content. + * Plain text. Inline content. */ CXComment_Text = 1, /** - * \brief A command with word-like arguments that is considered inline content. + * A command with word-like arguments that is considered inline content. * * For example: \\c command. */ CXComment_InlineCommand = 2, /** - * \brief HTML start tag with attributes (name-value pairs). Considered + * HTML start tag with attributes (name-value pairs). Considered * inline content. * * For example: @@ -82,7 +82,7 @@ enum CXCommentKind { CXComment_HTMLStartTag = 3, /** - * \brief HTML end tag. Considered inline content. + * HTML end tag. Considered inline content. * * For example: * \verbatim @@ -92,19 +92,19 @@ enum CXCommentKind { CXComment_HTMLEndTag = 4, /** - * \brief A paragraph, contains inline comment. The paragraph itself is + * A paragraph, contains inline comment. The paragraph itself is * block content. */ CXComment_Paragraph = 5, /** - * \brief A command that has zero or more word-like arguments (number of + * A command that has zero or more word-like arguments (number of * word-like arguments depends on command name) and a paragraph as an * argument. Block command is block content. * * Paragraph argument is also a child of the block command. * - * For example: \\brief has 0 word-like arguments and a paragraph argument. + * For example: \has 0 word-like arguments and a paragraph argument. * * AST nodes of special kinds that parser knows about (e. g., \\param * command) have their own node kinds. @@ -112,7 +112,7 @@ enum CXCommentKind { CXComment_BlockCommand = 6, /** - * \brief A \\param or \\arg command that describes the function parameter + * A \\param or \\arg command that describes the function parameter * (name, passing direction, description). * * For example: \\param [in] ParamName description. @@ -120,7 +120,7 @@ enum CXCommentKind { CXComment_ParamCommand = 7, /** - * \brief A \\tparam command that describes a template parameter (name and + * A \\tparam command that describes a template parameter (name and * description). * * For example: \\tparam T description. @@ -128,7 +128,7 @@ enum CXCommentKind { CXComment_TParamCommand = 8, /** - * \brief A verbatim block command (e. g., preformatted code). Verbatim + * A verbatim block command (e. g., preformatted code). Verbatim * block has an opening and a closing command and contains multiple lines of * text (\c CXComment_VerbatimBlockLine child nodes). * @@ -140,67 +140,67 @@ enum CXCommentKind { CXComment_VerbatimBlockCommand = 9, /** - * \brief A line of text that is contained within a + * A line of text that is contained within a * CXComment_VerbatimBlockCommand node. */ CXComment_VerbatimBlockLine = 10, /** - * \brief A verbatim line command. Verbatim line has an opening command, + * A verbatim line command. Verbatim line has an opening command, * a single line of text (up to the newline after the opening command) and * has no closing command. */ CXComment_VerbatimLine = 11, /** - * \brief A full comment attached to a declaration, contains block content. + * A full comment attached to a declaration, contains block content. */ CXComment_FullComment = 12 }; /** - * \brief The most appropriate rendering mode for an inline command, chosen on + * The most appropriate rendering mode for an inline command, chosen on * command semantics in Doxygen. */ enum CXCommentInlineCommandRenderKind { /** - * \brief Command argument should be rendered in a normal font. + * Command argument should be rendered in a normal font. */ CXCommentInlineCommandRenderKind_Normal, /** - * \brief Command argument should be rendered in a bold font. + * Command argument should be rendered in a bold font. */ CXCommentInlineCommandRenderKind_Bold, /** - * \brief Command argument should be rendered in a monospaced font. + * Command argument should be rendered in a monospaced font. */ CXCommentInlineCommandRenderKind_Monospaced, /** - * \brief Command argument should be rendered emphasized (typically italic + * Command argument should be rendered emphasized (typically italic * font). */ CXCommentInlineCommandRenderKind_Emphasized }; /** - * \brief Describes parameter passing direction for \\param or \\arg command. + * Describes parameter passing direction for \\param or \\arg command. */ enum CXCommentParamPassDirection { /** - * \brief The parameter is an input parameter. + * The parameter is an input parameter. */ CXCommentParamPassDirection_In, /** - * \brief The parameter is an output parameter. + * The parameter is an output parameter. */ CXCommentParamPassDirection_Out, /** - * \brief The parameter is an input and output parameter. + * The parameter is an input and output parameter. */ CXCommentParamPassDirection_InOut }; @@ -230,7 +230,7 @@ CINDEX_LINKAGE CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx); /** - * \brief A \c CXComment_Paragraph node is considered whitespace if it contains + * A \c CXComment_Paragraph node is considered whitespace if it contains * only \c CXComment_Text nodes that are empty or whitespace. * * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are @@ -487,7 +487,7 @@ CXString clang_VerbatimBlockLineComment_getText(CXComment Comment); CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment); /** - * \brief Convert an HTML tag AST node to string. + * Convert an HTML tag AST node to string. * * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST * node. @@ -497,13 +497,13 @@ CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment); CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment); /** - * \brief Convert a given full parsed comment to an HTML fragment. + * Convert a given full parsed comment to an HTML fragment. * * Specific details of HTML layout are subject to change. Don't try to parse * this HTML back into an AST, use other APIs instead. * * Currently the following CSS classes are used: - * \li "para-brief" for \\brief paragraph and equivalent commands; + * \li "para-brief" for \paragraph and equivalent commands; * \li "para-returns" for \\returns paragraph and equivalent commands; * \li "word-returns" for the "Returns" word in \\returns paragraph. * @@ -530,7 +530,7 @@ CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment); CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment); /** - * \brief Convert a given full parsed comment to an XML document. + * Convert a given full parsed comment to an XML document. * * A Relax NG schema for the XML can be found in comment-xml-schema.rng file * inside clang source tree. diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 587008a7210b..0ad90010ccd9 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -24,7 +24,7 @@ #include "clang-c/BuildSystem.h" /** - * \brief The version constants for the libclang API. + * The version constants for the libclang API. * CINDEX_VERSION_MINOR should increase when there are API additions. * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. * @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 45 +#define CINDEX_VERSION_MINOR 49 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -75,30 +75,30 @@ extern "C" { */ /** - * \brief An "index" that consists of a set of translation units that would + * An "index" that consists of a set of translation units that would * typically be linked together into an executable or library. */ typedef void *CXIndex; /** - * \brief An opaque type representing target information for a given translation + * An opaque type representing target information for a given translation * unit. */ typedef struct CXTargetInfoImpl *CXTargetInfo; /** - * \brief A single translation unit, which resides in an index. + * A single translation unit, which resides in an index. */ typedef struct CXTranslationUnitImpl *CXTranslationUnit; /** - * \brief Opaque pointer representing client data that will be passed through + * Opaque pointer representing client data that will be passed through * to various callbacks and visitors. */ typedef void *CXClientData; /** - * \brief Provides the contents of a file that has not yet been saved to disk. + * Provides the contents of a file that has not yet been saved to disk. * * Each CXUnsavedFile instance provides the name of a file on the * system along with the current contents of that file that have not @@ -106,66 +106,66 @@ typedef void *CXClientData; */ struct CXUnsavedFile { /** - * \brief The file whose contents have not yet been saved. + * The file whose contents have not yet been saved. * * This file must already exist in the file system. */ const char *Filename; /** - * \brief A buffer containing the unsaved contents of this file. + * A buffer containing the unsaved contents of this file. */ const char *Contents; /** - * \brief The length of the unsaved contents of this buffer. + * The length of the unsaved contents of this buffer. */ unsigned long Length; }; /** - * \brief Describes the availability of a particular entity, which indicates + * Describes the availability of a particular entity, which indicates * whether the use of this entity will result in a warning or error due to * it being deprecated or unavailable. */ enum CXAvailabilityKind { /** - * \brief The entity is available. + * The entity is available. */ CXAvailability_Available, /** - * \brief The entity is available, but has been deprecated (and its use is + * The entity is available, but has been deprecated (and its use is * not recommended). */ CXAvailability_Deprecated, /** - * \brief The entity is not available; any use of it will be an error. + * The entity is not available; any use of it will be an error. */ CXAvailability_NotAvailable, /** - * \brief The entity is available, but not accessible; any use of it will be + * The entity is available, but not accessible; any use of it will be * an error. */ CXAvailability_NotAccessible }; /** - * \brief Describes a version number of the form major.minor.subminor. + * Describes a version number of the form major.minor.subminor. */ typedef struct CXVersion { /** - * \brief The major version number, e.g., the '10' in '10.7.3'. A negative + * The major version number, e.g., the '10' in '10.7.3'. A negative * value indicates that there is no version number at all. */ int Major; /** - * \brief The minor version number, e.g., the '7' in '10.7.3'. This value + * 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 * version '10'. */ int Minor; /** - * \brief The subminor version number, e.g., the '3' in '10.7.3'. This value + * The subminor version number, e.g., the '3' in '10.7.3'. This value * will be negative if no minor or subminor version number was provided, * e.g., in version '10' or '10.7'. */ @@ -173,60 +173,60 @@ typedef struct CXVersion { } CXVersion; /** - * \brief Describes the exception specification of a cursor. + * Describes the exception specification of a cursor. * * A negative value indicates that the cursor is not a function declaration. */ enum CXCursor_ExceptionSpecificationKind { /** - * \brief The cursor has no exception specification. + * The cursor has no exception specification. */ CXCursor_ExceptionSpecificationKind_None, /** - * \brief The cursor has exception specification throw() + * The cursor has exception specification throw() */ CXCursor_ExceptionSpecificationKind_DynamicNone, /** - * \brief The cursor has exception specification throw(T1, T2) + * The cursor has exception specification throw(T1, T2) */ CXCursor_ExceptionSpecificationKind_Dynamic, /** - * \brief The cursor has exception specification throw(...). + * The cursor has exception specification throw(...). */ CXCursor_ExceptionSpecificationKind_MSAny, /** - * \brief The cursor has exception specification basic noexcept. + * The cursor has exception specification basic noexcept. */ CXCursor_ExceptionSpecificationKind_BasicNoexcept, /** - * \brief The cursor has exception specification computed noexcept. + * The cursor has exception specification computed noexcept. */ CXCursor_ExceptionSpecificationKind_ComputedNoexcept, /** - * \brief The exception specification has not yet been evaluated. + * The exception specification has not yet been evaluated. */ CXCursor_ExceptionSpecificationKind_Unevaluated, /** - * \brief The exception specification has not yet been instantiated. + * The exception specification has not yet been instantiated. */ CXCursor_ExceptionSpecificationKind_Uninstantiated, /** - * \brief The exception specification has not been parsed yet. + * The exception specification has not been parsed yet. */ CXCursor_ExceptionSpecificationKind_Unparsed }; /** - * \brief Provides a shared context for creating translation units. + * Provides a shared context for creating translation units. * * It provides two options: * @@ -269,7 +269,7 @@ CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, int displayDiagnostics); /** - * \brief Destroy the given index. + * Destroy the given index. * * The index must not be destroyed until all of the translation units created * within that index have been destroyed. @@ -278,12 +278,12 @@ CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); typedef enum { /** - * \brief Used to indicate that no special CXIndex options are needed. + * Used to indicate that no special CXIndex options are needed. */ CXGlobalOpt_None = 0x0, /** - * \brief Used to indicate that threads that libclang creates for indexing + * Used to indicate that threads that libclang creates for indexing * purposes should use background priority. * * Affects #clang_indexSourceFile, #clang_indexTranslationUnit, @@ -292,7 +292,7 @@ typedef enum { CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, /** - * \brief Used to indicate that threads that libclang creates for editing + * Used to indicate that threads that libclang creates for editing * purposes should use background priority. * * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, @@ -301,7 +301,7 @@ typedef enum { CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, /** - * \brief Used to indicate that all threads that libclang creates should use + * Used to indicate that all threads that libclang creates should use * background priority. */ CXGlobalOpt_ThreadBackgroundPriorityForAll = @@ -311,7 +311,7 @@ typedef enum { } CXGlobalOptFlags; /** - * \brief Sets general options associated with a CXIndex. + * Sets general options associated with a CXIndex. * * For example: * \code @@ -326,7 +326,7 @@ typedef enum { CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); /** - * \brief Gets the general options associated with a CXIndex. + * Gets the general options associated with a CXIndex. * * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that * are associated with the given CXIndex object. @@ -334,7 +334,7 @@ CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex); /** - * \brief Sets the invocation emission path option in a CXIndex. + * Sets the invocation emission path option in a CXIndex. * * The invocation emission path specifies a path which will contain log * files for certain libclang invocations. A null value (default) implies that @@ -350,22 +350,22 @@ clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path); */ /** - * \brief A particular source file that is part of a translation unit. + * A particular source file that is part of a translation unit. */ typedef void *CXFile; /** - * \brief Retrieve the complete file and path name of the given file. + * Retrieve the complete file and path name of the given file. */ CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); /** - * \brief Retrieve the last modification time of the given file. + * Retrieve the last modification time of the given file. */ CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); /** - * \brief Uniquely identifies a CXFile, that refers to the same underlying file, + * Uniquely identifies a CXFile, that refers to the same underlying file, * across an indexing session. */ typedef struct { @@ -373,7 +373,7 @@ typedef struct { } CXFileUniqueID; /** - * \brief Retrieve the unique ID for the given \c file. + * Retrieve the unique ID for the given \c file. * * \param file the file to get the ID for. * \param outID stores the returned CXFileUniqueID. @@ -383,7 +383,7 @@ typedef struct { CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID); /** - * \brief Determine whether the given header is guarded against + * Determine whether the given header is guarded against * multiple inclusions, either with the conventional * \#ifndef/\#define/\#endif macro guards or with \#pragma once. */ @@ -391,7 +391,7 @@ CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file); /** - * \brief Retrieve a file handle within the given translation unit. + * Retrieve a file handle within the given translation unit. * * \param tu the translation unit * @@ -404,7 +404,7 @@ CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, const char *file_name); /** - * \brief Retrieve the buffer associated with the given file. + * Retrieve the buffer associated with the given file. * * \param tu the translation unit * @@ -419,12 +419,19 @@ CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu, CXFile file, size_t *size); /** - * \brief Returns non-zero if the \c file1 and \c file2 point to the same file, + * Returns non-zero if the \c file1 and \c file2 point to the same file, * or they are both NULL. */ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); /** + * Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + +/** * @} */ @@ -442,7 +449,7 @@ CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); */ /** - * \brief Identifies a specific source location within a translation + * Identifies a specific source location within a translation * unit. * * Use clang_getExpansionLocation() or clang_getSpellingLocation() @@ -454,7 +461,7 @@ typedef struct { } CXSourceLocation; /** - * \brief Identifies a half-open character range in the source code. + * Identifies a half-open character range in the source code. * * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the * starting and end locations from a source range, respectively. @@ -466,12 +473,12 @@ typedef struct { } CXSourceRange; /** - * \brief Retrieve a NULL (invalid) source location. + * Retrieve a NULL (invalid) source location. */ CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void); /** - * \brief Determine whether two source locations, which must refer into + * Determine whether two source locations, which must refer into * the same translation unit, refer to exactly the same point in the source * code. * @@ -482,7 +489,7 @@ CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2); /** - * \brief Retrieves the source location associated with a given file/line/column + * Retrieves the source location associated with a given file/line/column * in a particular translation unit. */ CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, @@ -490,7 +497,7 @@ CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, unsigned line, unsigned column); /** - * \brief Retrieves the source location associated with a given character offset + * Retrieves the source location associated with a given character offset * in a particular translation unit. */ CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, @@ -498,30 +505,30 @@ CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, unsigned offset); /** - * \brief Returns non-zero if the given source location is in a system header. + * Returns non-zero if the given source location is in a system header. */ CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location); /** - * \brief Returns non-zero if the given source location is in the main file of + * Returns non-zero if the given source location is in the main file of * the corresponding translation unit. */ CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location); /** - * \brief Retrieve a NULL (invalid) source range. + * Retrieve a NULL (invalid) source range. */ CINDEX_LINKAGE CXSourceRange clang_getNullRange(void); /** - * \brief Retrieve a source range given the beginning and ending source + * Retrieve a source range given the beginning and ending source * locations. */ CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, CXSourceLocation end); /** - * \brief Determine whether two ranges are equivalent. + * Determine whether two ranges are equivalent. * * \returns non-zero if the ranges are the same, zero if they differ. */ @@ -529,12 +536,12 @@ CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, CXSourceRange range2); /** - * \brief Returns non-zero if \p range is null. + * Returns non-zero if \p range is null. */ CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); /** - * \brief Retrieve the file, line, column, and offset represented by + * Retrieve the file, line, column, and offset represented by * the given source location. * * If the location refers into a macro expansion, retrieves the @@ -562,7 +569,7 @@ CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, unsigned *offset); /** - * \brief Retrieve the file, line and column represented by the given source + * Retrieve the file, line and column represented by the given source * location, as specified in a # line directive. * * Example: given the following source code in a file somefile.c @@ -607,7 +614,7 @@ CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, unsigned *column); /** - * \brief Legacy API to retrieve the file, line, column, and offset represented + * Legacy API to retrieve the file, line, column, and offset represented * by the given source location. * * This interface has been replaced by the newer interface @@ -621,7 +628,7 @@ CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, unsigned *offset); /** - * \brief Retrieve the file, line, column, and offset represented by + * Retrieve the file, line, column, and offset represented by * the given source location. * * If the location refers into a macro instantiation, return where the @@ -649,7 +656,7 @@ CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, unsigned *offset); /** - * \brief Retrieve the file, line, column, and offset represented by + * Retrieve the file, line, column, and offset represented by * the given source location. * * If the location refers into a macro expansion, return where the macro was @@ -678,31 +685,31 @@ CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location, unsigned *offset); /** - * \brief Retrieve a source location representing the first character within a + * Retrieve a source location representing the first character within a * source range. */ CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); /** - * \brief Retrieve a source location representing the last character within a + * Retrieve a source location representing the last character within a * source range. */ CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); /** - * \brief Identifies an array of ranges. + * Identifies an array of ranges. */ typedef struct { - /** \brief The number of ranges in the \c ranges array. */ + /** The number of ranges in the \c ranges array. */ unsigned count; /** - * \brief An array of \c CXSourceRanges. + * An array of \c CXSourceRanges. */ CXSourceRange *ranges; } CXSourceRangeList; /** - * \brief Retrieve all ranges that were skipped by the preprocessor. + * Retrieve all ranges that were skipped by the preprocessor. * * The preprocessor will skip lines when they are surrounded by an * if/ifdef/ifndef directive whose condition does not evaluate to true. @@ -711,7 +718,7 @@ CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, CXFile file); /** - * \brief Retrieve all ranges from all files that were skipped by the + * Retrieve all ranges from all files that were skipped by the * preprocessor. * * The preprocessor will skip lines when they are surrounded by an @@ -720,7 +727,7 @@ CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu); /** - * \brief Destroy the given \c CXSourceRangeList. + * Destroy the given \c CXSourceRangeList. */ CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges); @@ -735,34 +742,34 @@ CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges); */ /** - * \brief Describes the severity of a particular diagnostic. + * Describes the severity of a particular diagnostic. */ enum CXDiagnosticSeverity { /** - * \brief A diagnostic that has been suppressed, e.g., by a command-line + * A diagnostic that has been suppressed, e.g., by a command-line * option. */ CXDiagnostic_Ignored = 0, /** - * \brief This diagnostic is a note that should be attached to the + * This diagnostic is a note that should be attached to the * previous (non-note) diagnostic. */ CXDiagnostic_Note = 1, /** - * \brief This diagnostic indicates suspicious code that may not be + * This diagnostic indicates suspicious code that may not be * wrong. */ CXDiagnostic_Warning = 2, /** - * \brief This diagnostic indicates that the code is ill-formed. + * This diagnostic indicates that the code is ill-formed. */ CXDiagnostic_Error = 3, /** - * \brief This diagnostic indicates that the code is ill-formed such + * This diagnostic indicates that the code is ill-formed such * that future parser recovery is unlikely to produce useful * results. */ @@ -770,23 +777,23 @@ enum CXDiagnosticSeverity { }; /** - * \brief A single diagnostic, containing the diagnostic's severity, + * A single diagnostic, containing the diagnostic's severity, * location, text, source ranges, and fix-it hints. */ typedef void *CXDiagnostic; /** - * \brief A group of CXDiagnostics. + * A group of CXDiagnostics. */ typedef void *CXDiagnosticSet; /** - * \brief Determine the number of diagnostics in a CXDiagnosticSet. + * Determine the number of diagnostics in a CXDiagnosticSet. */ CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); /** - * \brief Retrieve a diagnostic associated with the given CXDiagnosticSet. + * Retrieve a diagnostic associated with the given CXDiagnosticSet. * * \param Diags the CXDiagnosticSet to query. * \param Index the zero-based diagnostic number to retrieve. @@ -798,36 +805,36 @@ CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, unsigned Index); /** - * \brief Describes the kind of error that occurred (if any) in a call to + * Describes the kind of error that occurred (if any) in a call to * \c clang_loadDiagnostics. */ enum CXLoadDiag_Error { /** - * \brief Indicates that no error occurred. + * Indicates that no error occurred. */ CXLoadDiag_None = 0, /** - * \brief Indicates that an unknown error occurred while attempting to + * Indicates that an unknown error occurred while attempting to * deserialize diagnostics. */ CXLoadDiag_Unknown = 1, /** - * \brief Indicates that the file containing the serialized diagnostics + * Indicates that the file containing the serialized diagnostics * could not be opened. */ CXLoadDiag_CannotLoad = 2, /** - * \brief Indicates that the serialized diagnostics file is invalid or + * Indicates that the serialized diagnostics file is invalid or * corrupt. */ CXLoadDiag_InvalidFile = 3 }; /** - * \brief Deserialize a set of diagnostics from a Clang diagnostics bitcode + * Deserialize a set of diagnostics from a Clang diagnostics bitcode * file. * * \param file The name of the file to deserialize. @@ -844,12 +851,12 @@ CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file, CXString *errorString); /** - * \brief Release a CXDiagnosticSet and all of its contained diagnostics. + * Release a CXDiagnosticSet and all of its contained diagnostics. */ CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); /** - * \brief 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. @@ -857,13 +864,13 @@ CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D); /** - * \brief Determine the number of diagnostics produced for the given + * Determine the number of diagnostics produced for the given * translation unit. */ CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); /** - * \brief Retrieve a diagnostic associated with the given translation unit. + * Retrieve a diagnostic associated with the given translation unit. * * \param Unit the translation unit to query. * \param Index the zero-based diagnostic number to retrieve. @@ -875,7 +882,7 @@ CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, unsigned Index); /** - * \brief Retrieve the complete set of diagnostics associated with a + * Retrieve the complete set of diagnostics associated with a * translation unit. * * \param Unit the translation unit to query. @@ -884,19 +891,19 @@ CINDEX_LINKAGE CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); /** - * \brief Destroy a diagnostic. + * Destroy a diagnostic. */ CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); /** - * \brief Options to control the display of diagnostics. + * Options to control the display of diagnostics. * * The values in this enum are meant to be combined to customize the * behavior of \c clang_formatDiagnostic(). */ enum CXDiagnosticDisplayOptions { /** - * \brief Display the source-location information where the + * Display the source-location information where the * diagnostic was located. * * When set, diagnostics will be prefixed by the file, line, and @@ -911,7 +918,7 @@ enum CXDiagnosticDisplayOptions { CXDiagnostic_DisplaySourceLocation = 0x01, /** - * \brief If displaying the source-location information of the + * If displaying the source-location information of the * diagnostic, also include the column number. * * This option corresponds to the clang flag \c -fshow-column. @@ -919,7 +926,7 @@ enum CXDiagnosticDisplayOptions { CXDiagnostic_DisplayColumn = 0x02, /** - * \brief If displaying the source-location information of the + * If displaying the source-location information of the * diagnostic, also include information about source ranges in a * machine-parsable format. * @@ -929,7 +936,7 @@ enum CXDiagnosticDisplayOptions { CXDiagnostic_DisplaySourceRanges = 0x04, /** - * \brief Display the option name associated with this diagnostic, if any. + * Display the option name associated with this diagnostic, if any. * * The option name displayed (e.g., -Wconversion) will be placed in brackets * after the diagnostic text. This option corresponds to the clang flag @@ -938,7 +945,7 @@ enum CXDiagnosticDisplayOptions { CXDiagnostic_DisplayOption = 0x08, /** - * \brief Display the category number associated with this diagnostic, if any. + * 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 @@ -947,7 +954,7 @@ enum CXDiagnosticDisplayOptions { CXDiagnostic_DisplayCategoryId = 0x10, /** - * \brief Display the category name associated with this diagnostic, if any. + * 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 @@ -957,7 +964,7 @@ enum CXDiagnosticDisplayOptions { }; /** - * \brief Format the given diagnostic in a manner that is suitable for display. + * Format the given diagnostic in a manner that is suitable for display. * * This routine will format the given diagnostic to a string, rendering * the diagnostic according to the various options given. The @@ -975,7 +982,7 @@ CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options); /** - * \brief Retrieve the set of display options most similar to the + * Retrieve the set of display options most similar to the * default behavior of the clang compiler. * * \returns A set of display options suitable for use with \c @@ -984,13 +991,13 @@ CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); /** - * \brief Determine the severity of the given diagnostic. + * Determine the severity of the given diagnostic. */ CINDEX_LINKAGE enum CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic); /** - * \brief Retrieve the source location of the given diagnostic. + * Retrieve the source location of the given diagnostic. * * This location is where Clang would print the caret ('^') when * displaying the diagnostic on the command line. @@ -998,12 +1005,12 @@ clang_getDiagnosticSeverity(CXDiagnostic); CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); /** - * \brief Retrieve the text of the given diagnostic. + * Retrieve the text of the given diagnostic. */ CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); /** - * \brief Retrieve the name of the command-line option that enabled this + * Retrieve the name of the command-line option that enabled this * diagnostic. * * \param Diag The diagnostic to be queried. @@ -1018,7 +1025,7 @@ CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, CXString *Disable); /** - * \brief Retrieve the category number for this diagnostic. + * 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 @@ -1030,7 +1037,7 @@ CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); /** - * \brief Retrieve the name of a particular diagnostic category. This + * Retrieve the name of a particular diagnostic category. This * is now deprecated. Use clang_getDiagnosticCategoryText() * instead. * @@ -1043,20 +1050,20 @@ CINDEX_DEPRECATED CINDEX_LINKAGE CXString clang_getDiagnosticCategoryName(unsigned Category); /** - * \brief Retrieve the diagnostic category text for a given diagnostic. + * Retrieve the diagnostic category text for a given diagnostic. * * \returns The text of the given diagnostic category. */ CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); /** - * \brief Determine the number of source ranges associated with the given + * Determine the number of source ranges associated with the given * diagnostic. */ CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); /** - * \brief Retrieve a source range associated with the diagnostic. + * Retrieve a source range associated with the diagnostic. * * A diagnostic's source ranges highlight important elements in the source * code. On the command line, Clang displays source ranges by @@ -1072,13 +1079,13 @@ CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, unsigned Range); /** - * \brief Determine the number of fix-it hints associated with the + * Determine the number of fix-it hints associated with the * given diagnostic. */ CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); /** - * \brief Retrieve the replacement information for a given fix-it. + * Retrieve the replacement information for a given fix-it. * * Fix-its are described in terms of a source range whose contents * should be replaced by a string. This approach generalizes over @@ -1121,13 +1128,13 @@ CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic, */ /** - * \brief Get the original translation unit source file name. + * Get the original translation unit source file name. */ CINDEX_LINKAGE CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); /** - * \brief Return the CXTranslationUnit for a given source file and the provided + * Return the CXTranslationUnit for a given source file and the provided * command line arguments one would pass to the compiler. * * Note: The 'source_filename' argument is optional. If the caller provides a @@ -1175,7 +1182,7 @@ CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( struct CXUnsavedFile *unsaved_files); /** - * \brief Same as \c clang_createTranslationUnit2, but returns + * Same as \c clang_createTranslationUnit2, but returns * the \c CXTranslationUnit instead of an error code. In case of an error this * routine returns a \c NULL \c CXTranslationUnit, without further detailed * error codes. @@ -1185,7 +1192,7 @@ CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit( const char *ast_filename); /** - * \brief Create a translation unit from an AST file (\c -emit-ast). + * Create a translation unit from an AST file (\c -emit-ast). * * \param[out] out_TU A non-NULL pointer to store the created * \c CXTranslationUnit. @@ -1198,7 +1205,7 @@ CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2( CXTranslationUnit *out_TU); /** - * \brief Flags that control the creation of translation units. + * Flags that control the creation of translation units. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when @@ -1206,13 +1213,13 @@ CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2( */ enum CXTranslationUnit_Flags { /** - * \brief Used to indicate that no special translation-unit options are + * Used to indicate that no special translation-unit options are * needed. */ CXTranslationUnit_None = 0x0, /** - * \brief Used to indicate that the parser should construct a "detailed" + * Used to indicate that the parser should construct a "detailed" * preprocessing record, including all macro definitions and instantiations. * * Constructing a detailed preprocessing record requires more memory @@ -1224,7 +1231,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_DetailedPreprocessingRecord = 0x01, /** - * \brief Used to indicate that the translation unit is incomplete. + * Used to indicate that the translation unit is incomplete. * * When a translation unit is considered "incomplete", semantic * analysis that is typically performed at the end of the @@ -1237,7 +1244,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_Incomplete = 0x02, /** - * \brief 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 @@ -1253,7 +1260,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_PrecompiledPreamble = 0x04, /** - * \brief Used to indicate that the translation unit should cache some + * Used to indicate that the translation unit should cache some * code-completion results with each reparse of the source file. * * Caching of code-completion results is a performance optimization that @@ -1263,7 +1270,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_CacheCompletionResults = 0x08, /** - * \brief Used to indicate that the translation unit will be serialized with + * Used to indicate that the translation unit will be serialized with * \c clang_saveTranslationUnit. * * This option is typically used when parsing a header with the intent of @@ -1272,7 +1279,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_ForSerialization = 0x10, /** - * \brief DEPRECATED: Enabled chained precompiled preambles in C++. + * DEPRECATED: Enabled chained precompiled preambles in C++. * * Note: this is a *temporary* option that is available only while * we are testing C++ precompiled preamble support. It is deprecated. @@ -1280,7 +1287,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_CXXChainedPCH = 0x20, /** - * \brief Used to indicate that function/method bodies should be skipped while + * Used to indicate that function/method bodies should be skipped while * parsing. * * This option can be used to search for declarations/definitions while @@ -1289,14 +1296,14 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_SkipFunctionBodies = 0x40, /** - * \brief Used to indicate that brief documentation comments should be + * Used to indicate that brief documentation comments should be * included into the set of code completions returned from this translation * unit. */ CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, /** - * \brief Used to indicate that the precompiled preamble should be created on + * Used to indicate that the precompiled preamble should be created on * the first parse. Otherwise it will be created on the first reparse. This * trades runtime on the first parse (serializing the preamble takes time) for * reduced runtime on the second parse (can now reuse the preamble). @@ -1304,7 +1311,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, /** - * \brief Do not stop processing when fatal errors are encountered. + * Do not stop processing when fatal errors are encountered. * * When fatal errors are encountered while parsing a translation unit, * semantic analysis is typically stopped early when compiling code. A common @@ -1315,13 +1322,21 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_KeepGoing = 0x200, /** - * \brief Sets the preprocessor in a mode for parsing a single file only. + * Sets the preprocessor in a mode for parsing a single file only. + */ + CXTranslationUnit_SingleFileParse = 0x400, + + /** + * Used in combination with CXTranslationUnit_SkipFunctionBodies to + * constrain the skipping of function bodies to the preamble. + * + * The function bodies of the main file are not skipped. */ - CXTranslationUnit_SingleFileParse = 0x400 + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800 }; /** - * \brief Returns the set of flags that is suitable for parsing a translation + * Returns the set of flags that is suitable for parsing a translation * unit that is being edited. * * The set of flags returned provide options for \c clang_parseTranslationUnit() @@ -1335,7 +1350,7 @@ enum CXTranslationUnit_Flags { CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); /** - * \brief Same as \c clang_parseTranslationUnit2, but returns + * Same as \c clang_parseTranslationUnit2, but returns * the \c CXTranslationUnit instead of an error code. In case of an error this * routine returns a \c NULL \c CXTranslationUnit, without further detailed * error codes. @@ -1350,7 +1365,7 @@ clang_parseTranslationUnit(CXIndex CIdx, unsigned options); /** - * \brief Parse the given source file and the translation unit corresponding + * Parse the given source file and the translation unit corresponding * to that file. * * This routine is the main entry point for the Clang C API, providing the @@ -1404,7 +1419,7 @@ clang_parseTranslationUnit2(CXIndex CIdx, CXTranslationUnit *out_TU); /** - * \brief Same as clang_parseTranslationUnit2 but requires a full command line + * Same as clang_parseTranslationUnit2 but requires a full command line * for \c command_line_args including argv[0]. This is useful if the standard * library paths are relative to the binary. */ @@ -1415,7 +1430,7 @@ CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv( unsigned options, CXTranslationUnit *out_TU); /** - * \brief Flags that control how translation units are saved. + * Flags that control how translation units are saved. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when @@ -1423,13 +1438,13 @@ CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv( */ enum CXSaveTranslationUnit_Flags { /** - * \brief Used to indicate that no special saving options are needed. + * Used to indicate that no special saving options are needed. */ CXSaveTranslationUnit_None = 0x0 }; /** - * \brief Returns the set of flags that is suitable for saving a translation + * Returns the set of flags that is suitable for saving a translation * unit. * * The set of flags returned provide options for @@ -1440,17 +1455,17 @@ enum CXSaveTranslationUnit_Flags { CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); /** - * \brief Describes the kind of error that occurred (if any) in a call to + * Describes the kind of error that occurred (if any) in a call to * \c clang_saveTranslationUnit(). */ enum CXSaveError { /** - * \brief Indicates that no error occurred while saving a translation unit. + * Indicates that no error occurred while saving a translation unit. */ CXSaveError_None = 0, /** - * \brief Indicates that an unknown error occurred while attempting to save + * Indicates that an unknown error occurred while attempting to save * the file. * * This error typically indicates that file I/O failed when attempting to @@ -1459,7 +1474,7 @@ enum CXSaveError { CXSaveError_Unknown = 1, /** - * \brief Indicates that errors during translation prevented this attempt + * Indicates that errors during translation prevented this attempt * to save the translation unit. * * Errors that prevent the translation unit from being saved can be @@ -1468,14 +1483,14 @@ enum CXSaveError { CXSaveError_TranslationErrors = 2, /** - * \brief Indicates that the translation unit to be saved was somehow + * Indicates that the translation unit to be saved was somehow * invalid (e.g., NULL). */ CXSaveError_InvalidTU = 3 }; /** - * \brief Saves a translation unit into a serialized representation of + * Saves a translation unit into a serialized representation of * that translation unit on disk. * * Any translation unit that was parsed without error can be saved @@ -1502,7 +1517,7 @@ CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, unsigned options); /** - * \brief Suspend a translation unit in order to free memory associated with it. + * Suspend a translation unit in order to free memory associated with it. * * A suspended translation unit uses significantly less memory but on the other * side does not support any other calls than \c clang_reparseTranslationUnit @@ -1511,12 +1526,12 @@ CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit); /** - * \brief Destroy the specified CXTranslationUnit object. + * Destroy the specified CXTranslationUnit object. */ CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); /** - * \brief Flags that control the reparsing of translation units. + * Flags that control the reparsing of translation units. * * The enumerators in this enumeration type are meant to be bitwise * ORed together to specify which options should be used when @@ -1524,13 +1539,13 @@ CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); */ enum CXReparse_Flags { /** - * \brief Used to indicate that no special reparsing options are needed. + * Used to indicate that no special reparsing options are needed. */ CXReparse_None = 0x0 }; /** - * \brief Returns the set of flags that is suitable for reparsing a translation + * Returns the set of flags that is suitable for reparsing a translation * unit. * * The set of flags returned provide options for @@ -1542,7 +1557,7 @@ enum CXReparse_Flags { CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); /** - * \brief Reparse the source files that produced this translation unit. + * Reparse the source files that produced this translation unit. * * This routine can be used to re-parse the source files that originally * created the given translation unit, for example because those source files @@ -1586,7 +1601,7 @@ CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned options); /** - * \brief Categorizes how memory is being used by a translation unit. + * Categorizes how memory is being used by a translation unit. */ enum CXTUResourceUsageKind { CXTUResourceUsage_AST = 1, @@ -1612,38 +1627,38 @@ enum CXTUResourceUsageKind { }; /** - * \brief Returns the human-readable null-terminated C string that represents + * Returns the human-readable null-terminated C string that represents * the name of the memory category. This string should never be freed. */ CINDEX_LINKAGE const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); typedef struct CXTUResourceUsageEntry { - /* \brief The memory usage category. */ + /* The memory usage category. */ enum CXTUResourceUsageKind kind; - /* \brief Amount of resources used. + /* Amount of resources used. The units will depend on the resource kind. */ unsigned long amount; } CXTUResourceUsageEntry; /** - * \brief The memory usage of a CXTranslationUnit, broken into categories. + * The memory usage of a CXTranslationUnit, broken into categories. */ typedef struct CXTUResourceUsage { - /* \brief Private data member, used for queries. */ + /* Private data member, used for queries. */ void *data; - /* \brief The number of entries in the 'entries' array. */ + /* The number of entries in the 'entries' array. */ unsigned numEntries; - /* \brief An array of key-value pairs, representing the breakdown of memory + /* An array of key-value pairs, representing the breakdown of memory usage. */ CXTUResourceUsageEntry *entries; } CXTUResourceUsage; /** - * \brief Return the memory usage of a translation unit. This object + * Return the memory usage of a translation unit. This object * should be released with clang_disposeCXTUResourceUsage(). */ CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU); @@ -1651,7 +1666,7 @@ CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); /** - * \brief Get target information for this translation unit. + * Get target information for this translation unit. * * The CXTargetInfo object cannot outlive the CXTranslationUnit object. */ @@ -1659,13 +1674,13 @@ CINDEX_LINKAGE CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit); /** - * \brief Destroy the CXTargetInfo object. + * Destroy the CXTargetInfo object. */ CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info); /** - * \brief Get the normalized target triple as a string. + * Get the normalized target triple as a string. * * Returns the empty string in case of any error. */ @@ -1673,7 +1688,7 @@ CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info); /** - * \brief Get the pointer width of the target in bits. + * Get the pointer width of the target in bits. * * Returns -1 in case of error. */ @@ -1685,12 +1700,12 @@ clang_TargetInfo_getPointerWidth(CXTargetInfo Info); */ /** - * \brief Describes the kind of entity that a cursor refers to. + * Describes the kind of entity that a cursor refers to. */ enum CXCursorKind { /* Declarations */ /** - * \brief A declaration whose specific kind is not exposed via this + * A declaration whose specific kind is not exposed via this * interface. * * Unexposed declarations have the same operations as any other kind @@ -1699,84 +1714,84 @@ enum CXCursorKind { * of the declaration is not reported. */ CXCursor_UnexposedDecl = 1, - /** \brief A C or C++ struct. */ + /** A C or C++ struct. */ CXCursor_StructDecl = 2, - /** \brief A C or C++ union. */ + /** A C or C++ union. */ CXCursor_UnionDecl = 3, - /** \brief A C++ class. */ + /** A C++ class. */ CXCursor_ClassDecl = 4, - /** \brief An enumeration. */ + /** An enumeration. */ CXCursor_EnumDecl = 5, /** - * \brief A field (in C) or non-static data member (in C++) in a + * A field (in C) or non-static data member (in C++) in a * struct, union, or C++ class. */ CXCursor_FieldDecl = 6, - /** \brief An enumerator constant. */ + /** An enumerator constant. */ CXCursor_EnumConstantDecl = 7, - /** \brief A function. */ + /** A function. */ CXCursor_FunctionDecl = 8, - /** \brief A variable. */ + /** A variable. */ CXCursor_VarDecl = 9, - /** \brief A function or method parameter. */ + /** A function or method parameter. */ CXCursor_ParmDecl = 10, - /** \brief An Objective-C \@interface. */ + /** An Objective-C \@interface. */ CXCursor_ObjCInterfaceDecl = 11, - /** \brief An Objective-C \@interface for a category. */ + /** An Objective-C \@interface for a category. */ CXCursor_ObjCCategoryDecl = 12, - /** \brief An Objective-C \@protocol declaration. */ + /** An Objective-C \@protocol declaration. */ CXCursor_ObjCProtocolDecl = 13, - /** \brief An Objective-C \@property declaration. */ + /** An Objective-C \@property declaration. */ CXCursor_ObjCPropertyDecl = 14, - /** \brief An Objective-C instance variable. */ + /** An Objective-C instance variable. */ CXCursor_ObjCIvarDecl = 15, - /** \brief An Objective-C instance method. */ + /** An Objective-C instance method. */ CXCursor_ObjCInstanceMethodDecl = 16, - /** \brief An Objective-C class method. */ + /** An Objective-C class method. */ CXCursor_ObjCClassMethodDecl = 17, - /** \brief An Objective-C \@implementation. */ + /** An Objective-C \@implementation. */ CXCursor_ObjCImplementationDecl = 18, - /** \brief An Objective-C \@implementation for a category. */ + /** An Objective-C \@implementation for a category. */ CXCursor_ObjCCategoryImplDecl = 19, - /** \brief A typedef. */ + /** A typedef. */ CXCursor_TypedefDecl = 20, - /** \brief A C++ class method. */ + /** A C++ class method. */ CXCursor_CXXMethod = 21, - /** \brief A C++ namespace. */ + /** A C++ namespace. */ CXCursor_Namespace = 22, - /** \brief A linkage specification, e.g. 'extern "C"'. */ + /** A linkage specification, e.g. 'extern "C"'. */ CXCursor_LinkageSpec = 23, - /** \brief A C++ constructor. */ + /** A C++ constructor. */ CXCursor_Constructor = 24, - /** \brief A C++ destructor. */ + /** A C++ destructor. */ CXCursor_Destructor = 25, - /** \brief A C++ conversion function. */ + /** A C++ conversion function. */ CXCursor_ConversionFunction = 26, - /** \brief A C++ template type parameter. */ + /** A C++ template type parameter. */ CXCursor_TemplateTypeParameter = 27, - /** \brief A C++ non-type template parameter. */ + /** A C++ non-type template parameter. */ CXCursor_NonTypeTemplateParameter = 28, - /** \brief A C++ template template parameter. */ + /** A C++ template template parameter. */ CXCursor_TemplateTemplateParameter = 29, - /** \brief A C++ function template. */ + /** A C++ function template. */ CXCursor_FunctionTemplate = 30, - /** \brief A C++ class template. */ + /** A C++ class template. */ CXCursor_ClassTemplate = 31, - /** \brief A C++ class template partial specialization. */ + /** A C++ class template partial specialization. */ CXCursor_ClassTemplatePartialSpecialization = 32, - /** \brief A C++ namespace alias declaration. */ + /** A C++ namespace alias declaration. */ CXCursor_NamespaceAlias = 33, - /** \brief A C++ using directive. */ + /** A C++ using directive. */ CXCursor_UsingDirective = 34, - /** \brief A C++ using declaration. */ + /** A C++ using declaration. */ CXCursor_UsingDeclaration = 35, - /** \brief A C++ alias declaration */ + /** A C++ alias declaration */ CXCursor_TypeAliasDecl = 36, - /** \brief An Objective-C \@synthesize definition. */ + /** An Objective-C \@synthesize definition. */ CXCursor_ObjCSynthesizeDecl = 37, - /** \brief An Objective-C \@dynamic definition. */ + /** An Objective-C \@dynamic definition. */ CXCursor_ObjCDynamicDecl = 38, - /** \brief An access specifier. */ + /** An access specifier. */ CXCursor_CXXAccessSpecifier = 39, CXCursor_FirstDecl = CXCursor_UnexposedDecl, @@ -1788,7 +1803,7 @@ enum CXCursorKind { CXCursor_ObjCProtocolRef = 41, CXCursor_ObjCClassRef = 42, /** - * \brief A reference to a type declaration. + * A reference to a type declaration. * * A type reference occurs anywhere where a type is named but not * declared. For example, given: @@ -1805,21 +1820,21 @@ enum CXCursorKind { CXCursor_TypeRef = 43, CXCursor_CXXBaseSpecifier = 44, /** - * \brief A reference to a class template, function template, template + * A reference to a class template, function template, template * template parameter, or class template partial specialization. */ CXCursor_TemplateRef = 45, /** - * \brief A reference to a namespace or namespace alias. + * A reference to a namespace or namespace alias. */ CXCursor_NamespaceRef = 46, /** - * \brief 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, /** - * \brief A reference to a labeled statement. + * A reference to a labeled statement. * * This cursor kind is used to describe the jump to "start_over" in the * goto statement in the following example: @@ -1836,7 +1851,7 @@ enum CXCursorKind { CXCursor_LabelRef = 48, /** - * \brief A reference to a set of overloaded functions or function templates + * A reference to a set of overloaded functions or function templates * that has not yet been resolved to a specific function or function template. * * An overloaded declaration reference cursor occurs in C++ templates where @@ -1874,7 +1889,7 @@ enum CXCursorKind { CXCursor_OverloadedDeclRef = 49, /** - * \brief 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, @@ -1893,7 +1908,7 @@ enum CXCursorKind { CXCursor_FirstExpr = 100, /** - * \brief An expression whose specific kind is not exposed via this + * An expression whose specific kind is not exposed via this * interface. * * Unexposed expressions have the same operations as any other kind @@ -1904,103 +1919,103 @@ enum CXCursorKind { CXCursor_UnexposedExpr = 100, /** - * \brief An expression that refers to some value declaration, such + * An expression that refers to some value declaration, such * as a function, variable, or enumerator. */ CXCursor_DeclRefExpr = 101, /** - * \brief An expression that refers to a member of a struct, union, + * An expression that refers to a member of a struct, union, * class, Objective-C class, etc. */ CXCursor_MemberRefExpr = 102, - /** \brief An expression that calls a function. */ + /** An expression that calls a function. */ CXCursor_CallExpr = 103, - /** \brief An expression that sends a message to an Objective-C + /** An expression that sends a message to an Objective-C object or class. */ CXCursor_ObjCMessageExpr = 104, - /** \brief An expression that represents a block literal. */ + /** An expression that represents a block literal. */ CXCursor_BlockExpr = 105, - /** \brief An integer literal. + /** An integer literal. */ CXCursor_IntegerLiteral = 106, - /** \brief A floating point number literal. + /** A floating point number literal. */ CXCursor_FloatingLiteral = 107, - /** \brief An imaginary number literal. + /** An imaginary number literal. */ CXCursor_ImaginaryLiteral = 108, - /** \brief A string literal. + /** A string literal. */ CXCursor_StringLiteral = 109, - /** \brief A character literal. + /** A character literal. */ CXCursor_CharacterLiteral = 110, - /** \brief A parenthesized expression, e.g. "(1)". + /** A parenthesized expression, e.g. "(1)". * * This AST node is only formed if full location information is requested. */ CXCursor_ParenExpr = 111, - /** \brief This represents the unary-expression's (except sizeof and + /** This represents the unary-expression's (except sizeof and * alignof). */ CXCursor_UnaryOperator = 112, - /** \brief [C99 6.5.2.1] Array Subscripting. + /** [C99 6.5.2.1] Array Subscripting. */ CXCursor_ArraySubscriptExpr = 113, - /** \brief A builtin binary operation expression such as "x + y" or + /** A builtin binary operation expression such as "x + y" or * "x <= y". */ CXCursor_BinaryOperator = 114, - /** \brief Compound assignment such as "+=". + /** Compound assignment such as "+=". */ CXCursor_CompoundAssignOperator = 115, - /** \brief The ?: ternary operator. + /** The ?: ternary operator. */ CXCursor_ConditionalOperator = 116, - /** \brief An explicit cast in C (C99 6.5.4) or a C-style cast in C++ + /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++ * (C++ [expr.cast]), which uses the syntax (Type)expr. * * For example: (int)f. */ CXCursor_CStyleCastExpr = 117, - /** \brief [C99 6.5.2.5] + /** [C99 6.5.2.5] */ CXCursor_CompoundLiteralExpr = 118, - /** \brief Describes an C or C++ initializer list. + /** Describes an C or C++ initializer list. */ CXCursor_InitListExpr = 119, - /** \brief The GNU address of label extension, representing &&label. + /** The GNU address of label extension, representing &&label. */ CXCursor_AddrLabelExpr = 120, - /** \brief This is the GNU Statement Expression extension: ({int X=4; X;}) + /** This is the GNU Statement Expression extension: ({int X=4; X;}) */ CXCursor_StmtExpr = 121, - /** \brief Represents a C11 generic selection. + /** Represents a C11 generic selection. */ CXCursor_GenericSelectionExpr = 122, - /** \brief Implements the GNU __null extension, which is a name for a null + /** Implements the GNU __null extension, which is a name for a null * pointer constant that has integral type (e.g., int or long) and is the same * size and alignment as a pointer. * @@ -2010,23 +2025,23 @@ enum CXCursorKind { */ CXCursor_GNUNullExpr = 123, - /** \brief C++'s static_cast<> expression. + /** C++'s static_cast<> expression. */ CXCursor_CXXStaticCastExpr = 124, - /** \brief C++'s dynamic_cast<> expression. + /** C++'s dynamic_cast<> expression. */ CXCursor_CXXDynamicCastExpr = 125, - /** \brief C++'s reinterpret_cast<> expression. + /** C++'s reinterpret_cast<> expression. */ CXCursor_CXXReinterpretCastExpr = 126, - /** \brief C++'s const_cast<> expression. + /** C++'s const_cast<> expression. */ CXCursor_CXXConstCastExpr = 127, - /** \brief Represents an explicit C++ type conversion that uses "functional" + /** Represents an explicit C++ type conversion that uses "functional" * notion (C++ [expr.type.conv]). * * Example: @@ -2036,60 +2051,60 @@ enum CXCursorKind { */ CXCursor_CXXFunctionalCastExpr = 128, - /** \brief A C++ typeid expression (C++ [expr.typeid]). + /** A C++ typeid expression (C++ [expr.typeid]). */ CXCursor_CXXTypeidExpr = 129, - /** \brief [C++ 2.13.5] C++ Boolean Literal. + /** [C++ 2.13.5] C++ Boolean Literal. */ CXCursor_CXXBoolLiteralExpr = 130, - /** \brief [C++0x 2.14.7] C++ Pointer Literal. + /** [C++0x 2.14.7] C++ Pointer Literal. */ CXCursor_CXXNullPtrLiteralExpr = 131, - /** \brief Represents the "this" expression in C++ + /** Represents the "this" expression in C++ */ CXCursor_CXXThisExpr = 132, - /** \brief [C++ 15] C++ Throw Expression. + /** [C++ 15] C++ Throw Expression. * * This handles 'throw' and 'throw' assignment-expression. When * assignment-expression isn't present, Op will be null. */ CXCursor_CXXThrowExpr = 133, - /** \brief A new expression for memory allocation and constructor calls, e.g: + /** A new expression for memory allocation and constructor calls, e.g: * "new CXXNewExpr(foo)". */ CXCursor_CXXNewExpr = 134, - /** \brief A delete expression for memory deallocation and destructor calls, + /** A delete expression for memory deallocation and destructor calls, * e.g. "delete[] pArray". */ CXCursor_CXXDeleteExpr = 135, - /** \brief A unary expression. (noexcept, sizeof, or other traits) + /** A unary expression. (noexcept, sizeof, or other traits) */ CXCursor_UnaryExpr = 136, - /** \brief An Objective-C string literal i.e. @"foo". + /** An Objective-C string literal i.e. @"foo". */ CXCursor_ObjCStringLiteral = 137, - /** \brief An Objective-C \@encode expression. + /** An Objective-C \@encode expression. */ CXCursor_ObjCEncodeExpr = 138, - /** \brief An Objective-C \@selector expression. + /** An Objective-C \@selector expression. */ CXCursor_ObjCSelectorExpr = 139, - /** \brief An Objective-C \@protocol expression. + /** An Objective-C \@protocol expression. */ CXCursor_ObjCProtocolExpr = 140, - /** \brief An Objective-C "bridged" cast expression, which casts between + /** An Objective-C "bridged" cast expression, which casts between * Objective-C pointers and C pointers, transferring ownership in the process. * * \code @@ -2098,7 +2113,7 @@ enum CXCursorKind { */ CXCursor_ObjCBridgedCastExpr = 141, - /** \brief Represents a C++0x pack expansion that produces a sequence of + /** Represents a C++0x pack expansion that produces a sequence of * expressions. * * A pack expansion expression contains a pattern (which itself is an @@ -2113,7 +2128,7 @@ enum CXCursorKind { */ CXCursor_PackExpansionExpr = 142, - /** \brief Represents an expression that computes the length of a parameter + /** Represents an expression that computes the length of a parameter * pack. * * \code @@ -2125,7 +2140,7 @@ enum CXCursorKind { */ CXCursor_SizeOfPackExpr = 143, - /* \brief Represents a C++ lambda expression that produces a local function + /* Represents a C++ lambda expression that produces a local function * object. * * \code @@ -2139,28 +2154,33 @@ enum CXCursorKind { */ CXCursor_LambdaExpr = 144, - /** \brief Objective-c Boolean Literal. + /** Objective-c Boolean Literal. */ CXCursor_ObjCBoolLiteralExpr = 145, - /** \brief Represents the "self" expression in an Objective-C method. + /** Represents the "self" expression in an Objective-C method. */ CXCursor_ObjCSelfExpr = 146, - /** \brief OpenMP 4.0 [2.4, Array Section]. + /** OpenMP 4.0 [2.4, Array Section]. */ CXCursor_OMPArraySectionExpr = 147, - /** \brief Represents an @available(...) check. + /** Represents an @available(...) check. */ CXCursor_ObjCAvailabilityCheckExpr = 148, - CXCursor_LastExpr = CXCursor_ObjCAvailabilityCheckExpr, + /** + * Fixed point literal + */ + CXCursor_FixedPointLiteral = 149, + + CXCursor_LastExpr = CXCursor_FixedPointLiteral, /* Statements */ CXCursor_FirstStmt = 200, /** - * \brief A statement whose specific kind is not exposed via this + * A statement whose specific kind is not exposed via this * interface. * * Unexposed statements have the same operations as any other kind of @@ -2170,7 +2190,7 @@ enum CXCursorKind { */ CXCursor_UnexposedStmt = 200, - /** \brief 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 * the following example: @@ -2183,329 +2203,329 @@ enum CXCursorKind { */ CXCursor_LabelStmt = 201, - /** \brief A group of statements like { stmt stmt }. + /** A group of statements like { stmt stmt }. * * This cursor kind is used to describe compound statements, e.g. function * bodies. */ CXCursor_CompoundStmt = 202, - /** \brief A case statement. + /** A case statement. */ CXCursor_CaseStmt = 203, - /** \brief A default statement. + /** A default statement. */ CXCursor_DefaultStmt = 204, - /** \brief An if statement + /** An if statement */ CXCursor_IfStmt = 205, - /** \brief A switch statement. + /** A switch statement. */ CXCursor_SwitchStmt = 206, - /** \brief A while statement. + /** A while statement. */ CXCursor_WhileStmt = 207, - /** \brief A do statement. + /** A do statement. */ CXCursor_DoStmt = 208, - /** \brief A for statement. + /** A for statement. */ CXCursor_ForStmt = 209, - /** \brief A goto statement. + /** A goto statement. */ CXCursor_GotoStmt = 210, - /** \brief An indirect goto statement. + /** An indirect goto statement. */ CXCursor_IndirectGotoStmt = 211, - /** \brief A continue statement. + /** A continue statement. */ CXCursor_ContinueStmt = 212, - /** \brief A break statement. + /** A break statement. */ CXCursor_BreakStmt = 213, - /** \brief A return statement. + /** A return statement. */ CXCursor_ReturnStmt = 214, - /** \brief A GCC inline assembly statement extension. + /** A GCC inline assembly statement extension. */ CXCursor_GCCAsmStmt = 215, CXCursor_AsmStmt = CXCursor_GCCAsmStmt, - /** \brief Objective-C's overall \@try-\@catch-\@finally statement. + /** Objective-C's overall \@try-\@catch-\@finally statement. */ CXCursor_ObjCAtTryStmt = 216, - /** \brief Objective-C's \@catch statement. + /** Objective-C's \@catch statement. */ CXCursor_ObjCAtCatchStmt = 217, - /** \brief Objective-C's \@finally statement. + /** Objective-C's \@finally statement. */ CXCursor_ObjCAtFinallyStmt = 218, - /** \brief Objective-C's \@throw statement. + /** Objective-C's \@throw statement. */ CXCursor_ObjCAtThrowStmt = 219, - /** \brief Objective-C's \@synchronized statement. + /** Objective-C's \@synchronized statement. */ CXCursor_ObjCAtSynchronizedStmt = 220, - /** \brief Objective-C's autorelease pool statement. + /** Objective-C's autorelease pool statement. */ CXCursor_ObjCAutoreleasePoolStmt = 221, - /** \brief Objective-C's collection statement. + /** Objective-C's collection statement. */ CXCursor_ObjCForCollectionStmt = 222, - /** \brief C++'s catch statement. + /** C++'s catch statement. */ CXCursor_CXXCatchStmt = 223, - /** \brief C++'s try statement. + /** C++'s try statement. */ CXCursor_CXXTryStmt = 224, - /** \brief C++'s for (* : *) statement. + /** C++'s for (* : *) statement. */ CXCursor_CXXForRangeStmt = 225, - /** \brief Windows Structured Exception Handling's try statement. + /** Windows Structured Exception Handling's try statement. */ CXCursor_SEHTryStmt = 226, - /** \brief Windows Structured Exception Handling's except statement. + /** Windows Structured Exception Handling's except statement. */ CXCursor_SEHExceptStmt = 227, - /** \brief Windows Structured Exception Handling's finally statement. + /** Windows Structured Exception Handling's finally statement. */ CXCursor_SEHFinallyStmt = 228, - /** \brief A MS inline assembly statement extension. + /** A MS inline assembly statement extension. */ CXCursor_MSAsmStmt = 229, - /** \brief The null statement ";": C99 6.8.3p3. + /** The null statement ";": C99 6.8.3p3. * * This cursor kind is used to describe the null statement. */ CXCursor_NullStmt = 230, - /** \brief Adaptor class for mixing declarations with statements and + /** Adaptor class for mixing declarations with statements and * expressions. */ CXCursor_DeclStmt = 231, - /** \brief OpenMP parallel directive. + /** OpenMP parallel directive. */ CXCursor_OMPParallelDirective = 232, - /** \brief OpenMP SIMD directive. + /** OpenMP SIMD directive. */ CXCursor_OMPSimdDirective = 233, - /** \brief OpenMP for directive. + /** OpenMP for directive. */ CXCursor_OMPForDirective = 234, - /** \brief OpenMP sections directive. + /** OpenMP sections directive. */ CXCursor_OMPSectionsDirective = 235, - /** \brief OpenMP section directive. + /** OpenMP section directive. */ CXCursor_OMPSectionDirective = 236, - /** \brief OpenMP single directive. + /** OpenMP single directive. */ CXCursor_OMPSingleDirective = 237, - /** \brief OpenMP parallel for directive. + /** OpenMP parallel for directive. */ CXCursor_OMPParallelForDirective = 238, - /** \brief OpenMP parallel sections directive. + /** OpenMP parallel sections directive. */ CXCursor_OMPParallelSectionsDirective = 239, - /** \brief OpenMP task directive. + /** OpenMP task directive. */ CXCursor_OMPTaskDirective = 240, - /** \brief OpenMP master directive. + /** OpenMP master directive. */ CXCursor_OMPMasterDirective = 241, - /** \brief OpenMP critical directive. + /** OpenMP critical directive. */ CXCursor_OMPCriticalDirective = 242, - /** \brief OpenMP taskyield directive. + /** OpenMP taskyield directive. */ CXCursor_OMPTaskyieldDirective = 243, - /** \brief OpenMP barrier directive. + /** OpenMP barrier directive. */ CXCursor_OMPBarrierDirective = 244, - /** \brief OpenMP taskwait directive. + /** OpenMP taskwait directive. */ CXCursor_OMPTaskwaitDirective = 245, - /** \brief OpenMP flush directive. + /** OpenMP flush directive. */ CXCursor_OMPFlushDirective = 246, - /** \brief Windows Structured Exception Handling's leave statement. + /** Windows Structured Exception Handling's leave statement. */ CXCursor_SEHLeaveStmt = 247, - /** \brief OpenMP ordered directive. + /** OpenMP ordered directive. */ CXCursor_OMPOrderedDirective = 248, - /** \brief OpenMP atomic directive. + /** OpenMP atomic directive. */ CXCursor_OMPAtomicDirective = 249, - /** \brief OpenMP for SIMD directive. + /** OpenMP for SIMD directive. */ CXCursor_OMPForSimdDirective = 250, - /** \brief OpenMP parallel for SIMD directive. + /** OpenMP parallel for SIMD directive. */ CXCursor_OMPParallelForSimdDirective = 251, - /** \brief OpenMP target directive. + /** OpenMP target directive. */ CXCursor_OMPTargetDirective = 252, - /** \brief OpenMP teams directive. + /** OpenMP teams directive. */ CXCursor_OMPTeamsDirective = 253, - /** \brief OpenMP taskgroup directive. + /** OpenMP taskgroup directive. */ CXCursor_OMPTaskgroupDirective = 254, - /** \brief OpenMP cancellation point directive. + /** OpenMP cancellation point directive. */ CXCursor_OMPCancellationPointDirective = 255, - /** \brief OpenMP cancel directive. + /** OpenMP cancel directive. */ CXCursor_OMPCancelDirective = 256, - /** \brief OpenMP target data directive. + /** OpenMP target data directive. */ CXCursor_OMPTargetDataDirective = 257, - /** \brief OpenMP taskloop directive. + /** OpenMP taskloop directive. */ CXCursor_OMPTaskLoopDirective = 258, - /** \brief OpenMP taskloop simd directive. + /** OpenMP taskloop simd directive. */ CXCursor_OMPTaskLoopSimdDirective = 259, - /** \brief OpenMP distribute directive. + /** OpenMP distribute directive. */ CXCursor_OMPDistributeDirective = 260, - /** \brief OpenMP target enter data directive. + /** OpenMP target enter data directive. */ CXCursor_OMPTargetEnterDataDirective = 261, - /** \brief OpenMP target exit data directive. + /** OpenMP target exit data directive. */ CXCursor_OMPTargetExitDataDirective = 262, - /** \brief OpenMP target parallel directive. + /** OpenMP target parallel directive. */ CXCursor_OMPTargetParallelDirective = 263, - /** \brief OpenMP target parallel for directive. + /** OpenMP target parallel for directive. */ CXCursor_OMPTargetParallelForDirective = 264, - /** \brief OpenMP target update directive. + /** OpenMP target update directive. */ CXCursor_OMPTargetUpdateDirective = 265, - /** \brief OpenMP distribute parallel for directive. + /** OpenMP distribute parallel for directive. */ CXCursor_OMPDistributeParallelForDirective = 266, - /** \brief OpenMP distribute parallel for simd directive. + /** OpenMP distribute parallel for simd directive. */ CXCursor_OMPDistributeParallelForSimdDirective = 267, - /** \brief OpenMP distribute simd directive. + /** OpenMP distribute simd directive. */ CXCursor_OMPDistributeSimdDirective = 268, - /** \brief OpenMP target parallel for simd directive. + /** OpenMP target parallel for simd directive. */ CXCursor_OMPTargetParallelForSimdDirective = 269, - /** \brief OpenMP target simd directive. + /** OpenMP target simd directive. */ CXCursor_OMPTargetSimdDirective = 270, - /** \brief OpenMP teams distribute directive. + /** OpenMP teams distribute directive. */ CXCursor_OMPTeamsDistributeDirective = 271, - /** \brief OpenMP teams distribute simd directive. + /** OpenMP teams distribute simd directive. */ CXCursor_OMPTeamsDistributeSimdDirective = 272, - /** \brief OpenMP teams distribute parallel for simd directive. + /** OpenMP teams distribute parallel for simd directive. */ CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, - /** \brief OpenMP teams distribute parallel for directive. + /** OpenMP teams distribute parallel for directive. */ CXCursor_OMPTeamsDistributeParallelForDirective = 274, - /** \brief OpenMP target teams directive. + /** OpenMP target teams directive. */ CXCursor_OMPTargetTeamsDirective = 275, - /** \brief OpenMP target teams distribute directive. + /** OpenMP target teams distribute directive. */ CXCursor_OMPTargetTeamsDistributeDirective = 276, - /** \brief OpenMP target teams distribute parallel for directive. + /** OpenMP target teams distribute parallel for directive. */ CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, - /** \brief OpenMP target teams distribute parallel for simd directive. + /** OpenMP target teams distribute parallel for simd directive. */ CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, - /** \brief OpenMP target teams distribute simd directive. + /** OpenMP target teams distribute simd directive. */ CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective, /** - * \brief Cursor that represents the translation unit itself. + * Cursor that represents the translation unit itself. * * The translation unit cursor exists primarily to act as the root * cursor for traversing the contents of a translation unit. @@ -2515,7 +2535,7 @@ enum CXCursorKind { /* Attributes */ CXCursor_FirstAttr = 400, /** - * \brief An attribute whose specific kind is not exposed via this + * An attribute whose specific kind is not exposed via this * interface. */ CXCursor_UnexposedAttr = 400, @@ -2552,29 +2572,29 @@ enum CXCursorKind { /* Extra Declarations */ /** - * \brief A module import declaration. + * A module import declaration. */ CXCursor_ModuleImportDecl = 600, CXCursor_TypeAliasTemplateDecl = 601, /** - * \brief A static_assert or _Static_assert node + * A static_assert or _Static_assert node */ CXCursor_StaticAssert = 602, /** - * \brief a friend declaration. + * a friend declaration. */ CXCursor_FriendDecl = 603, CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, CXCursor_LastExtraDecl = CXCursor_FriendDecl, /** - * \brief A code completion overload candidate. + * A code completion overload candidate. */ CXCursor_OverloadCandidate = 700 }; /** - * \brief A cursor representing some element in the abstract syntax tree for + * A cursor representing some element in the abstract syntax tree for * a translation unit. * * The cursor abstraction unifies the different kinds of entities in a @@ -2604,12 +2624,12 @@ typedef struct { */ /** - * \brief Retrieve the NULL cursor, which represents no entity. + * Retrieve the NULL cursor, which represents no entity. */ CINDEX_LINKAGE CXCursor clang_getNullCursor(void); /** - * \brief Retrieve the cursor that represents the given translation unit. + * Retrieve the cursor that represents the given translation unit. * * The translation unit cursor can be used to start traversing the * various declarations within the given translation unit. @@ -2617,32 +2637,42 @@ CINDEX_LINKAGE CXCursor clang_getNullCursor(void); CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); /** - * \brief Determine whether two cursors are equivalent. + * Determine whether two cursors are equivalent. */ CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); /** - * \brief Returns non-zero if \p cursor is null. + * Returns non-zero if \p cursor is null. */ CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); /** - * \brief Compute a hash value for the given cursor. + * Compute a hash value for the given cursor. */ CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); /** - * \brief Retrieve the kind of the given cursor. + * Retrieve the kind of the given cursor. */ CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); /** - * \brief Determine whether the given cursor kind represents a declaration. + * Determine whether the given cursor kind represents a declaration. */ CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); /** - * \brief Determine whether the given cursor kind represents a simple + * Determine whether the given declaration is invalid. + * + * A declaration is invalid if it could not be parsed successfully. + * + * \returns non-zero if the cursor represents a declaration and it is + * invalid, otherwise NULL. + */ +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); + +/** + * Determine whether the given cursor kind represents a simple * reference. * * Note that other kinds of cursors (such as expressions) can also refer to @@ -2652,90 +2682,90 @@ CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); /** - * \brief Determine whether the given cursor kind represents an expression. + * Determine whether the given cursor kind represents an expression. */ CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); /** - * \brief Determine whether the given cursor kind represents a statement. + * Determine whether the given cursor kind represents a statement. */ CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); /** - * \brief Determine whether the given cursor kind represents an attribute. + * Determine whether the given cursor kind represents an attribute. */ CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); /** - * \brief Determine whether the given cursor has any attributes. + * Determine whether the given cursor has any attributes. */ CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C); /** - * \brief Determine whether the given cursor kind represents an invalid + * Determine whether the given cursor kind represents an invalid * cursor. */ CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); /** - * \brief Determine whether the given cursor kind represents a translation + * Determine whether the given cursor kind represents a translation * unit. */ CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); /*** - * \brief Determine whether the given cursor represents a preprocessing + * Determine whether the given cursor represents a preprocessing * element, such as a preprocessor directive or macro instantiation. */ CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); /*** - * \brief Determine whether the given cursor represents a currently + * Determine whether the given cursor represents a currently * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). */ CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); /** - * \brief Describe the linkage of the entity referred to by a cursor. + * Describe the linkage of the entity referred to by a cursor. */ enum CXLinkageKind { - /** \brief This value indicates that no linkage information is available + /** This value indicates that no linkage information is available * for a provided CXCursor. */ CXLinkage_Invalid, /** - * \brief This is the linkage for variables, parameters, and so on that + * This is the linkage for variables, parameters, and so on that * have automatic storage. This covers normal (non-extern) local variables. */ CXLinkage_NoLinkage, - /** \brief This is the linkage for static variables and static functions. */ + /** This is the linkage for static variables and static functions. */ CXLinkage_Internal, - /** \brief This is the linkage for entities with external linkage that live + /** This is the linkage for entities with external linkage that live * in C++ anonymous namespaces.*/ CXLinkage_UniqueExternal, - /** \brief This is the linkage for entities with true, external linkage. */ + /** This is the linkage for entities with true, external linkage. */ CXLinkage_External }; /** - * \brief Determine the linkage of the entity referred to by a given cursor. + * Determine the linkage of the entity referred to by a given cursor. */ CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); enum CXVisibilityKind { - /** \brief This value indicates that no visibility information is available + /** This value indicates that no visibility information is available * for a provided CXCursor. */ CXVisibility_Invalid, - /** \brief Symbol not seen by the linker. */ + /** Symbol not seen by the linker. */ CXVisibility_Hidden, - /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */ + /** Symbol seen by the linker but resolves to a symbol inside this object. */ CXVisibility_Protected, - /** \brief Symbol seen by the linker and acts like a normal symbol. */ + /** Symbol seen by the linker and acts like a normal symbol. */ CXVisibility_Default }; /** - * \brief Describe the visibility of the entity referred to by a cursor. + * Describe the visibility of the entity referred to by a cursor. * * This returns the default visibility if not explicitly specified by * a visibility attribute. The default visibility may be changed by @@ -2748,7 +2778,7 @@ enum CXVisibilityKind { CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); /** - * \brief Determine the availability of the entity that this cursor refers to, + * Determine the availability of the entity that this cursor refers to, * taking the current target platform into account. * * \param cursor The cursor to query. @@ -2764,39 +2794,39 @@ clang_getCursorAvailability(CXCursor cursor); */ typedef struct CXPlatformAvailability { /** - * \brief A string that describes the platform for which this structure + * A string that describes the platform for which this structure * provides availability information. * * Possible values are "ios" or "macos". */ CXString Platform; /** - * \brief The version number in which this entity was introduced. + * The version number in which this entity was introduced. */ CXVersion Introduced; /** - * \brief The version number in which this entity was deprecated (but is + * The version number in which this entity was deprecated (but is * still available). */ CXVersion Deprecated; /** - * \brief The version number in which this entity was obsoleted, and therefore + * The version number in which this entity was obsoleted, and therefore * is no longer available. */ CXVersion Obsoleted; /** - * \brief Whether the entity is unconditionally unavailable on this platform. + * Whether the entity is unconditionally unavailable on this platform. */ int Unavailable; /** - * \brief An optional message to provide to a user of this API, e.g., to + * An optional message to provide to a user of this API, e.g., to * suggest replacement APIs. */ CXString Message; } CXPlatformAvailability; /** - * \brief Determine the availability of the entity that this cursor refers to + * Determine the availability of the entity that this cursor refers to * on any platforms for which availability information is known. * * \param cursor The cursor to query. @@ -2841,13 +2871,13 @@ clang_getCursorPlatformAvailability(CXCursor cursor, int availability_size); /** - * \brief Free the memory associated with a \c CXPlatformAvailability structure. + * Free the memory associated with a \c CXPlatformAvailability structure. */ CINDEX_LINKAGE void clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); /** - * \brief Describe the "language" of the entity referred to by a cursor. + * Describe the "language" of the entity referred to by a cursor. */ enum CXLanguageKind { CXLanguage_Invalid = 0, @@ -2857,12 +2887,12 @@ enum CXLanguageKind { }; /** - * \brief Determine the "language" of the entity referred to by a given cursor. + * Determine the "language" of the entity referred to by a given cursor. */ CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); /** - * \brief Describe the "thread-local storage (TLS) kind" of the declaration + * Describe the "thread-local storage (TLS) kind" of the declaration * referred to by a cursor. */ enum CXTLSKind { @@ -2872,33 +2902,33 @@ enum CXTLSKind { }; /** - * \brief Determine the "thread-local storage (TLS) kind" of the declaration + * Determine the "thread-local storage (TLS) kind" of the declaration * referred to by a cursor. */ CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor); /** - * \brief Returns the translation unit that a cursor originated from. + * Returns the translation unit that a cursor originated from. */ CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); /** - * \brief A fast container representing a set of CXCursors. + * A fast container representing a set of CXCursors. */ typedef struct CXCursorSetImpl *CXCursorSet; /** - * \brief Creates an empty CXCursorSet. + * Creates an empty CXCursorSet. */ CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void); /** - * \brief Disposes a CXCursorSet and releases its associated memory. + * Disposes a CXCursorSet and releases its associated memory. */ CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); /** - * \brief Queries a CXCursorSet to see if it contains a specific CXCursor. + * Queries a CXCursorSet to see if it contains a specific CXCursor. * * \returns non-zero if the set contains the specified cursor. */ @@ -2906,7 +2936,7 @@ CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, CXCursor cursor); /** - * \brief Inserts a CXCursor into a CXCursorSet. + * Inserts a CXCursor into a CXCursorSet. * * \returns zero if the CXCursor was already in the set, and non-zero otherwise. */ @@ -2914,7 +2944,7 @@ CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, CXCursor cursor); /** - * \brief Determine the semantic parent of the given cursor. + * Determine the semantic parent of the given cursor. * * The semantic parent of a cursor is the cursor that semantically contains * the given \p cursor. For many declarations, the lexical and semantic parents @@ -2949,7 +2979,7 @@ CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); /** - * \brief Determine the lexical parent of the given cursor. + * Determine the lexical parent of the given 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 @@ -2985,7 +3015,7 @@ CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); /** - * \brief Determine the set of methods that are overridden by the given + * Determine the set of methods that are overridden by the given * method. * * In both Objective-C and C++, a method (aka virtual member function, @@ -3032,13 +3062,13 @@ CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, unsigned *num_overridden); /** - * \brief Free the set of overridden cursors returned by \c + * Free the set of overridden cursors returned by \c * clang_getOverriddenCursors(). */ CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); /** - * \brief Retrieve the file that is included by the given inclusion directive + * Retrieve the file that is included by the given inclusion directive * cursor. */ CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); @@ -3059,7 +3089,7 @@ CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); */ /** - * \brief Map a source location to the cursor that describes the entity at that + * Map a source location to the cursor that describes the entity at that * location in the source code. * * clang_getCursor() maps an arbitrary source location within a translation @@ -3076,7 +3106,7 @@ CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); /** - * \brief Retrieve the physical location of the source constructor referenced + * Retrieve the physical location of the source constructor referenced * by the given cursor. * * The location of a declaration is typically the location of the name of that @@ -3088,7 +3118,7 @@ CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); /** - * \brief Retrieve the physical extent of the source construct referenced by + * Retrieve the physical extent of the source construct referenced by * the given cursor. * * The extent of a cursor starts with the file/line/column pointing at the @@ -3111,16 +3141,16 @@ CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); */ /** - * \brief Describes the kind of type + * Describes the kind of type */ enum CXTypeKind { /** - * \brief Represents an invalid type (e.g., where no type is available). + * Represents an invalid type (e.g., where no type is available). */ CXType_Invalid = 0, /** - * \brief A type whose specific kind is not exposed via this + * A type whose specific kind is not exposed via this * interface. */ CXType_Unexposed = 1, @@ -3157,8 +3187,14 @@ enum CXTypeKind { CXType_Float128 = 30, CXType_Half = 31, CXType_Float16 = 32, + CXType_ShortAccum = 33, + CXType_Accum = 34, + CXType_LongAccum = 35, + CXType_UShortAccum = 36, + CXType_UAccum = 37, + CXType_ULongAccum = 38, CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_Float16, + CXType_LastBuiltin = CXType_ULongAccum, CXType_Complex = 100, CXType_Pointer = 101, @@ -3181,7 +3217,7 @@ enum CXTypeKind { CXType_Auto = 118, /** - * \brief Represents a type that was referred to using an elaborated type keyword. + * Represents a type that was referred to using an elaborated type keyword. * * E.g., struct S, or via a qualified name, e.g., N::M::type, or both. */ @@ -3234,7 +3270,7 @@ enum CXTypeKind { }; /** - * \brief Describes the calling convention of a function type + * Describes the calling convention of a function type */ enum CXCallingConv { CXCallingConv_Default = 0, @@ -3261,7 +3297,7 @@ enum CXCallingConv { }; /** - * \brief The type of an element in the abstract syntax tree. + * The type of an element in the abstract syntax tree. * */ typedef struct { @@ -3270,12 +3306,12 @@ typedef struct { } CXType; /** - * \brief Retrieve the type of a CXCursor (if any). + * Retrieve the type of a CXCursor (if any). */ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); /** - * \brief Pretty-print the underlying type using the rules of the + * Pretty-print the underlying type using the rules of the * language of the translation unit from which it came. * * If the type is invalid, an empty string is returned. @@ -3283,7 +3319,7 @@ CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT); /** - * \brief Retrieve the underlying type of a typedef declaration. + * Retrieve the underlying type of a typedef declaration. * * If the cursor does not reference a typedef declaration, an invalid type is * returned. @@ -3291,7 +3327,7 @@ CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT); CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); /** - * \brief Retrieve the integer type of an enum declaration. + * Retrieve the integer type of an enum declaration. * * If the cursor does not reference an enum declaration, an invalid type is * returned. @@ -3299,7 +3335,7 @@ CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); /** - * \brief Retrieve the integer value of an enum constant declaration as a signed + * Retrieve the integer value of an enum constant declaration as a signed * long long. * * If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. @@ -3309,7 +3345,7 @@ CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); /** - * \brief Retrieve the integer value of an enum constant declaration as an unsigned + * Retrieve the integer value of an enum constant declaration as an unsigned * long long. * * If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. @@ -3319,14 +3355,14 @@ CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C); /** - * \brief Retrieve the bit width of a bit field declaration as an integer. + * Retrieve the bit width of a bit field declaration as an integer. * * If a cursor that is not a bit field declaration is passed in, -1 is returned. */ CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C); /** - * \brief Retrieve the number of non-variadic arguments associated with a given + * Retrieve the number of non-variadic arguments associated with a given * cursor. * * The number of arguments can be determined for calls as well as for @@ -3335,7 +3371,7 @@ CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C); CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); /** - * \brief Retrieve the argument cursor of a function or method. + * Retrieve the argument cursor of a function or method. * * The argument cursor can be determined for calls as well as for declarations * of functions or methods. For other cursors and for invalid indices, an @@ -3344,7 +3380,7 @@ CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i); /** - * \brief Describes the kind of a template argument. + * Describes the kind of a template argument. * * See the definition of llvm::clang::TemplateArgument::ArgKind for full * element descriptions. @@ -3364,7 +3400,7 @@ enum CXTemplateArgumentKind { }; /** - *\brief Returns the number of template args of a function decl representing a + *Returns the number of template args of a function decl representing a * template specialization. * * If the argument cursor cannot be converted into a template function @@ -3382,7 +3418,7 @@ enum CXTemplateArgumentKind { CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C); /** - * \brief Retrieve the kind of the I'th template argument of the CXCursor C. + * Retrieve the kind of the I'th template argument of the CXCursor C. * * If the argument CXCursor does not represent a FunctionDecl, an invalid * template argument kind is returned. @@ -3401,7 +3437,7 @@ CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( CXCursor C, unsigned I); /** - * \brief Retrieve a CXType representing the type of a TemplateArgument of a + * Retrieve a CXType representing the type of a TemplateArgument of a * function decl representing a template specialization. * * If the argument CXCursor does not represent a FunctionDecl whose I'th @@ -3422,7 +3458,7 @@ CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C, unsigned I); /** - * \brief Retrieve the value of an Integral TemplateArgument (of a function + * Retrieve the value of an Integral TemplateArgument (of a function * decl representing a template specialization) as a signed long long. * * It is undefined to call this function on a CXCursor that does not represent a @@ -3442,7 +3478,7 @@ CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C, unsigned I); /** - * \brief Retrieve the value of an Integral TemplateArgument (of a function + * Retrieve the value of an Integral TemplateArgument (of a function * decl representing a template specialization) as an unsigned long long. * * It is undefined to call this function on a CXCursor that does not represent a @@ -3462,7 +3498,7 @@ CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue( CXCursor C, unsigned I); /** - * \brief Determine whether two CXTypes represent the same type. + * Determine whether two CXTypes represent the same type. * * \returns non-zero if the CXTypes represent the same type and * zero otherwise. @@ -3470,7 +3506,7 @@ CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue( CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); /** - * \brief Return the canonical type for a CXType. + * Return the canonical type for a CXType. * * Clang's type system explicitly models typedefs and all the ways * a specific type can be represented. The canonical type is the underlying @@ -3480,61 +3516,61 @@ CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); /** - * \brief Determine whether a CXType has the "const" qualifier set, + * Determine whether a CXType has the "const" qualifier set, * without looking through typedefs that may have added "const" at a * different level. */ CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); /** - * \brief Determine whether a CXCursor that is a macro, is + * Determine whether a CXCursor that is a macro, is * function like. */ CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C); /** - * \brief Determine whether a CXCursor that is a macro, is a + * Determine whether a CXCursor that is a macro, is a * builtin one. */ CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C); /** - * \brief Determine whether a CXCursor that is a function declaration, is an + * Determine whether a CXCursor that is a function declaration, is an * inline declaration. */ CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C); /** - * \brief Determine whether a CXType has the "volatile" qualifier set, + * Determine whether a CXType has the "volatile" qualifier set, * without looking through typedefs that may have added "volatile" at * a different level. */ CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); /** - * \brief Determine whether a CXType has the "restrict" qualifier set, + * Determine whether a CXType has the "restrict" qualifier set, * without looking through typedefs that may have added "restrict" at a * different level. */ CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); /** - * \brief Returns the address space of the given type. + * Returns the address space of the given type. */ CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T); /** - * \brief Returns the typedef name of the given type. + * Returns the typedef name of the given type. */ CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT); /** - * \brief For pointer types, returns the type of the pointee. + * For pointer types, returns the type of the pointee. */ CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); /** - * \brief Return the cursor for the declaration of the given type. + * Return the cursor for the declaration of the given type. */ CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); @@ -3549,33 +3585,34 @@ CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); /** - * \brief Retrieve the spelling of a given CXTypeKind. + * Retrieve the spelling of a given CXTypeKind. */ CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); /** - * \brief Retrieve the calling convention associated with a function type. + * Retrieve the calling convention associated with a function type. * * If a non-function type is passed in, CXCallingConv_Invalid is returned. */ CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); /** - * \brief Retrieve the return type associated with a function type. + * Retrieve the return type associated with a function type. * * If a non-function type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_getResultType(CXType T); /** - * \brief Retrieve the exception specification type associated with a function type. + * Retrieve the exception specification type associated with a function type. + * This is a value of type CXCursor_ExceptionSpecificationKind. * * If a non-function type is passed in, an error code of -1 is returned. */ CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T); /** - * \brief Retrieve the number of non-variadic parameters associated with a + * Retrieve the number of non-variadic parameters associated with a * function type. * * If a non-function type is passed in, -1 is returned. @@ -3583,7 +3620,7 @@ CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T); CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); /** - * \brief Retrieve the type of a parameter of a function type. + * Retrieve the type of a parameter of a function type. * * If a non-function type is passed in or the function does not have enough * parameters, an invalid type is returned. @@ -3591,32 +3628,33 @@ CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); /** - * \brief Return 1 if the CXType is a variadic function type, and 0 otherwise. + * Return 1 if the CXType is a variadic function type, and 0 otherwise. */ CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); /** - * \brief Retrieve the return type associated with a given cursor. + * Retrieve the return type associated with a given cursor. * * This only returns a valid type if the cursor refers to a function or method. */ CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); /** - * \brief Retrieve the exception specification type associated with a given cursor. + * Retrieve the exception specification type associated with a given cursor. + * This is a value of type CXCursor_ExceptionSpecificationKind. * * This only returns a valid result if the cursor refers to a function or method. */ CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C); /** - * \brief Return 1 if the CXType is a POD (plain old data) type, and 0 + * Return 1 if the CXType is a POD (plain old data) type, and 0 * otherwise. */ CINDEX_LINKAGE unsigned clang_isPODType(CXType T); /** - * \brief Return the element type of an array, complex, or vector type. + * Return the element type of an array, complex, or vector type. * * If a type is passed in that is not an array, complex, or vector type, * an invalid type is returned. @@ -3624,7 +3662,7 @@ CINDEX_LINKAGE unsigned clang_isPODType(CXType T); CINDEX_LINKAGE CXType clang_getElementType(CXType T); /** - * \brief Return the number of elements of an array or vector type. + * Return the number of elements of an array or vector type. * * If a type is passed in that is not an array or vector type, * -1 is returned. @@ -3632,28 +3670,28 @@ CINDEX_LINKAGE CXType clang_getElementType(CXType T); CINDEX_LINKAGE long long clang_getNumElements(CXType T); /** - * \brief Return the element type of an array type. + * Return the element type of an array type. * * If a non-array type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); /** - * \brief Return the array size of a constant array. + * Return the array size of a constant array. * * If a non-array type is passed in, -1 is returned. */ CINDEX_LINKAGE long long clang_getArraySize(CXType T); /** - * \brief Retrieve the type named by the qualified-id. + * Retrieve the type named by the qualified-id. * * If a non-elaborated type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T); /** - * \brief Determine if a typedef is 'transparent' tag. + * Determine if a typedef is 'transparent' tag. * * A typedef is considered 'transparent' if it shares a name and spelling * location with its underlying tag type, as is the case with the NS_ENUM macro. @@ -3663,7 +3701,7 @@ CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T); CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T); /** - * \brief List the possible error codes for \c clang_Type_getSizeOf, + * List the possible error codes for \c clang_Type_getSizeOf, * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and * \c clang_Cursor_getOffsetOf. * @@ -3672,29 +3710,29 @@ CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T); */ enum CXTypeLayoutError { /** - * \brief Type is of kind CXType_Invalid. + * Type is of kind CXType_Invalid. */ CXTypeLayoutError_Invalid = -1, /** - * \brief The type is an incomplete Type. + * The type is an incomplete Type. */ CXTypeLayoutError_Incomplete = -2, /** - * \brief The type is a dependent Type. + * The type is a dependent Type. */ CXTypeLayoutError_Dependent = -3, /** - * \brief The type is not a constant size type. + * The type is not a constant size type. */ CXTypeLayoutError_NotConstantSize = -4, /** - * \brief The Field name is not valid for this record. + * The Field name is not valid for this record. */ CXTypeLayoutError_InvalidFieldName = -5 }; /** - * \brief Return the alignment of a type in bytes as per C++[expr.alignof] + * Return the alignment of a type in bytes as per C++[expr.alignof] * standard. * * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. @@ -3708,14 +3746,14 @@ enum CXTypeLayoutError { CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T); /** - * \brief Return the class type of an member pointer type. + * Return the class type of an member pointer type. * * If a non-member-pointer type is passed in, an invalid type is returned. */ CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T); /** - * \brief Return the size of a type in bytes as per C++[expr.sizeof] standard. + * Return the size of a type in bytes as per C++[expr.sizeof] standard. * * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete @@ -3726,7 +3764,7 @@ CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T); CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); /** - * \brief Return the offset of a field named S in a record of type T in bits + * Return the offset of a field named S in a record of type T in bits * as it would be returned by __offsetof__ as per C++11[18.2p4] * * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid @@ -3741,7 +3779,7 @@ CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); /** - * \brief Return the offset of the field represented by the Cursor. + * Return the offset of the field represented by the Cursor. * * If the cursor is not a field declaration, -1 is returned. * If the cursor semantic parent is not a record field declaration, @@ -3756,28 +3794,28 @@ CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C); /** - * \brief Determine whether the given cursor represents an anonymous record + * Determine whether the given cursor represents an anonymous record * declaration. */ CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); enum CXRefQualifierKind { - /** \brief No ref-qualifier was provided. */ + /** No ref-qualifier was provided. */ CXRefQualifier_None = 0, - /** \brief An lvalue ref-qualifier was provided (\c &). */ + /** An lvalue ref-qualifier was provided (\c &). */ CXRefQualifier_LValue, - /** \brief An rvalue ref-qualifier was provided (\c &&). */ + /** An rvalue ref-qualifier was provided (\c &&). */ CXRefQualifier_RValue }; /** - * \brief Returns the number of template arguments for given template + * Returns the number of template arguments for given template * specialization, or -1 if type \c T is not a template specialization. */ CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); /** - * \brief Returns the type template argument of a template class specialization + * Returns the type template argument of a template class specialization * at given index. * * This function only returns template type arguments and does not handle @@ -3786,7 +3824,7 @@ CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i); /** - * \brief Retrieve the ref-qualifier kind of a function or method. + * Retrieve the ref-qualifier kind of a function or method. * * The ref-qualifier is returned for C++ functions or methods. For other types * or non-C++ declarations, CXRefQualifier_None is returned. @@ -3794,19 +3832,19 @@ CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i) CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T); /** - * \brief Returns non-zero if the cursor specifies a Record member that is a + * Returns non-zero if the cursor specifies a Record member that is a * bitfield. */ CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C); /** - * \brief Returns 1 if the base class specified by the cursor with kind + * Returns 1 if the base class specified by the cursor with kind * CX_CXXBaseSpecifier is virtual. */ CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); /** - * \brief Represents the C++ access control level to a base class for a + * Represents the C++ access control level to a base class for a * cursor with kind CX_CXXBaseSpecifier. */ enum CX_CXXAccessSpecifier { @@ -3817,7 +3855,7 @@ enum CX_CXXAccessSpecifier { }; /** - * \brief Returns the access control level for the referenced object. + * Returns the access control level for the referenced object. * * If the cursor refers to a C++ declaration, its access control level within its * parent scope is returned. Otherwise, if the cursor refers to a base specifier or @@ -3826,7 +3864,7 @@ enum CX_CXXAccessSpecifier { CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); /** - * \brief Represents the storage classes as declared in the source. CX_SC_Invalid + * Represents the storage classes as declared in the source. CX_SC_Invalid * was added for the case that the passed cursor in not a declaration. */ enum CX_StorageClass { @@ -3841,7 +3879,7 @@ enum CX_StorageClass { }; /** - * \brief Returns the storage class for a function or variable declaration. + * Returns the storage class for a function or variable declaration. * * If the passed in Cursor is not a function or variable declaration, * CX_SC_Invalid is returned else the storage class. @@ -3849,7 +3887,7 @@ enum CX_StorageClass { CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); /** - * \brief 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. @@ -3860,7 +3898,7 @@ CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); /** - * \brief Retrieve a cursor for one of the overloaded declarations referenced + * Retrieve a cursor for one of the overloaded declarations referenced * by a \c CXCursor_OverloadedDeclRef cursor. * * \param cursor The cursor whose overloaded declarations are being queried. @@ -3887,7 +3925,7 @@ CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, */ /** - * \brief For cursors representing an iboutletcollection attribute, + * For cursors representing an iboutletcollection attribute, * this function returns the collection element type. * */ @@ -3907,7 +3945,7 @@ CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); */ /** - * \brief Describes how the traversal of the children of a particular + * Describes how the traversal of the children of a particular * cursor should proceed after visiting a particular child cursor. * * A value of this enumeration type should be returned by each @@ -3915,23 +3953,23 @@ CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); */ enum CXChildVisitResult { /** - * \brief Terminates the cursor traversal. + * Terminates the cursor traversal. */ CXChildVisit_Break, /** - * \brief Continues the cursor traversal with the next sibling of + * Continues the cursor traversal with the next sibling of * the cursor just visited, without visiting its children. */ CXChildVisit_Continue, /** - * \brief Recursively traverse the children of this cursor, using + * Recursively traverse the children of this cursor, using * the same visitor and client data. */ CXChildVisit_Recurse }; /** - * \brief Visitor invoked for each cursor found by a traversal. + * Visitor invoked for each cursor found by a traversal. * * This visitor function will be invoked for each cursor found by * clang_visitCursorChildren(). Its first argument is the cursor being @@ -3947,7 +3985,7 @@ typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, CXClientData client_data); /** - * \brief Visit the children of a particular cursor. + * Visit the children of a particular cursor. * * This function visits all the direct children of the given cursor, * invoking the given \p visitor function with the cursors of each @@ -3974,7 +4012,7 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, #ifdef __has_feature # if __has_feature(blocks) /** - * \brief Visitor invoked for each cursor found by a traversal. + * Visitor invoked for each cursor found by a traversal. * * This visitor block will be invoked for each cursor found by * clang_visitChildrenWithBlock(). Its first argument is the cursor being @@ -4011,7 +4049,7 @@ CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent, */ /** - * \brief Retrieve a Unified Symbol Resolution (USR) for the entity referenced + * Retrieve a Unified Symbol Resolution (USR) for the entity referenced * by the given cursor. * * A Unified Symbol Resolution (USR) is a string that identifies a particular @@ -4022,32 +4060,32 @@ CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent, CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); /** - * \brief Construct a USR for a specified Objective-C class. + * Construct a USR for a specified Objective-C class. */ CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); /** - * \brief Construct a USR for a specified Objective-C category. + * Construct a USR for a specified Objective-C category. */ CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(const char *class_name, const char *category_name); /** - * \brief Construct a USR for a specified Objective-C protocol. + * Construct a USR for a specified Objective-C protocol. */ CINDEX_LINKAGE CXString clang_constructUSR_ObjCProtocol(const char *protocol_name); /** - * \brief Construct a USR for a specified Objective-C instance variable and + * Construct a USR for a specified Objective-C instance variable and * the USR for its containing class. */ CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR); /** - * \brief Construct a USR for a specified Objective-C method and + * Construct a USR for a specified Objective-C method and * the USR for its containing class. */ CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, @@ -4055,19 +4093,19 @@ CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, CXString classUSR); /** - * \brief Construct a USR for a specified Objective-C property and the USR + * Construct a USR for a specified Objective-C property and the USR * for its containing class. */ CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, CXString classUSR); /** - * \brief Retrieve a name for the entity referenced by this cursor. + * Retrieve a name for the entity referenced by this cursor. */ CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); /** - * \brief Retrieve a range for a piece that forms the cursors spelling name. + * Retrieve a range for a piece that forms the cursors spelling name. * 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. @@ -4082,7 +4120,90 @@ CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor, unsigned options); /** - * \brief Retrieve the display name for the entity referenced by this cursor. + * Opaque pointer representing a policy that controls pretty printing + * for \c clang_getCursorPrettyPrinted. + */ +typedef void *CXPrintingPolicy; + +/** + * Properties for the printing policy. + * + * See \c clang::PrintingPolicy for more information. + */ +enum CXPrintingPolicyProperty { + CXPrintingPolicy_Indentation, + CXPrintingPolicy_SuppressSpecifiers, + CXPrintingPolicy_SuppressTagKeyword, + CXPrintingPolicy_IncludeTagDefinition, + CXPrintingPolicy_SuppressScope, + CXPrintingPolicy_SuppressUnwrittenScope, + CXPrintingPolicy_SuppressInitializers, + CXPrintingPolicy_ConstantArraySizeAsWritten, + CXPrintingPolicy_AnonymousTagLocations, + CXPrintingPolicy_SuppressStrongLifetime, + CXPrintingPolicy_SuppressLifetimeQualifiers, + CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + CXPrintingPolicy_Bool, + CXPrintingPolicy_Restrict, + CXPrintingPolicy_Alignof, + CXPrintingPolicy_UnderscoreAlignof, + CXPrintingPolicy_UseVoidForZeroParams, + CXPrintingPolicy_TerseOutput, + CXPrintingPolicy_PolishForDeclaration, + CXPrintingPolicy_Half, + CXPrintingPolicy_MSWChar, + CXPrintingPolicy_IncludeNewlines, + CXPrintingPolicy_MSVCFormatting, + CXPrintingPolicy_ConstantsAsWritten, + CXPrintingPolicy_SuppressImplicitBase, + CXPrintingPolicy_FullyQualifiedName, + + CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName +}; + +/** + * Get a property value for the given printing policy. + */ +CINDEX_LINKAGE unsigned +clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy, + enum CXPrintingPolicyProperty Property); + +/** + * Set a property value for the given printing policy. + */ +CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, + enum CXPrintingPolicyProperty Property, + unsigned Value); + +/** + * Retrieve the default policy for the cursor. + * + * The policy should be released after use with \c + * clang_PrintingPolicy_dispose. + */ +CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor); + +/** + * Release a printing policy. + */ +CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy); + +/** + * Pretty print declarations. + * + * \param Cursor The cursor representing a declaration. + * + * \param Policy The policy to control the entities being printed. If + * NULL, a default policy is used. + * + * \returns The pretty printed declaration or the empty string for + * other cursors. + */ +CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor, + CXPrintingPolicy Policy); + +/** + * 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 @@ -4090,7 +4211,7 @@ CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor, */ CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); -/** \brief For a cursor that is a reference, retrieve a cursor representing the +/** For a cursor that is a reference, retrieve a cursor representing the * entity that it references. * * Reference cursors refer to other entities in the AST. For example, an @@ -4103,7 +4224,7 @@ CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); /** - * \brief For a cursor that is either a reference to or a declaration + * For a cursor that is either a reference to or a declaration * of some entity, retrieve a cursor that describes the definition of * that entity. * @@ -4133,13 +4254,13 @@ CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); /** - * \brief Determine whether the declaration pointed to by this cursor + * Determine whether the declaration pointed to by this cursor * is also a definition of that entity. */ CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); /** - * \brief Retrieve the canonical cursor corresponding to the given cursor. + * Retrieve the canonical cursor corresponding to the given cursor. * * In the C family of languages, many kinds of entities can be declared several * times within a single translation unit. For example, a structure type can @@ -4165,7 +4286,7 @@ CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); /** - * \brief If the cursor points to a selector identifier in an Objective-C + * If the cursor points to a selector identifier in an Objective-C * method or message expression, this returns the selector index. * * After getting a cursor with #clang_getCursor, this can be called to @@ -4178,7 +4299,7 @@ CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); /** - * \brief Given a cursor pointing to a C++ method call or an Objective-C + * 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. @@ -4191,13 +4312,13 @@ CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C); /** - * \brief Given a cursor pointing to an Objective-C message or property + * Given a cursor pointing to an Objective-C message or property * reference, or C++ method call, returns the CXType of the receiver. */ CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C); /** - * \brief Property attributes for a \c CXCursor_ObjCPropertyDecl. + * Property attributes for a \c CXCursor_ObjCPropertyDecl. */ typedef enum { CXObjCPropertyAttr_noattr = 0x00, @@ -4217,7 +4338,7 @@ typedef enum { } CXObjCPropertyAttrKind; /** - * \brief Given a cursor that represents a property declaration, return the + * Given a cursor that represents a property declaration, return the * associated property attributes. The bits are formed from * \c CXObjCPropertyAttrKind. * @@ -4227,7 +4348,7 @@ CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved); /** - * \brief 'Qualifiers' written next to the return and parameter types in + * 'Qualifiers' written next to the return and parameter types in * Objective-C method declarations. */ typedef enum { @@ -4241,7 +4362,7 @@ typedef enum { } CXObjCDeclQualifierKind; /** - * \brief Given a cursor that represents an Objective-C method or parameter + * Given a cursor that represents an Objective-C method or parameter * declaration, return the associated Objective-C qualifiers for the return * type or the parameter respectively. The bits are formed from * CXObjCDeclQualifierKind. @@ -4249,19 +4370,19 @@ typedef enum { CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C); /** - * \brief Given a cursor that represents an Objective-C method or property + * Given a cursor that represents an Objective-C method or property * declaration, return non-zero if the declaration was affected by "\@optional". * Returns zero if the cursor is not such a declaration or it is "\@required". */ CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C); /** - * \brief Returns non-zero if the given cursor is a variadic function or method. + * Returns non-zero if the given cursor is a variadic function or method. */ CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C); /** - * \brief Returns non-zero if the given cursor points to a symbol marked with + * Returns non-zero if the given cursor points to a symbol marked with * external_source_symbol attribute. * * \param language If non-NULL, and the attribute is present, will be set to @@ -4278,21 +4399,21 @@ CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C, unsigned *isGenerated); /** - * \brief Given a cursor that represents a declaration, return the associated + * Given a cursor that represents a declaration, return the associated * comment's source range. The range may include multiple consecutive comments * with whitespace in between. */ CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C); /** - * \brief Given a cursor that represents a declaration, return the associated + * Given a cursor that represents a declaration, return the associated * comment text, including comment markers. */ CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C); /** - * \brief Given a cursor that represents a documentable entity (e.g., - * declaration), return the associated \\brief paragraph; otherwise return the + * Given a cursor that represents a documentable entity (e.g., + * declaration), return the associated \paragraph; otherwise return the * first paragraph. */ CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); @@ -4307,18 +4428,18 @@ CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); */ /** - * \brief Retrieve the CXString representing the mangled name of the cursor. + * Retrieve the CXString representing the mangled name of the cursor. */ CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor); /** - * \brief Retrieve the CXStrings representing the mangled symbols of the C++ + * Retrieve the CXStrings representing the mangled symbols of the C++ * constructor or destructor at the cursor. */ CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor); /** - * \brief Retrieve the CXStrings representing the mangled symbols of the ObjC + * Retrieve the CXStrings representing the mangled symbols of the ObjC * class interface or implementation at the cursor. */ CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor); @@ -4338,12 +4459,12 @@ CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor); typedef void *CXModule; /** - * \brief Given a CXCursor_ModuleImportDecl cursor, return the associated module. + * Given a CXCursor_ModuleImportDecl cursor, return the associated module. */ CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C); /** - * \brief Given a CXFile header file, return the module that contains it, if one + * Given a CXFile header file, return the module that contains it, if one * exists. */ CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile); @@ -4418,73 +4539,73 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, */ /** - * \brief Determine if a C++ constructor is a converting constructor. + * Determine if a C++ constructor is a converting constructor. */ CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C); /** - * \brief Determine if a C++ constructor is a copy constructor. + * Determine if a C++ constructor is a copy constructor. */ CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C); /** - * \brief Determine if a C++ constructor is the default constructor. + * Determine if a C++ constructor is the default constructor. */ CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C); /** - * \brief Determine if a C++ constructor is a move constructor. + * Determine if a C++ constructor is a move constructor. */ CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C); /** - * \brief Determine if a C++ field is declared 'mutable'. + * Determine if a C++ field is declared 'mutable'. */ CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C); /** - * \brief Determine if a C++ method is declared '= default'. + * Determine if a C++ method is declared '= default'. */ CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C); /** - * \brief Determine if a C++ member function or member function template is + * Determine if a C++ member function or member function template is * pure virtual. */ CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C); /** - * \brief 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); /** - * \brief Determine if a C++ member function or member function template is + * Determine if a C++ member function or member function template is * explicitly declared 'virtual' or if it overrides a virtual method from * one of the base classes. */ CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); /** - * \brief Determine if a C++ record is abstract, i.e. whether a class or struct + * Determine if a C++ record is abstract, i.e. whether a class or struct * has a pure virtual member function. */ CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C); /** - * \brief Determine if an enum declaration refers to a scoped enum. + * Determine if an enum declaration refers to a scoped enum. */ CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C); /** - * \brief Determine if a C++ member function or member function template is + * Determine if a C++ member function or member function template is * declared 'const'. */ CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); /** - * \brief Given a cursor that represents a template, determine + * Given a cursor that represents a template, determine * the cursor kind of the specializations would be generated by instantiating * the template. * @@ -4503,7 +4624,7 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); /** - * \brief Given a cursor that may represent a specialization or instantiation + * 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. * @@ -4533,7 +4654,7 @@ CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); /** - * \brief Given a cursor that references something else, return the source range + * Given a cursor that references something else, return the source range * covering that reference. * * \param C A cursor pointing to a member reference, a declaration reference, or @@ -4556,19 +4677,19 @@ CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, enum CXNameRefFlags { /** - * \brief Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the + * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the * range. */ CXNameRange_WantQualifier = 0x1, /** - * \brief Include the explicit template arguments, e.g. \<int> in x.f<int>, + * Include the explicit template arguments, e.g. \<int> in x.f<int>, * in the range. */ CXNameRange_WantTemplateArgs = 0x2, /** - * \brief If the name is non-contiguous, return the full spanning range. + * If the name is non-contiguous, return the full spanning range. * * Non-contiguous names occur in Objective-C when a selector with two or more * parameters is used, or in C++ when using an operator: @@ -4595,37 +4716,37 @@ enum CXNameRefFlags { */ /** - * \brief Describes a kind of token. + * Describes a kind of token. */ typedef enum CXTokenKind { /** - * \brief A token that contains some kind of punctuation. + * A token that contains some kind of punctuation. */ CXToken_Punctuation, /** - * \brief A language keyword. + * A language keyword. */ CXToken_Keyword, /** - * \brief An identifier (that is not a keyword). + * An identifier (that is not a keyword). */ CXToken_Identifier, /** - * \brief A numeric, string, or character literal. + * A numeric, string, or character literal. */ CXToken_Literal, /** - * \brief A comment. + * A comment. */ CXToken_Comment } CXTokenKind; /** - * \brief Describes a single preprocessing token. + * Describes a single preprocessing token. */ typedef struct { unsigned int_data[4]; @@ -4633,12 +4754,26 @@ typedef struct { } CXToken; /** - * \brief Determine the kind of the given token. + * Get the raw lexical token starting with the given location. + * + * \param TU the translation unit whose text is being tokenized. + * + * \param Location the source location with which the token starts. + * + * \returns The token starting with the given location or NULL if no such token + * exist. The returned pointer must be freed with clang_disposeTokens before the + * translation unit is destroyed. + */ +CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU, + CXSourceLocation Location); + +/** + * Determine the kind of the given token. */ CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); /** - * \brief Determine the spelling of the given token. + * Determine the spelling of the given token. * * The spelling of a token is the textual representation of that token, e.g., * the text of an identifier or keyword. @@ -4646,18 +4781,18 @@ CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); /** - * \brief Retrieve the source location of the given token. + * Retrieve the source location of the given token. */ CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, CXToken); /** - * \brief Retrieve a source range that covers the given token. + * Retrieve a source range that covers the given token. */ CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); /** - * \brief Tokenize the source code described by the given range into raw + * Tokenize the source code described by the given range into raw * lexical tokens. * * \param TU the translation unit whose text is being tokenized. @@ -4677,7 +4812,7 @@ CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, CXToken **Tokens, unsigned *NumTokens); /** - * \brief Annotate the given set of tokens by providing cursors for each token + * Annotate the given set of tokens by providing cursors for each token * that can be mapped to a specific entity within the abstract syntax tree. * * This token-annotation routine is equivalent to invoking @@ -4711,7 +4846,7 @@ CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXCursor *Cursors); /** - * \brief Free the given set of tokens. + * Free the given set of tokens. */ CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens, unsigned NumTokens); @@ -4759,7 +4894,7 @@ CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, */ /** - * \brief A semantic string that describes a code-completion result. + * A semantic string that describes a code-completion result. * * A semantic string that describes the formatting of a code-completion * result as a single "template" of text that should be inserted into the @@ -4774,11 +4909,11 @@ CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data, typedef void *CXCompletionString; /** - * \brief A single result of code completion. + * A single result of code completion. */ typedef struct { /** - * \brief The kind of entity that this completion refers to. + * The kind of entity that this completion refers to. * * The cursor kind will be a macro, keyword, or a declaration (one of the * *Decl cursor kinds), describing the entity that the completion is @@ -4790,14 +4925,14 @@ typedef struct { enum CXCursorKind CursorKind; /** - * \brief The code-completion string that describes how to insert this + * The code-completion string that describes how to insert this * code-completion result into the editing buffer. */ CXCompletionString CompletionString; } CXCompletionResult; /** - * \brief Describes a single piece of text within a code-completion string. + * Describes a single piece of text within a code-completion string. * * Each "chunk" within a code-completion string (\c CXCompletionString) is * either a piece of text with a specific "kind" that describes how that text @@ -4805,7 +4940,7 @@ typedef struct { */ enum CXCompletionChunkKind { /** - * \brief A code-completion string that describes "optional" text that + * A code-completion string that describes "optional" text that * could be a part of the template (but is not required). * * The Optional chunk is the only kind of chunk that has a code-completion @@ -4839,7 +4974,7 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_Optional, /** - * \brief Text that a user would be expected to type to get this + * Text that a user would be expected to type to get this * code-completion result. * * There will be exactly one "typed text" chunk in a semantic string, which @@ -4850,7 +4985,7 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_TypedText, /** - * \brief Text that should be inserted as part of a code-completion result. + * Text that should be inserted as part of a code-completion result. * * A "text" chunk represents text that is part of the template to be * inserted into user code should this particular code-completion result @@ -4858,7 +4993,7 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_Text, /** - * \brief Placeholder text that should be replaced by the user. + * Placeholder text that should be replaced by the user. * * A "placeholder" chunk marks a place where the user should insert text * into the code-completion template. For example, placeholders might mark @@ -4869,7 +5004,7 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_Placeholder, /** - * \brief Informative text that should be displayed but never inserted as + * Informative text that should be displayed but never inserted as * part of the template. * * An "informative" chunk contains annotations that can be displayed to @@ -4879,7 +5014,7 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_Informative, /** - * \brief Text that describes the current parameter when code-completion is + * Text that describes the current parameter when code-completion is * referring to function call, message send, or template specialization. * * A "current parameter" chunk occurs when code-completion is providing @@ -4895,49 +5030,49 @@ enum CXCompletionChunkKind { * for "int x", indicating that the current argument will initialize that * parameter. After typing further, to \c add(17, (where the code-completion * point is after the ","), the code-completion string will contain a - * "current paremeter" chunk to "int y". + * "current parameter" chunk to "int y". */ CXCompletionChunk_CurrentParameter, /** - * \brief A left parenthesis ('('), used to initiate a function call or + * A left parenthesis ('('), used to initiate a function call or * signal the beginning of a function parameter list. */ CXCompletionChunk_LeftParen, /** - * \brief A right parenthesis (')'), used to finish a function call or + * A right parenthesis (')'), used to finish a function call or * signal the end of a function parameter list. */ CXCompletionChunk_RightParen, /** - * \brief A left bracket ('['). + * A left bracket ('['). */ CXCompletionChunk_LeftBracket, /** - * \brief A right bracket (']'). + * A right bracket (']'). */ CXCompletionChunk_RightBracket, /** - * \brief A left brace ('{'). + * A left brace ('{'). */ CXCompletionChunk_LeftBrace, /** - * \brief A right brace ('}'). + * A right brace ('}'). */ CXCompletionChunk_RightBrace, /** - * \brief A left angle bracket ('<'). + * A left angle bracket ('<'). */ CXCompletionChunk_LeftAngle, /** - * \brief A right angle bracket ('>'). + * A right angle bracket ('>'). */ CXCompletionChunk_RightAngle, /** - * \brief A comma separator (','). + * A comma separator (','). */ CXCompletionChunk_Comma, /** - * \brief Text that specifies the result type of a given result. + * Text that specifies the result type of a given result. * * This special kind of informative chunk is not meant to be inserted into * the text buffer. Rather, it is meant to illustrate the type that an @@ -4945,15 +5080,15 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_ResultType, /** - * \brief A colon (':'). + * A colon (':'). */ CXCompletionChunk_Colon, /** - * \brief A semicolon (';'). + * A semicolon (';'). */ CXCompletionChunk_SemiColon, /** - * \brief An '=' sign. + * An '=' sign. */ CXCompletionChunk_Equal, /** @@ -4968,7 +5103,7 @@ enum CXCompletionChunkKind { }; /** - * \brief Determine the kind of a particular chunk within a completion string. + * Determine the kind of a particular chunk within a completion string. * * \param completion_string the completion string to query. * @@ -4981,7 +5116,7 @@ clang_getCompletionChunkKind(CXCompletionString completion_string, unsigned chunk_number); /** - * \brief Retrieve the text associated with a particular chunk within a + * Retrieve the text associated with a particular chunk within a * completion string. * * \param completion_string the completion string to query. @@ -4995,7 +5130,7 @@ clang_getCompletionChunkText(CXCompletionString completion_string, unsigned chunk_number); /** - * \brief Retrieve the completion string associated with a particular chunk + * Retrieve the completion string associated with a particular chunk * within a completion string. * * \param completion_string the completion string to query. @@ -5010,13 +5145,13 @@ clang_getCompletionChunkCompletionString(CXCompletionString completion_string, unsigned chunk_number); /** - * \brief Retrieve the number of chunks in the given code-completion string. + * Retrieve the number of chunks in the given code-completion string. */ CINDEX_LINKAGE unsigned clang_getNumCompletionChunks(CXCompletionString completion_string); /** - * \brief Determine the priority of this code completion. + * Determine the priority of this code completion. * * The priority of a code completion indicates how likely it is that this * particular completion is the completion that the user will select. The @@ -5031,7 +5166,7 @@ CINDEX_LINKAGE unsigned clang_getCompletionPriority(CXCompletionString completion_string); /** - * \brief Determine the availability of the entity that this code-completion + * Determine the availability of the entity that this code-completion * string refers to. * * \param completion_string The completion string to query. @@ -5042,7 +5177,7 @@ CINDEX_LINKAGE enum CXAvailabilityKind clang_getCompletionAvailability(CXCompletionString completion_string); /** - * \brief Retrieve the number of annotations associated with the given + * Retrieve the number of annotations associated with the given * completion string. * * \param completion_string the completion string to query. @@ -5054,7 +5189,7 @@ CINDEX_LINKAGE unsigned clang_getCompletionNumAnnotations(CXCompletionString completion_string); /** - * \brief Retrieve the annotation associated with the given completion string. + * Retrieve the annotation associated with the given completion string. * * \param completion_string the completion string to query. * @@ -5069,7 +5204,7 @@ clang_getCompletionAnnotation(CXCompletionString completion_string, unsigned annotation_number); /** - * \brief Retrieve the parent context of the given completion string. + * Retrieve the parent context of the given completion string. * * The parent context of a completion string is the semantic parent of * the declaration (if any) that the code completion represents. For example, @@ -5089,14 +5224,14 @@ clang_getCompletionParent(CXCompletionString completion_string, enum CXCursorKind *kind); /** - * \brief Retrieve the brief documentation comment attached to the declaration + * Retrieve the brief documentation comment attached to the declaration * that corresponds to the given completion string. */ CINDEX_LINKAGE CXString clang_getCompletionBriefComment(CXCompletionString completion_string); /** - * \brief Retrieve a completion string for an arbitrary declaration or macro + * Retrieve a completion string for an arbitrary declaration or macro * definition cursor. * * \param cursor The cursor to query. @@ -5108,7 +5243,7 @@ CINDEX_LINKAGE CXCompletionString clang_getCursorCompletionString(CXCursor cursor); /** - * \brief Contains the results of code-completion. + * Contains the results of code-completion. * * This data structure contains the results of code completion, as * produced by \c clang_codeCompleteAt(). Its contents must be freed by @@ -5116,19 +5251,83 @@ clang_getCursorCompletionString(CXCursor cursor); */ typedef struct { /** - * \brief The code-completion results. + * The code-completion results. */ CXCompletionResult *Results; /** - * \brief The number of code-completion results stored in the + * The number of code-completion results stored in the * \c Results array. */ unsigned NumResults; } CXCodeCompleteResults; /** - * \brief Flags that can be passed to \c clang_codeCompleteAt() to + * Retrieve the number of fix-its for the given completion index. + * + * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts + * option was set. + * + * \param results The structure keeping all completion results + * + * \param completion_index The index of the completion + * + * \return The number of fix-its which must be applied before the completion at + * completion_index can be applied + */ +CINDEX_LINKAGE unsigned +clang_getCompletionNumFixIts(CXCodeCompleteResults *results, + unsigned completion_index); + +/** + * Fix-its that *must* be applied before inserting the text for the + * corresponding completion. + * + * By default, clang_codeCompleteAt() only returns completions with empty + * fix-its. Extra completions with non-empty fix-its should be explicitly + * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts. + * + * For the clients to be able to compute position of the cursor after applying + * fix-its, the following conditions are guaranteed to hold for + * replacement_range of the stored fix-its: + * - Ranges in the fix-its are guaranteed to never contain the completion + * point (or identifier under completion point, if any) inside them, except + * at the start or at the end of the range. + * - If a fix-it range starts or ends with completion point (or starts or + * ends after the identifier under completion point), it will contain at + * least one character. It allows to unambiguously recompute completion + * point after applying the fix-it. + * + * The intuition is that provided fix-its change code around the identifier we + * complete, but are not allowed to touch the identifier itself or the + * completion point. One example of completions with corrections are the ones + * replacing '.' with '->' and vice versa: + * + * std::unique_ptr<std::vector<int>> vec_ptr; + * In 'vec_ptr.^', one of the completions is 'push_back', it requires + * replacing '.' with '->'. + * In 'vec_ptr->^', one of the completions is 'release', it requires + * replacing '->' with '.'. + * + * \param results The structure keeping all completion results + * + * \param completion_index The index of the completion + * + * \param fixit_index The index of the fix-it for the completion at + * completion_index + * + * \param replacement_range The fix-it range that must be replaced before the + * completion at completion_index can be applied + * + * \returns The fix-it string that must replace the code at replacement_range + * before the completion at completion_index can be applied + */ +CINDEX_LINKAGE CXString clang_getCompletionFixIt( + CXCodeCompleteResults *results, unsigned completion_index, + unsigned fixit_index, CXSourceRange *replacement_range); + +/** + * Flags that can be passed to \c clang_codeCompleteAt() to * modify its behavior. * * The enumerators in this enumeration can be bitwise-OR'd together to @@ -5136,163 +5335,176 @@ typedef struct { */ enum CXCodeComplete_Flags { /** - * \brief Whether to include macros within the set of code + * Whether to include macros within the set of code * completions returned. */ CXCodeComplete_IncludeMacros = 0x01, /** - * \brief Whether to include code patterns for language constructs + * Whether to include code patterns for language constructs * within the set of code completions, e.g., for loops. */ CXCodeComplete_IncludeCodePatterns = 0x02, /** - * \brief Whether to include brief documentation within the set of code + * Whether to include brief documentation within the set of code * completions returned. */ - CXCodeComplete_IncludeBriefComments = 0x04 + CXCodeComplete_IncludeBriefComments = 0x04, + + /** + * Whether to speed up completion by omitting top- or namespace-level entities + * defined in the preamble. There's no guarantee any particular entity is + * omitted. This may be useful if the headers are indexed externally. + */ + CXCodeComplete_SkipPreamble = 0x08, + + /** + * Whether to include completions with small + * fix-its, e.g. change '.' to '->' on member access, etc. + */ + CXCodeComplete_IncludeCompletionsWithFixIts = 0x10 }; /** - * \brief Bits that represent the context under which completion is occurring. + * Bits that represent the context under which completion is occurring. * * The enumerators in this enumeration may be bitwise-OR'd together if multiple * contexts are occurring simultaneously. */ enum CXCompletionContext { /** - * \brief The context for completions is unexposed, as only Clang results + * The context for completions is unexposed, as only Clang results * should be included. (This is equivalent to having no context bits set.) */ CXCompletionContext_Unexposed = 0, /** - * \brief Completions for any possible type should be included in the results. + * Completions for any possible type should be included in the results. */ CXCompletionContext_AnyType = 1 << 0, /** - * \brief Completions for any possible value (variables, function calls, etc.) + * Completions for any possible value (variables, function calls, etc.) * should be included in the results. */ CXCompletionContext_AnyValue = 1 << 1, /** - * \brief Completions for values that resolve to an Objective-C object should + * Completions for values that resolve to an Objective-C object should * be included in the results. */ CXCompletionContext_ObjCObjectValue = 1 << 2, /** - * \brief Completions for values that resolve to an Objective-C selector + * Completions for values that resolve to an Objective-C selector * should be included in the results. */ CXCompletionContext_ObjCSelectorValue = 1 << 3, /** - * \brief Completions for values that resolve to a C++ class type should be + * Completions for values that resolve to a C++ class type should be * included in the results. */ CXCompletionContext_CXXClassTypeValue = 1 << 4, /** - * \brief Completions for fields of the member being accessed using the dot + * Completions for fields of the member being accessed using the dot * operator should be included in the results. */ CXCompletionContext_DotMemberAccess = 1 << 5, /** - * \brief Completions for fields of the member being accessed using the arrow + * Completions for fields of the member being accessed using the arrow * operator should be included in the results. */ CXCompletionContext_ArrowMemberAccess = 1 << 6, /** - * \brief Completions for properties of the Objective-C object being accessed + * Completions for properties of the Objective-C object being accessed * using the dot operator should be included in the results. */ CXCompletionContext_ObjCPropertyAccess = 1 << 7, /** - * \brief Completions for enum tags should be included in the results. + * Completions for enum tags should be included in the results. */ CXCompletionContext_EnumTag = 1 << 8, /** - * \brief Completions for union tags should be included in the results. + * Completions for union tags should be included in the results. */ CXCompletionContext_UnionTag = 1 << 9, /** - * \brief Completions for struct tags should be included in the results. + * Completions for struct tags should be included in the results. */ CXCompletionContext_StructTag = 1 << 10, /** - * \brief Completions for C++ class names should be included in the results. + * Completions for C++ class names should be included in the results. */ CXCompletionContext_ClassTag = 1 << 11, /** - * \brief Completions for C++ namespaces and namespace aliases should be + * Completions for C++ namespaces and namespace aliases should be * included in the results. */ CXCompletionContext_Namespace = 1 << 12, /** - * \brief Completions for C++ nested name specifiers should be included in + * Completions for C++ nested name specifiers should be included in * the results. */ CXCompletionContext_NestedNameSpecifier = 1 << 13, /** - * \brief Completions for Objective-C interfaces (classes) should be included + * Completions for Objective-C interfaces (classes) should be included * in the results. */ CXCompletionContext_ObjCInterface = 1 << 14, /** - * \brief Completions for Objective-C protocols should be included in + * Completions for Objective-C protocols should be included in * the results. */ CXCompletionContext_ObjCProtocol = 1 << 15, /** - * \brief Completions for Objective-C categories should be included in + * Completions for Objective-C categories should be included in * the results. */ CXCompletionContext_ObjCCategory = 1 << 16, /** - * \brief Completions for Objective-C instance messages should be included + * Completions for Objective-C instance messages should be included * in the results. */ CXCompletionContext_ObjCInstanceMessage = 1 << 17, /** - * \brief Completions for Objective-C class messages should be included in + * Completions for Objective-C class messages should be included in * the results. */ CXCompletionContext_ObjCClassMessage = 1 << 18, /** - * \brief Completions for Objective-C selector names should be included in + * Completions for Objective-C selector names should be included in * the results. */ CXCompletionContext_ObjCSelectorName = 1 << 19, /** - * \brief Completions for preprocessor macro names should be included in + * Completions for preprocessor macro names should be included in * the results. */ CXCompletionContext_MacroName = 1 << 20, /** - * \brief Natural language completions should be included in the results. + * Natural language completions should be included in the results. */ CXCompletionContext_NaturalLanguage = 1 << 21, /** - * \brief The current context is unknown, so set all contexts. + * The current context is unknown, so set all contexts. */ CXCompletionContext_Unknown = ((1 << 22) - 1) }; /** - * \brief Returns a default set of code-completion options that can be + * Returns a default set of code-completion options that can be * passed to\c clang_codeCompleteAt(). */ CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); /** - * \brief Perform code completion at a given location in a translation unit. + * Perform code completion at a given location in a translation unit. * * This function performs code completion at a particular file, line, and * column within source code, providing results that suggest potential @@ -5309,7 +5521,7 @@ CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); * user types punctuation characters or whitespace, at which point the * code-completion location will coincide with the cursor. For example, if \c p * is a pointer, code-completion might be triggered after the "-" and then - * after the ">" in \c p->. When the code-completion location is afer the ">", + * after the ">" in \c p->. When the code-completion location is after the ">", * the completion results will provide, e.g., the members of the struct that * "p" points to. The client is responsible for placing the cursor at the * beginning of the token currently being typed, then filtering the results @@ -5369,7 +5581,7 @@ CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU, unsigned options); /** - * \brief 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. @@ -5380,20 +5592,20 @@ void clang_sortCodeCompletionResults(CXCompletionResult *Results, unsigned NumResults); /** - * \brief Free the given set of code-completion results. + * Free the given set of code-completion results. */ CINDEX_LINKAGE void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); /** - * \brief Determine the number of diagnostics produced prior to the + * Determine the number of diagnostics produced prior to the * location where code completion was performed. */ CINDEX_LINKAGE unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); /** - * \brief Retrieve a diagnostic associated with the given code completion. + * Retrieve a diagnostic associated with the given code completion. * * \param Results the code completion results to query. * \param Index the zero-based diagnostic number to retrieve. @@ -5406,7 +5618,7 @@ CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, unsigned Index); /** - * \brief Determines what completions are appropriate for the context + * Determines what completions are appropriate for the context * the given code completion. * * \param Results the code completion results to query @@ -5419,7 +5631,7 @@ unsigned long long clang_codeCompleteGetContexts( CXCodeCompleteResults *Results); /** - * \brief Returns the cursor kind for the container for the current code + * Returns the cursor kind for the container for the current code * completion context. The container is only guaranteed to be set for * contexts where a container exists (i.e. member accesses or Objective-C * message sends); if there is not a container, this function will return @@ -5440,7 +5652,7 @@ enum CXCursorKind clang_codeCompleteGetContainerKind( unsigned *IsIncomplete); /** - * \brief Returns the USR for the container for the current code completion + * Returns the USR for the container for the current code completion * context. If there is not a container for the current context, this * function will return the empty string. * @@ -5452,7 +5664,7 @@ CINDEX_LINKAGE CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); /** - * \brief Returns the currently-entered selector for an Objective-C message + * Returns the currently-entered selector for an Objective-C message * send, formatted like "initWithFoo:bar:". Only guaranteed to return a * non-empty string for CXCompletionContext_ObjCInstanceMessage and * CXCompletionContext_ObjCClassMessage. @@ -5476,13 +5688,13 @@ CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); */ /** - * \brief Return a version string, suitable for showing to a user, but not + * Return a version string, suitable for showing to a user, but not * intended to be parsed (the format is not guaranteed to be stable). */ CINDEX_LINKAGE CXString clang_getClangVersion(void); /** - * \brief Enable/disable crash recovery. + * Enable/disable crash recovery. * * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero * value enables crash recovery, while 0 disables it. @@ -5490,7 +5702,7 @@ CINDEX_LINKAGE CXString clang_getClangVersion(void); CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); /** - * \brief Visitor invoked for each file in a translation unit + * Visitor invoked for each file in a translation unit * (used with clang_getInclusions()). * * This visitor function will be invoked by clang_getInclusions() for each @@ -5506,7 +5718,7 @@ typedef void (*CXInclusionVisitor)(CXFile included_file, CXClientData client_data); /** - * \brief Visit the set of preprocessor inclusions in a translation unit. + * Visit the set of preprocessor inclusions in a translation unit. * The visitor function is called with the provided data for every included * file. This does not include headers included by the PCH file (unless one * is inspecting the inclusions in the PCH file itself). @@ -5528,55 +5740,55 @@ typedef enum { } CXEvalResultKind ; /** - * \brief Evaluation result of a cursor + * Evaluation result of a cursor */ typedef void * CXEvalResult; /** - * \brief 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. */ CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C); /** - * \brief Returns the kind of the evaluated result. + * Returns the kind of the evaluated result. */ CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E); /** - * \brief Returns the evaluation result as integer if the + * Returns the evaluation result as integer if the * kind is Int. */ CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E); /** - * \brief Returns the evaluation result as a long long integer if the + * Returns the evaluation result as a long long integer if the * kind is Int. This prevents overflows that may happen if the result is * returned with clang_EvalResult_getAsInt. */ CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E); /** - * \brief Returns a non-zero value if the kind is Int and the evaluation + * Returns a non-zero value if the kind is Int and the evaluation * result resulted in an unsigned integer. */ CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E); /** - * \brief Returns the evaluation result as an unsigned integer if + * Returns the evaluation result as an unsigned integer if * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. */ CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E); /** - * \brief Returns the evaluation result as double if the + * Returns the evaluation result as double if the * kind is double. */ CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E); /** - * \brief Returns the evaluation result as a constant string if the + * Returns the evaluation result as a constant string if the * kind is other than Int or float. User must not free this pointer, * instead call clang_EvalResult_dispose on the CXEvalResult returned * by clang_Cursor_Evaluate. @@ -5584,7 +5796,7 @@ CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E); CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E); /** - * \brief Disposes the created Eval memory. + * Disposes the created Eval memory. */ CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E); /** @@ -5597,12 +5809,12 @@ CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E); */ /** - * \brief A remapping of original source files and their translated files. + * A remapping of original source files and their translated files. */ typedef void *CXRemapping; /** - * \brief Retrieve a remapping. + * Retrieve a remapping. * * \param path the path that contains metadata about remappings. * @@ -5612,7 +5824,7 @@ typedef void *CXRemapping; CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path); /** - * \brief Retrieve a remapping. + * Retrieve a remapping. * * \param filePaths pointer to an array of file paths containing remapping info. * @@ -5626,12 +5838,12 @@ CXRemapping clang_getRemappingsFromFileList(const char **filePaths, unsigned numFiles); /** - * \brief Determine the number of remappings. + * Determine the number of remappings. */ CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); /** - * \brief Get the original and the associated filename from the remapping. + * Get the original and the associated filename from the remapping. * * \param original If non-NULL, will be set to the original filename. * @@ -5642,7 +5854,7 @@ CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, CXString *original, CXString *transformed); /** - * \brief Dispose the remapping. + * Dispose the remapping. */ CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); @@ -5667,15 +5879,15 @@ typedef struct CXCursorAndRangeVisitor { typedef enum { /** - * \brief Function returned successfully. + * Function returned successfully. */ CXResult_Success = 0, /** - * \brief One of the parameters was invalid for the function. + * One of the parameters was invalid for the function. */ CXResult_Invalid = 1, /** - * \brief The function was terminated by a callback (e.g. it returned + * The function was terminated by a callback (e.g. it returned * CXVisit_Break) */ CXResult_VisitBreak = 2 @@ -5683,7 +5895,7 @@ typedef enum { } CXResult; /** - * \brief Find references of a declaration in a specific file. + * Find references of a declaration in a specific file. * * \param cursor pointing to a declaration or a reference of one. * @@ -5700,7 +5912,7 @@ CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor); /** - * \brief Find #import/#include directives in a specific file. + * Find #import/#include directives in a specific file. * * \param TU translation unit containing the file to query. * @@ -5733,29 +5945,29 @@ CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile, #endif /** - * \brief The client's data object that is associated with a CXFile. + * The client's data object that is associated with a CXFile. */ typedef void *CXIdxClientFile; /** - * \brief The client's data object that is associated with a semantic entity. + * The client's data object that is associated with a semantic entity. */ typedef void *CXIdxClientEntity; /** - * \brief The client's data object that is associated with a semantic container + * The client's data object that is associated with a semantic container * of entities. */ typedef void *CXIdxClientContainer; /** - * \brief The client's data object that is associated with an AST file (PCH + * The client's data object that is associated with an AST file (PCH * or module). */ typedef void *CXIdxClientASTFile; /** - * \brief Source location passed to index callbacks. + * Source location passed to index callbacks. */ typedef struct { void *ptr_data[2]; @@ -5763,48 +5975,48 @@ typedef struct { } CXIdxLoc; /** - * \brief Data for ppIncludedFile callback. + * Data for ppIncludedFile callback. */ typedef struct { /** - * \brief Location of '#' in the \#include/\#import directive. + * Location of '#' in the \#include/\#import directive. */ CXIdxLoc hashLoc; /** - * \brief Filename as written in the \#include/\#import directive. + * Filename as written in the \#include/\#import directive. */ const char *filename; /** - * \brief The actual file that the \#include/\#import directive resolved to. + * The actual file that the \#include/\#import directive resolved to. */ CXFile file; int isImport; int isAngled; /** - * \brief Non-zero if the directive was automatically turned into a module + * Non-zero if the directive was automatically turned into a module * import. */ int isModuleImport; } CXIdxIncludedFileInfo; /** - * \brief Data for IndexerCallbacks#importedASTFile. + * Data for IndexerCallbacks#importedASTFile. */ typedef struct { /** - * \brief Top level AST file containing the imported PCH, module or submodule. + * Top level AST file containing the imported PCH, module or submodule. */ CXFile file; /** - * \brief The imported module or NULL if the AST file is a PCH. + * The imported module or NULL if the AST file is a PCH. */ CXModule module; /** - * \brief Location where the file is imported. Applicable only for modules. + * Location where the file is imported. Applicable only for modules. */ CXIdxLoc loc; /** - * \brief Non-zero if an inclusion directive was automatically turned into + * Non-zero if an inclusion directive was automatically turned into * a module import. Applicable only for modules. */ int isImplicit; @@ -5855,7 +6067,7 @@ typedef enum { } CXIdxEntityLanguage; /** - * \brief Extra C++ template information for an entity. This can apply to: + * Extra C++ template information for an entity. This can apply to: * CXIdxEntity_Function * CXIdxEntity_CXXClass * CXIdxEntity_CXXStaticMethod @@ -5916,7 +6128,7 @@ typedef struct { CXIdxLoc loc; const CXIdxContainerInfo *semanticContainer; /** - * \brief Generally same as #semanticContainer but can be different in + * Generally same as #semanticContainer but can be different in * cases like out-of-line C++ member functions. */ const CXIdxContainerInfo *lexicalContainer; @@ -5925,7 +6137,7 @@ typedef struct { int isContainer; const CXIdxContainerInfo *declAsContainer; /** - * \brief Whether the declaration exists in code or was created implicitly + * Whether the declaration exists in code or was created implicitly * by the compiler, e.g. implicit Objective-C methods for properties. */ int isImplicit; @@ -5991,36 +6203,58 @@ typedef struct { } CXIdxCXXClassDeclInfo; /** - * \brief Data for IndexerCallbacks#indexEntityReference. + * Data for IndexerCallbacks#indexEntityReference. + * + * This may be deprecated in a future version as this duplicates + * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole. */ typedef enum { /** - * \brief The entity is referenced directly in user's code. + * The entity is referenced directly in user's code. */ CXIdxEntityRef_Direct = 1, /** - * \brief An implicit reference, e.g. a reference of an Objective-C method + * An implicit reference, e.g. a reference of an Objective-C method * via the dot syntax. */ CXIdxEntityRef_Implicit = 2 } CXIdxEntityRefKind; /** - * \brief Data for IndexerCallbacks#indexEntityReference. + * Roles that are attributed to symbol occurrences. + * + * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with + * higher bits zeroed. These high bits may be exposed in the future. + */ +typedef enum { + CXSymbolRole_None = 0, + CXSymbolRole_Declaration = 1 << 0, + CXSymbolRole_Definition = 1 << 1, + CXSymbolRole_Reference = 1 << 2, + CXSymbolRole_Read = 1 << 3, + CXSymbolRole_Write = 1 << 4, + CXSymbolRole_Call = 1 << 5, + CXSymbolRole_Dynamic = 1 << 6, + CXSymbolRole_AddressOf = 1 << 7, + CXSymbolRole_Implicit = 1 << 8 +} CXSymbolRole; + +/** + * Data for IndexerCallbacks#indexEntityReference. */ typedef struct { CXIdxEntityRefKind kind; /** - * \brief Reference cursor. + * Reference cursor. */ CXCursor cursor; CXIdxLoc loc; /** - * \brief The entity that gets referenced. + * The entity that gets referenced. */ const CXIdxEntityInfo *referencedEntity; /** - * \brief Immediate "parent" of the reference. For example: + * Immediate "parent" of the reference. For example: * * \code * Foo *var; @@ -6032,24 +6266,28 @@ typedef struct { */ const CXIdxEntityInfo *parentEntity; /** - * \brief Lexical container context of the reference. + * Lexical container context of the reference. */ const CXIdxContainerInfo *container; + /** + * Sets of symbol roles of the reference. + */ + CXSymbolRole role; } CXIdxEntityRefInfo; /** - * \brief A group of callbacks used by #clang_indexSourceFile and + * A group of callbacks used by #clang_indexSourceFile and * #clang_indexTranslationUnit. */ typedef struct { /** - * \brief Called periodically to check whether indexing should be aborted. + * Called periodically to check whether indexing should be aborted. * Should return 0 to continue, and non-zero to abort. */ int (*abortQuery)(CXClientData client_data, void *reserved); /** - * \brief Called at the end of indexing; passes the complete diagnostic set. + * Called at the end of indexing; passes the complete diagnostic set. */ void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved); @@ -6058,13 +6296,13 @@ typedef struct { CXFile mainFile, void *reserved); /** - * \brief Called when a file gets \#included/\#imported. + * Called when a file gets \#included/\#imported. */ CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, const CXIdxIncludedFileInfo *); /** - * \brief Called when a AST file (PCH or module) gets imported. + * 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 @@ -6075,7 +6313,7 @@ typedef struct { const CXIdxImportedASTFileInfo *); /** - * \brief Called at the beginning of indexing a translation unit. + * Called at the beginning of indexing a translation unit. */ CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data, void *reserved); @@ -6084,7 +6322,7 @@ typedef struct { const CXIdxDeclInfo *); /** - * \brief Called to index a reference of an entity. + * Called to index a reference of an entity. */ void (*indexEntityReference)(CXClientData client_data, const CXIdxEntityRefInfo *); @@ -6115,39 +6353,39 @@ CINDEX_LINKAGE const CXIdxCXXClassDeclInfo * clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *); /** - * \brief For retrieving a custom CXIdxClientContainer attached to a + * For retrieving a custom CXIdxClientContainer attached to a * container. */ CINDEX_LINKAGE CXIdxClientContainer clang_index_getClientContainer(const CXIdxContainerInfo *); /** - * \brief For setting a custom CXIdxClientContainer attached to a + * For setting a custom CXIdxClientContainer attached to a * container. */ CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer); /** - * \brief For retrieving a custom CXIdxClientEntity attached to an entity. + * For retrieving a custom CXIdxClientEntity attached to an entity. */ CINDEX_LINKAGE CXIdxClientEntity clang_index_getClientEntity(const CXIdxEntityInfo *); /** - * \brief For setting a custom CXIdxClientEntity attached to an entity. + * For setting a custom CXIdxClientEntity attached to an entity. */ CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity); /** - * \brief An indexing action/session, to be applied to one or multiple + * An indexing action/session, to be applied to one or multiple * translation units. */ typedef void *CXIndexAction; /** - * \brief An indexing action/session, to be applied to one or multiple + * An indexing action/session, to be applied to one or multiple * translation units. * * \param CIdx The index object with which the index action will be associated. @@ -6155,7 +6393,7 @@ typedef void *CXIndexAction; CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx); /** - * \brief Destroy the given index action. + * Destroy the given index action. * * The index action must not be destroyed until all of the translation units * created within that index action have been destroyed. @@ -6164,36 +6402,36 @@ CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction); typedef enum { /** - * \brief Used to indicate that no special indexing options are needed. + * Used to indicate that no special indexing options are needed. */ CXIndexOpt_None = 0x0, /** - * \brief Used to indicate that IndexerCallbacks#indexEntityReference should + * Used to indicate that IndexerCallbacks#indexEntityReference should * be invoked for only one reference of an entity per source file that does * not also include a declaration/definition of the entity. */ CXIndexOpt_SuppressRedundantRefs = 0x1, /** - * \brief Function-local symbols should be indexed. If this is not set + * Function-local symbols should be indexed. If this is not set * function-local symbols will be ignored. */ CXIndexOpt_IndexFunctionLocalSymbols = 0x2, /** - * \brief Implicit function/class template instantiations should be indexed. + * Implicit function/class template instantiations should be indexed. * If this is not set, implicit instantiations will be ignored. */ CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, /** - * \brief Suppress all compiler warnings when parsing for indexing. + * Suppress all compiler warnings when parsing for indexing. */ CXIndexOpt_SuppressWarnings = 0x8, /** - * \brief Skip a function/method body that was already parsed during an + * Skip a function/method body that was already parsed during an * indexing session associated with a \c CXIndexAction object. * Bodies in system headers are always skipped. */ @@ -6202,7 +6440,7 @@ typedef enum { } CXIndexOptFlags; /** - * \brief Index the given source file and the translation unit corresponding + * Index the given source file and the translation unit corresponding * to that file via callbacks implemented through #IndexerCallbacks. * * \param client_data pointer data supplied by the client, which will @@ -6240,7 +6478,7 @@ CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction, unsigned TU_options); /** - * \brief Same as clang_indexSourceFile but requires a full command line + * Same as clang_indexSourceFile but requires a full command line * for \c command_line_args including argv[0]. This is useful if the standard * library paths are relative to the binary. */ @@ -6252,7 +6490,7 @@ CINDEX_LINKAGE int clang_indexSourceFileFullArgv( unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); /** - * \brief Index the given translation unit via callbacks implemented through + * Index the given translation unit via callbacks implemented through * #IndexerCallbacks. * * The order of callback invocations is not guaranteed to be the same as @@ -6275,7 +6513,7 @@ CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction, CXTranslationUnit); /** - * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by + * Retrieve the CXIdxFile, file, line, column, and offset represented by * the given CXIdxLoc. * * If the location refers into a macro expansion, retrieves the @@ -6290,13 +6528,13 @@ CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc, unsigned *offset); /** - * \brief Retrieve the CXSourceLocation represented by the given CXIdxLoc. + * Retrieve the CXSourceLocation represented by the given CXIdxLoc. */ CINDEX_LINKAGE CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc); /** - * \brief Visitor invoked for each field found by a traversal. + * Visitor invoked for each field found by a traversal. * * This visitor function will be invoked for each field found by * \c clang_Type_visitFields. Its first argument is the cursor being @@ -6310,7 +6548,7 @@ typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C, CXClientData client_data); /** - * \brief Visit the fields of a particular type. + * Visit the fields of a particular type. * * This function visits all the direct fields of the given cursor, * invoking the given \p visitor function with the cursors of each diff --git a/include/clang/ARCMigrate/ARCMT.h b/include/clang/ARCMigrate/ARCMT.h index 74081867eebc..30c24f1cdb10 100644 --- a/include/clang/ARCMigrate/ARCMT.h +++ b/include/clang/ARCMigrate/ARCMT.h @@ -22,7 +22,7 @@ namespace clang { namespace arcmt { class MigrationPass; -/// \brief Creates an AST with the provided CompilerInvocation but with these +/// Creates an AST with the provided CompilerInvocation but with these /// changes: /// -if a PCH/PTH is set, the original header is used instead /// -Automatic Reference Counting mode is enabled @@ -45,7 +45,7 @@ checkForManualIssues(CompilerInvocation &CI, const FrontendInputFile &Input, bool emitPremigrationARCErrors = false, StringRef plistOut = StringRef()); -/// \brief Works similar to checkForManualIssues but instead of checking, it +/// Works similar to checkForManualIssues but instead of checking, it /// applies automatic modifications to source files to conform to ARC. /// /// \returns false if no error is produced, true otherwise. @@ -55,7 +55,7 @@ applyTransformations(CompilerInvocation &origCI, std::shared_ptr<PCHContainerOperations> PCHContainerOps, DiagnosticConsumer *DiagClient); -/// \brief Applies automatic modifications and produces temporary files +/// Applies automatic modifications and produces temporary files /// and metadata into the \p outputDir path. /// /// \param emitPremigrationARCErrors if true all ARC errors will get emitted @@ -72,7 +72,7 @@ bool migrateWithTemporaryFiles( DiagnosticConsumer *DiagClient, StringRef outputDir, bool emitPremigrationARCErrors, StringRef plistOut); -/// \brief Get the set of file remappings from the \p outputDir path that +/// Get the set of file remappings from the \p outputDir path that /// migrateWithTemporaryFiles produced. /// /// \returns false if no error is produced, true otherwise. @@ -80,7 +80,7 @@ bool getFileRemappings(std::vector<std::pair<std::string,std::string> > &remap, StringRef outputDir, DiagnosticConsumer *DiagClient); -/// \brief Get the set of file remappings from a list of files with remapping +/// Get the set of file remappings from a list of files with remapping /// info. /// /// \returns false if no error is produced, true otherwise. diff --git a/include/clang/ARCMigrate/ARCMTActions.h b/include/clang/ARCMigrate/ARCMTActions.h index 554e0c0c6d02..2571ca75be51 100644 --- a/include/clang/ARCMigrate/ARCMTActions.h +++ b/include/clang/ARCMigrate/ARCMTActions.h @@ -55,7 +55,7 @@ public: bool emitPremigrationARCErrors); }; -/// \brief Migrates to modern ObjC syntax. +/// Migrates to modern ObjC syntax. class ObjCMigrateAction : public WrapperFrontendAction { std::string MigrateDir; unsigned ObjCMigAction; diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h index 7c431f3be8c4..d4057c9da5f3 100644 --- a/include/clang/AST/APValue.h +++ b/include/clang/AST/APValue.h @@ -53,7 +53,58 @@ public: MemberPointer, AddrLabelDiff }; - typedef llvm::PointerUnion<const ValueDecl *, const Expr *> LValueBase; + + class LValueBase { + public: + typedef llvm::PointerUnion<const ValueDecl *, const Expr *> PtrTy; + + LValueBase() : CallIndex(0), Version(0) {} + + template <class T> + LValueBase(T P, unsigned I = 0, unsigned V = 0) + : Ptr(P), CallIndex(I), Version(V) {} + + template <class T> + bool is() const { return Ptr.is<T>(); } + + template <class T> + T get() const { return Ptr.get<T>(); } + + template <class T> + T dyn_cast() const { return Ptr.dyn_cast<T>(); } + + void *getOpaqueValue() const; + + bool isNull() const; + + explicit operator bool () const; + + PtrTy getPointer() const { + return Ptr; + } + + unsigned getCallIndex() const { + return CallIndex; + } + + void setCallIndex(unsigned Index) { + CallIndex = Index; + } + + unsigned getVersion() const { + return Version; + } + + bool operator==(const LValueBase &Other) const { + return Ptr == Other.Ptr && CallIndex == Other.CallIndex && + Version == Other.Version; + } + + private: + PtrTy Ptr; + unsigned CallIndex, Version; + }; + typedef llvm::PointerIntPair<const Decl *, 1, bool> BaseOrMemberType; union LValuePathEntry { /// BaseOrMember - The FieldDecl or CXXRecordDecl indicating the next item @@ -135,15 +186,15 @@ public: } APValue(const APValue &RHS); APValue(APValue &&RHS) : Kind(Uninitialized) { swap(RHS); } - APValue(LValueBase B, const CharUnits &O, NoLValuePath N, unsigned CallIndex, + APValue(LValueBase B, const CharUnits &O, NoLValuePath N, bool IsNullPtr = false) : Kind(Uninitialized) { - MakeLValue(); setLValue(B, O, N, CallIndex, IsNullPtr); + MakeLValue(); setLValue(B, O, N, IsNullPtr); } APValue(LValueBase B, const CharUnits &O, ArrayRef<LValuePathEntry> Path, - bool OnePastTheEnd, unsigned CallIndex, bool IsNullPtr = false) + bool OnePastTheEnd, bool IsNullPtr = false) : Kind(Uninitialized) { - MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex, IsNullPtr); + MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, IsNullPtr); } APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) { MakeArray(InitElts, Size); @@ -168,14 +219,14 @@ public: MakeUninit(); } - /// \brief Returns whether the object performed allocations. + /// Returns whether the object performed allocations. /// /// If APValues are constructed via placement new, \c needsCleanup() /// indicates whether the destructor must be called in order to correctly /// free all allocated memory. bool needsCleanup() const; - /// \brief Swaps the contents of this and the given APValue. + /// Swaps the contents of this and the given APValue. void swap(APValue &RHS); ValueKind getKind() const { return Kind; } @@ -255,6 +306,7 @@ public: bool hasLValuePath() const; ArrayRef<LValuePathEntry> getLValuePath() const; unsigned getLValueCallIndex() const; + unsigned getLValueVersion() const; bool isNullPointer() const; APValue &getVectorElt(unsigned I) { @@ -376,10 +428,10 @@ public: ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I); } void setLValue(LValueBase B, const CharUnits &O, NoLValuePath, - unsigned CallIndex, bool IsNullPtr); + bool IsNullPtr); void setLValue(LValueBase B, const CharUnits &O, ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd, - unsigned CallIndex, bool IsNullPtr); + bool IsNullPtr); void setUnion(const FieldDecl *Field, const APValue &Value) { assert(isUnion() && "Invalid accessor"); ((UnionData*)(char*)Data.buffer)->Field = Field; @@ -451,4 +503,14 @@ private: } // end namespace clang. +namespace llvm { +template<> struct DenseMapInfo<clang::APValue::LValueBase> { + static clang::APValue::LValueBase getEmptyKey(); + static clang::APValue::LValueBase getTombstoneKey(); + static unsigned getHashValue(const clang::APValue::LValueBase &Base); + static bool isEqual(const clang::APValue::LValueBase &LHS, + const clang::APValue::LValueBase &RHS); +}; +} + #endif diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h index ad368c86c79c..1167c566a35f 100644 --- a/include/clang/AST/ASTConsumer.h +++ b/include/clang/AST/ASTConsumer.h @@ -32,7 +32,7 @@ namespace clang { /// clients that read ASTs. This abstraction layer allows the client to be /// independent of the AST producer (e.g. parser vs AST dump file reader, etc). class ASTConsumer { - /// \brief Whether this AST consumer also requires information about + /// Whether this AST consumer also requires information about /// semantic analysis. bool SemaConsumer; @@ -53,7 +53,7 @@ public: /// \returns true to continue parsing, or false to abort parsing. virtual bool HandleTopLevelDecl(DeclGroupRef D); - /// \brief This callback is invoked each time an inline (method or friend) + /// This callback is invoked each time an inline (method or friend) /// function definition in a class is completed. virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {} @@ -72,22 +72,22 @@ public: /// can be defined in declspecs). virtual void HandleTagDeclDefinition(TagDecl *D) {} - /// \brief This callback is invoked the first time each TagDecl is required to + /// This callback is invoked the first time each TagDecl is required to /// be complete. virtual void HandleTagDeclRequiredDefinition(const TagDecl *D) {} - /// \brief Invoked when a function is implicitly instantiated. + /// Invoked when a function is implicitly instantiated. /// Note that at this point point it does not have a body, its body is /// instantiated at the end of the translation unit and passed to /// HandleTopLevelDecl. virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {} - /// \brief Handle the specified top-level declaration that occurred inside + /// Handle the specified top-level declaration that occurred inside /// and ObjC container. /// The default implementation ignored them. virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D); - /// \brief Handle an ImportDecl that was implicitly created due to an + /// Handle an ImportDecl that was implicitly created due to an /// inclusion directive. /// The default implementation passes it to HandleTopLevelDecl. virtual void HandleImplicitImportDecl(ImportDecl *D); @@ -103,7 +103,7 @@ public: /// modified by the introduction of an implicit zero initializer. virtual void CompleteTentativeDefinition(VarDecl *D) {} - /// \brief Callback invoked when an MSInheritanceAttr has been attached to a + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} @@ -111,19 +111,19 @@ public: // variable has been instantiated. virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D) {} - /// \brief Callback involved at the end of a translation unit to + /// Callback involved at the end of a translation unit to /// notify the consumer that a vtable for the given C++ class is /// required. /// /// \param RD The class whose vtable was used. virtual void HandleVTable(CXXRecordDecl *RD) {} - /// \brief If the consumer is interested in entities getting modified after + /// If the consumer is interested in entities getting modified after /// their initial creation, it should return a pointer to /// an ASTMutationListener here. virtual ASTMutationListener *GetASTMutationListener() { return nullptr; } - /// \brief If the consumer is interested in entities being deserialized from + /// If the consumer is interested in entities being deserialized from /// AST files, it should return a pointer to a ASTDeserializationListener here virtual ASTDeserializationListener *GetASTDeserializationListener() { return nullptr; @@ -132,7 +132,7 @@ public: /// PrintStats - If desired, print any statistics. virtual void PrintStats() {} - /// \brief This callback is called for each function if the Parser was + /// This callback is called for each function if the Parser was /// initialized with \c SkipFunctionBodies set to \c true. /// /// \return \c true if the function's body should be skipped. The function diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index a5d080035df0..c6f8e2973e8e 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // /// \file -/// \brief Defines the clang::ASTContext interface. +/// Defines the clang::ASTContext interface. // //===----------------------------------------------------------------------===// @@ -18,6 +18,7 @@ #include "clang/AST/ASTTypeTraits.h" #include "clang/AST/CanonicalType.h" #include "clang/AST/CommentCommandTraits.h" +#include "clang/AST/ComparisonCategories.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclBase.h" #include "clang/AST/DeclarationName.h" @@ -144,7 +145,7 @@ struct TypeInfo { : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} }; -/// \brief Holds long-lived AST nodes (such as types and decls) that can be +/// Holds long-lived AST nodes (such as types and decls) that can be /// referred to throughout the semantic analysis of a file. class ASTContext : public RefCountedBase<ASTContext> { friend class NestedNameSpecifier; @@ -167,6 +168,7 @@ class ASTContext : public RefCountedBase<ASTContext> { mutable llvm::FoldingSet<DependentAddressSpaceType> DependentAddressSpaceTypes; mutable llvm::FoldingSet<VectorType> VectorTypes; + mutable llvm::FoldingSet<DependentVectorType> DependentVectorTypes; mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes; mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&> FunctionProtoTypes; @@ -206,13 +208,13 @@ class ASTContext : public RefCountedBase<ASTContext> { ASTContext&> SubstTemplateTemplateParmPacks; - /// \brief The set of nested name specifiers. + /// The set of nested name specifiers. /// /// This set is managed by the NestedNameSpecifier class. mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers; mutable NestedNameSpecifier *GlobalNestedNameSpecifier = nullptr; - /// \brief A cache mapping from RecordDecls to ASTRecordLayouts. + /// A cache mapping from RecordDecls to ASTRecordLayouts. /// /// This is lazily created. This is intentionally not serialized. mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*> @@ -220,35 +222,35 @@ class ASTContext : public RefCountedBase<ASTContext> { mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*> ObjCLayouts; - /// \brief A cache from types to size and alignment information. + /// A cache from types to size and alignment information. using TypeInfoMap = llvm::DenseMap<const Type *, struct TypeInfo>; mutable TypeInfoMap MemoizedTypeInfo; - /// \brief A cache mapping from CXXRecordDecls to key functions. + /// A cache mapping from CXXRecordDecls to key functions. llvm::DenseMap<const CXXRecordDecl*, LazyDeclPtr> KeyFunctions; - /// \brief Mapping from ObjCContainers to their ObjCImplementations. + /// Mapping from ObjCContainers to their ObjCImplementations. llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls; - /// \brief Mapping from ObjCMethod to its duplicate declaration in the same + /// Mapping from ObjCMethod to its duplicate declaration in the same /// interface. llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls; - /// \brief Mapping from __block VarDecls to their copy initialization expr. + /// Mapping from __block VarDecls to their copy initialization expr. llvm::DenseMap<const VarDecl*, Expr*> BlockVarCopyInits; - /// \brief Mapping from class scope functions specialization to their + /// Mapping from class scope functions specialization to their /// template patterns. llvm::DenseMap<const FunctionDecl*, FunctionDecl*> ClassScopeSpecializationPattern; - /// \brief Mapping from materialized temporaries with static storage duration + /// Mapping from materialized temporaries with static storage duration /// that appear in constant initializers to their evaluated values. These are /// allocated in a std::map because their address must be stable. llvm::DenseMap<const MaterializeTemporaryExpr *, APValue *> MaterializedTemporaryValues; - /// \brief Representation of a "canonical" template template parameter that + /// Representation of a "canonical" template template parameter that /// is used in canonical template names. class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode { TemplateTemplateParmDecl *Parm; @@ -270,32 +272,32 @@ class ASTContext : public RefCountedBase<ASTContext> { TemplateTemplateParmDecl * getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; - /// \brief The typedef for the __int128_t type. + /// The typedef for the __int128_t type. mutable TypedefDecl *Int128Decl = nullptr; - /// \brief The typedef for the __uint128_t type. + /// The typedef for the __uint128_t type. mutable TypedefDecl *UInt128Decl = nullptr; - /// \brief The typedef for the target specific predefined + /// The typedef for the target specific predefined /// __builtin_va_list type. mutable TypedefDecl *BuiltinVaListDecl = nullptr; /// The typedef for the predefined \c __builtin_ms_va_list type. mutable TypedefDecl *BuiltinMSVaListDecl = nullptr; - /// \brief The typedef for the predefined \c id type. + /// The typedef for the predefined \c id type. mutable TypedefDecl *ObjCIdDecl = nullptr; - /// \brief The typedef for the predefined \c SEL type. + /// The typedef for the predefined \c SEL type. mutable TypedefDecl *ObjCSelDecl = nullptr; - /// \brief The typedef for the predefined \c Class type. + /// The typedef for the predefined \c Class type. mutable TypedefDecl *ObjCClassDecl = nullptr; - /// \brief The typedef for the predefined \c Protocol class in Objective-C. + /// The typedef for the predefined \c Protocol class in Objective-C. mutable ObjCInterfaceDecl *ObjCProtocolClassDecl = nullptr; - /// \brief The typedef for the predefined 'BOOL' type. + /// The typedef for the predefined 'BOOL' type. mutable TypedefDecl *BOOLDecl = nullptr; // Typedefs which may be provided defining the structure of Objective-C @@ -327,53 +329,53 @@ class ASTContext : public RefCountedBase<ASTContext> { QualType ObjCNSStringType; - /// \brief The typedef declaration for the Objective-C "instancetype" type. + /// The typedef declaration for the Objective-C "instancetype" type. TypedefDecl *ObjCInstanceTypeDecl = nullptr; - /// \brief The type for the C FILE type. + /// The type for the C FILE type. TypeDecl *FILEDecl = nullptr; - /// \brief The type for the C jmp_buf type. + /// The type for the C jmp_buf type. TypeDecl *jmp_bufDecl = nullptr; - /// \brief The type for the C sigjmp_buf type. + /// The type for the C sigjmp_buf type. TypeDecl *sigjmp_bufDecl = nullptr; - /// \brief The type for the C ucontext_t type. + /// The type for the C ucontext_t type. TypeDecl *ucontext_tDecl = nullptr; - /// \brief Type for the Block descriptor for Blocks CodeGen. + /// Type for the Block descriptor for Blocks CodeGen. /// /// Since this is only used for generation of debug info, it is not /// serialized. mutable RecordDecl *BlockDescriptorType = nullptr; - /// \brief Type for the Block descriptor for Blocks CodeGen. + /// Type for the Block descriptor for Blocks CodeGen. /// /// Since this is only used for generation of debug info, it is not /// serialized. mutable RecordDecl *BlockDescriptorExtendedType = nullptr; - /// \brief Declaration for the CUDA cudaConfigureCall function. + /// Declaration for the CUDA cudaConfigureCall function. FunctionDecl *cudaConfigureCallDecl = nullptr; - /// \brief Keeps track of all declaration attributes. + /// Keeps track of all declaration attributes. /// /// Since so few decls have attrs, we keep them in a hash map instead of /// wasting space in the Decl class. llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs; - /// \brief A mapping from non-redeclarable declarations in modules that were + /// A mapping from non-redeclarable declarations in modules that were /// merged with other declarations to the canonical declaration that they were /// merged into. llvm::DenseMap<Decl*, Decl*> MergedDecls; - /// \brief A mapping from a defining declaration to a list of modules (other + /// A mapping from a defining declaration to a list of modules (other /// than the owning module of the declaration) that contain merged /// definitions of that entity. llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules; - /// \brief Initializers for a module, in order. Each Decl will be either + /// Initializers for a module, in order. Each Decl will be either /// something that has a semantic effect on startup (such as a variable with /// a non-constant initializer), or an ImportDecl (which recursively triggers /// initialization of another module). @@ -388,7 +390,7 @@ class ASTContext : public RefCountedBase<ASTContext> { ASTContext &this_() { return *this; } public: - /// \brief A type synonym for the TemplateOrInstantiation mapping. + /// A type synonym for the TemplateOrInstantiation mapping. using TemplateOrSpecializationInfo = llvm::PointerUnion<VarTemplateDecl *, MemberSpecializationInfo *>; @@ -398,7 +400,7 @@ private: friend class ASTWriter; friend class CXXRecordDecl; - /// \brief A mapping to contain the template or declaration that + /// A mapping to contain the template or declaration that /// a variable declaration describes or was instantiated from, /// respectively. /// @@ -431,7 +433,7 @@ private: llvm::DenseMap<const VarDecl *, TemplateOrSpecializationInfo> TemplateOrInstantiation; - /// \brief Keeps track of the declaration from which a using declaration was + /// Keeps track of the declaration from which a using declaration was /// created during instantiation. /// /// The source and target declarations are always a UsingDecl, an @@ -461,7 +463,7 @@ private: llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl; - /// \brief Mapping that stores the methods overridden by a given C++ + /// Mapping that stores the methods overridden by a given C++ /// member function. /// /// Since most C++ member functions aren't virtual and therefore @@ -470,18 +472,18 @@ private: using CXXMethodVector = llvm::TinyPtrVector<const CXXMethodDecl *>; llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods; - /// \brief Mapping from each declaration context to its corresponding + /// Mapping from each declaration context to its corresponding /// mangling numbering context (used for constructs like lambdas which /// need to be consistently numbered for the mangler). llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>> MangleNumberingContexts; - /// \brief Side-table of mangling numbers for declarations which rarely + /// Side-table of mangling numbers for declarations which rarely /// need them (like static local vars). llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers; llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers; - /// \brief Mapping that stores parameterIndex values for ParmVarDecls when + /// Mapping that stores parameterIndex values for ParmVarDecls when /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex. using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>; ParameterIndexTable ParamIndices; @@ -494,38 +496,38 @@ private: mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr; mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr; - /// \brief The associated SourceManager object. + /// The associated SourceManager object. SourceManager &SourceMgr; - /// \brief The language options used to create the AST associated with + /// The language options used to create the AST associated with /// this ASTContext object. LangOptions &LangOpts; - /// \brief Blacklist object that is used by sanitizers to decide which + /// Blacklist object that is used by sanitizers to decide which /// entities should not be instrumented. std::unique_ptr<SanitizerBlacklist> SanitizerBL; - /// \brief Function filtering mechanism to determine whether a given function + /// Function filtering mechanism to determine whether a given function /// should be imbued with the XRay "always" or "never" attributes. std::unique_ptr<XRayFunctionFilter> XRayFilter; - /// \brief The allocator used to create AST objects. + /// The allocator used to create AST objects. /// /// AST objects are never destructed; rather, all memory associated with the /// AST objects will be released when the ASTContext itself is destroyed. mutable llvm::BumpPtrAllocator BumpAlloc; - /// \brief Allocator for partial diagnostics. + /// Allocator for partial diagnostics. PartialDiagnostic::StorageAllocator DiagAllocator; - /// \brief The current C++ ABI. + /// The current C++ ABI. std::unique_ptr<CXXABI> ABI; CXXABI *createCXXABI(const TargetInfo &T); - /// \brief The logical -> physical address space map. + /// The logical -> physical address space map. const LangASMap *AddrSpaceMap = nullptr; - /// \brief Address space map mangling must be used with language specific + /// Address space map mangling must be used with language specific /// address spaces (e.g. OpenCL/CUDA) bool AddrSpaceMapMangling; @@ -541,10 +543,10 @@ public: IntrusiveRefCntPtr<ExternalASTSource> ExternalSource; ASTMutationListener *Listener = nullptr; - /// \brief Contains parents of a node. + /// Contains parents of a node. using ParentVector = llvm::SmallVector<ast_type_traits::DynTypedNode, 2>; - /// \brief Maps from a node to its parents. This is used for nodes that have + /// Maps from a node to its parents. This is used for nodes that have /// pointer identity only, which are more common and we can save space by /// only storing a unique pointer to them. using ParentMapPointers = @@ -602,7 +604,7 @@ public: } }; - /// \brief Returns the parents of the given node. + /// Returns the parents of the given node. /// /// Note that this will lazily compute the parents of all nodes /// and store them for later retrieval. Thus, the first call is O(n) @@ -701,10 +703,10 @@ public: return FullSourceLoc(Loc,SourceMgr); } - /// \brief All comments in this translation unit. + /// All comments in this translation unit. RawCommentList Comments; - /// \brief True if comments are already loaded from ExternalASTSource. + /// True if comments are already loaded from ExternalASTSource. mutable bool CommentsLoaded = false; class RawCommentAndCacheFlags { @@ -761,18 +763,18 @@ public: const Decl *OriginalDecl; }; - /// \brief Mapping from declarations to comments attached to any + /// Mapping from declarations to comments attached to any /// redeclaration. /// /// Raw comments are owned by Comments list. This mapping is populated /// lazily. mutable llvm::DenseMap<const Decl *, RawCommentAndCacheFlags> RedeclComments; - /// \brief Mapping from declarations to parsed comments attached to any + /// Mapping from declarations to parsed comments attached to any /// redeclaration. mutable llvm::DenseMap<const Decl *, comments::FullComment *> ParsedComments; - /// \brief Return the documentation comment attached to a given declaration, + /// Return the documentation comment attached to a given declaration, /// without looking into cache. RawComment *getRawCommentForDeclNoCache(const Decl *D) const; @@ -784,10 +786,10 @@ public: void addComment(const RawComment &RC) { assert(LangOpts.RetainCommentsFromSystemHeaders || !SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin())); - Comments.addComment(RC, BumpAlloc); + Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc); } - /// \brief Return the documentation comment attached to a given declaration. + /// Return the documentation comment attached to a given declaration. /// Returns nullptr if no comment is attached. /// /// \param OriginalDecl if not nullptr, is set to declaration AST node that @@ -815,7 +817,7 @@ public: private: mutable comments::CommandTraits CommentCommandTraits; - /// \brief Iterator that visits import declarations. + /// Iterator that visits import declarations. class import_iterator { ImportDecl *Import = nullptr; @@ -857,13 +859,13 @@ public: return CommentCommandTraits; } - /// \brief Retrieve the attributes for the given declaration. + /// Retrieve the attributes for the given declaration. AttrVec& getDeclAttrs(const Decl *D); - /// \brief Erase the attributes corresponding to the given declaration. + /// Erase the attributes corresponding to the given declaration. void eraseDeclAttrs(const Decl *D); - /// \brief If this variable is an instantiated static data member of a + /// If this variable is an instantiated static data member of a /// class template specialization, returns the templated static data member /// from which it was instantiated. // FIXME: Remove ? @@ -878,7 +880,7 @@ public: void setClassScopeSpecializationPattern(FunctionDecl *FD, FunctionDecl *Pattern); - /// \brief Note that the static data member \p Inst is an instantiation of + /// Note that the static data member \p Inst is an instantiation of /// the static data member template \p Tmpl of a class template. void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, @@ -887,12 +889,12 @@ public: void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI); - /// \brief If the given using decl \p Inst is an instantiation of a + /// If the given using decl \p Inst is an instantiation of a /// (possibly unresolved) using decl from a template instantiation, /// return it. NamedDecl *getInstantiatedFromUsingDecl(NamedDecl *Inst); - /// \brief Remember that the using decl \p Inst is an instantiation + /// Remember that the using decl \p Inst is an instantiation /// of the using decl \p Pattern of a class template. void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern); @@ -919,12 +921,12 @@ public: overridden_method_range overridden_methods(const CXXMethodDecl *Method) const; - /// \brief Note that the given C++ \p Method overrides the given \p + /// Note that the given C++ \p Method overrides the given \p /// Overridden method. void addOverriddenMethod(const CXXMethodDecl *Method, const CXXMethodDecl *Overridden); - /// \brief Return C++ or ObjC overridden methods for the given \p Method. + /// Return C++ or ObjC overridden methods for the given \p Method. /// /// An ObjC method is considered to override any method in the class's /// base classes, its protocols, or its categories' protocols, that has @@ -935,7 +937,7 @@ public: const NamedDecl *Method, SmallVectorImpl<const NamedDecl *> &Overridden) const; - /// \brief Notify the AST context that a new import declaration has been + /// Notify the AST context that a new import declaration has been /// parsed or implicitly created within this translation unit. void addedLocalImportDecl(ImportDecl *Import); @@ -957,16 +959,16 @@ public: MergedDecls[D] = Primary; } - /// \brief Note that the definition \p ND has been merged into module \p M, + /// Note that the definition \p ND has been merged into module \p M, /// and should be visible whenever \p M is visible. void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners = true); - /// \brief Clean up the merged definition list. Call this if you might have + /// Clean up the merged definition list. Call this if you might have /// added duplicates into the list. void deduplicateMergedDefinitonsFor(NamedDecl *ND); - /// \brief Get the additional modules in which the definition \p Def has + /// Get the additional modules in which the definition \p Def has /// been merged. ArrayRef<Module*> getModulesWithMergedDefinition(const NamedDecl *Def) { auto MergedIt = MergedDefModules.find(Def); @@ -999,12 +1001,24 @@ public: CanQualType WCharTy; // [C++ 3.9.1p5]. CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99. CanQualType WIntTy; // [C99 7.24.1], integer type unchanged by default promotions. + CanQualType Char8Ty; // [C++20 proposal] CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99. CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99. CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty; CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; CanQualType UnsignedLongLongTy, UnsignedInt128Ty; CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty; + CanQualType ShortAccumTy, AccumTy, + LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension + CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy; + CanQualType ShortFractTy, FractTy, LongFractTy; + CanQualType UnsignedShortFractTy, UnsignedFractTy, UnsignedLongFractTy; + CanQualType SatShortAccumTy, SatAccumTy, SatLongAccumTy; + CanQualType SatUnsignedShortAccumTy, SatUnsignedAccumTy, + SatUnsignedLongAccumTy; + CanQualType SatShortFractTy, SatFractTy, SatLongFractTy; + CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy, + SatUnsignedLongFractTy; CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3 CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; @@ -1036,20 +1050,20 @@ public: ASTContext &operator=(const ASTContext &) = delete; ~ASTContext(); - /// \brief Attach an external AST source to the AST context. + /// Attach an external AST source to the AST context. /// /// The external AST source provides the ability to load parts of /// the abstract syntax tree as needed from some external storage, /// e.g., a precompiled header. void setExternalSource(IntrusiveRefCntPtr<ExternalASTSource> Source); - /// \brief Retrieve a pointer to the external AST source associated + /// Retrieve a pointer to the external AST source associated /// with this AST context, if any. ExternalASTSource *getExternalSource() const { return ExternalSource.get(); } - /// \brief Attach an AST mutation listener to the AST context. + /// Attach an AST mutation listener to the AST context. /// /// The AST mutation listener provides the ability to track modifications to /// the abstract syntax tree entities committed after they were initially @@ -1058,7 +1072,7 @@ public: this->Listener = Listener; } - /// \brief Retrieve a pointer to the AST mutation listener associated + /// Retrieve a pointer to the AST mutation listener associated /// with this AST context, if any. ASTMutationListener *getASTMutationListener() const { return Listener; } @@ -1068,18 +1082,18 @@ public: BuiltinTemplateDecl *buildBuiltinTemplateDecl(BuiltinTemplateKind BTK, const IdentifierInfo *II) const; - /// \brief Create a new implicit TU-level CXXRecordDecl or RecordDecl + /// Create a new implicit TU-level CXXRecordDecl or RecordDecl /// declaration. RecordDecl *buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK = TTK_Struct) const; - /// \brief Create a new implicit TU-level typedef declaration. + /// Create a new implicit TU-level typedef declaration. TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const; - /// \brief Retrieve the declaration for the 128-bit signed integer type. + /// Retrieve the declaration for the 128-bit signed integer type. TypedefDecl *getInt128Decl() const; - /// \brief Retrieve the declaration for the 128-bit unsigned integer type. + /// Retrieve the declaration for the 128-bit unsigned integer type. TypedefDecl *getUInt128Decl() const; //===--------------------------------------------------------------------===// @@ -1087,7 +1101,7 @@ public: //===--------------------------------------------------------------------===// private: - /// \brief Return a type with extended qualifiers. + /// Return a type with extended qualifiers. QualType getExtQualType(const Type *Base, Qualifiers Quals) const; QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const; @@ -1095,7 +1109,7 @@ private: QualType getPipeType(QualType T, bool ReadOnly) const; public: - /// \brief Return the uniqued reference to the type for an address space + /// Return the uniqued reference to the type for an address space /// qualified type with the specified type and address space. /// /// The resulting type has a union of the qualifiers from T and the address @@ -1103,29 +1117,29 @@ public: /// replaced. QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const; - /// \brief Remove any existing address space on the type and returns the type + /// Remove any existing address space on the type and returns the type /// with qualifiers intact (or that's the idea anyway) /// /// The return type should be T with all prior qualifiers minus the address /// space. QualType removeAddrSpaceQualType(QualType T) const; - /// \brief Apply Objective-C protocol qualifiers to the given type. + /// Apply Objective-C protocol qualifiers to the given type. /// \param allowOnPointerType specifies if we can apply protocol /// qualifiers on ObjCObjectPointerType. It can be set to true when - /// contructing the canonical type of a Objective-C type parameter. + /// constructing the canonical type of a Objective-C type parameter. QualType applyObjCProtocolQualifiers(QualType type, ArrayRef<ObjCProtocolDecl *> protocols, bool &hasError, bool allowOnPointerType = false) const; - /// \brief Return the uniqued reference to the type for an Objective-C + /// Return the uniqued reference to the type for an Objective-C /// gc-qualified type. /// - /// The retulting type has a union of the qualifiers from T and the gc + /// The resulting type has a union of the qualifiers from T and the gc /// attribute. QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const; - /// \brief Return the uniqued reference to the type for a \c restrict + /// Return the uniqued reference to the type for a \c restrict /// qualified type. /// /// The resulting type has a union of the qualifiers from \p T and @@ -1134,7 +1148,7 @@ public: return T.withFastQualifiers(Qualifiers::Restrict); } - /// \brief Return the uniqued reference to the type for a \c volatile + /// Return the uniqued reference to the type for a \c volatile /// qualified type. /// /// The resulting type has a union of the qualifiers from \p T and @@ -1143,7 +1157,7 @@ public: return T.withFastQualifiers(Qualifiers::Volatile); } - /// \brief Return the uniqued reference to the type for a \c const + /// Return the uniqued reference to the type for a \c const /// qualified type. /// /// The resulting type has a union of the qualifiers from \p T and \c const. @@ -1152,41 +1166,48 @@ public: /// calling T.withConst(). QualType getConstType(QualType T) const { return T.withConst(); } - /// \brief Change the ExtInfo on a function type. + /// Change the ExtInfo on a function type. const FunctionType *adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo); /// Adjust the given function result type. CanQualType getCanonicalFunctionResultType(QualType ResultType) const; - /// \brief Change the result type of a function type once it is deduced. + /// Change the result type of a function type once it is deduced. void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType); - /// \brief Determine whether two function types are the same, ignoring + /// Get a function type and produce the equivalent function type with the + /// specified exception specification. Type sugar that can be present on a + /// declaration of a function with an exception specification is permitted + /// and preserved. Other type sugar (for instance, typedefs) is not. + QualType getFunctionTypeWithExceptionSpec( + QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI); + + /// Determine whether two function types are the same, ignoring /// exception specifications in cases where they're part of the type. bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U); - /// \brief Change the exception specification on a function once it is + /// Change the exception specification on a function once it is /// delay-parsed, instantiated, or computed. void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten = false); - /// \brief Return the uniqued reference to the type for a complex + /// Return the uniqued reference to the type for a complex /// number with the specified element type. QualType getComplexType(QualType T) const; CanQualType getComplexType(CanQualType T) const { return CanQualType::CreateUnsafe(getComplexType((QualType) T)); } - /// \brief Return the uniqued reference to the type for a pointer to + /// Return the uniqued reference to the type for a pointer to /// the specified type. QualType getPointerType(QualType T) const; CanQualType getPointerType(CanQualType T) const { return CanQualType::CreateUnsafe(getPointerType((QualType) T)); } - /// \brief Return the uniqued reference to a type adjusted from the original + /// Return the uniqued reference to a type adjusted from the original /// type to a new type. QualType getAdjustedType(QualType Orig, QualType New) const; CanQualType getAdjustedType(CanQualType Orig, CanQualType New) const { @@ -1194,7 +1215,7 @@ public: getAdjustedType((QualType)Orig, (QualType)New)); } - /// \brief Return the uniqued reference to the decayed version of the given + /// Return the uniqued reference to the decayed version of the given /// type. Can only be called on array and function types which decay to /// pointer types. QualType getDecayedType(QualType T) const; @@ -1202,11 +1223,11 @@ public: return CanQualType::CreateUnsafe(getDecayedType((QualType) T)); } - /// \brief Return the uniqued reference to the atomic type for the specified + /// Return the uniqued reference to the atomic type for the specified /// type. QualType getAtomicType(QualType T) const; - /// \brief Return the uniqued reference to the type for a block of the + /// Return the uniqued reference to the type for a block of the /// specified type. QualType getBlockPointerType(QualType T) const; @@ -1214,10 +1235,10 @@ public: /// blocks. QualType getBlockDescriptorType() const; - /// \brief Return a read_only pipe type for the specified type. + /// Return a read_only pipe type for the specified type. QualType getReadPipeType(QualType T) const; - /// \brief Return a write_only pipe type for the specified type. + /// Return a write_only pipe type for the specified type. QualType getWritePipeType(QualType T) const; /// Gets the struct used to keep track of the extended descriptor for @@ -1241,36 +1262,36 @@ public: /// Returns true iff we need copy/dispose helpers for the given type. bool BlockRequiresCopying(QualType Ty, const VarDecl *D); - /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout is set - /// to false in this case. If HasByrefExtendedLayout returns true, byref variable - /// has extended lifetime. + /// Returns true, if given type has a known lifetime. HasByrefExtendedLayout + /// is set to false in this case. If HasByrefExtendedLayout returns true, + /// byref variable has extended lifetime. bool getByrefLifetime(QualType Ty, Qualifiers::ObjCLifetime &Lifetime, bool &HasByrefExtendedLayout) const; - /// \brief Return the uniqued reference to the type for an lvalue reference + /// Return the uniqued reference to the type for an lvalue reference /// to the specified type. QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true) const; - /// \brief Return the uniqued reference to the type for an rvalue reference + /// Return the uniqued reference to the type for an rvalue reference /// to the specified type. QualType getRValueReferenceType(QualType T) const; - /// \brief Return the uniqued reference to the type for a member pointer to + /// Return the uniqued reference to the type for a member pointer to /// the specified type in the specified class. /// /// The class \p Cls is a \c Type because it could be a dependent name. QualType getMemberPointerType(QualType T, const Type *Cls) const; - /// \brief Return a non-unique reference to the type for a variable array of + /// Return a non-unique reference to the type for a variable array of /// the specified element type. QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const; - /// \brief Return a non-unique reference to the type for a dependently-sized + /// Return a non-unique reference to the type for a dependently-sized /// array of the specified element type. /// /// FIXME: We will need these to be uniqued, or at least comparable, at some @@ -1280,29 +1301,34 @@ public: unsigned IndexTypeQuals, SourceRange Brackets) const; - /// \brief Return a unique reference to the type for an incomplete array of + /// Return a unique reference to the type for an incomplete array of /// the specified element type. QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const; - /// \brief Return the unique reference to the type for a constant array of + /// Return the unique reference to the type for a constant array of /// the specified element type. QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const; - /// \brief Returns a vla type where known sizes are replaced with [*]. + /// Returns a vla type where known sizes are replaced with [*]. QualType getVariableArrayDecayedType(QualType Ty) const; - /// \brief Return the unique reference to a vector type of the specified + /// Return the unique reference to a vector type of the specified /// element type and size. /// /// \pre \p VectorType must be a built-in type. QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const; + /// Return the unique reference to the type for a dependently sized vector of + /// the specified element type. + QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr, + SourceLocation AttrLoc, + VectorType::VectorKind VecKind) const; - /// \brief Return the unique reference to an extended vector type + /// Return the unique reference to an extended vector type /// of the specified element type and size. /// /// \pre \p VectorType must be a built-in type. @@ -1321,7 +1347,7 @@ public: Expr *AddrSpaceExpr, SourceLocation AttrLoc) const; - /// \brief Return a K&R style C function type like 'int()'. + /// Return a K&R style C function type like 'int()'. QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const; @@ -1329,20 +1355,22 @@ public: return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo()); } - /// \brief Return a normal function type with a typed argument list. + /// Return a normal function type with a typed argument list. QualType getFunctionType(QualType ResultTy, ArrayRef<QualType> Args, const FunctionProtoType::ExtProtoInfo &EPI) const { return getFunctionTypeInternal(ResultTy, Args, EPI, false); } + QualType adjustStringLiteralBaseType(QualType StrLTy) const; + private: - /// \brief Return a normal function type with a typed argument list. + /// Return a normal function type with a typed argument list. QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args, const FunctionProtoType::ExtProtoInfo &EPI, bool OnlyWantCanonical) const; public: - /// \brief Return the unique reference to the type for the specified type + /// Return the unique reference to the type for the specified type /// declaration. QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl = nullptr) const { @@ -1358,7 +1386,7 @@ public: return getTypeDeclTypeSlow(Decl); } - /// \brief Return the unique reference to the type for the specified + /// Return the unique reference to the type for the specified /// typedef-name decl. QualType getTypedefType(const TypedefNameDecl *Decl, QualType Canon = QualType()) const; @@ -1404,8 +1432,8 @@ public: QualType getParenType(QualType NamedType) const; QualType getElaboratedType(ElaboratedTypeKeyword Keyword, - NestedNameSpecifier *NNS, - QualType NamedType) const; + NestedNameSpecifier *NNS, QualType NamedType, + TagDecl *OwnedTagDecl = nullptr) const; QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, @@ -1455,105 +1483,105 @@ public: bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl); - /// \brief Return a ObjCObjectPointerType type for the given ObjCObjectType. + /// Return a ObjCObjectPointerType type for the given ObjCObjectType. QualType getObjCObjectPointerType(QualType OIT) const; - /// \brief GCC extension. + /// GCC extension. QualType getTypeOfExprType(Expr *e) const; QualType getTypeOfType(QualType t) const; - /// \brief C++11 decltype. + /// C++11 decltype. QualType getDecltypeType(Expr *e, QualType UnderlyingType) const; - /// \brief Unary type transforms + /// Unary type transforms QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const; - /// \brief C++11 deduced auto type. + /// C++11 deduced auto type. QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const; - /// \brief C++11 deduction pattern for 'auto' type. + /// C++11 deduction pattern for 'auto' type. QualType getAutoDeductType() const; - /// \brief C++11 deduction pattern for 'auto &&' type. + /// C++11 deduction pattern for 'auto &&' type. QualType getAutoRRefDeductType() const; - /// \brief C++17 deduced class template specialization type. + /// C++17 deduced class template specialization type. QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const; - /// \brief Return the unique reference to the type for the specified TagDecl + /// Return the unique reference to the type for the specified TagDecl /// (struct/union/class/enum) decl. QualType getTagDeclType(const TagDecl *Decl) const; - /// \brief Return the unique type for "size_t" (C99 7.17), defined in + /// Return the unique type for "size_t" (C99 7.17), defined in /// <stddef.h>. /// /// The sizeof operator requires this (C99 6.5.3.4p4). CanQualType getSizeType() const; - /// \brief Return the unique signed counterpart of + /// Return the unique signed counterpart of /// the integer type corresponding to size_t. CanQualType getSignedSizeType() const; - /// \brief Return the unique type for "intmax_t" (C99 7.18.1.5), defined in + /// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in /// <stdint.h>. CanQualType getIntMaxType() const; - /// \brief Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in + /// Return the unique type for "uintmax_t" (C99 7.18.1.5), defined in /// <stdint.h>. CanQualType getUIntMaxType() const; - /// \brief Return the unique wchar_t type available in C++ (and available as + /// Return the unique wchar_t type available in C++ (and available as /// __wchar_t as a Microsoft extension). QualType getWCharType() const { return WCharTy; } - /// \brief Return the type of wide characters. In C++, this returns the + /// Return the type of wide characters. In C++, this returns the /// unique wchar_t type. In C99, this returns a type compatible with the type /// defined in <stddef.h> as defined by the target. QualType getWideCharType() const { return WideCharTy; } - /// \brief Return the type of "signed wchar_t". + /// Return the type of "signed wchar_t". /// /// Used when in C++, as a GCC extension. QualType getSignedWCharType() const; - /// \brief Return the type of "unsigned wchar_t". + /// Return the type of "unsigned wchar_t". /// /// Used when in C++, as a GCC extension. QualType getUnsignedWCharType() const; - /// \brief In C99, this returns a type compatible with the type + /// In C99, this returns a type compatible with the type /// defined in <stddef.h> as defined by the target. QualType getWIntType() const { return WIntTy; } - /// \brief Return a type compatible with "intptr_t" (C99 7.18.1.4), + /// Return a type compatible with "intptr_t" (C99 7.18.1.4), /// as defined by the target. QualType getIntPtrType() const; - /// \brief Return a type compatible with "uintptr_t" (C99 7.18.1.4), + /// Return a type compatible with "uintptr_t" (C99 7.18.1.4), /// as defined by the target. QualType getUIntPtrType() const; - /// \brief Return the unique type for "ptrdiff_t" (C99 7.17) defined in + /// Return the unique type for "ptrdiff_t" (C99 7.17) defined in /// <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9). QualType getPointerDiffType() const; - /// \brief Return the unique unsigned counterpart of "ptrdiff_t" + /// Return the unique unsigned counterpart of "ptrdiff_t" /// integer type. The standard (C11 7.21.6.1p7) refers to this type /// in the definition of %tu format specifier. QualType getUnsignedPointerDiffType() const; - /// \brief Return the unique type for "pid_t" defined in + /// Return the unique type for "pid_t" defined in /// <sys/types.h>. We need this to compute the correct type for vfork(). QualType getProcessIDType() const; - /// \brief Return the C structure type used to represent constant CFStrings. + /// Return the C structure type used to represent constant CFStrings. QualType getCFConstantStringType() const; - /// \brief Returns the C struct type for objc_super + /// Returns the C struct type for objc_super QualType getObjCSuperType() const; void setObjCSuperType(QualType ST) { ObjCSuperType = ST; } @@ -1582,7 +1610,7 @@ public: ObjCNSStringType = T; } - /// \brief Retrieve the type that \c id has been defined to, which may be + /// Retrieve the type that \c id has been defined to, which may be /// different from the built-in \c id if \c id has been typedef'd. QualType getObjCIdRedefinitionType() const { if (ObjCIdRedefinitionType.isNull()) @@ -1590,12 +1618,12 @@ public: return ObjCIdRedefinitionType; } - /// \brief Set the user-written type that redefines \c id. + /// Set the user-written type that redefines \c id. void setObjCIdRedefinitionType(QualType RedefType) { ObjCIdRedefinitionType = RedefType; } - /// \brief Retrieve the type that \c Class has been defined to, which may be + /// Retrieve the type that \c Class has been defined to, which may be /// different from the built-in \c Class if \c Class has been typedef'd. QualType getObjCClassRedefinitionType() const { if (ObjCClassRedefinitionType.isNull()) @@ -1603,12 +1631,12 @@ public: return ObjCClassRedefinitionType; } - /// \brief Set the user-written type that redefines 'SEL'. + /// Set the user-written type that redefines 'SEL'. void setObjCClassRedefinitionType(QualType RedefType) { ObjCClassRedefinitionType = RedefType; } - /// \brief Retrieve the type that 'SEL' has been defined to, which may be + /// Retrieve the type that 'SEL' has been defined to, which may be /// different from the built-in 'SEL' if 'SEL' has been typedef'd. QualType getObjCSelRedefinitionType() const { if (ObjCSelRedefinitionType.isNull()) @@ -1616,7 +1644,7 @@ public: return ObjCSelRedefinitionType; } - /// \brief Set the user-written type that redefines 'SEL'. + /// Set the user-written type that redefines 'SEL'. void setObjCSelRedefinitionType(QualType RedefType) { ObjCSelRedefinitionType = RedefType; } @@ -1676,68 +1704,68 @@ public: return TypePackElementName; } - /// \brief Retrieve the Objective-C "instancetype" type, if already known; + /// Retrieve the Objective-C "instancetype" type, if already known; /// otherwise, returns a NULL type; QualType getObjCInstanceType() { return getTypeDeclType(getObjCInstanceTypeDecl()); } - /// \brief Retrieve the typedef declaration corresponding to the Objective-C + /// Retrieve the typedef declaration corresponding to the Objective-C /// "instancetype" type. TypedefDecl *getObjCInstanceTypeDecl(); - /// \brief Set the type for the C FILE type. + /// Set the type for the C FILE type. void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; } - /// \brief Retrieve the C FILE type. + /// Retrieve the C FILE type. QualType getFILEType() const { if (FILEDecl) return getTypeDeclType(FILEDecl); return QualType(); } - /// \brief Set the type for the C jmp_buf type. + /// Set the type for the C jmp_buf type. void setjmp_bufDecl(TypeDecl *jmp_bufDecl) { this->jmp_bufDecl = jmp_bufDecl; } - /// \brief Retrieve the C jmp_buf type. + /// Retrieve the C jmp_buf type. QualType getjmp_bufType() const { if (jmp_bufDecl) return getTypeDeclType(jmp_bufDecl); return QualType(); } - /// \brief Set the type for the C sigjmp_buf type. + /// Set the type for the C sigjmp_buf type. void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) { this->sigjmp_bufDecl = sigjmp_bufDecl; } - /// \brief Retrieve the C sigjmp_buf type. + /// Retrieve the C sigjmp_buf type. QualType getsigjmp_bufType() const { if (sigjmp_bufDecl) return getTypeDeclType(sigjmp_bufDecl); return QualType(); } - /// \brief Set the type for the C ucontext_t type. + /// Set the type for the C ucontext_t type. void setucontext_tDecl(TypeDecl *ucontext_tDecl) { this->ucontext_tDecl = ucontext_tDecl; } - /// \brief Retrieve the C ucontext_t type. + /// Retrieve the C ucontext_t type. QualType getucontext_tType() const { if (ucontext_tDecl) return getTypeDeclType(ucontext_tDecl); return QualType(); } - /// \brief The result type of logical operations, '<', '>', '!=', etc. + /// The result type of logical operations, '<', '>', '!=', etc. QualType getLogicalOperationType() const { return getLangOpts().CPlusPlus ? BoolTy : IntTy; } - /// \brief Emit the Objective-CC type encoding for the given type \p T into + /// Emit the Objective-CC type encoding for the given type \p T into /// \p S. /// /// If \p Field is specified then record field names are also encoded. @@ -1745,17 +1773,17 @@ public: const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const; - /// \brief Emit the Objective-C property type encoding for the given + /// Emit the Objective-C property type encoding for the given /// type \p T into \p S. void getObjCEncodingForPropertyType(QualType T, std::string &S) const; void getLegacyIntegralTypeEncoding(QualType &t) const; - /// \brief Put the string version of the type qualifiers \p QT into \p S. + /// Put the string version of the type qualifiers \p QT into \p S. void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, std::string &S) const; - /// \brief Emit the encoded type for the function \p Decl into \p S. + /// Emit the encoded type for the function \p Decl into \p S. /// /// This is in the same format as Objective-C method encodings. /// @@ -1763,12 +1791,12 @@ public: /// types is incomplete), false otherwise. std::string getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const; - /// \brief Emit the encoded type for the method declaration \p Decl into + /// Emit the encoded type for the method declaration \p Decl into /// \p S. std::string getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, bool Extended = false) const; - /// \brief Return the encoded type for this block declaration. + /// Return the encoded type for this block declaration. std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const; /// getObjCEncodingForPropertyDecl - Return the encoded type for @@ -1785,15 +1813,15 @@ public: const ObjCPropertyDecl *PD, const Decl *Container) const; - /// \brief Return the size of type \p T for Objective-C encoding purpose, + /// Return the size of type \p T for Objective-C encoding purpose, /// in characters. CharUnits getObjCEncodingTypeSize(QualType T) const; - /// \brief Retrieve the typedef corresponding to the predefined \c id type + /// Retrieve the typedef corresponding to the predefined \c id type /// in Objective-C. TypedefDecl *getObjCIdDecl() const; - /// \brief Represents the Objective-CC \c id type. + /// Represents the Objective-CC \c id type. /// /// This is set up lazily, by Sema. \c id is always a (typedef for a) /// pointer type, a pointer to a struct. @@ -1801,21 +1829,21 @@ public: return getTypeDeclType(getObjCIdDecl()); } - /// \brief Retrieve the typedef corresponding to the predefined 'SEL' type + /// Retrieve the typedef corresponding to the predefined 'SEL' type /// in Objective-C. TypedefDecl *getObjCSelDecl() const; - /// \brief Retrieve the type that corresponds to the predefined Objective-C + /// Retrieve the type that corresponds to the predefined Objective-C /// 'SEL' type. QualType getObjCSelType() const { return getTypeDeclType(getObjCSelDecl()); } - /// \brief Retrieve the typedef declaration corresponding to the predefined + /// Retrieve the typedef declaration corresponding to the predefined /// Objective-C 'Class' type. TypedefDecl *getObjCClassDecl() const; - /// \brief Represents the Objective-C \c Class type. + /// Represents the Objective-C \c Class type. /// /// This is set up lazily, by Sema. \c Class is always a (typedef for a) /// pointer type, a pointer to a struct. @@ -1823,40 +1851,40 @@ public: return getTypeDeclType(getObjCClassDecl()); } - /// \brief Retrieve the Objective-C class declaration corresponding to + /// Retrieve the Objective-C class declaration corresponding to /// the predefined \c Protocol class. ObjCInterfaceDecl *getObjCProtocolDecl() const; - /// \brief Retrieve declaration of 'BOOL' typedef + /// Retrieve declaration of 'BOOL' typedef TypedefDecl *getBOOLDecl() const { return BOOLDecl; } - /// \brief Save declaration of 'BOOL' typedef + /// Save declaration of 'BOOL' typedef void setBOOLDecl(TypedefDecl *TD) { BOOLDecl = TD; } - /// \brief type of 'BOOL' type. + /// type of 'BOOL' type. QualType getBOOLType() const { return getTypeDeclType(getBOOLDecl()); } - /// \brief Retrieve the type of the Objective-C \c Protocol class. + /// Retrieve the type of the Objective-C \c Protocol class. QualType getObjCProtoType() const { return getObjCInterfaceType(getObjCProtocolDecl()); } - /// \brief Retrieve the C type declaration corresponding to the predefined + /// Retrieve the C type declaration corresponding to the predefined /// \c __builtin_va_list type. TypedefDecl *getBuiltinVaListDecl() const; - /// \brief Retrieve the type of the \c __builtin_va_list type. + /// Retrieve the type of the \c __builtin_va_list type. QualType getBuiltinVaListType() const { return getTypeDeclType(getBuiltinVaListDecl()); } - /// \brief Retrieve the C type declaration corresponding to the predefined + /// Retrieve the C type declaration corresponding to the predefined /// \c __va_list_tag type used to help define the \c __builtin_va_list type /// for some targets. Decl *getVaListTagDecl() const; @@ -1870,18 +1898,22 @@ public: return getTypeDeclType(getBuiltinMSVaListDecl()); } - /// \brief Return a type with additional \c const, \c volatile, or + /// Return whether a declaration to a builtin is allowed to be + /// overloaded/redeclared. + bool canBuiltinBeRedeclared(const FunctionDecl *) const; + + /// Return a type with additional \c const, \c volatile, or /// \c restrict qualifiers. QualType getCVRQualifiedType(QualType T, unsigned CVR) const { return getQualifiedType(T, Qualifiers::fromCVRMask(CVR)); } - /// \brief Un-split a SplitQualType. + /// Un-split a SplitQualType. QualType getQualifiedType(SplitQualType split) const { return getQualifiedType(split.Ty, split.Quals); } - /// \brief Return a type with additional qualifiers. + /// Return a type with additional qualifiers. QualType getQualifiedType(QualType T, Qualifiers Qs) const { if (!Qs.hasNonFastQualifiers()) return T.withFastQualifiers(Qs.getFastQualifiers()); @@ -1890,14 +1922,14 @@ public: return getExtQualType(Ptr, Qc); } - /// \brief Return a type with additional qualifiers. + /// Return a type with additional qualifiers. QualType getQualifiedType(const Type *T, Qualifiers Qs) const { if (!Qs.hasNonFastQualifiers()) return QualType(T, Qs.getFastQualifiers()); return getExtQualType(T, Qs); } - /// \brief Return a type with the given lifetime qualifier. + /// Return a type with the given lifetime qualifier. /// /// \pre Neither type.ObjCLifetime() nor \p lifetime may be \c OCL_None. QualType getLifetimeQualifiedType(QualType type, @@ -1921,6 +1953,9 @@ public: return getQualifiedType(type.getUnqualifiedType(), Qs); } + unsigned char getFixedPointScale(QualType Ty) const; + unsigned char getFixedPointIBits(QualType Ty) const; + DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const; @@ -1954,7 +1989,7 @@ public: GE_Missing_ucontext }; - /// \brief Return the type for the specified builtin. + /// Return the type for the specified builtin. /// /// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of /// arguments to the builtin that are required to be integer constant @@ -1962,6 +1997,10 @@ public: QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs = nullptr) const; + /// Types and expressions required to build C++2a three-way comparisons + /// using operator<=>, including the values return by builtin <=> operators. + ComparisonCategories CompCategories; + private: CanQualType getFromTargetType(unsigned Type) const; TypeInfo getTypeInfoImpl(const Type *T) const; @@ -1971,18 +2010,18 @@ private: //===--------------------------------------------------------------------===// public: - /// \brief Return one of the GCNone, Weak or Strong Objective-C garbage + /// Return one of the GCNone, Weak or Strong Objective-C garbage /// collection attributes. Qualifiers::GC getObjCGCAttrKind(QualType Ty) const; - /// \brief Return true if the given vector types are of the same unqualified + /// Return true if the given vector types are of the same unqualified /// type or if they are equivalent to the same GCC vector type. /// /// \note This ignores whether they are target-specific (AltiVec or Neon) /// types. bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec); - /// \brief Return true if this is an \c NSObject object with its \c NSObject + /// Return true if this is an \c NSObject object with its \c NSObject /// attribute set. static bool isObjCNSObjectType(QualType Ty) { return Ty->isObjCNSObjectType(); @@ -1992,48 +2031,48 @@ public: // Type Sizing and Analysis //===--------------------------------------------------------------------===// - /// \brief Return the APFloat 'semantics' for the specified scalar floating + /// Return the APFloat 'semantics' for the specified scalar floating /// point type. const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const; - /// \brief Get the size and alignment of the specified complete type in bits. + /// Get the size and alignment of the specified complete type in bits. TypeInfo getTypeInfo(const Type *T) const; TypeInfo getTypeInfo(QualType T) const { return getTypeInfo(T.getTypePtr()); } - /// \brief Get default simd alignment of the specified complete type in bits. + /// Get default simd alignment of the specified complete type in bits. unsigned getOpenMPDefaultSimdAlign(QualType T) const; - /// \brief Return the size of the specified (complete) type \p T, in bits. + /// Return the size of the specified (complete) type \p T, in bits. uint64_t getTypeSize(QualType T) const { return getTypeInfo(T).Width; } uint64_t getTypeSize(const Type *T) const { return getTypeInfo(T).Width; } - /// \brief Return the size of the character type, in bits. + /// Return the size of the character type, in bits. uint64_t getCharWidth() const { return getTypeSize(CharTy); } - /// \brief Convert a size in bits to a size in characters. + /// Convert a size in bits to a size in characters. CharUnits toCharUnitsFromBits(int64_t BitSize) const; - /// \brief Convert a size in characters to a size in bits. + /// Convert a size in characters to a size in bits. int64_t toBits(CharUnits CharSize) const; - /// \brief Return the size of the specified (complete) type \p T, in + /// Return the size of the specified (complete) type \p T, in /// characters. CharUnits getTypeSizeInChars(QualType T) const; CharUnits getTypeSizeInChars(const Type *T) const; - /// \brief Return the ABI-specified alignment of a (complete) type \p T, in + /// Return the ABI-specified alignment of a (complete) type \p T, in /// bits. unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; } unsigned getTypeAlign(const Type *T) const { return getTypeInfo(T).Align; } - /// \brief Return the ABI-specified alignment of a type, in bits, or 0 if + /// Return the ABI-specified alignment of a type, in bits, or 0 if /// the type is incomplete and we cannot determine the alignment (for /// example, from alignment attributes). unsigned getTypeAlignIfKnown(QualType T) const; - /// \brief Return the ABI-specified alignment of a (complete) type \p T, in + /// Return the ABI-specified alignment of a (complete) type \p T, in /// characters. CharUnits getTypeAlignInChars(QualType T) const; CharUnits getTypeAlignInChars(const Type *T) const; @@ -2045,31 +2084,31 @@ public: std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const; std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const; - /// \brief Determine if the alignment the type has was required using an + /// Determine if the alignment the type has was required using an /// alignment attribute. bool isAlignmentRequired(const Type *T) const; bool isAlignmentRequired(QualType T) const; - /// \brief Return the "preferred" alignment of the specified type \p T for + /// Return the "preferred" alignment of the specified type \p T for /// the current target, in bits. /// /// This can be different than the ABI alignment in cases where it is /// beneficial for performance to overalign a data type. unsigned getPreferredTypeAlign(const Type *T) const; - /// \brief Return the default alignment for __attribute__((aligned)) on + /// Return the default alignment for __attribute__((aligned)) on /// this target, to be used if no alignment value is specified. unsigned getTargetDefaultAlignForAttributeAligned() const; - /// \brief Return the alignment in bits that should be given to a + /// Return the alignment in bits that should be given to a /// global variable with type \p T. unsigned getAlignOfGlobalVar(QualType T) const; - /// \brief Return the alignment in characters that should be given to a + /// Return the alignment in characters that should be given to a /// global variable with type \p T. CharUnits getAlignOfGlobalVarInChars(QualType T) const; - /// \brief Return a conservative estimate of the alignment of the specified + /// Return a conservative estimate of the alignment of the specified /// decl \p D. /// /// \pre \p D must not be a bitfield type, as bitfields do not have a valid @@ -2081,12 +2120,12 @@ public: /// pointers and large arrays get extra alignment. CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const; - /// \brief Get or compute information about the layout of the specified + /// Get or compute information about the layout of the specified /// record (struct/union/class) \p D, which indicates its size and field /// position information. const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const; - /// \brief Get or compute information about the layout of the specified + /// Get or compute information about the layout of the specified /// Objective-C interface. const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const; @@ -2094,14 +2133,14 @@ public: void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS, bool Simple = false) const; - /// \brief Get or compute information about the layout of the specified + /// Get or compute information about the layout of the specified /// Objective-C implementation. /// /// This may differ from the interface if synthesized ivars are present. const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const; - /// \brief Get our current best idea for the key function of the + /// Get our current best idea for the key function of the /// given record decl, or nullptr if there isn't one. /// /// The key function is, according to the Itanium C++ ABI section 5.2.3: @@ -2113,7 +2152,7 @@ public: /// the result of this computation can change. const CXXMethodDecl *getCurrentKeyFunction(const CXXRecordDecl *RD); - /// \brief Observe that the given method cannot be a key function. + /// Observe that the given method cannot be a key function. /// Checks the key-function cache for the method's class and clears it /// if matches the given declaration. /// @@ -2155,7 +2194,7 @@ public: void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols); - /// \brief Return true if the specified type has unique object representations + /// Return true if the specified type has unique object representations /// according to (C++17 [meta.unary.prop]p9) bool hasUniqueObjectRepresentations(QualType Ty) const; @@ -2163,7 +2202,7 @@ public: // Type Operators //===--------------------------------------------------------------------===// - /// \brief Return the canonical (structural) type corresponding to the + /// Return the canonical (structural) type corresponding to the /// specified potentially non-canonical type \p T. /// /// The non-canonical version of a type may have many "decorated" versions of @@ -2179,14 +2218,14 @@ public: return T->getCanonicalTypeInternal().getTypePtr(); } - /// \brief Return the canonical parameter type corresponding to the specific + /// Return the canonical parameter type corresponding to the specific /// potentially non-canonical one. /// /// Qualifiers are stripped off, functions are turned into function /// pointers, and arrays decay one level into pointers. CanQualType getCanonicalParamType(QualType T) const; - /// \brief Determine whether the given types \p T1 and \p T2 are equivalent. + /// Determine whether the given types \p T1 and \p T2 are equivalent. bool hasSameType(QualType T1, QualType T2) const { return getCanonicalType(T1) == getCanonicalType(T2); } @@ -2194,7 +2233,7 @@ public: return getCanonicalType(T1) == getCanonicalType(T2); } - /// \brief Return this type as a completely-unqualified array type, + /// Return this type as a completely-unqualified array type, /// capturing the qualifiers in \p Quals. /// /// This will remove the minimal amount of sugaring from the types, similar @@ -2209,7 +2248,7 @@ public: /// that corresponds to it. Otherwise, returns T.getUnqualifiedType(). QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals); - /// \brief Determine whether the given types are equivalent after + /// Determine whether the given types are equivalent after /// cvr-qualifiers have been removed. bool hasSameUnqualifiedType(QualType T1, QualType T2) const { return getCanonicalType(T1).getTypePtr() == @@ -2249,9 +2288,22 @@ public: bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp); - bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2); + bool UnwrapSimilarTypes(QualType &T1, QualType &T2); + bool UnwrapSimilarArrayTypes(QualType &T1, QualType &T2); + + /// Determine if two types are similar, according to the C++ rules. That is, + /// determine if they are the same other than qualifiers on the initial + /// sequence of pointer / pointer-to-member / array (and in Clang, object + /// pointer) types and their element types. + /// + /// Clang offers a number of qualifiers in addition to the C++ qualifiers; + /// those qualifiers are also ignored in the 'similarity' check. + bool hasSimilarType(QualType T1, QualType T2); + + /// Determine if two types are similar, ignoring only CVR qualifiers. + bool hasCvrSimilarType(QualType T1, QualType T2); - /// \brief Retrieves the "canonical" nested name specifier for a + /// Retrieves the "canonical" nested name specifier for a /// given nested name specifier. /// /// The canonical nested name specifier is a nested name specifier @@ -2277,11 +2329,11 @@ public: NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const; - /// \brief Retrieves the default calling convention for the current target. + /// Retrieves the default calling convention for the current target. CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const; - /// \brief Retrieves the "canonical" template name that refers to a + /// Retrieves the "canonical" template name that refers to a /// given template. /// /// The canonical template name is the simplest expression that can @@ -2301,11 +2353,11 @@ public: /// types, values, and templates. TemplateName getCanonicalTemplateName(TemplateName Name) const; - /// \brief Determine whether the given template names refer to the same + /// Determine whether the given template names refer to the same /// template. bool hasSameTemplateName(TemplateName X, TemplateName Y); - /// \brief Retrieve the "canonical" template argument. + /// Retrieve the "canonical" template argument. /// /// The canonical template argument is the simplest template argument /// (which may be a type, value, expression, or declaration) that @@ -2332,33 +2384,33 @@ public: return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T)); } - /// \brief Return the innermost element type of an array type. + /// Return the innermost element type of an array type. /// /// For example, will return "int" for int[m][n] QualType getBaseElementType(const ArrayType *VAT) const; - /// \brief Return the innermost element type of a type (which needn't + /// Return the innermost element type of a type (which needn't /// actually be an array type). QualType getBaseElementType(QualType QT) const; - /// \brief Return number of constant array elements. + /// Return number of constant array elements. uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const; - /// \brief Perform adjustment on the parameter type of a function. + /// Perform adjustment on the parameter type of a function. /// /// This routine adjusts the given parameter type @p T to the actual /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8], /// C++ [dcl.fct]p3). The adjusted parameter type is returned. QualType getAdjustedParameterType(QualType T) const; - /// \brief Retrieve the parameter type as adjusted for use in the signature + /// Retrieve the parameter type as adjusted for use in the signature /// of a function, decaying array and function types and removing top-level /// cv-qualifiers. QualType getSignatureParameterType(QualType T) const; QualType getExceptionObjectType(QualType T) const; - /// \brief Return the properly qualified result of decaying the specified + /// Return the properly qualified result of decaying the specified /// array type to a pointer. /// /// This operation is non-trivial when handling typedefs etc. The canonical @@ -2368,35 +2420,35 @@ public: /// See C99 6.7.5.3p7 and C99 6.3.2.1p3. QualType getArrayDecayedType(QualType T) const; - /// \brief Return the type that \p PromotableType will promote to: C99 + /// Return the type that \p PromotableType will promote to: C99 /// 6.3.1.1p2, assuming that \p PromotableType is a promotable integer type. QualType getPromotedIntegerType(QualType PromotableType) const; - /// \brief Recurses in pointer/array types until it finds an Objective-C + /// Recurses in pointer/array types until it finds an Objective-C /// retainable type and returns its ownership. Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const; - /// \brief Whether this is a promotable bitfield reference according + /// Whether this is a promotable bitfield reference according /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions). /// /// \returns the type this bit-field will promote to, or NULL if no /// promotion occurs. QualType isPromotableBitField(Expr *E) const; - /// \brief Return the highest ranked integer type, see C99 6.3.1.8p1. + /// Return the highest ranked integer type, see C99 6.3.1.8p1. /// /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If /// \p LHS < \p RHS, return -1. int getIntegerTypeOrder(QualType LHS, QualType RHS) const; - /// \brief Compare the rank of the two specified floating point types, + /// Compare the rank of the two specified floating point types, /// ignoring the domain of the type (i.e. 'double' == '_Complex double'). /// /// If \p LHS > \p RHS, returns 1. If \p LHS == \p RHS, returns 0. If /// \p LHS < \p RHS, return -1. int getFloatingTypeOrder(QualType LHS, QualType RHS) const; - /// \brief Return a real floating point or a complex type (based on + /// Return a real floating point or a complex type (based on /// \p typeDomain/\p typeSize). /// /// \param typeDomain a real floating point or complex type. @@ -2521,13 +2573,20 @@ public: // Per C99 6.2.5p6, for every signed integer type, there is a corresponding // unsigned integer type. This method takes a signed type, and returns the // corresponding unsigned integer type. + // With the introduction of fixed point types in ISO N1169, this method also + // accepts fixed point types and returns the corresponding unsigned type for + // a given fixed point type. QualType getCorrespondingUnsignedType(QualType T) const; + // Per ISO N1169, this method accepts fixed point types and returns the + // corresponding saturated type for a given fixed point type. + QualType getCorrespondingSaturatedType(QualType Ty) const; + //===--------------------------------------------------------------------===// // Integer Values //===--------------------------------------------------------------------===// - /// \brief Make an APSInt of the appropriate width and signedness for the + /// Make an APSInt of the appropriate width and signedness for the /// given \p Value and integer \p Type. llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const { // If Type is a signed integer type larger than 64 bits, we need to be sure @@ -2542,28 +2601,28 @@ public: bool isSentinelNullExpr(const Expr *E); - /// \brief Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if + /// Get the implementation of the ObjCInterfaceDecl \p D, or nullptr if /// none exists. ObjCImplementationDecl *getObjCImplementation(ObjCInterfaceDecl *D); - /// \brief Get the implementation of the ObjCCategoryDecl \p D, or nullptr if + /// Get the implementation of the ObjCCategoryDecl \p D, or nullptr if /// none exists. ObjCCategoryImplDecl *getObjCImplementation(ObjCCategoryDecl *D); - /// \brief Return true if there is at least one \@implementation in the TU. + /// Return true if there is at least one \@implementation in the TU. bool AnyObjCImplementation() { return !ObjCImpls.empty(); } - /// \brief Set the implementation of ObjCInterfaceDecl. + /// Set the implementation of ObjCInterfaceDecl. void setObjCImplementation(ObjCInterfaceDecl *IFaceD, ObjCImplementationDecl *ImplD); - /// \brief Set the implementation of ObjCCategoryDecl. + /// Set the implementation of ObjCCategoryDecl. void setObjCImplementation(ObjCCategoryDecl *CatD, ObjCCategoryImplDecl *ImplD); - /// \brief Get the duplicate declaration of a ObjCMethod in the same + /// Get the duplicate declaration of a ObjCMethod in the same /// interface, or null if none exists. const ObjCMethodDecl * getObjCMethodRedeclaration(const ObjCMethodDecl *MD) const; @@ -2571,19 +2630,19 @@ public: void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, const ObjCMethodDecl *Redecl); - /// \brief Returns the Objective-C interface that \p ND belongs to if it is + /// Returns the Objective-C interface that \p ND belongs to if it is /// an Objective-C method/property/ivar etc. that is part of an interface, /// otherwise returns null. const ObjCInterfaceDecl *getObjContainingInterface(const NamedDecl *ND) const; - /// \brief Set the copy inialization expression of a block var decl. + /// Set the copy inialization expression of a block var decl. void setBlockVarCopyInits(VarDecl*VD, Expr* Init); - /// \brief Get the copy initialization expression of the VarDecl \p VD, or + /// Get the copy initialization expression of the VarDecl \p VD, or /// nullptr if none exists. Expr *getBlockVarCopyInits(const VarDecl* VD); - /// \brief Allocate an uninitialized TypeSourceInfo. + /// Allocate an uninitialized TypeSourceInfo. /// /// The caller should initialize the memory held by TypeSourceInfo using /// the TypeLoc wrappers. @@ -2596,14 +2655,14 @@ public: /// should be calculated based on the type. TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const; - /// \brief Allocate a TypeSourceInfo where all locations have been + /// Allocate a TypeSourceInfo where all locations have been /// initialized to a given location, which defaults to the empty /// location. TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc = SourceLocation()) const; - /// \brief Add a deallocation callback that will be invoked when the + /// Add a deallocation callback that will be invoked when the /// ASTContext is destroyed. /// /// \param Callback A callback function that will be invoked on destruction. @@ -2625,7 +2684,7 @@ public: GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const; GVALinkage GetGVALinkageForVariable(const VarDecl *VD); - /// \brief Determines if the decl can be CodeGen'ed or deserialized from PCH + /// Determines if the decl can be CodeGen'ed or deserialized from PCH /// lazily, only when used; this is only relevant for function or file scoped /// var definitions. /// @@ -2633,6 +2692,12 @@ public: /// it is not used. bool DeclMustBeEmitted(const Decl *D); + /// Visits all versions of a multiversioned function with the passed + /// predicate. + void forEachMultiversionedFunctionVersion( + const FunctionDecl *FD, + llvm::function_ref<void(const FunctionDecl *)> Pred) const; + const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD); @@ -2653,21 +2718,21 @@ public: void setStaticLocalNumber(const VarDecl *VD, unsigned Number); unsigned getStaticLocalNumber(const VarDecl *VD) const; - /// \brief Retrieve the context for computing mangling numbers in the given + /// Retrieve the context for computing mangling numbers in the given /// DeclContext. MangleNumberingContext &getManglingNumberContext(const DeclContext *DC); std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const; - /// \brief Used by ParmVarDecl to store on the side the + /// Used by ParmVarDecl to store on the side the /// index of the parameter when it exceeds the size of the normal bitfield. void setParameterIndex(const ParmVarDecl *D, unsigned index); - /// \brief Used by ParmVarDecl to retrieve on the side the + /// Used by ParmVarDecl to retrieve on the side the /// index of the parameter when it exceeds the size of the normal bitfield. unsigned getParameterIndex(const ParmVarDecl *D) const; - /// \brief Get the storage for the constant value of a materialized temporary + /// Get the storage for the constant value of a materialized temporary /// of static storage duration. APValue *getMaterializedTemporaryValue(const MaterializeTemporaryExpr *E, bool MayCreate); @@ -2676,50 +2741,50 @@ public: // Statistics //===--------------------------------------------------------------------===// - /// \brief The number of implicitly-declared default constructors. + /// The number of implicitly-declared default constructors. static unsigned NumImplicitDefaultConstructors; - /// \brief The number of implicitly-declared default constructors for + /// The number of implicitly-declared default constructors for /// which declarations were built. static unsigned NumImplicitDefaultConstructorsDeclared; - /// \brief The number of implicitly-declared copy constructors. + /// The number of implicitly-declared copy constructors. static unsigned NumImplicitCopyConstructors; - /// \brief The number of implicitly-declared copy constructors for + /// The number of implicitly-declared copy constructors for /// which declarations were built. static unsigned NumImplicitCopyConstructorsDeclared; - /// \brief The number of implicitly-declared move constructors. + /// The number of implicitly-declared move constructors. static unsigned NumImplicitMoveConstructors; - /// \brief The number of implicitly-declared move constructors for + /// The number of implicitly-declared move constructors for /// which declarations were built. static unsigned NumImplicitMoveConstructorsDeclared; - /// \brief The number of implicitly-declared copy assignment operators. + /// The number of implicitly-declared copy assignment operators. static unsigned NumImplicitCopyAssignmentOperators; - /// \brief The number of implicitly-declared copy assignment operators for + /// The number of implicitly-declared copy assignment operators for /// which declarations were built. static unsigned NumImplicitCopyAssignmentOperatorsDeclared; - /// \brief The number of implicitly-declared move assignment operators. + /// The number of implicitly-declared move assignment operators. static unsigned NumImplicitMoveAssignmentOperators; - /// \brief The number of implicitly-declared move assignment operators for + /// The number of implicitly-declared move assignment operators for /// which declarations were built. static unsigned NumImplicitMoveAssignmentOperatorsDeclared; - /// \brief The number of implicitly-declared destructors. + /// The number of implicitly-declared destructors. static unsigned NumImplicitDestructors; - /// \brief The number of implicitly-declared destructors for which + /// The number of implicitly-declared destructors for which /// declarations were built. static unsigned NumImplicitDestructorsDeclared; public: - /// \brief Initialize built-in types. + /// Initialize built-in types. /// /// This routine may only be invoked once for a given ASTContext object. /// It is normally invoked after ASTContext construction. @@ -2756,7 +2821,7 @@ public: QualType T, std::string& S, bool Extended) const; - /// \brief Returns true if this is an inline-initialized static data member + /// Returns true if this is an inline-initialized static data member /// which is treated as a definition for MSVC compatibility. bool isMSStaticDataMemberInlineDefinition(const VarDecl *VD) const; @@ -2774,7 +2839,7 @@ public: Strong }; - /// \brief Determine whether a definition of this inline variable should + /// Determine whether a definition of this inline variable should /// be treated as a weak or strong definition. For compatibility with /// C++14 and before, for a constexpr static data member, if there is an /// out-of-line declaration of the member, we may promote it from weak to @@ -2790,7 +2855,7 @@ private: getObjCLayout(const ObjCInterfaceDecl *D, const ObjCImplementationDecl *Impl) const; - /// \brief A set of deallocations that should be performed when the + /// A set of deallocations that should be performed when the /// ASTContext is destroyed. // FIXME: We really should have a better mechanism in the ASTContext to // manage running destructors for types which do variable sized allocation @@ -2841,13 +2906,13 @@ public: llvm::StringMap<SectionInfo> SectionInfos; }; -/// \brief Utility function for constructing a nullary selector. +/// Utility function for constructing a nullary selector. inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) { IdentifierInfo* II = &Ctx.Idents.get(name); return Ctx.Selectors.getSelector(0, &II); } -/// \brief Utility function for constructing an unary selector. +/// Utility function for constructing an unary selector. inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) { IdentifierInfo* II = &Ctx.Idents.get(name); return Ctx.Selectors.getSelector(1, &II); @@ -2857,7 +2922,7 @@ inline Selector GetUnarySelector(StringRef name, ASTContext &Ctx) { // operator new and delete aren't allowed inside namespaces. -/// @brief Placement new for using the ASTContext's allocator. +/// Placement new for using the ASTContext's allocator. /// /// This placement form of operator new uses the ASTContext's allocator for /// obtaining memory. @@ -2890,7 +2955,7 @@ inline void *operator new(size_t Bytes, const clang::ASTContext &C, return C.Allocate(Bytes, Alignment); } -/// @brief Placement delete companion to the new above. +/// Placement delete companion to the new above. /// /// This operator is just a companion to the new above. There is no way of /// invoking it directly; see the new operator for more details. This operator @@ -2928,7 +2993,7 @@ inline void *operator new[](size_t Bytes, const clang::ASTContext& C, return C.Allocate(Bytes, Alignment); } -/// @brief Placement delete[] companion to the new[] above. +/// Placement delete[] companion to the new[] above. /// /// This operator is just a companion to the new[] above. There is no way of /// invoking it directly; see the new[] operator for more details. This operator @@ -2938,7 +3003,7 @@ inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) { C.Deallocate(Ptr); } -/// \brief Create the representation of a LazyGenerationalUpdatePtr. +/// Create the representation of a LazyGenerationalUpdatePtr. template <typename Owner, typename T, void (clang::ExternalASTSource::*Update)(Owner)> typename clang::LazyGenerationalUpdatePtr<Owner, T, Update>::ValueType diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h index 27c85e65f2c1..b08865dde3c1 100644 --- a/include/clang/AST/ASTDiagnostic.h +++ b/include/clang/AST/ASTDiagnostic.h @@ -24,7 +24,7 @@ namespace clang { }; } // end namespace diag - /// \brief DiagnosticsEngine argument formatting function for diagnostics that + /// DiagnosticsEngine argument formatting function for diagnostics that /// involve AST nodes. /// /// This function formats diagnostic arguments for various AST nodes, diff --git a/include/clang/AST/ASTFwd.h b/include/clang/AST/ASTFwd.h index 003d489c1ca4..038d5c3d3611 100644 --- a/include/clang/AST/ASTFwd.h +++ b/include/clang/AST/ASTFwd.h @@ -8,7 +8,7 @@ //===--------------------------------------------------------------===// /// /// \file -/// \brief Forward declaration of all AST node types. +/// Forward declaration of all AST node types. /// //===-------------------------------------------------------------===// diff --git a/include/clang/AST/ASTImporter.h b/include/clang/AST/ASTImporter.h index 66b9cd394b9d..6e6a1926254b 100644 --- a/include/clang/AST/ASTImporter.h +++ b/include/clang/AST/ASTImporter.h @@ -1,4 +1,4 @@ -//===--- ASTImporter.h - Importing ASTs from other Contexts -----*- C++ -*-===// +//===- ASTImporter.h - Importing ASTs from other Contexts -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,82 +11,95 @@ // context into another context. // //===----------------------------------------------------------------------===// + #ifndef LLVM_CLANG_AST_ASTIMPORTER_H #define LLVM_CLANG_AST_ASTIMPORTER_H #include "clang/AST/DeclarationName.h" +#include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SmallVector.h" +#include <utility> namespace clang { - class ASTContext; - class CXXCtorInitializer; - class CXXBaseSpecifier; - class Decl; - class DeclContext; - class DiagnosticsEngine; - class Expr; - class FileManager; - class IdentifierInfo; - class NestedNameSpecifier; - class Stmt; - class TypeSourceInfo; - - /// \brief Imports selected nodes from one AST context into another context, + +class ASTContext; +class CXXBaseSpecifier; +class CXXCtorInitializer; +class Decl; +class DeclContext; +class Expr; +class FileManager; +class NamedDecl; +class Stmt; +class TagDecl; +class TypeSourceInfo; +class Attr; + + // \brief Returns with a list of declarations started from the canonical decl + // then followed by subsequent decls in the translation unit. + // This gives a canonical list for each entry in the redecl chain. + // `Decl::redecls()` gives a list of decls which always start from the + // previous decl and the next item is actually the previous item in the order + // of source locations. Thus, `Decl::redecls()` gives different lists for + // the different entries in a given redecl chain. + llvm::SmallVector<Decl*, 2> getCanonicalForwardRedeclChain(Decl* D); + + /// Imports selected nodes from one AST context into another context, /// merging AST nodes where appropriate. class ASTImporter { public: - typedef llvm::DenseSet<std::pair<Decl *, Decl *> > NonEquivalentDeclSet; - typedef llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *> - ImportedCXXBaseSpecifierMap; + using NonEquivalentDeclSet = llvm::DenseSet<std::pair<Decl *, Decl *>>; + using ImportedCXXBaseSpecifierMap = + llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *>; private: - /// \brief The contexts we're importing to and from. + /// The contexts we're importing to and from. ASTContext &ToContext, &FromContext; - /// \brief The file managers we're importing to and from. + /// The file managers we're importing to and from. FileManager &ToFileManager, &FromFileManager; - /// \brief Whether to perform a minimal import. + /// Whether to perform a minimal import. bool Minimal; - /// \brief Whether the last diagnostic came from the "from" context. - bool LastDiagFromFrom; + /// Whether the last diagnostic came from the "from" context. + bool LastDiagFromFrom = false; - /// \brief Mapping from the already-imported types in the "from" context + /// 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; - /// \brief Mapping from the already-imported declarations in the "from" + /// Mapping from the already-imported declarations in the "from" /// context to the corresponding declarations in the "to" context. llvm::DenseMap<Decl *, Decl *> ImportedDecls; - /// \brief Mapping from the already-imported statements in the "from" + /// Mapping from the already-imported statements in the "from" /// context to the corresponding statements in the "to" context. llvm::DenseMap<Stmt *, Stmt *> ImportedStmts; - /// \brief Mapping from the already-imported FileIDs in the "from" source + /// Mapping from the already-imported FileIDs in the "from" source /// manager to the corresponding FileIDs in the "to" source manager. llvm::DenseMap<FileID, FileID> ImportedFileIDs; - /// \brief Mapping from the already-imported CXXBasesSpecifier in + /// Mapping from the already-imported CXXBasesSpecifier in /// the "from" source manager to the corresponding CXXBasesSpecifier /// in the "to" source manager. ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers; - - /// \brief Imported, anonymous tag declarations that are missing their - /// corresponding typedefs. - SmallVector<TagDecl *, 4> AnonTagsWithPendingTypedefs; - /// \brief Declaration (from, to) pairs that are known not to be equivalent + /// Declaration (from, to) pairs that are known not to be equivalent /// (which we have already complained about). NonEquivalentDeclSet NonEquivalentDecls; public: - /// \brief Create a new AST importer. + /// Create a new AST importer. /// /// \param ToContext The context we'll be importing into. /// @@ -105,135 +118,144 @@ namespace clang { virtual ~ASTImporter(); - /// \brief Whether the importer will perform a minimal import, creating + /// Whether the importer will perform a minimal import, creating /// to-be-completed forward declarations when possible. bool isMinimalImport() const { return Minimal; } - /// \brief Import the given type from the "from" context into the "to" + /// Import the given type from the "from" context into the "to" /// context. /// /// \returns the equivalent type in the "to" context, or a NULL type if /// an error occurred. QualType Import(QualType FromT); - /// \brief Import the given type source information from the + /// Import the given type source information from the /// "from" context into the "to" context. /// /// \returns the equivalent type source information in the "to" /// context, or NULL if an error occurred. TypeSourceInfo *Import(TypeSourceInfo *FromTSI); - /// \brief Import the given declaration from the "from" context into the + /// Import the given attribute from the "from" context into the + /// "to" context. + /// + /// \returns the equivalent attribute in the "to" context. + Attr *Import(const Attr *FromAttr); + + /// Import the given declaration from the "from" context into the /// "to" context. /// /// \returns the equivalent declaration in the "to" context, or a NULL type /// if an error occurred. Decl *Import(Decl *FromD); + Decl *Import(const Decl *FromD) { + return Import(const_cast<Decl *>(FromD)); + } - /// \brief Return the copy of the given declaration in the "to" context if + /// Return the copy of the given declaration in the "to" context if /// it has already been imported from the "from" context. Otherwise return /// NULL. Decl *GetAlreadyImportedOrNull(Decl *FromD); - /// \brief Import the given declaration context from the "from" + /// Import the given declaration context from the "from" /// AST context into the "to" AST context. /// /// \returns the equivalent declaration context in the "to" /// context, or a NULL type if an error occurred. DeclContext *ImportContext(DeclContext *FromDC); - /// \brief Import the given expression from the "from" context into the + /// Import the given expression from the "from" context into the /// "to" context. /// /// \returns the equivalent expression in the "to" context, or NULL if /// an error occurred. Expr *Import(Expr *FromE); - /// \brief Import the given statement from the "from" context into the + /// Import the given statement from the "from" context into the /// "to" context. /// /// \returns the equivalent statement in the "to" context, or NULL if /// an error occurred. Stmt *Import(Stmt *FromS); - /// \brief Import the given nested-name-specifier from the "from" + /// Import the given nested-name-specifier from the "from" /// context into the "to" context. /// /// \returns the equivalent nested-name-specifier in the "to" /// context, or NULL if an error occurred. NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS); - /// \brief Import the given nested-name-specifier from the "from" + /// Import the given nested-name-specifier from the "from" /// context into the "to" context. /// /// \returns the equivalent nested-name-specifier in the "to" /// context. NestedNameSpecifierLoc Import(NestedNameSpecifierLoc FromNNS); - /// \brief Import the goven template name from the "from" context into the + /// Import the goven template name from the "from" context into the /// "to" context. TemplateName Import(TemplateName From); - /// \brief Import the given source location from the "from" context into + /// Import the given source location from the "from" context into /// the "to" context. /// /// \returns the equivalent source location in the "to" context, or an /// invalid source location if an error occurred. SourceLocation Import(SourceLocation FromLoc); - /// \brief Import the given source range from the "from" context into + /// Import the given source range from the "from" context into /// the "to" context. /// /// \returns the equivalent source range in the "to" context, or an /// invalid source location if an error occurred. SourceRange Import(SourceRange FromRange); - /// \brief Import the given declaration name from the "from" + /// Import the given declaration name from the "from" /// context into the "to" context. /// /// \returns the equivalent declaration name in the "to" context, /// or an empty declaration name if an error occurred. DeclarationName Import(DeclarationName FromName); - /// \brief Import the given identifier from the "from" context + /// Import the given identifier from the "from" context /// into the "to" context. /// /// \returns the equivalent identifier in the "to" context. IdentifierInfo *Import(const IdentifierInfo *FromId); - /// \brief Import the given Objective-C selector from the "from" + /// Import the given Objective-C selector from the "from" /// context into the "to" context. /// /// \returns the equivalent selector in the "to" context. Selector Import(Selector FromSel); - /// \brief 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" /// context. FileID Import(FileID); - /// \brief Import the given C++ constructor initializer from the "from" + /// Import the given C++ constructor initializer from the "from" /// context into the "to" context. /// /// \returns the equivalent initializer in the "to" context. CXXCtorInitializer *Import(CXXCtorInitializer *FromInit); - /// \brief Import the given CXXBaseSpecifier from the "from" context into + /// Import the given CXXBaseSpecifier from the "from" context into /// the "to" context. /// /// \returns the equivalent CXXBaseSpecifier in the source manager of the /// "to" context. CXXBaseSpecifier *Import(const CXXBaseSpecifier *FromSpec); - /// \brief Import the definition of the given declaration, including all of + /// Import the definition of the given declaration, including all of /// the declarations it contains. /// /// This routine is intended to be used void ImportDefinition(Decl *From); - /// \brief Cope with a name conflict when importing a declaration into the + /// Cope with a name conflict when importing a declaration into the /// given context. /// /// This routine is invoked whenever there is a name conflict while @@ -265,41 +287,41 @@ namespace clang { NamedDecl **Decls, unsigned NumDecls); - /// \brief Retrieve the context that AST nodes are being imported into. + /// Retrieve the context that AST nodes are being imported into. ASTContext &getToContext() const { return ToContext; } - /// \brief Retrieve the context that AST nodes are being imported from. + /// Retrieve the context that AST nodes are being imported from. ASTContext &getFromContext() const { return FromContext; } - /// \brief Retrieve the file manager that AST nodes are being imported into. + /// Retrieve the file manager that AST nodes are being imported into. FileManager &getToFileManager() const { return ToFileManager; } - /// \brief Retrieve the file manager that AST nodes are being imported from. + /// Retrieve the file manager that AST nodes are being imported from. FileManager &getFromFileManager() const { return FromFileManager; } - /// \brief Report a diagnostic in the "to" context. + /// Report a diagnostic in the "to" context. DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID); - /// \brief Report a diagnostic in the "from" context. + /// Report a diagnostic in the "from" context. DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID); - /// \brief Return the set of declarations that we know are not equivalent. + /// Return the set of declarations that we know are not equivalent. NonEquivalentDeclSet &getNonEquivalentDecls() { return NonEquivalentDecls; } - /// \brief Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl. + /// Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl. /// Mark the Decl as complete, filling it in as much as possible. /// /// \param D A declaration in the "to" context. virtual void CompleteDecl(Decl* D); - /// \brief Note that we have imported the "from" declaration by mapping it - /// to the (potentially-newly-created) "to" declaration. - /// /// 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); - - /// \brief Called by StructuralEquivalenceContext. If a RecordDecl is + virtual Decl *Imported(Decl *From, Decl *To) { return To; } + + /// Store and assign the imported declaration to its counterpart. + Decl *MapImported(Decl *From, Decl *To); + + /// Called by StructuralEquivalenceContext. If a RecordDecl is /// being compared to another RecordDecl as part of import, completing the /// other RecordDecl may trigger importation of the first RecordDecl. This /// happens especially for anonymous structs. If the original of the second @@ -307,11 +329,12 @@ namespace clang { /// importation, eliminating this loop. virtual Decl *GetOriginalDecl(Decl *To) { return nullptr; } - /// \brief Determine whether the given types are structurally + /// Determine whether the given types are structurally /// equivalent. bool IsStructurallyEquivalent(QualType From, QualType To, bool Complain = true); }; -} + +} // namespace clang #endif // LLVM_CLANG_AST_ASTIMPORTER_H diff --git a/include/clang/AST/ASTLambda.h b/include/clang/AST/ASTLambda.h index 69df2d8c0113..2fe4e2563b36 100644 --- a/include/clang/AST/ASTLambda.h +++ b/include/clang/AST/ASTLambda.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// /// /// \file -/// \brief This file provides some common utility functions for processing +/// This file provides some common utility functions for processing /// Lambda related AST Constructs. /// //===----------------------------------------------------------------------===// diff --git a/include/clang/AST/ASTMutationListener.h b/include/clang/AST/ASTMutationListener.h index 9395d36d87e5..31ae2b111e01 100644 --- a/include/clang/AST/ASTMutationListener.h +++ b/include/clang/AST/ASTMutationListener.h @@ -41,86 +41,86 @@ namespace clang { class VarTemplateDecl; class VarTemplateSpecializationDecl; -/// \brief An abstract interface that should be implemented by listeners +/// An abstract interface that should be implemented by listeners /// that want to be notified when an AST entity gets modified after its /// initial creation. class ASTMutationListener { public: virtual ~ASTMutationListener(); - /// \brief A new TagDecl definition was completed. + /// A new TagDecl definition was completed. virtual void CompletedTagDefinition(const TagDecl *D) { } - /// \brief A new declaration with name has been added to a DeclContext. + /// A new declaration with name has been added to a DeclContext. virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D) {} - /// \brief An implicit member was added after the definition was completed. + /// An implicit member was added after the definition was completed. virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {} - /// \brief A template specialization (or partial one) was added to the + /// A template specialization (or partial one) was added to the /// template declaration. virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) {} - /// \brief A template specialization (or partial one) was added to the + /// A template specialization (or partial one) was added to the /// template declaration. virtual void AddedCXXTemplateSpecialization(const VarTemplateDecl *TD, const VarTemplateSpecializationDecl *D) {} - /// \brief A template specialization (or partial one) was added to the + /// A template specialization (or partial one) was added to the /// template declaration. virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD, const FunctionDecl *D) {} - /// \brief A function's exception specification has been evaluated or + /// A function's exception specification has been evaluated or /// instantiated. virtual void ResolvedExceptionSpec(const FunctionDecl *FD) {} - /// \brief A function's return type has been deduced. + /// A function's return type has been deduced. virtual void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType); - /// \brief A virtual destructor's operator delete has been resolved. + /// A virtual destructor's operator delete has been resolved. virtual void ResolvedOperatorDelete(const CXXDestructorDecl *DD, const FunctionDecl *Delete, Expr *ThisArg) {} - /// \brief An implicit member got a definition. + /// An implicit member got a definition. virtual void CompletedImplicitDefinition(const FunctionDecl *D) {} - /// \brief The instantiation of a templated function or variable was + /// The instantiation of a templated function or variable was /// requested. In particular, the point of instantiation and template /// specialization kind of \p D may have changed. virtual void InstantiationRequested(const ValueDecl *D) {} - /// \brief A templated variable's definition was implicitly instantiated. + /// A templated variable's definition was implicitly instantiated. virtual void VariableDefinitionInstantiated(const VarDecl *D) {} - /// \brief A function template's definition was instantiated. + /// A function template's definition was instantiated. virtual void FunctionDefinitionInstantiated(const FunctionDecl *D) {} - /// \brief A default argument was instantiated. + /// A default argument was instantiated. virtual void DefaultArgumentInstantiated(const ParmVarDecl *D) {} - /// \brief A default member initializer was instantiated. + /// A default member initializer was instantiated. virtual void DefaultMemberInitializerInstantiated(const FieldDecl *D) {} - /// \brief A new objc category class was added for an interface. + /// A new objc category class was added for an interface. virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD) {} - /// \brief A declaration is marked used which was not previously marked used. + /// A declaration is marked used which was not previously marked used. /// /// \param D the declaration marked used virtual void DeclarationMarkedUsed(const Decl *D) {} - /// \brief A declaration is marked as OpenMP threadprivate which was not + /// A declaration is marked as OpenMP threadprivate which was not /// previously marked as threadprivate. /// /// \param D the declaration marked OpenMP threadprivate. virtual void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {} - /// \brief A declaration is marked as OpenMP declaretarget which was not + /// A declaration is marked as OpenMP declaretarget which was not /// previously marked as declaretarget. /// /// \param D the declaration marked OpenMP declaretarget. @@ -128,14 +128,14 @@ public: virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D, const Attr *Attr) {} - /// \brief A definition has been made visible by being redefined locally. + /// A definition has been made visible by being redefined locally. /// /// \param D The definition that was previously not visible. /// \param M The containing module in which the definition was made visible, /// if any. virtual void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {} - /// \brief An attribute was added to a RecordDecl + /// An attribute was added to a RecordDecl /// /// \param Attr The attribute that was added to the Record /// diff --git a/include/clang/AST/ASTStructuralEquivalence.h b/include/clang/AST/ASTStructuralEquivalence.h index 23674c65f332..d32f87d43e04 100644 --- a/include/clang/AST/ASTStructuralEquivalence.h +++ b/include/clang/AST/ASTStructuralEquivalence.h @@ -1,4 +1,4 @@ -//===--- ASTStructuralEquivalence.h - ---------------------------*- C++ -*-===// +//===- ASTStructuralEquivalence.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -19,6 +19,7 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" #include <deque> +#include <utility> namespace clang { @@ -29,6 +30,14 @@ class QualType; class RecordDecl; class SourceLocation; +/// \brief Whether to perform a normal or minimal equivalence check. +/// In case of `Minimal`, we do not perform a recursive check of decls with +/// external storage. +enum class StructuralEquivalenceKind { + Default, + Minimal, +}; + struct StructuralEquivalenceContext { /// AST contexts for which we are checking structural equivalence. ASTContext &FromCtx, &ToCtx; @@ -46,6 +55,8 @@ struct StructuralEquivalenceContext { /// (which we have already complained about). llvm::DenseSet<std::pair<Decl *, Decl *>> &NonEquivalentDecls; + StructuralEquivalenceKind EqKind; + /// Whether we're being strict about the spelling of types when /// unifying two types. bool StrictTypeSpelling; @@ -57,27 +68,35 @@ struct StructuralEquivalenceContext { bool Complain; /// \c true if the last diagnostic came from ToCtx. - bool LastDiagFromC2; + bool LastDiagFromC2 = false; StructuralEquivalenceContext( ASTContext &FromCtx, ASTContext &ToCtx, llvm::DenseSet<std::pair<Decl *, Decl *>> &NonEquivalentDecls, + StructuralEquivalenceKind EqKind, bool StrictTypeSpelling = false, bool Complain = true, bool ErrorOnTagTypeMismatch = false) : FromCtx(FromCtx), ToCtx(ToCtx), NonEquivalentDecls(NonEquivalentDecls), - StrictTypeSpelling(StrictTypeSpelling), - ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain), - LastDiagFromC2(false) {} + EqKind(EqKind), StrictTypeSpelling(StrictTypeSpelling), + ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain) {} DiagnosticBuilder Diag1(SourceLocation Loc, unsigned DiagID); DiagnosticBuilder Diag2(SourceLocation Loc, unsigned DiagID); /// Determine whether the two declarations are structurally /// equivalent. - bool IsStructurallyEquivalent(Decl *D1, Decl *D2); + /// Implementation functions (all static functions in + /// ASTStructuralEquivalence.cpp) must never call this function because that + /// will wreak havoc the internal state (\c DeclsToCheck and + /// \c TentativeEquivalences members) and can cause faulty equivalent results. + bool IsEquivalent(Decl *D1, Decl *D2); /// Determine whether the two types are structurally equivalent. - bool IsStructurallyEquivalent(QualType T1, QualType T2); + /// Implementation functions (all static functions in + /// ASTStructuralEquivalence.cpp) must never call this function because that + /// will wreak havoc the internal state (\c DeclsToCheck and + /// \c TentativeEquivalences members) and can cause faulty equivalent results. + bool IsEquivalent(QualType T1, QualType T2); /// Find the index of the given anonymous struct/union within its /// context. @@ -98,6 +117,7 @@ private: /// \returns true if an error occurred, false otherwise. bool Finish(); }; + } // namespace clang #endif // LLVM_CLANG_AST_ASTSTRUCTURALEQUIVALENCE_H diff --git a/include/clang/AST/ASTTypeTraits.h b/include/clang/AST/ASTTypeTraits.h index 51d60a90a146..9df9793370c4 100644 --- a/include/clang/AST/ASTTypeTraits.h +++ b/include/clang/AST/ASTTypeTraits.h @@ -38,62 +38,62 @@ struct PrintingPolicy; namespace ast_type_traits { -/// \brief Kind identifier. +/// Kind identifier. /// /// It can be constructed from any node kind and allows for runtime type /// hierarchy checks. /// Use getFromNodeKind<T>() to construct them. class ASTNodeKind { public: - /// \brief Empty identifier. It matches nothing. + /// Empty identifier. It matches nothing. ASTNodeKind() : KindId(NKI_None) {} - /// \brief Construct an identifier for T. + /// Construct an identifier for T. template <class T> static ASTNodeKind getFromNodeKind() { return ASTNodeKind(KindToKindId<T>::Id); } /// \{ - /// \brief Construct an identifier for the dynamic type of the node + /// Construct an identifier for the dynamic type of the node static ASTNodeKind getFromNode(const Decl &D); static ASTNodeKind getFromNode(const Stmt &S); static ASTNodeKind getFromNode(const Type &T); /// \} - /// \brief Returns \c true if \c this and \c Other represent the same kind. + /// Returns \c true if \c this and \c Other represent the same kind. bool isSame(ASTNodeKind Other) const { return KindId != NKI_None && KindId == Other.KindId; } - /// \brief Returns \c true only for the default \c ASTNodeKind() + /// Returns \c true only for the default \c ASTNodeKind() bool isNone() const { return KindId == NKI_None; } - /// \brief Returns \c true if \c this is a base kind of (or same as) \c Other. + /// Returns \c true if \c this is a base kind of (or same as) \c Other. /// \param Distance If non-null, used to return the distance between \c this /// and \c Other in the class hierarchy. bool isBaseOf(ASTNodeKind Other, unsigned *Distance = nullptr) const; - /// \brief String representation of the kind. + /// String representation of the kind. StringRef asStringRef() const; - /// \brief Strict weak ordering for ASTNodeKind. + /// Strict weak ordering for ASTNodeKind. bool operator<(const ASTNodeKind &Other) const { return KindId < Other.KindId; } - /// \brief Return the most derived type between \p Kind1 and \p Kind2. + /// Return the most derived type between \p Kind1 and \p Kind2. /// /// Return ASTNodeKind() if they are not related. static ASTNodeKind getMostDerivedType(ASTNodeKind Kind1, ASTNodeKind Kind2); - /// \brief Return the most derived common ancestor between Kind1 and Kind2. + /// Return the most derived common ancestor between Kind1 and Kind2. /// /// Return ASTNodeKind() if they are not related. static ASTNodeKind getMostDerivedCommonAncestor(ASTNodeKind Kind1, ASTNodeKind Kind2); - /// \brief Hooks for using ASTNodeKind as a key in a DenseMap. + /// Hooks for using ASTNodeKind as a key in a DenseMap. struct DenseMapInfo { // ASTNodeKind() is a good empty key because it is represented as a 0. static inline ASTNodeKind getEmptyKey() { return ASTNodeKind(); } @@ -115,7 +115,7 @@ public: } private: - /// \brief Kind ids. + /// Kind ids. /// /// Includes all possible base and derived kinds. enum NodeKindId { @@ -140,16 +140,16 @@ private: NKI_NumberOfKinds }; - /// \brief Use getFromNodeKind<T>() to construct the kind. + /// Use getFromNodeKind<T>() to construct the kind. ASTNodeKind(NodeKindId KindId) : KindId(KindId) {} - /// \brief Returns \c true if \c Base is a base kind of (or same as) \c + /// Returns \c true if \c Base is a base kind of (or same as) \c /// Derived. /// \param Distance If non-null, used to return the distance between \c Base /// and \c Derived in the class hierarchy. static bool isBaseOf(NodeKindId Base, NodeKindId Derived, unsigned *Distance); - /// \brief Helper meta-function to convert a kind T to its enum value. + /// Helper meta-function to convert a kind T to its enum value. /// /// This struct is specialized below for all known kinds. template <class T> struct KindToKindId { @@ -158,11 +158,11 @@ private: template <class T> struct KindToKindId<const T> : KindToKindId<T> {}; - /// \brief Per kind info. + /// Per kind info. struct KindInfo { - /// \brief The id of the parent kind, or None if it has no parent. + /// The id of the parent kind, or None if it has no parent. NodeKindId ParentId; - /// \brief Name of the kind. + /// Name of the kind. const char *Name; }; static const KindInfo AllKindInfo[NKI_NumberOfKinds]; @@ -197,7 +197,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) { return OS; } -/// \brief A dynamically typed AST node container. +/// A dynamically typed AST node container. /// /// Stores an AST node in a type safe way. This allows writing code that /// works with different kinds of AST nodes, despite the fact that they don't @@ -211,13 +211,13 @@ inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) { /// the supported base types. class DynTypedNode { public: - /// \brief Creates a \c DynTypedNode from \c Node. + /// Creates a \c DynTypedNode from \c Node. template <typename T> static DynTypedNode create(const T &Node) { return BaseConverter<T>::create(Node); } - /// \brief Retrieve the stored node as type \c T. + /// Retrieve the stored node as type \c T. /// /// Returns NULL if the stored node does not have a type that is /// convertible to \c T. @@ -234,7 +234,7 @@ public: return BaseConverter<T>::get(NodeKind, Storage.buffer); } - /// \brief Retrieve the stored node as type \c T. + /// Retrieve the stored node as type \c T. /// /// Similar to \c get(), but asserts that the type is what we are expecting. template <typename T> @@ -244,7 +244,7 @@ public: ASTNodeKind getNodeKind() const { return NodeKind; } - /// \brief Returns a pointer that identifies the stored AST node. + /// Returns a pointer that identifies the stored AST node. /// /// Note that this is not supported by all AST nodes. For AST nodes /// that don't have a pointer-defined identity inside the AST, this @@ -255,21 +255,21 @@ public: : nullptr; } - /// \brief Prints the node to the given output stream. + /// Prints the node to the given output stream. void print(llvm::raw_ostream &OS, const PrintingPolicy &PP) const; - /// \brief Dumps the node to the given output stream. + /// Dumps the node to the given output stream. void dump(llvm::raw_ostream &OS, SourceManager &SM) const; - /// \brief For nodes which represent textual entities in the source code, + /// For nodes which represent textual entities in the source code, /// return their SourceRange. For all other nodes, return SourceRange(). SourceRange getSourceRange() const; /// @{ - /// \brief Imposes an order on \c DynTypedNode. + /// Imposes an order on \c DynTypedNode. /// /// Supports comparison of nodes that support memoization. - /// FIXME: Implement comparsion for other node types (currently + /// FIXME: Implement comparison for other node types (currently /// only Stmt, Decl, Type and NestedNameSpecifier return memoization data). bool operator<(const DynTypedNode &Other) const { if (!NodeKind.isSame(Other.NodeKind)) @@ -326,7 +326,7 @@ public: } /// @} - /// \brief Hooks for using DynTypedNode as a key in a DenseMap. + /// Hooks for using DynTypedNode as a key in a DenseMap. struct DenseMapInfo { static inline DynTypedNode getEmptyKey() { DynTypedNode Node; @@ -368,10 +368,10 @@ public: }; private: - /// \brief Takes care of converting from and to \c T. + /// Takes care of converting from and to \c T. template <typename T, typename EnablerT = void> struct BaseConverter; - /// \brief Converter that uses dyn_cast<T> from a stored BaseT*. + /// Converter that uses dyn_cast<T> from a stored BaseT*. template <typename T, typename BaseT> struct DynCastPtrConverter { static const T *get(ASTNodeKind NodeKind, const char Storage[]) { if (ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind)) @@ -391,7 +391,7 @@ private: } }; - /// \brief Converter that stores T* (by pointer). + /// Converter that stores T* (by pointer). template <typename T> struct PtrConverter { static const T *get(ASTNodeKind NodeKind, const char Storage[]) { if (ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind)) @@ -411,7 +411,7 @@ private: } }; - /// \brief Converter that stores T (by value). + /// Converter that stores T (by value). template <typename T> struct ValueConverter { static const T *get(ASTNodeKind NodeKind, const char Storage[]) { if (ASTNodeKind::getFromNodeKind<T>().isSame(NodeKind)) @@ -432,7 +432,7 @@ private: ASTNodeKind NodeKind; - /// \brief Stores the data of the node. + /// Stores the data of the node. /// /// Note that we can store \c Decls, \c Stmts, \c Types, /// \c NestedNameSpecifiers and \c CXXCtorInitializer by pointer as they are diff --git a/include/clang/AST/ASTUnresolvedSet.h b/include/clang/AST/ASTUnresolvedSet.h index 3693aeccfe14..9bf63bb6e2d7 100644 --- a/include/clang/AST/ASTUnresolvedSet.h +++ b/include/clang/AST/ASTUnresolvedSet.h @@ -26,7 +26,7 @@ namespace clang { class NamedDecl; -/// \brief An UnresolvedSet-like class which uses the ASTContext's allocator. +/// An UnresolvedSet-like class which uses the ASTContext's allocator. class ASTUnresolvedSet { friend class LazyASTUnresolvedSet; @@ -89,7 +89,7 @@ public: const DeclAccessPair &operator[](unsigned I) const { return Decls[I]; } }; -/// \brief An UnresolvedSet-like class that might not have been loaded from the +/// An UnresolvedSet-like class that might not have been loaded from the /// external AST source yet. class LazyASTUnresolvedSet { mutable ASTUnresolvedSet Impl; diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index bbe320c28a3b..32a61c59d236 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -23,9 +23,9 @@ #include "clang/Basic/OpenMPKinds.h" #include "clang/Basic/Sanitizers.h" #include "clang/Basic/SourceLocation.h" -#include "clang/Basic/VersionTuple.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/VersionTuple.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cassert> @@ -52,8 +52,10 @@ protected: unsigned Inherited : 1; unsigned IsPackExpansion : 1; unsigned Implicit : 1; + // FIXME: These are properties of the attribute kind, not state for this + // instance of the attribute. unsigned IsLateParsed : 1; - unsigned DuplicatesAllowed : 1; + unsigned InheritEvenIfAlreadyPresent : 1; void *operator new(size_t bytes) noexcept { llvm_unreachable("Attrs cannot be allocated with regular 'new'."); @@ -74,10 +76,10 @@ public: protected: Attr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, - bool IsLateParsed, bool DuplicatesAllowed) + bool IsLateParsed) : Range(R), AttrKind(AK), SpellingListIndex(SpellingListIndex), Inherited(false), IsPackExpansion(false), Implicit(false), - IsLateParsed(IsLateParsed), DuplicatesAllowed(DuplicatesAllowed) {} + IsLateParsed(IsLateParsed), InheritEvenIfAlreadyPresent(false) {} public: @@ -94,7 +96,7 @@ public: bool isInherited() const { return Inherited; } - /// \brief Returns true if the attribute has been implicitly created instead + /// Returns true if the attribute has been implicitly created instead /// of explicitly written by the user. bool isImplicit() const { return Implicit; } void setImplicit(bool I) { Implicit = I; } @@ -109,18 +111,13 @@ public: // Pretty print this attribute. void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const; - - /// \brief By default, attributes cannot be duplicated when being merged; - /// however, an attribute can override this. Returns true if the attribute - /// can be duplicated when merging. - bool duplicatesAllowed() const { return DuplicatesAllowed; } }; class StmtAttr : public Attr { protected: StmtAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, - bool IsLateParsed, bool DuplicatesAllowed) - : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed) {} + bool IsLateParsed) + : Attr(AK, R, SpellingListIndex, IsLateParsed) {} public: static bool classof(const Attr *A) { @@ -132,12 +129,20 @@ public: class InheritableAttr : public Attr { protected: InheritableAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, - bool IsLateParsed, bool DuplicatesAllowed) - : Attr(AK, R, SpellingListIndex, IsLateParsed, DuplicatesAllowed) {} + bool IsLateParsed, bool InheritEvenIfAlreadyPresent) + : Attr(AK, R, SpellingListIndex, IsLateParsed) { + this->InheritEvenIfAlreadyPresent = InheritEvenIfAlreadyPresent; + } public: void setInherited(bool I) { Inherited = I; } + /// Should this attribute be inherited from a prior declaration even if it's + /// explicitly provided in the current declaration? + bool shouldInheritEvenIfAlreadyPresent() const { + return InheritEvenIfAlreadyPresent; + } + // Implement isa/cast/dyncast/etc. static bool classof(const Attr *A) { return A->getKind() >= attr::FirstInheritableAttr && @@ -148,9 +153,9 @@ public: class InheritableParamAttr : public InheritableAttr { protected: InheritableParamAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, - bool IsLateParsed, bool DuplicatesAllowed) + bool IsLateParsed, bool InheritEvenIfAlreadyPresent) : InheritableAttr(AK, R, SpellingListIndex, IsLateParsed, - DuplicatesAllowed) {} + InheritEvenIfAlreadyPresent) {} public: // Implement isa/cast/dyncast/etc. @@ -166,9 +171,9 @@ class ParameterABIAttr : public InheritableParamAttr { protected: ParameterABIAttr(attr::Kind AK, SourceRange R, unsigned SpellingListIndex, bool IsLateParsed, - bool DuplicatesAllowed) + bool InheritEvenIfAlreadyPresent) : InheritableParamAttr(AK, R, SpellingListIndex, IsLateParsed, - DuplicatesAllowed) {} + InheritEvenIfAlreadyPresent) {} public: ParameterABI getABI() const { @@ -190,6 +195,128 @@ public: } }; +/// A single parameter index whose accessors require each use to make explicit +/// the parameter index encoding needed. +class ParamIdx { + // Idx is exposed only via accessors that specify specific encodings. + unsigned Idx : 30; + unsigned HasThis : 1; + unsigned IsValid : 1; + + void assertComparable(const ParamIdx &I) const { + assert(isValid() && I.isValid() && + "ParamIdx must be valid to be compared"); + // It's possible to compare indices from separate functions, but so far + // it's not proven useful. Moreover, it might be confusing because a + // comparison on the results of getASTIndex might be inconsistent with a + // comparison on the ParamIdx objects themselves. + assert(HasThis == I.HasThis && + "ParamIdx must be for the same function to be compared"); + } + +public: + /// Construct an invalid parameter index (\c isValid returns false and + /// accessors fail an assert). + ParamIdx() : Idx(0), HasThis(false), IsValid(false) {} + + /// \param Idx is the parameter index as it is normally specified in + /// attributes in the source: one-origin including any C++ implicit this + /// parameter. + /// + /// \param D is the declaration containing the parameters. It is used to + /// determine if there is a C++ implicit this parameter. + ParamIdx(unsigned Idx, const Decl *D) + : Idx(Idx), HasThis(false), IsValid(true) { + assert(Idx >= 1 && "Idx must be one-origin"); + if (const auto *FD = dyn_cast<FunctionDecl>(D)) + HasThis = FD->isCXXInstanceMember(); + } + + /// A type into which \c ParamIdx can be serialized. + /// + /// A static assertion that it's of the correct size follows the \c ParamIdx + /// class definition. + typedef uint32_t SerialType; + + /// Produce a representation that can later be passed to \c deserialize to + /// construct an equivalent \c ParamIdx. + SerialType serialize() const { + return *reinterpret_cast<const SerialType *>(this); + } + + /// Construct from a result from \c serialize. + static ParamIdx deserialize(SerialType S) { + ParamIdx P(*reinterpret_cast<ParamIdx *>(&S)); + assert((!P.IsValid || P.Idx >= 1) && "valid Idx must be one-origin"); + return P; + } + + /// Is this parameter index valid? + bool isValid() const { return IsValid; } + + /// Get the parameter index as it would normally be encoded for attributes at + /// the source level of representation: one-origin including any C++ implicit + /// this parameter. + /// + /// This encoding thus makes sense for diagnostics, pretty printing, and + /// constructing new attributes from a source-like specification. + unsigned getSourceIndex() const { + assert(isValid() && "ParamIdx must be valid"); + return Idx; + } + + /// Get the parameter index as it would normally be encoded at the AST level + /// of representation: zero-origin not including any C++ implicit this + /// parameter. + /// + /// This is the encoding primarily used in Sema. However, in diagnostics, + /// Sema uses \c getSourceIndex instead. + unsigned getASTIndex() const { + assert(isValid() && "ParamIdx must be valid"); + assert(Idx >= 1 + HasThis && + "stored index must be base-1 and not specify C++ implicit this"); + return Idx - 1 - HasThis; + } + + /// Get the parameter index as it would normally be encoded at the LLVM level + /// of representation: zero-origin including any C++ implicit this parameter. + /// + /// This is the encoding primarily used in CodeGen. + unsigned getLLVMIndex() const { + assert(isValid() && "ParamIdx must be valid"); + assert(Idx >= 1 && "stored index must be base-1"); + return Idx - 1; + } + + bool operator==(const ParamIdx &I) const { + assertComparable(I); + return Idx == I.Idx; + } + bool operator!=(const ParamIdx &I) const { + assertComparable(I); + return Idx != I.Idx; + } + bool operator<(const ParamIdx &I) const { + assertComparable(I); + return Idx < I.Idx; + } + bool operator>(const ParamIdx &I) const { + assertComparable(I); + return Idx > I.Idx; + } + bool operator<=(const ParamIdx &I) const { + assertComparable(I); + return Idx <= I.Idx; + } + bool operator>=(const ParamIdx &I) const { + assertComparable(I); + return Idx >= I.Idx; + } +}; + +static_assert(sizeof(ParamIdx) == sizeof(ParamIdx::SerialType), + "ParamIdx does not fit its serialization type"); + #include "clang/AST/Attrs.inc" inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, diff --git a/include/clang/AST/Availability.h b/include/clang/AST/Availability.h index 5ed831378456..28f3c3c01d20 100644 --- a/include/clang/AST/Availability.h +++ b/include/clang/AST/Availability.h @@ -15,12 +15,12 @@ #define LLVM_CLANG_AST_AVAILABILITY_H #include "clang/Basic/SourceLocation.h" -#include "clang/Basic/VersionTuple.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/VersionTuple.h" namespace clang { -/// \brief One specifier in an @available expression. +/// One specifier in an @available expression. /// /// \code /// @available(macos 10.10, *) diff --git a/include/clang/AST/BuiltinTypes.def b/include/clang/AST/BuiltinTypes.def index e4f5f7db2f73..400efcb1981f 100644 --- a/include/clang/AST/BuiltinTypes.def +++ b/include/clang/AST/BuiltinTypes.def @@ -72,6 +72,9 @@ UNSIGNED_TYPE(UChar, UnsignedCharTy) // 'wchar_t' for targets where it's unsigned SHARED_SINGLETON_TYPE(UNSIGNED_TYPE(WChar_U, WCharTy)) +// 'char8_t' in C++20 (proposed) +UNSIGNED_TYPE(Char8, Char8Ty) + // 'char16_t' in C++ UNSIGNED_TYPE(Char16, Char16Ty) @@ -119,6 +122,80 @@ SIGNED_TYPE(LongLong, LongLongTy) // '__int128_t' SIGNED_TYPE(Int128, Int128Ty) +//===- Fixed point types --------------------------------------------------===// + +// 'short _Accum' +SIGNED_TYPE(ShortAccum, ShortAccumTy) + +// '_Accum' +SIGNED_TYPE(Accum, AccumTy) + +// 'long _Accum' +SIGNED_TYPE(LongAccum, LongAccumTy) + +// 'unsigned short _Accum' +UNSIGNED_TYPE(UShortAccum, UnsignedShortAccumTy) + +// 'unsigned _Accum' +UNSIGNED_TYPE(UAccum, UnsignedAccumTy) + +// 'unsigned long _Accum' +UNSIGNED_TYPE(ULongAccum, UnsignedLongAccumTy) + +// 'short _Fract' +SIGNED_TYPE(ShortFract, ShortFractTy) + +// '_Fract' +SIGNED_TYPE(Fract, FractTy) + +// 'long _Fract' +SIGNED_TYPE(LongFract, LongFractTy) + +// 'unsigned short _Fract' +UNSIGNED_TYPE(UShortFract, UnsignedShortFractTy) + +// 'unsigned _Fract' +UNSIGNED_TYPE(UFract, UnsignedFractTy) + +// 'unsigned long _Fract' +UNSIGNED_TYPE(ULongFract, UnsignedLongFractTy) + +// '_Sat short _Accum' +SIGNED_TYPE(SatShortAccum, SatShortAccumTy) + +// '_Sat _Accum' +SIGNED_TYPE(SatAccum, SatAccumTy) + +// '_Sat long _Accum' +SIGNED_TYPE(SatLongAccum, SatLongAccumTy) + +// '_Sat unsigned short _Accum' +UNSIGNED_TYPE(SatUShortAccum, SatUnsignedShortAccumTy) + +// '_Sat unsigned _Accum' +UNSIGNED_TYPE(SatUAccum, SatUnsignedAccumTy) + +// '_Sat unsigned long _Accum' +UNSIGNED_TYPE(SatULongAccum, SatUnsignedLongAccumTy) + +// '_Sat short _Fract' +SIGNED_TYPE(SatShortFract, SatShortFractTy) + +// '_Sat _Fract' +SIGNED_TYPE(SatFract, SatFractTy) + +// '_Sat long _Fract' +SIGNED_TYPE(SatLongFract, SatLongFractTy) + +// '_Sat unsigned short _Fract' +UNSIGNED_TYPE(SatUShortFract, SatUnsignedShortFractTy) + +// '_Sat unsigned _Fract' +UNSIGNED_TYPE(SatUFract, SatUnsignedFractTy) + +// '_Sat unsigned long _Fract' +UNSIGNED_TYPE(SatULongFract, SatUnsignedLongFractTy) + //===- Floating point types -----------------------------------------------===// // 'half' in OpenCL, '__fp16' in ARM NEON. diff --git a/include/clang/AST/CXXInheritance.h b/include/clang/AST/CXXInheritance.h index 11fb229f0c09..2ae1d8b25823 100644 --- a/include/clang/AST/CXXInheritance.h +++ b/include/clang/AST/CXXInheritance.h @@ -35,7 +35,7 @@ namespace clang { class ASTContext; class NamedDecl; -/// \brief Represents an element in a path from a derived class to a +/// Represents an element in a path from a derived class to a /// base class. /// /// Each step in the path references the link from a @@ -43,15 +43,15 @@ class NamedDecl; /// base "number" that identifies which base subobject of the /// original derived class we are referencing. struct CXXBasePathElement { - /// \brief The base specifier that states the link from a derived + /// The base specifier that states the link from a derived /// class to a base class, which will be followed by this base /// path element. const CXXBaseSpecifier *Base; - /// \brief The record decl of the class that the base is a base of. + /// The record decl of the class that the base is a base of. const CXXRecordDecl *Class; - /// \brief Identifies which base class subobject (of type + /// Identifies which base class subobject (of type /// \c Base->getType()) this base path element refers to. /// /// This value is only valid if \c !Base->isVirtual(), because there @@ -60,7 +60,7 @@ struct CXXBasePathElement { int SubobjectNumber; }; -/// \brief Represents a path from a specific derived class +/// Represents a path from a specific derived class /// (which is not represented as part of the path) to a particular /// (direct or indirect) base class subobject. /// @@ -70,14 +70,14 @@ struct CXXBasePathElement { /// subobject is being used. class CXXBasePath : public SmallVector<CXXBasePathElement, 4> { public: - /// \brief The access along this inheritance path. This is only + /// The access along this inheritance path. This is only /// calculated when recording paths. AS_none is a special value /// used to indicate a path which permits no legal access. AccessSpecifier Access = AS_public; CXXBasePath() = default; - /// \brief The set of declarations found inside this base class + /// The set of declarations found inside this base class /// subobject. DeclContext::lookup_result Decls; @@ -119,24 +119,42 @@ public: class CXXBasePaths { friend class CXXRecordDecl; - /// \brief The type from which this search originated. + /// 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; - + /// ClassSubobjects - Records the class subobjects for each class - /// type that we've seen. The first element in the pair says + /// type that we've seen. The first element IsVirtBase says /// whether we found a path to a virtual base for that class type, - /// while the element contains the number of non-virtual base + /// while NumberOfNonVirtBases contains the number of non-virtual base /// class subobjects for that class type. The key of the map is /// the cv-unqualified canonical type of the base class subobject. - llvm::SmallDenseMap<QualType, std::pair<bool, unsigned>, 8> ClassSubobjects; + struct IsVirtBaseAndNumberNonVirtBases { + unsigned IsVirtBase : 1; + unsigned NumberOfNonVirtBases : 31; + }; + llvm::SmallDenseMap<QualType, IsVirtBaseAndNumberNonVirtBases, 8> + ClassSubobjects; /// VisitedDependentRecords - Records the dependent records that have been /// already visited. - llvm::SmallDenseSet<const CXXRecordDecl *, 4> VisitedDependentRecords; + llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedDependentRecords; + + /// DetectedVirtual - The base class that is virtual. + const RecordType *DetectedVirtual = nullptr; + + /// ScratchPath - A BasePath that is used by Sema::lookupInBases + /// to help build the set of paths. + CXXBasePath ScratchPath; + + /// Array of the declarations that have been found. This + /// array is constructed only if needed, e.g., to iterate over the + /// results within LookupResult. + std::unique_ptr<NamedDecl *[]> DeclsFound; + unsigned NumDeclsFound = 0; /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find /// ambiguous paths while it is looking for a path from a derived @@ -152,20 +170,7 @@ class CXXBasePaths { /// if it finds a path that goes across a virtual base. The virtual class /// is also recorded. bool DetectVirtual; - - /// ScratchPath - A BasePath that is used by Sema::lookupInBases - /// to help build the set of paths. - CXXBasePath ScratchPath; - /// DetectedVirtual - The base class that is virtual. - const RecordType *DetectedVirtual = nullptr; - - /// \brief Array of the declarations that have been found. This - /// array is constructed only if needed, e.g., to iterate over the - /// results within LookupResult. - std::unique_ptr<NamedDecl *[]> DeclsFound; - unsigned NumDeclsFound = 0; - void ComputeDeclsFound(); bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, @@ -196,53 +201,53 @@ public: decl_range found_decls(); - /// \brief Determine whether the path from the most-derived type to the + /// 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); - /// \brief Whether we are finding multiple paths to detect ambiguities. + /// Whether we are finding multiple paths to detect ambiguities. bool isFindingAmbiguities() const { return FindAmbiguities; } - /// \brief Whether we are recording paths. + /// Whether we are recording paths. bool isRecordingPaths() const { return RecordPaths; } - /// \brief Specify whether we should be recording paths or not. + /// Specify whether we should be recording paths or not. void setRecordingPaths(bool RP) { RecordPaths = RP; } - /// \brief Whether we are detecting virtual bases. + /// Whether we are detecting virtual bases. bool isDetectingVirtual() const { return DetectVirtual; } - /// \brief The virtual base discovered on the path (if we are merely + /// The virtual base discovered on the path (if we are merely /// detecting virtuals). const RecordType* getDetectedVirtual() const { return DetectedVirtual; } - /// \brief Retrieve the type from which this base-paths search + /// Retrieve the type from which this base-paths search /// began CXXRecordDecl *getOrigin() const { return Origin; } void setOrigin(CXXRecordDecl *Rec) { Origin = Rec; } - /// \brief Clear the base-paths results. + /// Clear the base-paths results. void clear(); - /// \brief Swap this data structure's contents with another CXXBasePaths + /// Swap this data structure's contents with another CXXBasePaths /// object. void swap(CXXBasePaths &Other); }; -/// \brief Uniquely identifies a virtual method within a class +/// Uniquely identifies a virtual method within a class /// hierarchy by the method itself and a class subobject number. struct UniqueVirtualMethod { - /// \brief The overriding virtual method. + /// The overriding virtual method. CXXMethodDecl *Method = nullptr; - /// \brief The subobject in which the overriding virtual method + /// The subobject in which the overriding virtual method /// resides. unsigned Subobject = 0; - /// \brief The virtual base class subobject of which this overridden + /// The virtual base class subobject of which this overridden /// virtual method is a part. Note that this records the closest /// derived virtual base class subobject. const CXXRecordDecl *InVirtualSubobject = nullptr; @@ -266,7 +271,7 @@ struct UniqueVirtualMethod { } }; -/// \brief The set of methods that override a given virtual method in +/// The set of methods that override a given virtual method in /// each subobject where it occurs. /// /// The first part of the pair is the subobject in which the @@ -310,7 +315,7 @@ public: void replaceAll(UniqueVirtualMethod Overriding); }; -/// \brief A mapping from each virtual member function to its set of +/// A mapping from each virtual member function to its set of /// final overriders. /// /// Within a class hierarchy for a given derived class, each virtual @@ -364,7 +369,7 @@ public: class CXXFinalOverriderMap : public llvm::MapVector<const CXXMethodDecl *, OverridingMethods> {}; -/// \brief A set of all the primary bases for a class. +/// A set of all the primary bases for a class. class CXXIndirectPrimaryBaseSet : public llvm::SmallSet<const CXXRecordDecl*, 32> {}; diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h index 6487613200de..63a0af66eec3 100644 --- a/include/clang/AST/CanonicalType.h +++ b/include/clang/AST/CanonicalType.h @@ -44,7 +44,7 @@ class TemplateTypeParmDecl; // Canonical, qualified type template //----------------------------------------------------------------------------// -/// \brief Represents a canonical, potentially-qualified type. +/// Represents a canonical, potentially-qualified type. /// /// The CanQual template is a lightweight smart pointer that provides access /// to the canonical representation of a type, where all typedefs and other @@ -64,35 +64,35 @@ class TemplateTypeParmDecl; /// a call to ASTContext::getCanonicalType(). template<typename T = Type> class CanQual { - /// \brief The actual, canonical type. + /// The actual, canonical type. QualType Stored; public: - /// \brief Constructs a NULL canonical type. + /// Constructs a NULL canonical type. CanQual() = default; - /// \brief Converting constructor that permits implicit upcasting of + /// Converting constructor that permits implicit upcasting of /// canonical type pointers. template <typename U> CanQual(const CanQual<U> &Other, typename std::enable_if<std::is_base_of<T, U>::value, int>::type = 0); - /// \brief Retrieve the underlying type pointer, which refers to a + /// Retrieve the underlying type pointer, which refers to a /// canonical type. /// /// The underlying pointer must not be nullptr. const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); } - /// \brief Retrieve the underlying type pointer, which refers to a + /// Retrieve the underlying type pointer, which refers to a /// canonical type, or nullptr. const T *getTypePtrOrNull() const { return cast_or_null<T>(Stored.getTypePtrOrNull()); } - /// \brief Implicit conversion to a qualified type. + /// Implicit conversion to a qualified type. operator QualType() const { return Stored; } - /// \brief Implicit conversion to bool. + /// Implicit conversion to bool. explicit operator bool() const { return !isNull(); } bool isNull() const { @@ -101,7 +101,7 @@ public: SplitQualType split() const { return Stored.split(); } - /// \brief Retrieve a canonical type pointer with a different static type, + /// Retrieve a canonical type pointer with a different static type, /// upcasting or downcasting as needed. /// /// The getAs() function is typically used to try to downcast to a @@ -122,17 +122,17 @@ public: template<typename U> CanProxy<U> castAs() const; - /// \brief Overloaded arrow operator that produces a canonical type + /// Overloaded arrow operator that produces a canonical type /// proxy. CanProxy<T> operator->() const; - /// \brief Retrieve all qualifiers. + /// Retrieve all qualifiers. Qualifiers getQualifiers() const { return Stored.getLocalQualifiers(); } - /// \brief Retrieve the const/volatile/restrict qualifiers. + /// Retrieve the const/volatile/restrict qualifiers. unsigned getCVRQualifiers() const { return Stored.getLocalCVRQualifiers(); } - /// \brief Determines whether this type has any qualifiers + /// Determines whether this type has any qualifiers bool hasQualifiers() const { return Stored.hasLocalQualifiers(); } bool isConstQualified() const { @@ -147,45 +147,45 @@ public: return Stored.isLocalRestrictQualified(); } - /// \brief Determines if this canonical type is furthermore + /// Determines if this canonical type is furthermore /// canonical as a parameter. The parameter-canonicalization /// process decays arrays to pointers and drops top-level qualifiers. bool isCanonicalAsParam() const { return Stored.isCanonicalAsParam(); } - /// \brief Retrieve the unqualified form of this type. + /// Retrieve the unqualified form of this type. CanQual<T> getUnqualifiedType() const; - /// \brief Retrieves a version of this type with const applied. + /// Retrieves a version of this type with const applied. /// Note that this does not always yield a canonical type. QualType withConst() const { return Stored.withConst(); } - /// \brief Determines whether this canonical type is more qualified than + /// Determines whether this canonical type is more qualified than /// the @p Other canonical type. bool isMoreQualifiedThan(CanQual<T> Other) const { return Stored.isMoreQualifiedThan(Other.Stored); } - /// \brief Determines whether this canonical type is at least as qualified as + /// Determines whether this canonical type is at least as qualified as /// the @p Other canonical type. bool isAtLeastAsQualifiedAs(CanQual<T> Other) const { return Stored.isAtLeastAsQualifiedAs(Other.Stored); } - /// \brief If the canonical type is a reference type, returns the type that + /// If the canonical type is a reference type, returns the type that /// it refers to; otherwise, returns the type itself. CanQual<Type> getNonReferenceType() const; - /// \brief Retrieve the internal representation of this canonical type. + /// Retrieve the internal representation of this canonical type. void *getAsOpaquePtr() const { return Stored.getAsOpaquePtr(); } - /// \brief Construct a canonical type from its internal representation. + /// Construct a canonical type from its internal representation. static CanQual<T> getFromOpaquePtr(void *Ptr); - /// \brief Builds a canonical type from a QualType. + /// Builds a canonical type from a QualType. /// /// This routine is inherently unsafe, because it requires the user to /// ensure that the given type is a canonical type with the correct @@ -209,7 +209,7 @@ inline bool operator!=(CanQual<T> x, CanQual<U> y) { return x.getAsOpaquePtr() != y.getAsOpaquePtr(); } -/// \brief Represents a canonical, potentially-qualified type. +/// Represents a canonical, potentially-qualified type. using CanQualType = CanQual<Type>; inline CanQualType Type::getCanonicalTypeUnqualified() const { @@ -234,7 +234,7 @@ return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor()); \ #define LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type, Accessor) \ Type Accessor() const { return this->getTypePtr()->Accessor(); } -/// \brief Base class of all canonical proxy types, which is responsible for +/// Base class of all canonical proxy types, which is responsible for /// storing the underlying canonical type and providing basic conversions. template<typename T> class CanProxyBase { @@ -242,10 +242,10 @@ protected: CanQual<T> Stored; public: - /// \brief Retrieve the pointer to the underlying Type + /// Retrieve the pointer to the underlying Type const T *getTypePtr() const { return Stored.getTypePtr(); } - /// \brief Implicit conversion to the underlying pointer. + /// Implicit conversion to the underlying pointer. /// /// Also provides the ability to use canonical type proxies in a Boolean // context,e.g., @@ -254,7 +254,7 @@ public: /// @endcode operator const T*() const { return this->Stored.getTypePtrOrNull(); } - /// \brief Try to convert the given canonical type to a specific structural + /// Try to convert the given canonical type to a specific structural /// type. template<typename U> CanProxy<U> getAs() const { return this->Stored.template getAs<U>(); @@ -313,7 +313,7 @@ public: LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSpecifierType) LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(CXXRecordDecl*, getAsCXXRecordDecl) - /// \brief Retrieve the proxy-adaptor type. + /// Retrieve the proxy-adaptor type. /// /// This arrow operator is used when CanProxyAdaptor has been specialized /// for the given type T. In that case, we reference members of the @@ -324,7 +324,7 @@ public: } }; -/// \brief Replacable canonical proxy adaptor class that provides the link +/// Replaceable canonical proxy adaptor class that provides the link /// between a canonical type and the accessors of the type. /// /// The CanProxyAdaptor is a replaceable class template that is instantiated @@ -337,7 +337,7 @@ public: template<typename T> struct CanProxyAdaptor : CanProxyBase<T> {}; -/// \brief Canonical proxy type returned when retrieving the members of a +/// Canonical proxy type returned when retrieving the members of a /// canonical type or as the result of the @c CanQual<T>::getAs member /// function. /// @@ -347,13 +347,13 @@ struct CanProxyAdaptor : CanProxyBase<T> {}; template<typename T> class CanProxy : public CanProxyAdaptor<T> { public: - /// \brief Build a NULL proxy. + /// Build a NULL proxy. CanProxy() = default; - /// \brief Build a proxy to the given canonical type. + /// Build a proxy to the given canonical type. CanProxy(CanQual<T> Stored) { this->Stored = Stored; } - /// \brief Implicit conversion to the stored canonical type. + /// Implicit conversion to the stored canonical type. operator CanQual<T>() const { return this->Stored; } }; @@ -396,7 +396,7 @@ namespace clang { // Canonical proxy adaptors for canonical type nodes. //----------------------------------------------------------------------------// -/// \brief Iterator adaptor that turns an iterator over canonical QualTypes +/// Iterator adaptor that turns an iterator over canonical QualTypes /// into an iterator over CanQualTypes. template <typename InputIterator> struct CanTypeIterator diff --git a/include/clang/AST/Comment.h b/include/clang/AST/Comment.h index 94470cbf305f..e3a427d8aa0d 100644 --- a/include/clang/AST/Comment.h +++ b/include/clang/AST/Comment.h @@ -990,7 +990,7 @@ struct DeclInfo { /// CurrentDecl is the declaration with which the FullComment is associated. /// - /// It can be different from \c CommentDecl. It happens when we we decide + /// It can be different from \c CommentDecl. It happens when we decide /// that the comment originally attached to \c CommentDecl is fine for /// \c CurrentDecl too (for example, for a redeclaration or an overrider of /// \c CommentDecl). diff --git a/include/clang/AST/CommentBriefParser.h b/include/clang/AST/CommentBriefParser.h index be5b8eeb80c3..baa22930539e 100644 --- a/include/clang/AST/CommentBriefParser.h +++ b/include/clang/AST/CommentBriefParser.h @@ -24,7 +24,7 @@ namespace comments { /// /// Due to a variety of comment styles, it considers the following as "a brief /// description", in order of priority: -/// \li a \\brief or \\short command, +/// \li a \or \\short command, /// \li the first paragraph, /// \li a \\result or \\return or \\returns paragraph. class BriefParser { diff --git a/include/clang/AST/CommentCommandTraits.h b/include/clang/AST/CommentCommandTraits.h index 289f2fd345af..bac4e99dc7a4 100644 --- a/include/clang/AST/CommentCommandTraits.h +++ b/include/clang/AST/CommentCommandTraits.h @@ -26,7 +26,7 @@ namespace clang { namespace comments { -/// \brief Information about a single command. +/// Information about a single command. /// /// When reordering, adding or removing members please update the corresponding /// TableGen backend. @@ -57,7 +57,7 @@ struct CommandInfo { unsigned IsBlockCommand : 1; /// True if this command is introducing a brief documentation - /// paragraph (\\brief or an alias). + /// paragraph (\or an alias). unsigned IsBriefCommand : 1; /// True if this command is \\returns or an alias. @@ -77,29 +77,29 @@ struct CommandInfo { /// True if this command is \\deprecated or an alias. unsigned IsDeprecatedCommand : 1; - /// \brief True if this is a \\headerfile-like command. + /// True if this is a \\headerfile-like command. unsigned IsHeaderfileCommand : 1; /// True if we don't want to warn about this command being passed an empty /// paragraph. Meaningful only for block commands. unsigned IsEmptyParagraphAllowed : 1; - /// \brief True if this command is a verbatim-like block command. + /// True if this command is a verbatim-like block command. /// /// A verbatim-like block command eats every character (except line starting /// decorations) until matching end command is seen or comment end is hit. unsigned IsVerbatimBlockCommand : 1; - /// \brief True if this command is an end command for a verbatim-like block. + /// True if this command is an end command for a verbatim-like block. unsigned IsVerbatimBlockEndCommand : 1; - /// \brief True if this command is a verbatim line command. + /// True if this command is a verbatim line command. /// /// A verbatim-like line command eats everything until a newline is seen or /// comment end is hit. unsigned IsVerbatimLineCommand : 1; - /// \brief True if this command contains a declaration for the entity being + /// True if this command contains a declaration for the entity being /// documented. /// /// For example: @@ -108,17 +108,17 @@ struct CommandInfo { /// \endcode unsigned IsDeclarationCommand : 1; - /// \brief True if verbatim-like line command is a function declaration. + /// True if verbatim-like line command is a function declaration. unsigned IsFunctionDeclarationCommand : 1; - /// \brief True if block command is further describing a container API; such + /// True if block command is further describing a container API; such /// as \@coclass, \@classdesign, etc. unsigned IsRecordLikeDetailCommand : 1; - /// \brief True if block command is a container API; such as \@interface. + /// True if block command is a container API; such as \@interface. unsigned IsRecordLikeDeclarationCommand : 1; - /// \brief True if this command is unknown. This \c CommandInfo object was + /// True if this command is unknown. This \c CommandInfo object was /// created during parsing. unsigned IsUnknownCommand : 1; }; diff --git a/include/clang/AST/CommentLexer.h b/include/clang/AST/CommentLexer.h index 5bb075807be5..52c4eb9e309a 100644 --- a/include/clang/AST/CommentLexer.h +++ b/include/clang/AST/CommentLexer.h @@ -52,7 +52,7 @@ enum TokenKind { }; } // end namespace tok -/// \brief Comment token. +/// Comment token. class Token { friend class Lexer; friend class TextTokenRetokenizer; @@ -72,7 +72,7 @@ class Token { /// Integer value associated with a token. /// - /// If the token is a konwn command, contains command ID and TextPtr is + /// If the token is a known command, contains command ID and TextPtr is /// unused (command spelling can be found with CommandTraits). Otherwise, /// contains the length of the string that starts at TextPtr. unsigned IntVal; @@ -217,7 +217,7 @@ public: void dump(const Lexer &L, const SourceManager &SM) const; }; -/// \brief Comment lexer. +/// Comment lexer. class Lexer { private: Lexer(const Lexer &) = delete; @@ -281,6 +281,11 @@ private: /// command, including command marker. SmallString<16> VerbatimBlockEndCommandName; + /// If true, the commands, html tags, etc will be parsed and reported as + /// separate tokens inside the comment body. If false, the comment text will + /// be parsed into text and newline tokens. + bool ParseCommands; + /// Given a character reference name (e.g., "lt"), return the character that /// it stands for (e.g., "<"). StringRef resolveHTMLNamedCharacterReference(StringRef Name) const; @@ -315,12 +320,11 @@ private: /// Eat string matching regexp \code \s*\* \endcode. void skipLineStartingDecorations(); - /// Lex stuff inside comments. CommentEnd should be set correctly. + /// Lex comment text, including commands if ParseCommands is set to true. void lexCommentText(Token &T); - void setupAndLexVerbatimBlock(Token &T, - const char *TextBegin, - char Marker, const CommandInfo *Info); + void setupAndLexVerbatimBlock(Token &T, const char *TextBegin, char Marker, + const CommandInfo *Info); void lexVerbatimBlockFirstLine(Token &T); @@ -343,14 +347,13 @@ private: public: Lexer(llvm::BumpPtrAllocator &Allocator, DiagnosticsEngine &Diags, - const CommandTraits &Traits, - SourceLocation FileLoc, - const char *BufferStart, const char *BufferEnd); + const CommandTraits &Traits, SourceLocation FileLoc, + const char *BufferStart, const char *BufferEnd, + bool ParseCommands = true); void lex(Token &T); - StringRef getSpelling(const Token &Tok, - const SourceManager &SourceMgr, + StringRef getSpelling(const Token &Tok, const SourceManager &SourceMgr, bool *Invalid = nullptr) const; }; diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h index 230e52739f24..0e94c33970ca 100644 --- a/include/clang/AST/CommentSema.h +++ b/include/clang/AST/CommentSema.h @@ -55,7 +55,7 @@ class Sema { /// Contains a valid value if \c DeclInfo->IsFilled is true. llvm::StringMap<TParamCommandComment *> TemplateParameterDocs; - /// AST node for the \\brief command and its aliases. + /// AST node for the \command and its aliases. const BlockCommandComment *BriefCommand; /// AST node for the \\headerfile command. @@ -187,7 +187,7 @@ public: void checkReturnsCommand(const BlockCommandComment *Command); /// Emit diagnostics about duplicate block commands that should be - /// used only once per comment, e.g., \\brief and \\returns. + /// used only once per comment, e.g., \and \\returns. void checkBlockCommandDuplicate(const BlockCommandComment *Command); void checkDeprecatedCommand(const BlockCommandComment *Comment); diff --git a/include/clang/AST/ComparisonCategories.h b/include/clang/AST/ComparisonCategories.h new file mode 100644 index 000000000000..23bfd708e7eb --- /dev/null +++ b/include/clang/AST/ComparisonCategories.h @@ -0,0 +1,243 @@ +//===- ComparisonCategories.h - Three Way Comparison Data -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the Comparison Category enum and data types, which +// store the types and expressions needed to support operator<=> +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_COMPARISONCATEGORIES_H +#define LLVM_CLANG_AST_COMPARISONCATEGORIES_H + +#include "clang/Basic/LLVM.h" +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/DenseMap.h" +#include <array> +#include <cassert> + +namespace llvm { + class StringRef; + class APSInt; +} + +namespace clang { + +class ASTContext; +class VarDecl; +class CXXRecordDecl; +class Sema; +class QualType; +class NamespaceDecl; + +/// An enumeration representing the different comparison categories +/// types. +/// +/// C++2a [cmp.categories.pre] The types weak_equality, strong_equality, +/// partial_ordering, weak_ordering, and strong_ordering are collectively +/// termed the comparison category types. +enum class ComparisonCategoryType : unsigned char { + WeakEquality, + StrongEquality, + PartialOrdering, + WeakOrdering, + StrongOrdering, + First = WeakEquality, + Last = StrongOrdering +}; + +/// An enumeration representing the possible results of a three-way +/// comparison. These values map onto instances of comparison category types +/// defined in the standard library. e.g. 'std::strong_ordering::less'. +enum class ComparisonCategoryResult : unsigned char { + Equal, + Equivalent, + Nonequivalent, + Nonequal, + Less, + Greater, + Unordered, + Last = Unordered +}; + +class ComparisonCategoryInfo { + friend class ComparisonCategories; + friend class Sema; + +public: + ComparisonCategoryInfo(const ASTContext &Ctx, CXXRecordDecl *RD, + ComparisonCategoryType Kind) + : Ctx(Ctx), Record(RD), Kind(Kind) {} + + struct ValueInfo { + ComparisonCategoryResult Kind; + VarDecl *VD; + + ValueInfo(ComparisonCategoryResult Kind, VarDecl *VD) + : Kind(Kind), VD(VD) {} + + /// True iff we've successfully evaluated the variable as a constant + /// expression and extracted its integer value. + bool hasValidIntValue() const; + + /// Get the constant integer value used by this variable to represent + /// the comparison category result type. + llvm::APSInt getIntValue() const; + }; +private: + const ASTContext &Ctx; + + /// A map containing the comparison category result decls from the + /// standard library. The key is a value of ComparisonCategoryResult. + mutable llvm::SmallVector< + ValueInfo, static_cast<unsigned>(ComparisonCategoryResult::Last) + 1> + Objects; + + /// Lookup the ValueInfo struct for the specified ValueKind. If the + /// VarDecl for the value cannot be found, nullptr is returned. + /// + /// If the ValueInfo does not have a valid integer value the variable + /// is evaluated as a constant expression to determine that value. + ValueInfo *lookupValueInfo(ComparisonCategoryResult ValueKind) const; + +public: + /// The declaration for the comparison category type from the + /// standard library. + // FIXME: Make this const + CXXRecordDecl *Record = nullptr; + + /// The Kind of the comparison category type + ComparisonCategoryType Kind; + +public: + QualType getType() const; + + const ValueInfo *getValueInfo(ComparisonCategoryResult ValueKind) const { + ValueInfo *Info = lookupValueInfo(ValueKind); + assert(Info && + "comparison category does not contain the specified result kind"); + assert(Info->hasValidIntValue() && + "couldn't determine the integer constant for this value"); + return Info; + } + + /// True iff the comparison category is an equality comparison. + bool isEquality() const { return !isOrdered(); } + + /// True iff the comparison category is a relational comparison. + bool isOrdered() const { + using CCK = ComparisonCategoryType; + return Kind == CCK::PartialOrdering || Kind == CCK::WeakOrdering || + Kind == CCK::StrongOrdering; + } + + /// True iff the comparison is "strong". i.e. it checks equality and + /// not equivalence. + bool isStrong() const { + using CCK = ComparisonCategoryType; + return Kind == CCK::StrongEquality || Kind == CCK::StrongOrdering; + } + + /// True iff the comparison is not totally ordered. + bool isPartial() const { + using CCK = ComparisonCategoryType; + return Kind == CCK::PartialOrdering; + } + + /// Converts the specified result kind into the the correct result kind + /// for this category. Specifically it lowers strong equality results to + /// weak equivalence if needed. + ComparisonCategoryResult makeWeakResult(ComparisonCategoryResult Res) const { + using CCR = ComparisonCategoryResult; + if (!isStrong()) { + if (Res == CCR::Equal) + return CCR::Equivalent; + if (Res == CCR::Nonequal) + return CCR::Nonequivalent; + } + return Res; + } + + const ValueInfo *getEqualOrEquiv() const { + return getValueInfo(makeWeakResult(ComparisonCategoryResult::Equal)); + } + const ValueInfo *getNonequalOrNonequiv() const { + assert(isEquality()); + return getValueInfo(makeWeakResult(ComparisonCategoryResult::Nonequal)); + } + const ValueInfo *getLess() const { + assert(isOrdered()); + return getValueInfo(ComparisonCategoryResult::Less); + } + const ValueInfo *getGreater() const { + assert(isOrdered()); + return getValueInfo(ComparisonCategoryResult::Greater); + } + const ValueInfo *getUnordered() const { + assert(isPartial()); + return getValueInfo(ComparisonCategoryResult::Unordered); + } +}; + +class ComparisonCategories { +public: + static StringRef getCategoryString(ComparisonCategoryType Kind); + static StringRef getResultString(ComparisonCategoryResult Kind); + + /// Return the list of results which are valid for the specified + /// comparison category type. + static std::vector<ComparisonCategoryResult> + getPossibleResultsForType(ComparisonCategoryType Type); + + /// Return the comparison category information for the category + /// specified by 'Kind'. + const ComparisonCategoryInfo &getInfo(ComparisonCategoryType Kind) const { + const ComparisonCategoryInfo *Result = lookupInfo(Kind); + assert(Result != nullptr && + "information for specified comparison category has not been built"); + return *Result; + } + + /// Return the comparison category information as specified by + /// `getCategoryForType(Ty)`. If the information is not already cached, + /// the declaration is looked up and a cache entry is created. + /// NOTE: Lookup is expected to succeed. Use lookupInfo if failure is + /// possible. + const ComparisonCategoryInfo &getInfoForType(QualType Ty) const; + +public: + /// Return the cached comparison category information for the + /// specified 'Kind'. If no cache entry is present the comparison category + /// type is looked up. If lookup fails nullptr is returned. Otherwise, a + /// new cache entry is created and returned + const ComparisonCategoryInfo *lookupInfo(ComparisonCategoryType Kind) const; + + ComparisonCategoryInfo *lookupInfo(ComparisonCategoryType Kind) { + const auto &This = *this; + return const_cast<ComparisonCategoryInfo *>(This.lookupInfo(Kind)); + } + +private: + const ComparisonCategoryInfo *lookupInfoForType(QualType Ty) const; + +private: + friend class ASTContext; + + explicit ComparisonCategories(const ASTContext &Ctx) : Ctx(Ctx) {} + + const ASTContext &Ctx; + + /// A map from the ComparisonCategoryType (represented as 'char') to the + /// cached information for the specified category. + mutable llvm::DenseMap<char, ComparisonCategoryInfo> Data; + mutable NamespaceDecl *StdNS = nullptr; +}; + +} // namespace clang + +#endif diff --git a/include/clang/AST/DataCollection.h b/include/clang/AST/DataCollection.h index 229ac2bd0f22..8b2a8345d941 100644 --- a/include/clang/AST/DataCollection.h +++ b/include/clang/AST/DataCollection.h @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// /// \file -/// \brief This file declares helper methods for collecting data from AST nodes. +/// This file declares helper methods for collecting data from AST nodes. /// /// To collect data from Stmt nodes, subclass ConstStmtVisitor and include /// StmtDataCollectors.inc after defining the macros that you need. This /// provides data collection implementations for most Stmt kinds. Note -/// that that code requires some conditions to be met: +/// that the code requires some conditions to be met: /// /// - There must be a method addData(const T &Data) that accepts strings, /// integral types as well as QualType. All data is forwarded using diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 04a832e552a4..dde94599636f 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -76,14 +76,14 @@ class TypeLoc; class UnresolvedSetImpl; class VarTemplateDecl; -/// \brief A container of type source information. +/// A container of type source information. /// /// A client can read the relevant info using TypeLoc wrappers, e.g: /// @code /// TypeLoc TL = TypeSourceInfo->getTypeLoc(); /// TL.getStartLoc().print(OS, SrcMgr); /// @endcode -class TypeSourceInfo { +class alignas(8) TypeSourceInfo { // Contains a memory block after the class, used for type source information, // allocated by ASTContext. friend class ASTContext; @@ -93,17 +93,17 @@ class TypeSourceInfo { TypeSourceInfo(QualType ty) : Ty(ty) {} public: - /// \brief Return the type wrapped by this type source info. + /// Return the type wrapped by this type source info. QualType getType() const { return Ty; } - /// \brief Return the TypeLoc wrapper for the type source info. + /// Return the TypeLoc wrapper for the type source info. TypeLoc getTypeLoc() const; // implemented in TypeLoc.h - /// \brief Override the type stored in this TypeSourceInfo. Use with caution! + /// Override the type stored in this TypeSourceInfo. Use with caution! void overrideType(QualType T) { Ty = T; } }; -/// TranslationUnitDecl - The top declaration context. +/// The top declaration context. class TranslationUnitDecl : public Decl, public DeclContext { ASTContext &Ctx; @@ -134,7 +134,7 @@ public: } }; -/// \brief Represents a `#pragma comment` line. Always a child of +/// Represents a `#pragma comment` line. Always a child of /// TranslationUnitDecl. class PragmaCommentDecl final : public Decl, @@ -168,7 +168,7 @@ public: static bool classofKind(Kind K) { return K == PragmaComment; } }; -/// \brief Represents a `#pragma detect_mismatch` line. Always a child of +/// Represents a `#pragma detect_mismatch` line. Always a child of /// TranslationUnitDecl. class PragmaDetectMismatchDecl final : public Decl, @@ -201,7 +201,7 @@ public: static bool classofKind(Kind K) { return K == PragmaDetectMismatch; } }; -/// \brief Declaration context for names declared as extern "C" in C++. This +/// Declaration context for names declared as extern "C" in C++. This /// is neither the semantic nor lexical context for such declarations, but is /// used to check for conflicts with other extern "C" declarations. Example: /// @@ -240,10 +240,13 @@ public: } }; -/// NamedDecl - This represents a decl with a name. Many decls have names such +/// This represents a decl that may have a name. Many decls have names such /// as ObjCMethodDecl, but not \@class, etc. +/// +/// Note that not every NamedDecl is actually named (e.g., a struct might +/// be anonymous), and not every name is an identifier. class NamedDecl : public Decl { - /// Name - The name of this declaration, which is typically a normal + /// The name of this declaration, which is typically a normal /// identifier but may also be a special kind of name (C++ /// constructor, Objective-C selector, etc.) DeclarationName Name; @@ -258,13 +261,15 @@ protected: : Decl(DK, DC, L), Name(N) {} public: - /// getIdentifier - Get the identifier that names this declaration, - /// if there is one. This will return NULL if this declaration has - /// no name (e.g., for an unnamed class) or if the name is a special - /// name (C++ constructor, Objective-C selector, etc.). + /// Get the identifier that names this declaration, if there is one. + /// + /// This will return NULL if this declaration has no name (e.g., for + /// an unnamed class) or if the name is a special name (C++ constructor, + /// Objective-C selector, etc.). IdentifierInfo *getIdentifier() const { return Name.getAsIdentifierInfo(); } - /// getName - Get the name of identifier for this declaration as a StringRef. + /// Get the name of identifier for this declaration as a StringRef. + /// /// This requires that the declaration have a name and that it be a simple /// identifier. StringRef getName() const { @@ -272,11 +277,12 @@ public: return getIdentifier() ? getIdentifier()->getName() : ""; } - /// getNameAsString - Get a human-readable name for the declaration, even if - /// it is one of the special kinds of names (C++ constructor, Objective-C - /// selector, etc). Creating this name requires expensive string - /// manipulation, so it should be called only when performance doesn't matter. - /// For simple declarations, getNameAsCString() should suffice. + /// Get a human-readable name for the declaration, even if it is one of the + /// special kinds of names (C++ constructor, Objective-C selector, etc). + /// + /// Creating this name requires expensive string manipulation, so it should + /// be called only when performance doesn't matter. For simple declarations, + /// getNameAsCString() should suffice. // // FIXME: This function should be renamed to indicate that it is not just an // alternate form of getName(), and clients should move as appropriate. @@ -286,17 +292,19 @@ public: virtual void printName(raw_ostream &os) const; - /// getDeclName - Get the actual, stored name of the declaration, - /// which may be a special name. + /// Get the actual, stored name of the declaration, which may be a special + /// name. DeclarationName getDeclName() const { return Name; } - /// \brief Set the name of this declaration. + /// Set the name of this declaration. void setDeclName(DeclarationName N) { Name = N; } - /// printQualifiedName - Returns human-readable qualified name for - /// declaration, like A::B::i, for i being member of namespace A::B. - /// If declaration is not member of context which can be named (record, - /// namespace), it will return same result as printName(). + /// Returns a human-readable qualified name for this declaration, like + /// A::B::i, for i being member of namespace A::B. + /// + /// If the declaration is not a member of context which can be named (record, + /// namespace), it will return the same result as printName(). + /// /// Creating this name is expensive, so it should be called only when /// performance doesn't matter. void printQualifiedName(raw_ostream &OS) const; @@ -315,25 +323,25 @@ public: const PrintingPolicy &Policy, bool Qualified) const; - /// \brief Determine whether this declaration, if - /// known to be well-formed within its context, will replace the - /// declaration OldD if introduced into scope. A declaration will - /// replace another declaration if, for example, it is a - /// redeclaration of the same variable or function, but not if it is - /// a declaration of a different kind (function vs. class) or an - /// overloaded function. + /// Determine whether this declaration, if known to be well-formed within + /// its context, will replace the declaration OldD if introduced into scope. + /// + /// A declaration will replace another declaration if, for example, it is + /// a redeclaration of the same variable or function, but not if it is a + /// declaration of a different kind (function vs. class) or an overloaded + /// function. /// /// \param IsKnownNewer \c true if this declaration is known to be newer /// than \p OldD (for instance, if this declaration is newly-created). bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer = true) const; - /// \brief Determine whether this declaration has linkage. + /// Determine whether this declaration has linkage. bool hasLinkage() const; using Decl::isModulePrivate; using Decl::setModulePrivate; - /// \brief Determine whether this declaration is a C++ class member. + /// Determine whether this declaration is a C++ class member. bool isCXXClassMember() const { const DeclContext *DC = getDeclContext(); @@ -346,23 +354,24 @@ public: return DC->isRecord(); } - /// \brief Determine whether the given declaration is an instance member of + /// Determine whether the given declaration is an instance member of /// a C++ class. bool isCXXInstanceMember() const; - /// \brief Determine what kind of linkage this entity has. + /// Determine what kind of linkage this entity has. + /// /// This is not the linkage as defined by the standard or the codegen notion /// of linkage. It is just an implementation detail that is used to compute /// those. Linkage getLinkageInternal() const; - /// \brief Get the linkage from a semantic point of view. Entities in + /// Get the linkage from a semantic point of view. Entities in /// anonymous namespaces are external (in c++98). Linkage getFormalLinkage() const { return clang::getFormalLinkage(getLinkageInternal()); } - /// \brief True if this decl has external linkage. + /// True if this decl has external linkage. bool hasExternalFormalLinkage() const { return isExternalFormalLinkage(getLinkageInternal()); } @@ -377,12 +386,12 @@ public: return isExternallyVisible() && !getOwningModuleForLinkage(); } - /// \brief Determines the visibility of this entity. + /// Determines the visibility of this entity. Visibility getVisibility() const { return getLinkageAndVisibility().getVisibility(); } - /// \brief Determines the linkage and visibility of this entity. + /// Determines the linkage and visibility of this entity. LinkageInfo getLinkageAndVisibility() const; /// Kinds of explicit visibility. @@ -398,16 +407,16 @@ public: VisibilityForValue }; - /// \brief If visibility was explicitly specified for this + /// If visibility was explicitly specified for this /// declaration, return that visibility. Optional<Visibility> getExplicitVisibility(ExplicitVisibilityKind kind) const; - /// \brief True if the computed linkage is valid. Used for consistency + /// True if the computed linkage is valid. Used for consistency /// checking. Should always return true. bool isLinkageValid() const; - /// \brief True if something has required us to compute the linkage + /// True if something has required us to compute the linkage /// of this declaration. /// /// Language features which can retroactively change linkage (like a @@ -417,7 +426,7 @@ public: return hasCachedLinkage(); } - /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for + /// Looks through UsingDecls and ObjCCompatibleAliasDecls for /// the underlying named decl. NamedDecl *getUnderlyingDecl() { // Fast-path the common case. @@ -451,7 +460,7 @@ inline raw_ostream &operator<<(raw_ostream &OS, const NamedDecl &ND) { return OS; } -/// LabelDecl - Represents the declaration of a label. Labels also have a +/// Represents the declaration of a label. Labels also have a /// corresponding LabelStmt, which indicates the position that the label was /// defined at. For normal labels, the location of the decl is the same as the /// location of the statement. For GNU local labels (__label__), the decl @@ -461,7 +470,7 @@ class LabelDecl : public NamedDecl { StringRef MSAsmName; bool MSAsmNameResolved = false; - /// LocStart - For normal labels, this is the same as the main declaration + /// For normal labels, this is the same as the main declaration /// label, i.e., the location of the identifier; for GNU local labels, /// this is the location of the __label__ keyword. SourceLocation LocStart; @@ -501,18 +510,18 @@ public: static bool classofKind(Kind K) { return K == Label; } }; -/// NamespaceDecl - Represent a C++ namespace. +/// Represent a C++ namespace. class NamespaceDecl : public NamedDecl, public DeclContext, public Redeclarable<NamespaceDecl> { - /// LocStart - The starting location of the source range, pointing + /// The starting location of the source range, pointing /// to either the namespace or the inline keyword. SourceLocation LocStart; - /// RBraceLoc - The ending location of the source range. + /// The ending location of the source range. SourceLocation RBraceLoc; - /// \brief A pointer to either the anonymous namespace that lives just inside + /// 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 /// boolean value indicating whether this is an inline namespace. @@ -549,7 +558,7 @@ public: using redeclarable_base::getMostRecentDecl; using redeclarable_base::isFirstDecl; - /// \brief Returns true if this is an anonymous namespace declaration. + /// Returns true if this is an anonymous namespace declaration. /// /// For example: /// \code @@ -562,28 +571,28 @@ public: return !getIdentifier(); } - /// \brief Returns true if this is an inline namespace declaration. + /// Returns true if this is an inline namespace declaration. bool isInline() const { return AnonOrFirstNamespaceAndInline.getInt(); } - /// \brief Set whether this is an inline namespace declaration. + /// Set whether this is an inline namespace declaration. void setInline(bool Inline) { AnonOrFirstNamespaceAndInline.setInt(Inline); } - /// \brief Get the original (first) namespace declaration. + /// Get the original (first) namespace declaration. NamespaceDecl *getOriginalNamespace(); - /// \brief Get the original (first) namespace declaration. + /// Get the original (first) namespace declaration. const NamespaceDecl *getOriginalNamespace() const; - /// \brief Return true if this declaration is an original (first) declaration + /// Return true if this declaration is an original (first) declaration /// of the namespace. This is false for non-original (subsequent) namespace /// declarations and anonymous namespaces. bool isOriginalNamespace() const; - /// \brief Retrieve the anonymous namespace nested inside this namespace, + /// Retrieve the anonymous namespace nested inside this namespace, /// if any. NamespaceDecl *getAnonymousNamespace() const { return getOriginalNamespace()->AnonOrFirstNamespaceAndInline.getPointer(); @@ -621,7 +630,7 @@ public: } }; -/// ValueDecl - Represent the declaration of a variable (in which case it is +/// Represent the declaration of a variable (in which case it is /// an lvalue) a function (in which case it is a function designator) or /// an enum constant. class ValueDecl : public NamedDecl { @@ -638,7 +647,7 @@ public: QualType getType() const { return DeclType; } void setType(QualType newType) { DeclType = newType; } - /// \brief Determine whether this symbol is weakly-imported, + /// Determine whether this symbol is weakly-imported, /// or declared with the weak or weak-ref attr. bool isWeak() const; @@ -647,18 +656,18 @@ public: static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; } }; -/// QualifierInfo - A struct with extended info about a syntactic +/// A struct with extended info about a syntactic /// name qualifier, to be used for the case of out-of-line declarations. struct QualifierInfo { NestedNameSpecifierLoc QualifierLoc; - /// NumTemplParamLists - The number of "outer" template parameter lists. + /// The number of "outer" template parameter lists. /// The count includes all of the template parameter lists that were matched /// against the template-ids occurring into the NNS and possibly (in the /// case of an explicit specialization) a final "template <>". unsigned NumTemplParamLists = 0; - /// TemplParamLists - A new-allocated array of size NumTemplParamLists, + /// A new-allocated array of size NumTemplParamLists, /// containing pointers to the "outer" template parameter lists. /// It includes all of the template parameter lists that were matched /// against the template-ids occurring into the NNS and possibly (in the @@ -669,13 +678,12 @@ struct QualifierInfo { QualifierInfo(const QualifierInfo &) = delete; QualifierInfo& operator=(const QualifierInfo &) = delete; - /// setTemplateParameterListsInfo - Sets info about "outer" template - /// parameter lists. + /// Sets info about "outer" template parameter lists. void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef<TemplateParameterList *> TPLists); }; -/// \brief Represents a ValueDecl that came out of a declarator. +/// Represents a ValueDecl that came out of a declarator. /// Contains type source information through TypeSourceInfo. class DeclaratorDecl : public ValueDecl { // A struct representing both a TInfo and a syntactic qualifier, @@ -686,7 +694,7 @@ class DeclaratorDecl : public ValueDecl { llvm::PointerUnion<TypeSourceInfo *, ExtInfo *> DeclInfo; - /// InnerLocStart - The start of the source range for this declaration, + /// The start of the source range for this declaration, /// ignoring outer template declarations. SourceLocation InnerLocStart; @@ -717,13 +725,12 @@ public: DeclInfo = TI; } - /// getInnerLocStart - Return SourceLocation representing start of source - /// range ignoring outer template declarations. + /// Return start of source range ignoring outer template declarations. SourceLocation getInnerLocStart() const { return InnerLocStart; } void setInnerLocStart(SourceLocation L) { InnerLocStart = L; } - /// getOuterLocStart - Return SourceLocation representing start of source - /// range taking into account any outer template declarations. + /// Return start of source range taking into account any outer template + /// declarations. SourceLocation getOuterLocStart() const; SourceRange getSourceRange() const override LLVM_READONLY; @@ -732,14 +739,14 @@ public: return getOuterLocStart(); } - /// \brief Retrieve the nested-name-specifier that qualifies the name of this + /// Retrieve the nested-name-specifier that qualifies the name of this /// declaration, if it was present in the source. NestedNameSpecifier *getQualifier() const { return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() : nullptr; } - /// \brief Retrieve the nested-name-specifier (with source-location + /// Retrieve the nested-name-specifier (with source-location /// information) that qualifies the name of this declaration, if it was /// present in the source. NestedNameSpecifierLoc getQualifierLoc() const { @@ -770,25 +777,25 @@ public: } }; -/// \brief Structure used to store a statement, the constant value to +/// Structure used to store a statement, the constant value to /// which it was evaluated (if any), and whether or not the statement /// is an integral constant expression (if known). struct EvaluatedStmt { - /// \brief Whether this statement was already evaluated. + /// Whether this statement was already evaluated. bool WasEvaluated : 1; - /// \brief Whether this statement is being evaluated. + /// Whether this statement is being evaluated. bool IsEvaluating : 1; - /// \brief Whether we already checked whether this statement was an + /// Whether we already checked whether this statement was an /// integral constant expression. bool CheckedICE : 1; - /// \brief Whether we are checking whether this statement is an + /// Whether we are checking whether this statement is an /// integral constant expression. bool CheckingICE : 1; - /// \brief Whether this statement is an integral constant expression, + /// Whether this statement is an integral constant expression, /// or in C++11, whether the statement is a constant expression. Only /// valid if CheckedICE is true. bool IsICE : 1; @@ -801,11 +808,10 @@ struct EvaluatedStmt { }; -/// VarDecl - An instance of this class is created to represent a variable -/// declaration or definition. +/// Represents a variable declaration or definition. class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> { public: - /// \brief Initialization styles. + /// Initialization styles. enum InitializationStyle { /// C-style initialization with assignment CInit, @@ -817,7 +823,7 @@ public: ListInit }; - /// \brief Kinds of thread-local storage. + /// Kinds of thread-local storage. enum TLSKind { /// Not a TLS variable. TLS_None, @@ -829,8 +835,7 @@ public: TLS_Dynamic }; - /// getStorageClassSpecifierString - Return the string used to - /// specify the storage class \p SC. + /// Return the string used to specify the storage class \p SC. /// /// It is illegal to call this function with SC == None. static const char *getStorageClassSpecifierString(StorageClass SC); @@ -845,7 +850,7 @@ protected: // allocated in trailing space when necessary. using InitType = llvm::PointerUnion<Stmt *, EvaluatedStmt *>; - /// \brief The initializer for this variable or, for a ParmVarDecl, the + /// The initializer for this variable or, for a ParmVarDecl, the /// C++ default argument. mutable InitType Init; @@ -915,41 +920,44 @@ protected: unsigned : NumVarDeclBits; // FIXME: We need something similar to CXXRecordDecl::DefinitionData. - /// \brief Whether this variable is a definition which was demoted due to + /// Whether this variable is a definition which was demoted due to /// module merge. unsigned IsThisDeclarationADemotedDefinition : 1; - /// \brief Whether this variable is the exception variable in a C++ catch + /// Whether this variable is the exception variable in a C++ catch /// or an Objective-C @catch statement. unsigned ExceptionVar : 1; - /// \brief Whether this local variable could be allocated in the return + /// Whether this local variable could be allocated in the return /// slot of its function, enabling the named return value optimization /// (NRVO). unsigned NRVOVariable : 1; - /// \brief Whether this variable is the for-range-declaration in a C++0x + /// Whether this variable is the for-range-declaration in a C++0x /// for-range statement. unsigned CXXForRangeDecl : 1; - /// \brief Whether this variable is an ARC pseudo-__strong + /// Whether this variable is the for-in loop declaration in Objective-C. + unsigned ObjCForDecl : 1; + + /// Whether this variable is an ARC pseudo-__strong /// variable; see isARCPseudoStrong() for details. unsigned ARCPseudoStrong : 1; - /// \brief Whether this variable is (C++1z) inline. + /// Whether this variable is (C++1z) inline. unsigned IsInline : 1; - /// \brief Whether this variable has (C++1z) inline explicitly specified. + /// Whether this variable has (C++1z) inline explicitly specified. unsigned IsInlineSpecified : 1; - /// \brief Whether this variable is (C++0x) constexpr. + /// Whether this variable is (C++0x) constexpr. unsigned IsConstexpr : 1; - /// \brief Whether this variable is the implicit variable for a lambda + /// Whether this variable is the implicit variable for a lambda /// init-capture. unsigned IsInitCapture : 1; - /// \brief Whether this local extern variable's previous declaration was + /// Whether this local extern variable's previous declaration was /// declared in the same block scope. This controls whether we should merge /// the type of this declaration with its previous declaration. unsigned PreviousDeclInSameBlockScope : 1; @@ -1004,7 +1012,7 @@ public: SourceRange getSourceRange() const override LLVM_READONLY; - /// \brief Returns the storage class as written in the source. For the + /// Returns the storage class as written in the source. For the /// computed linkage of symbol, see getLinkage. StorageClass getStorageClass() const { return (StorageClass) VarDeclBits.SClass; @@ -1020,8 +1028,8 @@ public: } TLSKind getTLSKind() const; - /// hasLocalStorage - Returns true if a variable with function scope - /// is a non-static local variable. + /// Returns true if a variable with function scope is a non-static local + /// variable. bool hasLocalStorage() const { if (getStorageClass() == SC_None) { // OpenCL v1.2 s6.5.3: The __constant or constant address space name is @@ -1044,8 +1052,8 @@ public: return getStorageClass() >= SC_Auto; } - /// isStaticLocal - Returns true if a variable with function scope is a - /// static local variable. + /// Returns true if a variable with function scope is a static local + /// variable. bool isStaticLocal() const { return (getStorageClass() == SC_Static || // C++11 [dcl.stc]p4 @@ -1053,43 +1061,42 @@ public: && !isFileVarDecl(); } - /// \brief Returns true if a variable has extern or __private_extern__ + /// Returns true if a variable has extern or __private_extern__ /// storage. bool hasExternalStorage() const { return getStorageClass() == SC_Extern || getStorageClass() == SC_PrivateExtern; } - /// \brief Returns true for all variables that do not have local storage. + /// Returns true for all variables that do not have local storage. /// /// This includes all global variables as well as static variables declared /// within a function. bool hasGlobalStorage() const { return !hasLocalStorage(); } - /// \brief Get the storage duration of this variable, per C++ [basic.stc]. + /// Get the storage duration of this variable, per C++ [basic.stc]. StorageDuration getStorageDuration() const { return hasLocalStorage() ? SD_Automatic : getTSCSpec() ? SD_Thread : SD_Static; } - /// \brief Compute the language linkage. + /// Compute the language linkage. LanguageLinkage getLanguageLinkage() const; - /// \brief Determines whether this variable is a variable with - /// external, C linkage. + /// Determines whether this variable is a variable with external, C linkage. bool isExternC() const; - /// \brief Determines whether this variable's context is, or is nested within, + /// Determines whether this variable's context is, or is nested within, /// a C++ extern "C" linkage spec. bool isInExternCContext() const; - /// \brief Determines whether this variable's context is, or is nested within, + /// Determines whether this variable's context is, or is nested within, /// a C++ extern "C++" linkage spec. bool isInExternCXXContext() const; - /// isLocalVarDecl - Returns true for local variable declarations - /// other than parameters. Note that this includes static variables - /// inside of functions. It also includes variables inside blocks. + /// Returns true for local variable declarations other than parameters. + /// Note that this includes static variables inside of functions. It also + /// includes variables inside blocks. /// /// void foo() { int x; static int y; extern int z; } bool isLocalVarDecl() const { @@ -1100,13 +1107,12 @@ public: return false; } - /// \brief Similar to isLocalVarDecl but also includes parameters. + /// Similar to isLocalVarDecl but also includes parameters. bool isLocalVarDeclOrParm() const { return isLocalVarDecl() || getKind() == Decl::ParmVar; } - /// isFunctionOrMethodVarDecl - Similar to isLocalVarDecl, but - /// excludes variables declared in blocks. + /// Similar to isLocalVarDecl, but excludes variables declared in blocks. bool isFunctionOrMethodVarDecl() const { if (getKind() != Decl::Var && getKind() != Decl::Decomposition) return false; @@ -1114,7 +1120,7 @@ public: return DC->isFunctionOrMethod() && DC->getDeclKind() != Decl::Block; } - /// \brief Determines whether this is a static data member. + /// Determines whether this is a static data member. /// /// This will only be true in C++, and applies to, e.g., the /// variable 'x' in: @@ -1144,7 +1150,7 @@ public: Definition }; - /// \brief Check whether this declaration is a definition. If this could be + /// Check whether this declaration is a definition. If this could be /// a tentative definition (in C), don't check whether there's an overriding /// definition. DefinitionKind isThisDeclarationADefinition(ASTContext &) const; @@ -1152,21 +1158,20 @@ public: return isThisDeclarationADefinition(getASTContext()); } - /// \brief Check whether this variable is defined in this - /// translation unit. + /// Check whether this variable is defined in this translation unit. DefinitionKind hasDefinition(ASTContext &) const; DefinitionKind hasDefinition() const { return hasDefinition(getASTContext()); } - /// \brief Get the tentative definition that acts as the real definition in - /// a TU. Returns null if there is a proper definition available. + /// Get the tentative definition that acts as the real definition in a TU. + /// Returns null if there is a proper definition available. VarDecl *getActingDefinition(); const VarDecl *getActingDefinition() const { return const_cast<VarDecl*>(this)->getActingDefinition(); } - /// \brief Get the real (not just tentative) definition for this declaration. + /// Get the real (not just tentative) definition for this declaration. VarDecl *getDefinition(ASTContext &); const VarDecl *getDefinition(ASTContext &C) const { return const_cast<VarDecl*>(this)->getDefinition(C); @@ -1178,11 +1183,11 @@ public: return const_cast<VarDecl*>(this)->getDefinition(); } - /// \brief Determine whether this is or was instantiated from an out-of-line + /// Determine whether this is or was instantiated from an out-of-line /// definition of a static data member. bool isOutOfLine() const override; - /// isFileVarDecl - Returns true for file scoped variable declaration. + /// Returns true for file scoped variable declaration. bool isFileVarDecl() const { Kind K = getKind(); if (K == ParmVar || K == ImplicitParam) @@ -1197,14 +1202,14 @@ public: return false; } - /// getAnyInitializer - Get the initializer for this variable, no matter which + /// Get the initializer for this variable, no matter which /// declaration it is attached to. const Expr *getAnyInitializer() const { const VarDecl *D; return getAnyInitializer(D); } - /// getAnyInitializer - Get the initializer for this variable, no matter which + /// Get the initializer for this variable, no matter which /// declaration it is attached to. Also get that declaration. const Expr *getAnyInitializer(const VarDecl *&D) const; @@ -1214,12 +1219,12 @@ public: } Expr *getInit(); - /// \brief Retrieve the address of the initializer expression. + /// Retrieve the address of the initializer expression. Stmt **getInitAddress(); void setInit(Expr *I); - /// \brief Determine whether this variable's value can be used in a + /// Determine whether this variable's value can be used in a /// constant expression, according to the relevant language standard. /// This only checks properties of the declaration, and does not check /// whether the initializer is in fact a constant expression. @@ -1227,30 +1232,30 @@ public: EvaluatedStmt *ensureEvaluatedStmt() const; - /// \brief Attempt to evaluate the value of the initializer attached to this + /// Attempt to evaluate the value of the initializer attached to this /// declaration, and produce notes explaining why it cannot be evaluated or is /// not a constant expression. Returns a pointer to the value if evaluation /// succeeded, 0 otherwise. APValue *evaluateValue() const; APValue *evaluateValue(SmallVectorImpl<PartialDiagnosticAt> &Notes) const; - /// \brief Return the already-evaluated value of this variable's + /// Return the already-evaluated value of this variable's /// initializer, or NULL if the value is not yet known. Returns pointer /// to untyped APValue if the value could not be evaluated. APValue *getEvaluatedValue() const; - /// \brief Determines whether it is already known whether the + /// Determines whether it is already known whether the /// initializer is an integral constant expression or not. bool isInitKnownICE() const; - /// \brief Determines whether the initializer is an integral constant + /// Determines whether the initializer is an integral constant /// expression, or in C++11, whether the initializer is a constant /// expression. /// /// \pre isInitKnownICE() bool isInitICE() const; - /// \brief Determine whether the value of the initializer attached to this + /// Determine whether the value of the initializer attached to this /// declaration is an integral constant expression. bool checkInitIsICE() const; @@ -1258,7 +1263,7 @@ public: VarDeclBits.InitStyle = Style; } - /// \brief The style of initialization for this declaration. + /// The style of initialization for this declaration. /// /// C-style initialization is "int x = 1;". Call-style initialization is /// a C++98 direct-initializer, e.g. "int x(1);". The Init expression will be @@ -1272,18 +1277,18 @@ public: return static_cast<InitializationStyle>(VarDeclBits.InitStyle); } - /// \brief Whether the initializer is a direct-initializer (list or call). + /// Whether the initializer is a direct-initializer (list or call). bool isDirectInit() const { return getInitStyle() != CInit; } - /// \brief If this definition should pretend to be a declaration. + /// If this definition should pretend to be a declaration. bool isThisDeclarationADemotedDefinition() const { return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsThisDeclarationADemotedDefinition; } - /// \brief This is a definition which should be demoted to a declaration. + /// This is a definition which should be demoted to a declaration. /// /// In some cases (mostly module merging) we can end up with two visible /// definitions one of which needs to be demoted to a declaration to keep @@ -1294,7 +1299,7 @@ public: NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1; } - /// \brief Determine whether this variable is the exception variable in a + /// Determine whether this variable is the exception variable in a /// C++ catch statememt or an Objective-C \@catch statement. bool isExceptionVariable() const { return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.ExceptionVar; @@ -1304,7 +1309,7 @@ public: NonParmVarDeclBits.ExceptionVar = EV; } - /// \brief Determine whether this local variable can be used with the named + /// Determine whether this local variable can be used with the named /// return value optimization (NRVO). /// /// The named return value optimization (NRVO) works by marking certain @@ -1322,7 +1327,7 @@ public: NonParmVarDeclBits.NRVOVariable = NRVO; } - /// \brief Determine whether this variable is the for-range-declaration in + /// Determine whether this variable is the for-range-declaration in /// a C++0x for-range statement. bool isCXXForRangeDecl() const { return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.CXXForRangeDecl; @@ -1332,7 +1337,17 @@ public: NonParmVarDeclBits.CXXForRangeDecl = FRD; } - /// \brief Determine whether this variable is an ARC pseudo-__strong + /// Determine whether this variable is a for-loop declaration for a + /// for-in statement in Objective-C. + bool isObjCForDecl() const { + return NonParmVarDeclBits.ObjCForDecl; + } + + void setObjCForDecl(bool FRD) { + NonParmVarDeclBits.ObjCForDecl = FRD; + } + + /// Determine whether this variable is an ARC pseudo-__strong /// variable. A pseudo-__strong variable has a __strong-qualified /// type but does not actually retain the object written into it. /// Generally such variables are also 'const' for safety. @@ -1392,41 +1407,41 @@ public: NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same; } - /// \brief Retrieve the variable declaration from which this variable could + /// Retrieve the variable declaration from which this variable could /// be instantiated, if it is an instantiation (rather than a non-template). VarDecl *getTemplateInstantiationPattern() const; - /// \brief If this variable is an instantiated static data member of a + /// If this variable is an instantiated static data member of a /// class template specialization, returns the templated static data member /// from which it was instantiated. VarDecl *getInstantiatedFromStaticDataMember() const; - /// \brief If this variable is an instantiation of a variable template or a + /// If this variable is an instantiation of a variable template or a /// static data member of a class template, determine what kind of /// template specialization or instantiation this is. TemplateSpecializationKind getTemplateSpecializationKind() const; - /// \brief If this variable is an instantiation of a variable template or a + /// If this variable is an instantiation of a variable template or a /// static data member of a class template, determine its point of /// instantiation. SourceLocation getPointOfInstantiation() const; - /// \brief If this variable is an instantiation of a static data member of a + /// If this variable is an instantiation of a static data member of a /// class template specialization, retrieves the member specialization /// information. MemberSpecializationInfo *getMemberSpecializationInfo() const; - /// \brief For a static data member that was instantiated from a static + /// For a static data member that was instantiated from a static /// data member of a class template, set the template specialiation kind. void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation = SourceLocation()); - /// \brief Specify that this variable is an instantiation of the + /// Specify that this variable is an instantiation of the /// static data member VD. void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK); - /// \brief Retrieves the variable template that is described by this + /// Retrieves the variable template that is described by this /// variable declaration. /// /// Every variable template is represented as a VarTemplateDecl and a @@ -1441,6 +1456,11 @@ public: void setDescribedVarTemplate(VarTemplateDecl *Template); + // Is this variable known to have a definition somewhere in the complete + // program? This may be true even if the declaration has internal linkage and + // has no definition within this source file. + bool isKnownToBeDefined() const; + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; } @@ -1509,7 +1529,7 @@ public: static bool classofKind(Kind K) { return K == ImplicitParam; } }; -/// ParmVarDecl - Represents a parameter to a function. +/// Represents a parameter to a function. class ParmVarDecl : public VarDecl { public: enum { MaxFunctionScopeDepth = 255 }; @@ -1598,7 +1618,7 @@ public: void setDefaultArg(Expr *defarg); - /// \brief Retrieve the source range that covers the entire default + /// Retrieve the source range that covers the entire default /// argument. SourceRange getDefaultArgRange() const; void setUninstantiatedDefaultArg(Expr *arg); @@ -1607,14 +1627,13 @@ public: return const_cast<ParmVarDecl *>(this)->getUninstantiatedDefaultArg(); } - /// hasDefaultArg - Determines whether this parameter has a default argument, + /// Determines whether this parameter has a default argument, /// either parsed or not. bool hasDefaultArg() const; - /// hasUnparsedDefaultArg - Determines whether this parameter has a - /// default argument that has not yet been parsed. This will occur - /// during the processing of a C++ class whose member functions have - /// default arguments, e.g., + /// Determines whether this parameter has a default argument that has not + /// yet been parsed. This will occur during the processing of a C++ class + /// whose member functions have default arguments, e.g., /// @code /// class X { /// public: @@ -1629,11 +1648,10 @@ public: return ParmVarDeclBits.DefaultArgKind == DAK_Uninstantiated; } - /// setUnparsedDefaultArg - Specify that this parameter has an - /// unparsed default argument. The argument will be replaced with a - /// real default argument via setDefaultArg when the class - /// definition enclosing the function declaration that owns this - /// default argument is completed. + /// Specify that this parameter has an unparsed default argument. + /// The argument will be replaced with a real default argument via + /// setDefaultArg when the class definition enclosing the function + /// declaration that owns this default argument is completed. void setUnparsedDefaultArg() { ParmVarDeclBits.DefaultArgKind = DAK_Unparsed; } @@ -1648,11 +1666,11 @@ public: QualType getOriginalType() const; - /// \brief Determine whether this parameter is actually a function + /// Determine whether this parameter is actually a function /// parameter pack. bool isParameterPack() const; - /// setOwningFunction - Sets the function declaration that owns this + /// Sets the function declaration that owns this /// ParmVarDecl. Since ParmVarDecls are often created before the /// FunctionDecls that own them, this routine is required to update /// the DeclContext appropriately. @@ -1683,8 +1701,7 @@ private: unsigned getParameterIndexLarge() const; }; -/// An instance of this class is created to represent a function declaration or -/// definition. +/// Represents a function declaration or definition. /// /// Since a given function can be declared several times in a program, /// there may be several FunctionDecls that correspond to that @@ -1697,7 +1714,7 @@ private: class FunctionDecl : public DeclaratorDecl, public DeclContext, public Redeclarable<FunctionDecl> { public: - /// \brief The kind of templated function a FunctionDecl can be. + /// The kind of templated function a FunctionDecl can be. enum TemplatedKind { TK_NonTemplate, TK_FunctionTemplate, @@ -1707,7 +1724,7 @@ public: }; private: - /// ParamInfo - new[]'d array of pointers to VarDecls for the formal + /// A new[]'d array of pointers to VarDecls for the formal /// parameters of this function. This is null if a prototype or if there are /// no formals. ParmVarDecl **ParamInfo = nullptr; @@ -1732,6 +1749,12 @@ private: unsigned HasWrittenPrototype : 1; unsigned IsDeleted : 1; unsigned IsTrivial : 1; // sunk from CXXMethodDecl + + /// This flag indicates whether this function is trivial for the purpose of + /// calls. This is meaningful only when this function is a copy/move + /// constructor or a destructor. + unsigned IsTrivialForCall : 1; + unsigned IsDefaulted : 1; // sunk from CXXMethoDecl unsigned IsExplicitlyDefaulted : 1; //sunk from CXXMethodDecl unsigned HasImplicitReturnZero : 1; @@ -1739,10 +1762,10 @@ private: unsigned IsConstexpr : 1; unsigned InstantiationIsPending : 1; - /// \brief Indicates if the function uses __try. + /// Indicates if the function uses __try. unsigned UsesSEHTry : 1; - /// \brief Indicates if the function was a definition but its body was + /// Indicates if the function was a definition but its body was /// skipped. unsigned HasSkippedBody : 1; @@ -1750,6 +1773,10 @@ private: /// parsing it. unsigned WillHaveBody : 1; + /// Indicates that this function is a multiversioned function using attribute + /// 'target'. + unsigned IsMultiVersion : 1; + protected: /// [C++17] Only used by CXXDeductionGuideDecl. Declared here to avoid /// increasing the size of CXXDeductionGuideDecl by the size of an unsigned @@ -1764,7 +1791,7 @@ private: unsigned HasODRHash : 1; unsigned ODRHash; - /// \brief End part of this FunctionDecl's source range. + /// End part of this FunctionDecl's source range. /// /// We could compute the full range in getSourceRange(). However, when we're /// dealing with a function definition deserialized from a PCH/AST file, @@ -1773,7 +1800,7 @@ private: /// EndRangeLoc. SourceLocation EndRangeLoc; - /// \brief The template or declaration that this declaration + /// The template or declaration that this declaration /// describes or was instantiated from, respectively. /// /// For non-templates, this value will be NULL. For function @@ -1795,7 +1822,7 @@ private: /// the DeclaratorDecl base class. DeclarationNameLoc DNLoc; - /// \brief Specify that this function declaration is actually a function + /// Specify that this function declaration is actually a function /// template specialization. /// /// \param C the ASTContext. @@ -1824,7 +1851,7 @@ private: const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation PointOfInstantiation); - /// \brief Specify that this record is an instantiation of the + /// Specify that this record is an instantiation of the /// member function FD. void setInstantiationOfMemberFunction(ASTContext &C, FunctionDecl *FD, TemplateSpecializationKind TSK); @@ -1842,13 +1869,14 @@ protected: IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified), IsExplicitSpecified(false), IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false), HasWrittenPrototype(true), - IsDeleted(false), IsTrivial(false), IsDefaulted(false), + IsDeleted(false), IsTrivial(false), IsTrivialForCall(false), + IsDefaulted(false), IsExplicitlyDefaulted(false), HasImplicitReturnZero(false), IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified), InstantiationIsPending(false), UsesSEHTry(false), HasSkippedBody(false), - WillHaveBody(false), IsCopyDeductionCandidate(false), HasODRHash(false), - ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()), - DNLoc(NameInfo.getInfo()) {} + WillHaveBody(false), IsMultiVersion(false), + IsCopyDeductionCandidate(false), HasODRHash(false), ODRHash(0), + EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {} using redeclarable_base = Redeclarable<FunctionDecl>; @@ -1915,11 +1943,25 @@ public: SourceRange getSourceRange() const override LLVM_READONLY; - /// \brief Returns true if the function has a body (definition). The - /// function body might be in any of the (re-)declarations of this - /// function. The variant that accepts a FunctionDecl pointer will - /// set that function declaration to the actual declaration - /// containing the body (if there is one). + // Function definitions. + // + // A function declaration may be: + // - a non defining declaration, + // - a definition. A function may be defined because: + // - it has a body, or will have it in the case of late parsing. + // - it has an uninstantiated body. The body does not exist because the + // function is not used yet, but the declaration is considered a + // definition and does not allow other definition of this function. + // - it does not have a user specified body, but it does not allow + // redefinition, because it is deleted/defaulted or is defined through + // some other mechanism (alias, ifunc). + + /// Returns true if the function has a body. + /// + /// The function body might be in any of the (re-)declarations of this + /// function. The variant that accepts a FunctionDecl pointer will set that + /// function declaration to the actual declaration containing the body (if + /// there is one). bool hasBody(const FunctionDecl *&Definition) const; bool hasBody() const override { @@ -1931,9 +1973,11 @@ public: /// specific codegen. bool hasTrivialBody() const; - /// Returns true if the function is defined at all, including a deleted - /// definition. Except for the behavior when the function is deleted, behaves - /// like hasBody. + /// Returns true if the function has a definition that does not need to be + /// instantiated. + /// + /// The variant that accepts a FunctionDecl pointer will set that function + /// declaration to the declaration that is a definition (if there is one). bool isDefined(const FunctionDecl *&Definition) const; virtual bool isDefined() const { @@ -1941,7 +1985,7 @@ public: return isDefined(Definition); } - /// \brief Get the definition for this declaration. + /// Get the definition for this declaration. FunctionDecl *getDefinition() { const FunctionDecl *Definition; if (isDefined(Definition)) @@ -1975,8 +2019,7 @@ public: IsLateTemplateParsed || WillHaveBody || hasDefiningAttr(); } - /// Returns whether this specific declaration of the function has a body - - /// that is, if it is a non-deleted definition. + /// Returns whether this specific declaration of the function has a body. bool doesThisDeclarationHaveABody() const { return Body || IsLateTemplateParsed; } @@ -2007,6 +2050,9 @@ public: bool isTrivial() const { return IsTrivial; } void setTrivial(bool IT) { IsTrivial = IT; } + bool isTrivialForCall() const { return IsTrivialForCall; } + void setTrivialForCall(bool IT) { IsTrivialForCall = IT; } + /// Whether this function is defaulted per C++0x. Only valid for /// special member functions. bool isDefaulted() const { return IsDefaulted; } @@ -2023,7 +2069,7 @@ public: bool hasImplicitReturnZero() const { return HasImplicitReturnZero; } void setHasImplicitReturnZero(bool IRZ) { HasImplicitReturnZero = IRZ; } - /// \brief Whether this function has a prototype, either because one + /// Whether this function has a prototype, either because one /// was explicitly written or because it was "inherited" by merging /// a declaration without a prototype with a declaration that has a /// prototype. @@ -2033,7 +2079,7 @@ public: bool hasWrittenPrototype() const { return HasWrittenPrototype; } - /// \brief Whether this function inherited its prototype from a + /// Whether this function inherited its prototype from a /// previous declaration. bool hasInheritedPrototype() const { return HasInheritedPrototype; } void setHasInheritedPrototype(bool P = true) { HasInheritedPrototype = P; } @@ -2042,7 +2088,7 @@ public: bool isConstexpr() const { return IsConstexpr; } void setConstexpr(bool IC) { IsConstexpr = IC; } - /// \brief Whether the instantiation of this function is pending. + /// Whether the instantiation of this function is pending. /// This bit is set when the decision to instantiate this function is made /// and unset if and when the function body is created. That leaves out /// cases where instantiation did not happen because the template definition @@ -2051,11 +2097,11 @@ public: bool instantiationIsPending() const { return InstantiationIsPending; } void setInstantiationIsPending(bool IC) { InstantiationIsPending = IC; } - /// \brief Indicates the function uses __try. + /// Indicates the function uses __try. bool usesSEHTry() const { return UsesSEHTry; } void setUsesSEHTry(bool UST) { UsesSEHTry = UST; } - /// \brief Whether this function has been deleted. + /// Whether this function has been deleted. /// /// A function that is "deleted" (via the C++0x "= delete" syntax) /// acts like a normal function, except that it cannot actually be @@ -2078,15 +2124,15 @@ public: bool isDeletedAsWritten() const { return IsDeleted && !IsDefaulted; } void setDeletedAsWritten(bool D = true) { IsDeleted = D; } - /// \brief Determines whether this function is "main", which is the + /// Determines whether this function is "main", which is the /// entry point into an executable program. bool isMain() const; - /// \brief Determines whether this function is a MSVCRT user defined entry + /// Determines whether this function is a MSVCRT user defined entry /// point. bool isMSVCRTEntryPoint() const; - /// \brief Determines whether this operator new or delete is one + /// Determines whether this operator new or delete is one /// of the reserved global placement operators: /// void *operator new(size_t, void *); /// void *operator new[](size_t, void *); @@ -2101,7 +2147,7 @@ public: /// This function must be an allocation or deallocation function. bool isReservedGlobalPlacementOperator() const; - /// \brief Determines whether this function is one of the replaceable + /// Determines whether this function is one of the replaceable /// global allocation functions: /// void *operator new(size_t); /// void *operator new(size_t, const std::nothrow_t &) noexcept; @@ -2121,32 +2167,32 @@ public: /// true through IsAligned. bool isReplaceableGlobalAllocationFunction(bool *IsAligned = nullptr) const; - /// \brief Determine whether this is a destroying operator delete. + /// Determine whether this is a destroying operator delete. bool isDestroyingOperatorDelete() const; /// Compute the language linkage. LanguageLinkage getLanguageLinkage() const; - /// \brief Determines whether this function is a function with + /// Determines whether this function is a function with /// external, C linkage. bool isExternC() const; - /// \brief Determines whether this function's context is, or is nested within, + /// Determines whether this function's context is, or is nested within, /// a C++ extern "C" linkage spec. bool isInExternCContext() const; - /// \brief Determines whether this function's context is, or is nested within, + /// Determines whether this function's context is, or is nested within, /// a C++ extern "C++" linkage spec. bool isInExternCXXContext() const; - /// \brief Determines whether this is a global function. + /// Determines whether this is a global function. bool isGlobal() const; - /// \brief Determines whether this function is known to be 'noreturn', through + /// Determines whether this function is known to be 'noreturn', through /// an attribute on its declaration or its type. bool isNoReturn() const; - /// \brief True if the function was a definition but its body was skipped. + /// True if the function was a definition but its body was skipped. bool hasSkippedBody() const { return HasSkippedBody; } void setHasSkippedBody(bool Skipped = true) { HasSkippedBody = Skipped; } @@ -2154,6 +2200,22 @@ public: bool willHaveBody() const { return WillHaveBody; } void setWillHaveBody(bool V = true) { WillHaveBody = V; } + /// True if this function is considered a multiversioned function. + bool isMultiVersion() const { return getCanonicalDecl()->IsMultiVersion; } + + /// Sets the multiversion state for this declaration and all of its + /// redeclarations. + void setIsMultiVersion(bool V = true) { + getCanonicalDecl()->IsMultiVersion = V; + } + + /// True if this function is a multiversioned dispatch function as a part of + /// the cpu_specific/cpu_dispatch functionality. + bool isCPUDispatchMultiVersion() const; + /// True if this function is a multiversioned processor specific function as a + /// part of the cpu_specific/cpu_dispatch functionality. + bool isCPUSpecificMultiVersion() const; + void setPreviousDeclaration(FunctionDecl * PrevDecl); FunctionDecl *getCanonicalDecl() override; @@ -2209,34 +2271,34 @@ public: return getType()->getAs<FunctionType>()->getReturnType(); } - /// \brief Attempt to compute an informative source range covering the + /// Attempt to compute an informative source range covering the /// function return type. This may omit qualifiers and other information with /// limited representation in the AST. SourceRange getReturnTypeSourceRange() const; - /// \brief Attempt to compute an informative source range covering the + /// Attempt to compute an informative source range covering the /// function exception specification, if any. SourceRange getExceptionSpecSourceRange() const; - /// \brief Determine the type of an expression that calls this function. + /// Determine the type of an expression that calls this function. QualType getCallResultType() const { assert(getType()->getAs<FunctionType>() && "Expected a FunctionType!"); return getType()->getAs<FunctionType>()->getCallResultType(getASTContext()); } - /// \brief Returns the WarnUnusedResultAttr that is either declared on this + /// Returns the WarnUnusedResultAttr that is either declared on this /// function, or its return type declaration. const Attr *getUnusedResultAttr() const; - /// \brief Returns true if this function or its return type has the + /// Returns true if this function or its return type has the /// warn_unused_result attribute. bool hasUnusedResultAttr() const { return getUnusedResultAttr() != nullptr; } - /// \brief Returns the storage class as written in the source. For the + /// Returns the storage class as written in the source. For the /// computed linkage of symbol, see getLinkage. StorageClass getStorageClass() const { return StorageClass(SClass); } - /// \brief Determine whether the "inline" keyword was specified for this + /// Determine whether the "inline" keyword was specified for this /// function. bool isInlineSpecified() const { return IsInlineSpecified; } @@ -2251,7 +2313,7 @@ public: IsInline = true; } - /// \brief Determine whether this function should be inlined, because it is + /// Determine whether this function should be inlined, because it is /// either marked "inline" or "constexpr" or is a member function of a class /// that was defined in the class body. bool isInlined() const { return IsInline; } @@ -2262,8 +2324,8 @@ public: bool doesDeclarationForceExternallyVisibleDefinition() const; - /// isOverloadedOperator - Whether this function declaration - /// represents an C++ overloaded operator, e.g., "operator+". + /// Whether this function declaration represents an C++ overloaded + /// operator, e.g., "operator+". bool isOverloadedOperator() const { return getOverloadedOperator() != OO_None; } @@ -2272,7 +2334,7 @@ public: const IdentifierInfo *getLiteralIdentifier() const; - /// \brief If this function is an instantiation of a member function + /// If this function is an instantiation of a member function /// of a class template specialization, retrieves the function from /// which it was instantiated. /// @@ -2295,22 +2357,22 @@ public: /// declaration returned by getInstantiatedFromMemberFunction(). FunctionDecl *getInstantiatedFromMemberFunction() const; - /// \brief What kind of templated function this is. + /// What kind of templated function this is. TemplatedKind getTemplatedKind() const; - /// \brief If this function is an instantiation of a member function of a + /// If this function is an instantiation of a member function of a /// class template specialization, retrieves the member specialization /// information. MemberSpecializationInfo *getMemberSpecializationInfo() const; - /// \brief Specify that this record is an instantiation of the + /// Specify that this record is an instantiation of the /// member function FD. void setInstantiationOfMemberFunction(FunctionDecl *FD, TemplateSpecializationKind TSK) { setInstantiationOfMemberFunction(getASTContext(), FD, TSK); } - /// \brief Retrieves the function template that is described by this + /// Retrieves the function template that is described by this /// function declaration. /// /// Every function template is represented as a FunctionTemplateDecl @@ -2326,50 +2388,50 @@ public: void setDescribedFunctionTemplate(FunctionTemplateDecl *Template); - /// \brief Determine whether this function is a function template + /// Determine whether this function is a function template /// specialization. bool isFunctionTemplateSpecialization() const { return getPrimaryTemplate() != nullptr; } - /// \brief Retrieve the class scope template pattern that this function + /// Retrieve the class scope template pattern that this function /// template specialization is instantiated from. FunctionDecl *getClassScopeSpecializationPattern() const; - /// \brief If this function is actually a function template specialization, + /// If this function is actually a function template specialization, /// retrieve information about this function template specialization. /// Otherwise, returns NULL. FunctionTemplateSpecializationInfo *getTemplateSpecializationInfo() const; - /// \brief Determines whether this function is a function template + /// Determines whether this function is a function template /// specialization or a member of a class template specialization that can /// be implicitly instantiated. bool isImplicitlyInstantiable() const; - /// \brief Determines if the given function was instantiated from a + /// Determines if the given function was instantiated from a /// function template. bool isTemplateInstantiation() const; - /// \brief Retrieve the function declaration from which this function could + /// Retrieve the function declaration from which this function could /// be instantiated, if it is an instantiation (rather than a non-template /// or a specialization, for example). FunctionDecl *getTemplateInstantiationPattern() const; - /// \brief Retrieve the primary template that this function template + /// Retrieve the primary template that this function template /// specialization either specializes or was instantiated from. /// /// If this function declaration is not a function template specialization, /// returns NULL. FunctionTemplateDecl *getPrimaryTemplate() const; - /// \brief Retrieve the template arguments used to produce this function + /// Retrieve the template arguments used to produce this function /// template specialization from the primary template. /// /// If this function declaration is not a function template specialization, /// returns NULL. const TemplateArgumentList *getTemplateSpecializationArgs() const; - /// \brief Retrieve the template argument list as written in the sources, + /// Retrieve the template argument list as written in the sources, /// if any. /// /// If this function declaration is not a function template specialization @@ -2379,7 +2441,7 @@ public: const ASTTemplateArgumentListInfo* getTemplateSpecializationArgsAsWritten() const; - /// \brief Specify that this function declaration is actually a function + /// Specify that this function declaration is actually a function /// template specialization. /// /// \param Template the function template that this function template @@ -2409,7 +2471,7 @@ public: PointOfInstantiation); } - /// \brief Specifies that this function declaration is actually a + /// Specifies that this function declaration is actually a /// dependent function template specialization. void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, @@ -2418,16 +2480,16 @@ public: DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const; - /// \brief Determine what kind of template instantiation this function + /// Determine what kind of template instantiation this function /// represents. TemplateSpecializationKind getTemplateSpecializationKind() const; - /// \brief Determine what kind of template instantiation this function + /// Determine what kind of template instantiation this function /// represents. void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation = SourceLocation()); - /// \brief Retrieve the (first) point of instantiation of a function template + /// Retrieve the (first) point of instantiation of a function template /// specialization or a member of a class template specialization. /// /// \returns the first point of instantiation, if this function was @@ -2435,20 +2497,24 @@ public: /// location. SourceLocation getPointOfInstantiation() const; - /// \brief Determine whether this is or was instantiated from an out-of-line + /// Determine whether this is or was instantiated from an out-of-line /// definition of a member function. bool isOutOfLine() const override; - /// \brief Identify a memory copying or setting function. + /// Identify a memory copying or setting function. /// If the given function is a memory copy or setting function, returns /// the corresponding Builtin ID. If the function is not a memory function, /// returns 0. unsigned getMemoryFunctionKind() const; - /// \brief Returns ODRHash of the function. This value is calculated and + /// Returns ODRHash of the function. This value is calculated and /// stored on first call, then the stored value returned on the other calls. unsigned getODRHash(); + /// Returns cached ODRHash of the function. This must have been previously + /// computed and stored. + unsigned getODRHash() const; + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { @@ -2462,8 +2528,7 @@ public: } }; -/// FieldDecl - An instance of this class is created by Sema::ActOnField to -/// represent a member of a struct/union/class. +/// Represents a member of a struct/union/class. class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> { unsigned BitField : 1; unsigned Mutable : 1; @@ -2499,7 +2564,7 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> { Expr *BitWidth; }; - /// \brief Storage for either the bit-width, the in-class initializer, or + /// Storage for either the bit-width, the in-class initializer, or /// both (via InitAndBitWidth), or the captured variable length array bound. /// /// If the storage kind is ISK_InClassCopyInit or @@ -2534,20 +2599,20 @@ public: static FieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); - /// getFieldIndex - Returns the index of this field within its record, + /// Returns the index of this field within its record, /// as appropriate for passing to ASTRecordLayout::getFieldOffset. unsigned getFieldIndex() const; - /// isMutable - Determines whether this field is mutable (C++ only). + /// Determines whether this field is mutable (C++ only). bool isMutable() const { return Mutable; } - /// \brief Determines whether this field is a bitfield. + /// Determines whether this field is a bitfield. bool isBitField() const { return BitField; } - /// @brief Determines whether this is an unnamed bitfield. + /// Determines whether this is an unnamed bitfield. bool isUnnamedBitfield() const { return isBitField() && !getDeclName(); } - /// isAnonymousStructOrUnion - Determines whether this field is a + /// Determines whether this field is a /// representative for an anonymous struct or union. Such fields are /// unnamed and are implicitly generated by the implementation to /// store the data for the anonymous union or struct. @@ -2564,7 +2629,7 @@ public: unsigned getBitWidthValue(const ASTContext &Ctx) const; - /// setBitWidth - Set the bit-field width for this member. + /// Set the bit-field width for this member. // Note: used by some clients (i.e., do not remove it). void setBitWidth(Expr *Width) { assert(!hasCapturedVLAType() && !BitField && @@ -2578,7 +2643,7 @@ public: BitField = true; } - /// removeBitWidth - Remove the bit-field width from this member. + /// Remove the bit-field width from this member. // Note: used by some clients (i.e., do not remove it). void removeBitWidth() { assert(isBitField() && "no bitfield width to remove"); @@ -2586,6 +2651,11 @@ public: BitField = false; } + /// Is this a zero-length bit-field? Such bit-fields aren't really bit-fields + /// at all and instead act as a separator between contiguous runs of other + /// bit-fields. + bool isZeroLengthBitField(const ASTContext &Ctx) const; + /// Get the kind of (C++11) default member initializer that this field has. InClassInitStyle getInClassInitStyle() const { InitStorageKind storageKind = InitStorage.getInt(); @@ -2610,8 +2680,7 @@ public: return static_cast<Expr*>(Ptr); } - /// setInClassInitializer - Set the C++11 in-class initializer for this - /// member. + /// Set the C++11 in-class initializer for this member. void setInClassInitializer(Expr *Init) { assert(hasInClassInitializer() && !getInClassInitializer()); if (BitField) @@ -2620,30 +2689,29 @@ public: InitStorage.setPointer(Init); } - /// removeInClassInitializer - Remove the C++11 in-class initializer from this - /// member. + /// Remove the C++11 in-class initializer from this member. void removeInClassInitializer() { assert(hasInClassInitializer() && "no initializer to remove"); InitStorage.setPointerAndInt(getBitWidth(), ISK_NoInit); } - /// \brief Determine whether this member captures the variable length array + /// Determine whether this member captures the variable length array /// type. bool hasCapturedVLAType() const { return InitStorage.getInt() == ISK_CapturedVLAType; } - /// \brief Get the captured variable length array type. + /// Get the captured variable length array type. const VariableArrayType *getCapturedVLAType() const { return hasCapturedVLAType() ? static_cast<const VariableArrayType *>( InitStorage.getPointer()) : nullptr; } - /// \brief Set the captured variable length array type for this field. + /// Set the captured variable length array type for this field. void setCapturedVLAType(const VariableArrayType *VLAType); - /// getParent - Returns the parent of this field declaration, which + /// Returns the parent of this field declaration, which /// is the struct in which this field is defined. const RecordDecl *getParent() const { return cast<RecordDecl>(getDeclContext()); @@ -2664,7 +2732,7 @@ public: static bool classofKind(Kind K) { return K >= firstField && K <= lastField; } }; -/// EnumConstantDecl - An instance of this object exists for each enum constant +/// An instance of this object exists for each enum constant /// that is defined. For example, in "enum X {a,b}", each of a/b are /// EnumConstantDecl's, X is an instance of EnumDecl, and the type of a/b is a /// TagType for the X EnumDecl. @@ -2705,9 +2773,8 @@ public: static bool classofKind(Kind K) { return K == EnumConstant; } }; -/// IndirectFieldDecl - An instance of this class is created to represent a -/// field injected from an anonymous union/struct into the parent scope. -/// IndirectFieldDecl are always implicit. +/// Represents a field injected from an anonymous union/struct into the parent +/// scope. These are always implicit. class IndirectFieldDecl : public ValueDecl, public Mergeable<IndirectFieldDecl> { NamedDecl **Chaining; @@ -2756,17 +2823,17 @@ public: static bool classofKind(Kind K) { return K == IndirectField; } }; -/// TypeDecl - Represents a declaration of a type. +/// Represents a declaration of a type. class TypeDecl : public NamedDecl { friend class ASTContext; - /// TypeForDecl - This indicates the Type object that represents + /// This indicates the Type object that represents /// this TypeDecl. It is a cache maintained by /// ASTContext::getTypedefType, ASTContext::getTagDeclType, and /// ASTContext::getTemplateTypeParmType, and TemplateTypeParmDecl. mutable const Type *TypeForDecl = nullptr; - /// LocStart - The start of the source range for this declaration. + /// The start of the source range for this declaration. SourceLocation LocStart; void anchor() override; @@ -2800,13 +2867,16 @@ public: /// Base class for declarations which introduce a typedef-name. class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> { - using ModedTInfo = std::pair<TypeSourceInfo *, QualType>; - llvm::PointerUnion<TypeSourceInfo *, ModedTInfo *> MaybeModedTInfo; + struct alignas(8) ModedTInfo { + TypeSourceInfo *first; + QualType second; + }; - // FIXME: This can be packed into the bitfields in Decl. - /// If 0, we have not computed IsTransparentTag. - /// Otherwise, IsTransparentTag is (CacheIsTransparentTag >> 1). - mutable unsigned CacheIsTransparentTag : 2; + /// If int part is 0, we have not computed IsTransparentTag. + /// Otherwise, IsTransparentTag is (getInt() >> 1). + mutable llvm::PointerIntPair< + llvm::PointerUnion<TypeSourceInfo *, ModedTInfo *>, 2> + MaybeModedTInfo; void anchor() override; @@ -2815,7 +2885,7 @@ protected: SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) : TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C), - MaybeModedTInfo(TInfo), CacheIsTransparentTag(0) {} + MaybeModedTInfo(TInfo, 0) {} using redeclarable_base = Redeclarable<TypedefNameDecl>; @@ -2842,26 +2912,29 @@ public: using redeclarable_base::getMostRecentDecl; using redeclarable_base::isFirstDecl; - bool isModed() const { return MaybeModedTInfo.is<ModedTInfo*>(); } + bool isModed() const { + return MaybeModedTInfo.getPointer().is<ModedTInfo *>(); + } TypeSourceInfo *getTypeSourceInfo() const { - return isModed() - ? MaybeModedTInfo.get<ModedTInfo*>()->first - : MaybeModedTInfo.get<TypeSourceInfo*>(); + return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->first + : MaybeModedTInfo.getPointer().get<TypeSourceInfo *>(); } QualType getUnderlyingType() const { - return isModed() - ? MaybeModedTInfo.get<ModedTInfo*>()->second - : MaybeModedTInfo.get<TypeSourceInfo*>()->getType(); + return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->second + : MaybeModedTInfo.getPointer() + .get<TypeSourceInfo *>() + ->getType(); } void setTypeSourceInfo(TypeSourceInfo *newType) { - MaybeModedTInfo = newType; + MaybeModedTInfo.setPointer(newType); } void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy) { - MaybeModedTInfo = new (getASTContext()) ModedTInfo(unmodedTSI, modedTy); + MaybeModedTInfo.setPointer(new (getASTContext(), 8) + ModedTInfo({unmodedTSI, modedTy})); } /// Retrieves the canonical declaration of this typedef-name. @@ -2878,8 +2951,8 @@ public: /// Determines if this typedef shares a name and spelling location with its /// underlying tag type, as is the case with the NS_ENUM macro. bool isTransparentTag() const { - if (CacheIsTransparentTag) - return CacheIsTransparentTag & 0x2; + if (MaybeModedTInfo.getInt()) + return MaybeModedTInfo.getInt() & 0x2; return isTransparentTagSlow(); } @@ -2893,7 +2966,7 @@ private: bool isTransparentTagSlow() const; }; -/// TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' +/// Represents the declaration of a typedef-name via the 'typedef' /// type specifier. class TypedefDecl : public TypedefNameDecl { TypedefDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, @@ -2913,7 +2986,7 @@ public: static bool classofKind(Kind K) { return K == Typedef; } }; -/// TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x +/// Represents the declaration of a typedef-name via a C++11 /// alias-declaration. class TypeAliasDecl : public TypedefNameDecl { /// The template for which this is the pattern, if any. @@ -2940,7 +3013,7 @@ public: static bool classofKind(Kind K) { return K == TypeAlias; } }; -/// TagDecl - Represents the declaration of a struct/union/class/enum. +/// Represents the declaration of a struct/union/class/enum. class TagDecl : public TypeDecl, public DeclContext, public Redeclarable<TagDecl> { public: @@ -2949,25 +3022,24 @@ public: private: // FIXME: This can be packed into the bitfields in Decl. - /// TagDeclKind - The TagKind enum. + /// The TagKind enum. unsigned TagDeclKind : 3; - /// IsCompleteDefinition - True if this is a definition ("struct foo - /// {};"), false if it is a declaration ("struct foo;"). It is not - /// a definition until the definition has been fully processed. + /// True if this is a definition ("struct foo {};"), false if it is a + /// declaration ("struct foo;"). It is not considered a definition + /// until the definition has been fully processed. unsigned IsCompleteDefinition : 1; protected: - /// IsBeingDefined - True if this is currently being defined. + /// True if this is currently being defined. unsigned IsBeingDefined : 1; private: - /// IsEmbeddedInDeclarator - True if this tag declaration is - /// "embedded" (i.e., defined or declared for the very first time) - /// in the syntax of a declarator. + /// True if this tag declaration is "embedded" (i.e., defined or declared + /// for the very first time) in the syntax of a declarator. unsigned IsEmbeddedInDeclarator : 1; - /// \brief True if this tag is free standing, e.g. "struct foo;". + /// True if this tag is free standing, e.g. "struct foo;". unsigned IsFreeStanding : 1; protected: @@ -2975,21 +3047,21 @@ protected: unsigned NumPositiveBits : 8; unsigned NumNegativeBits : 8; - /// IsScoped - True if this tag declaration is a scoped enumeration. Only + /// True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. unsigned IsScoped : 1; - /// IsScopedUsingClassTag - If this tag declaration is a scoped enum, + /// If this tag declaration is a scoped enum, /// then this is true if the scoped enum was declared using the class /// tag, false if it was declared with the struct tag. No meaning is /// associated if this tag declaration is not a scoped enum. unsigned IsScopedUsingClassTag : 1; - /// IsFixed - True if this is an enumeration with fixed underlying type. Only + /// True if this is an enumeration with fixed underlying type. Only /// possible in C++11, Microsoft extensions, or Objective C mode. unsigned IsFixed : 1; - /// \brief Indicates whether it is possible for declarations of this kind + /// Indicates whether it is possible for declarations of this kind /// to have an out-of-date definition. /// /// This option is only enabled when modules are enabled. @@ -3006,7 +3078,7 @@ private: // to be used for the (uncommon) case of out-of-line declarations. using ExtInfo = QualifierInfo; - /// \brief If the (out-of-line) tag declaration name + /// If the (out-of-line) tag declaration name /// is qualified, it points to the qualifier info (nns and range); /// otherwise, if the tag declaration is anonymous and it is part of /// a typedef or alias, it points to the TypedefNameDecl (used for mangling); @@ -3050,7 +3122,7 @@ protected: return getMostRecentDecl(); } - /// @brief Completes the definition of this tag declaration. + /// Completes the definition of this tag declaration. /// /// This is a helper function for derived classes. void completeDefinition(); @@ -3072,11 +3144,11 @@ public: SourceRange getBraceRange() const { return BraceRange; } void setBraceRange(SourceRange R) { BraceRange = R; } - /// getInnerLocStart - Return SourceLocation representing start of source + /// Return SourceLocation representing start of source /// range ignoring outer template declarations. SourceLocation getInnerLocStart() const { return getLocStart(); } - /// getOuterLocStart - Return SourceLocation representing start of source + /// Return SourceLocation representing start of source /// range taking into account any outer template declarations. SourceLocation getOuterLocStart() const; SourceRange getSourceRange() const override LLVM_READONLY; @@ -3086,25 +3158,24 @@ public: return const_cast<TagDecl*>(this)->getCanonicalDecl(); } - /// isThisDeclarationADefinition() - Return true if this declaration - /// is a completion definition of the type. Provided for consistency. + /// Return true if this declaration is a completion definition of the type. + /// Provided for consistency. bool isThisDeclarationADefinition() const { return isCompleteDefinition(); } - /// isCompleteDefinition - Return true if this decl has its body - /// fully specified. + /// Return true if this decl has its body fully specified. bool isCompleteDefinition() const { return IsCompleteDefinition; } - /// \brief Return true if this complete decl is + /// Return true if this complete decl is /// required to be complete for some existing use. bool isCompleteDefinitionRequired() const { return IsCompleteDefinitionRequired; } - /// isBeingDefined - Return true if this decl is currently being defined. + /// Return true if this decl is currently being defined. bool isBeingDefined() const { return IsBeingDefined; } @@ -3121,19 +3192,19 @@ public: IsFreeStanding = isFreeStanding; } - /// \brief Whether this declaration declares a type that is + /// Whether this declaration declares a type that is /// dependent, i.e., a type that somehow depends on template /// parameters. bool isDependentType() const { return isDependentContext(); } - /// @brief Starts the definition of this tag declaration. + /// Starts the definition of this tag declaration. /// /// This method should be invoked at the beginning of the definition /// of this tag declaration. It will set the tag type into a state /// where it is in the process of being defined. void startDefinition(); - /// getDefinition - Returns the TagDecl that actually defines this + /// Returns the TagDecl that actually defines this /// struct/union/class/enum. When determining whether or not a /// struct/union/class/enum has a definition, one should use this /// method as opposed to 'isDefinition'. 'isDefinition' indicates @@ -3191,14 +3262,14 @@ public: void setTypedefNameForAnonDecl(TypedefNameDecl *TDD); - /// \brief Retrieve the nested-name-specifier that qualifies the name of this + /// Retrieve the nested-name-specifier that qualifies the name of this /// declaration, if it was present in the source. NestedNameSpecifier *getQualifier() const { return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier() : nullptr; } - /// \brief Retrieve the nested-name-specifier (with source-location + /// Retrieve the nested-name-specifier (with source-location /// information) that qualifies the name of this declaration, if it was /// present in the source. NestedNameSpecifierLoc getQualifierLoc() const { @@ -3233,11 +3304,11 @@ public: } }; -/// EnumDecl - Represents an enum. In C++11, enums can be forward-declared +/// Represents an enum. In C++11, enums can be forward-declared /// with a fixed underlying type, and in C we allow them to be forward-declared /// with no underlying type as an extension. class EnumDecl : public TagDecl { - /// IntegerType - This represent the integer type that the enum corresponds + /// This represent the integer type that the enum corresponds /// to for code generation purposes. Note that the enumerator constants may /// have a different type than this does. /// @@ -3253,17 +3324,21 @@ class EnumDecl : public TagDecl { /// extra pointer when TypeSourceInfo is needed. llvm::PointerUnion<const Type *, TypeSourceInfo *> IntegerType; - /// PromotionType - The integer type that values of this type should + /// The integer type that values of this type should /// promote to. In C, enumerators are generally of an integer type /// directly, but gcc-style large enumerators (and all enumerators /// in C++) are of the enum type instead. QualType PromotionType; - /// \brief If this enumeration is an instantiation of a member enumeration + /// If this enumeration is an instantiation of a member enumeration /// of a class template specialization, this is the member specialization /// information. MemberSpecializationInfo *SpecializationInfo = nullptr; + /// Store the ODRHash after first calculation. + unsigned HasODRHash : 1; + unsigned ODRHash; + EnumDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool Scoped, bool ScopedUsingClassTag, bool Fixed) @@ -3275,6 +3350,8 @@ class EnumDecl : public TagDecl { IsScoped = Scoped; IsScopedUsingClassTag = ScopedUsingClassTag; IsFixed = Fixed; + HasODRHash = false; + ODRHash = 0; } void anchor() override; @@ -3317,9 +3394,9 @@ public: bool IsFixed); static EnumDecl *CreateDeserialized(ASTContext &C, unsigned ID); - /// completeDefinition - When created, the EnumDecl corresponds to a + /// When created, the EnumDecl corresponds to a /// forward-declared enum. This method is used to mark the - /// declaration as being defined; it's enumerators have already been + /// declaration as being defined; its enumerators have already been /// added (via DeclContext::addDecl). NewType is the new underlying /// type of the enumeration type. void completeDefinition(QualType NewType, @@ -3327,8 +3404,7 @@ public: unsigned NumPositiveBits, unsigned NumNegativeBits); - // enumerator_iterator - Iterates through the enumerators of this - // enumeration. + // Iterates through the enumerators of this enumeration. using enumerator_iterator = specific_decl_iterator<EnumConstantDecl>; using enumerator_range = llvm::iterator_range<specific_decl_iterator<EnumConstantDecl>>; @@ -3351,14 +3427,13 @@ public: return enumerator_iterator(E->decls_end()); } - /// getPromotionType - Return the integer type that enumerators - /// should promote to. + /// Return the integer type that enumerators should promote to. QualType getPromotionType() const { return PromotionType; } - /// \brief Set the promotion type. + /// Set the promotion type. void setPromotionType(QualType T) { PromotionType = T; } - /// getIntegerType - Return the integer type this enum decl corresponds to. + /// Return the integer type this enum decl corresponds to. /// This returns a null QualType for an enum forward definition with no fixed /// underlying type. QualType getIntegerType() const { @@ -3369,23 +3444,23 @@ public: return IntegerType.get<TypeSourceInfo*>()->getType().getUnqualifiedType(); } - /// \brief Set the underlying integer type. + /// Set the underlying integer type. void setIntegerType(QualType T) { IntegerType = T.getTypePtrOrNull(); } - /// \brief Set the underlying integer type source info. + /// Set the underlying integer type source info. void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo) { IntegerType = TInfo; } - /// \brief Return the type source info for the underlying integer type, + /// Return the type source info for the underlying integer type, /// if no type source info exists, return 0. TypeSourceInfo *getIntegerTypeSourceInfo() const { return IntegerType.dyn_cast<TypeSourceInfo*>(); } - /// \brief Retrieve the source range that covers the underlying type if + /// Retrieve the source range that covers the underlying type if /// specified. SourceRange getIntegerTypeRange() const LLVM_READONLY; - /// \brief Returns the width in bits required to store all the + /// Returns the width in bits required to store all the /// non-negative enumerators of this enum. unsigned getNumPositiveBits() const { return NumPositiveBits; @@ -3395,7 +3470,7 @@ public: assert(NumPositiveBits == Num && "can't store this bitcount"); } - /// \brief Returns the width in bits required to store all the + /// Returns the width in bits required to store all the /// negative enumerators of this enum. These widths include /// the rightmost leading 1; that is: /// @@ -3411,25 +3486,29 @@ public: NumNegativeBits = Num; } - /// \brief Returns true if this is a C++11 scoped enumeration. + /// Returns true if this is a C++11 scoped enumeration. bool isScoped() const { return IsScoped; } - /// \brief Returns true if this is a C++11 scoped enumeration. + /// Returns true if this is a C++11 scoped enumeration. bool isScopedUsingClassTag() const { return IsScopedUsingClassTag; } - /// \brief Returns true if this is an Objective-C, C++11, or + /// Returns true if this is an Objective-C, C++11, or /// Microsoft-style enumeration with a fixed underlying type. bool isFixed() const { return IsFixed; } - /// \brief Returns true if this can be considered a complete type. + unsigned getODRHash(); + + /// Returns true if this can be considered a complete type. bool isComplete() const { - return isCompleteDefinition() || isFixed(); + // IntegerType is set for fixed type enums and non-fixed but implicitly + // int-sized Microsoft enums. + return isCompleteDefinition() || IntegerType; } /// Returns true if this enum is either annotated with @@ -3444,33 +3523,33 @@ public: /// enum_extensibility(open). bool isClosedNonFlag() const; - /// \brief Retrieve the enum definition from which this enumeration could + /// Retrieve the enum definition from which this enumeration could /// be instantiated, if it is an instantiation (rather than a non-template). EnumDecl *getTemplateInstantiationPattern() const; - /// \brief Returns the enumeration (declared within the template) + /// Returns the enumeration (declared within the template) /// from which this enumeration type was instantiated, or NULL if /// this enumeration was not instantiated from any template. EnumDecl *getInstantiatedFromMemberEnum() const; - /// \brief If this enumeration is a member of a specialization of a + /// If this enumeration is a member of a specialization of a /// templated class, determine what kind of template specialization /// or instantiation this is. TemplateSpecializationKind getTemplateSpecializationKind() const; - /// \brief For an enumeration member that was instantiated from a member + /// For an enumeration member that was instantiated from a member /// enumeration of a templated class, set the template specialiation kind. void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation = SourceLocation()); - /// \brief If this enumeration is an instantiation of a member enumeration of + /// If this enumeration is an instantiation of a member enumeration of /// a class template specialization, retrieves the member specialization /// information. MemberSpecializationInfo *getMemberSpecializationInfo() const { return SpecializationInfo; } - /// \brief Specify that this enumeration is an instantiation of the + /// Specify that this enumeration is an instantiation of the /// member enumeration ED. void setInstantiationOfMemberEnum(EnumDecl *ED, TemplateSpecializationKind TSK) { @@ -3481,36 +3560,74 @@ public: static bool classofKind(Kind K) { return K == Enum; } }; -/// RecordDecl - Represents a struct/union/class. For example: +/// Represents a struct/union/class. For example: /// struct X; // Forward declaration, no "body". /// union Y { int A, B; }; // Has body with members A and B (FieldDecls). /// This decl will be marked invalid if *any* members are invalid. class RecordDecl : public TagDecl { +public: + /// Enum that represents the different ways arguments are passed to and + /// returned from function calls. This takes into account the target-specific + /// and version-specific rules along with the rules determined by the + /// language. + enum ArgPassingKind : unsigned { + /// The argument of this type can be passed directly in registers. + APK_CanPassInRegs, + + /// The argument of this type cannot be passed directly in registers. + /// Records containing this type as a subobject are not forced to be passed + /// indirectly. This value is used only in C++. This value is required by + /// C++ because, in uncommon situations, it is possible for a class to have + /// only trivial copy/move constructors even when one of its subobjects has + /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move + /// constructor in the derived class is deleted). + APK_CannotPassInRegs, + + /// The argument of this type cannot be passed directly in registers. + /// Records containing this type as a subobject are forced to be passed + /// indirectly. + APK_CanNeverPassInRegs + }; + +private: friend class DeclContext; // FIXME: This can be packed into the bitfields in Decl. - /// HasFlexibleArrayMember - This is true if this struct ends with a flexible + /// This is true if this struct ends with a flexible /// array member (e.g. int X[]) or if this union contains a struct that does. /// If so, this cannot be contained in arrays or other structs as a member. - bool HasFlexibleArrayMember : 1; + unsigned HasFlexibleArrayMember : 1; - /// AnonymousStructOrUnion - Whether this is the type of an anonymous struct - /// or union. - bool AnonymousStructOrUnion : 1; + /// Whether this is the type of an anonymous struct or union. + unsigned AnonymousStructOrUnion : 1; - /// HasObjectMember - This is true if this struct has at least one member + /// This is true if this struct has at least one member /// containing an Objective-C object pointer type. - bool HasObjectMember : 1; - - /// HasVolatileMember - This is true if struct has at least one member of + unsigned HasObjectMember : 1; + + /// This is true if struct has at least one member of /// 'volatile' type. - bool HasVolatileMember : 1; + unsigned HasVolatileMember : 1; - /// \brief Whether the field declarations of this record have been loaded + /// Whether the field declarations of this record have been loaded /// from external storage. To avoid unnecessary deserialization of /// methods/nested types we allow deserialization of just the fields /// when needed. - mutable bool LoadedFieldsFromExternalStorage : 1; + mutable unsigned LoadedFieldsFromExternalStorage : 1; + + /// Basic properties of non-trivial C structs. + unsigned NonTrivialToPrimitiveDefaultInitialize : 1; + unsigned NonTrivialToPrimitiveCopy : 1; + unsigned NonTrivialToPrimitiveDestroy : 1; + + /// Indicates whether this struct is destroyed in the callee. + /// + /// Please note that MSVC won't merge adjacent bitfields if they don't have + /// the same type. + unsigned ParamDestroyedInCallee : 1; + + /// Represents the way this type is passed to a function. + unsigned ArgPassingRestrictions : 2; protected: RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, @@ -3541,10 +3658,9 @@ public: bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; } void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; } - /// isAnonymousStructOrUnion - Whether this is an anonymous struct - /// or union. To be an anonymous struct or union, it must have been - /// declared without a name and there must be no objects of this - /// type declared, e.g., + /// Whether this is an anonymous struct or union. To be an anonymous + /// struct or union, it must have been declared without a name and + /// there must be no objects of this type declared, e.g., /// @code /// union { int i; float f; }; /// @endcode @@ -3571,7 +3687,55 @@ public: LoadedFieldsFromExternalStorage = val; } - /// \brief Determines whether this declaration represents the + /// Functions to query basic properties of non-trivial C structs. + bool isNonTrivialToPrimitiveDefaultInitialize() const { + return NonTrivialToPrimitiveDefaultInitialize; + } + + void setNonTrivialToPrimitiveDefaultInitialize(bool V) { + NonTrivialToPrimitiveDefaultInitialize = V; + } + + bool isNonTrivialToPrimitiveCopy() const { + return NonTrivialToPrimitiveCopy; + } + + void setNonTrivialToPrimitiveCopy(bool V) { + NonTrivialToPrimitiveCopy = V; + } + + bool isNonTrivialToPrimitiveDestroy() const { + return NonTrivialToPrimitiveDestroy; + } + + void setNonTrivialToPrimitiveDestroy(bool V) { + NonTrivialToPrimitiveDestroy = V; + } + + /// Determine whether this class can be passed in registers. In C++ mode, + /// it must have at least one trivial, non-deleted copy or move constructor. + /// FIXME: This should be set as part of completeDefinition. + bool canPassInRegisters() const { + return getArgPassingRestrictions() == APK_CanPassInRegs; + } + + ArgPassingKind getArgPassingRestrictions() const { + return static_cast<ArgPassingKind>(ArgPassingRestrictions); + } + + void setArgPassingRestrictions(ArgPassingKind Kind) { + ArgPassingRestrictions = static_cast<uint8_t>(Kind); + } + + bool isParamDestroyedInCallee() const { + return ParamDestroyedInCallee; + } + + void setParamDestroyedInCallee(bool V) { + ParamDestroyedInCallee = V; + } + + /// Determines whether this declaration represents the /// injected class name. /// /// The injected class name in C++ is the name of the class that @@ -3586,19 +3750,19 @@ public: /// \endcode bool isInjectedClassName() const; - /// \brief Determine whether this record is a class describing a lambda + /// Determine whether this record is a class describing a lambda /// function object. bool isLambda() const; - /// \brief Determine whether this record is a record for captured variables in + /// Determine whether this record is a record for captured variables in /// CapturedStmt construct. bool isCapturedRecord() const; - /// \brief Mark the record as a record for captured variables in CapturedStmt + /// Mark the record as a record for captured variables in CapturedStmt /// construct. void setCapturedRecord(); - /// getDefinition - Returns the RecordDecl that actually defines + /// Returns the RecordDecl that actually defines /// this struct/union/class. When determining whether or not a /// struct/union/class is completely defined, one should use this /// method as opposed to 'isCompleteDefinition'. @@ -3623,14 +3787,12 @@ public: return field_iterator(decl_iterator()); } - // field_empty - Whether there are any fields (non-static data - // members) in this record. + // Whether there are any fields (non-static data members) in this record. bool field_empty() const { return field_begin() == field_end(); } - /// completeDefinition - Notes that the definition of this type is - /// now complete. + /// Note that the definition of this type is now complete. virtual void completeDefinition(); static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -3638,12 +3800,12 @@ public: return K >= firstRecord && K <= lastRecord; } - /// \brief Get whether or not this is an ms_struct which can + /// Get whether or not this is an ms_struct which can /// be turned on with an attribute, pragma, or -mms-bitfields /// commandline option. bool isMsStruct(const ASTContext &C) const; - /// \brief Whether we are allowed to insert extra padding between fields. + /// Whether we are allowed to insert extra padding between fields. /// These padding are added to help AddressSanitizer detect /// intra-object-overflow bugs. bool mayInsertExtraPadding(bool EmitRemark = false) const; @@ -3653,7 +3815,7 @@ public: const FieldDecl *findFirstNamedDataMember() const; private: - /// \brief Deserialize just the fields. + /// Deserialize just the fields. void LoadFieldsFromExternalStorage() const; }; @@ -3689,7 +3851,7 @@ public: static bool classofKind(Kind K) { return K == FileScopeAsm; } }; -/// BlockDecl - This represents a block literal declaration, which is like an +/// Pepresents a block literal declaration, which is like an /// unnamed FunctionDecl. For example: /// ^{ statement-body } or ^(int arg1, float arg2){ statement-body } class BlockDecl : public Decl, public DeclContext { @@ -3739,7 +3901,11 @@ private: bool BlockMissingReturnType : 1; bool IsConversionFromLambda : 1; - /// ParamInfo - new[]'d array of pointers to ParmVarDecls for the formal + /// A bit that indicates this block is passed directly to a function as a + /// non-escaping parameter. + bool DoesNotEscape : 1; + + /// A new[]'d array of pointers to ParmVarDecls for the formal /// parameters of this function. This is null if a prototype or if there are /// no formals. ParmVarDecl **ParamInfo = nullptr; @@ -3758,7 +3924,7 @@ protected: BlockDecl(DeclContext *DC, SourceLocation CaretLoc) : Decl(Block, DC, CaretLoc), DeclContext(Block), IsVariadic(false), CapturesCXXThis(false), BlockMissingReturnType(true), - IsConversionFromLambda(false) {} + IsConversionFromLambda(false), DoesNotEscape(false) {} public: static BlockDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L); @@ -3808,11 +3974,11 @@ public: void setParams(ArrayRef<ParmVarDecl *> NewParamInfo); - /// hasCaptures - True if this block (or its nested blocks) captures + /// True if this block (or its nested blocks) captures /// anything of local storage from its enclosing scopes. bool hasCaptures() const { return NumCaptures != 0 || CapturesCXXThis; } - /// getNumCaptures - Returns the number of captured variables. + /// Returns the number of captured variables. /// Does not include an entry for 'this'. unsigned getNumCaptures() const { return NumCaptures; } @@ -3830,6 +3996,9 @@ public: bool isConversionFromLambda() const { return IsConversionFromLambda; } void setIsConversionFromLambda(bool val) { IsConversionFromLambda = val; } + bool doesNotEscape() const { return DoesNotEscape; } + void setDoesNotEscape() { DoesNotEscape = true; } + bool capturesVariable(const VarDecl *var) const; void setCaptures(ASTContext &Context, ArrayRef<Capture> Captures, @@ -3861,8 +4030,7 @@ public: } }; -/// \brief This represents the body of a CapturedStmt, and serves as its -/// DeclContext. +/// Represents the body of a CapturedStmt, and serves as its DeclContext. class CapturedDecl final : public Decl, public DeclContext, @@ -3873,13 +4041,13 @@ protected: } private: - /// \brief The number of parameters to the outlined function. + /// The number of parameters to the outlined function. unsigned NumParams; - /// \brief The position of context parameter in list of parameters. + /// The position of context parameter in list of parameters. unsigned ContextParam; - /// \brief The body of the outlined function. + /// The body of the outlined function. llvm::PointerIntPair<Stmt *, 1, bool> BodyAndNothrow; explicit CapturedDecl(DeclContext *DC, unsigned NumParams); @@ -3927,7 +4095,7 @@ public: return {getParams(), getNumParams()}; } - /// \brief Retrieve the parameter containing captured variables. + /// Retrieve the parameter containing captured variables. ImplicitParamDecl *getContextParam() const { assert(ContextParam < NumParams); return getParam(ContextParam); @@ -3942,9 +4110,9 @@ public: using param_iterator = ImplicitParamDecl *const *; using param_range = llvm::iterator_range<param_iterator>; - /// \brief Retrieve an iterator pointing to the first parameter decl. + /// Retrieve an iterator pointing to the first parameter decl. param_iterator param_begin() const { return getParams(); } - /// \brief Retrieve an iterator one past the last parameter decl. + /// Retrieve an iterator one past the last parameter decl. param_iterator param_end() const { return getParams() + NumParams; } // Implement isa/cast/dyncast/etc. @@ -3958,7 +4126,7 @@ public: } }; -/// \brief Describes a module import declaration, which makes the contents +/// Describes a module import declaration, which makes the contents /// of the named module visible in the current translation unit. /// /// An import declaration imports the named module (or submodule). For example: @@ -3975,7 +4143,7 @@ class ImportDecl final : public Decl, friend class ASTReader; friend TrailingObjects; - /// \brief The imported module, along with a bit that indicates whether + /// The imported module, along with a bit that indicates whether /// we have source-location information for each identifier in the module /// name. /// @@ -3983,7 +4151,7 @@ class ImportDecl final : public Decl, /// end of the import declaration. llvm::PointerIntPair<Module *, 1, bool> ImportedAndComplete; - /// \brief The next import in the list of imports local to the translation + /// The next import in the list of imports local to the translation /// unit being parsed (not loaded from an AST file). ImportDecl *NextLocalImport = nullptr; @@ -3996,25 +4164,25 @@ class ImportDecl final : public Decl, ImportDecl(EmptyShell Empty) : Decl(Import, Empty) {} public: - /// \brief Create a new module import declaration. + /// Create a new module import declaration. static ImportDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef<SourceLocation> IdentifierLocs); - /// \brief Create a new module import declaration for an implicitly-generated + /// Create a new module import declaration for an implicitly-generated /// import. static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc); - /// \brief Create a new, deserialized module import declaration. + /// Create a new, deserialized module import declaration. static ImportDecl *CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations); - /// \brief Retrieve the module that was imported by the import declaration. + /// Retrieve the module that was imported by the import declaration. Module *getImportedModule() const { return ImportedAndComplete.getPointer(); } - /// \brief Retrieves the locations of each of the identifiers that make up + /// Retrieves the locations of each of the identifiers that make up /// the complete module name in the import declaration. /// /// This will return an empty array if the locations of the individual @@ -4027,7 +4195,7 @@ public: static bool classofKind(Kind K) { return K == Import; } }; -/// \brief Represents a C++ Modules TS module export declaration. +/// Represents a C++ Modules TS module export declaration. /// /// For example: /// \code @@ -4039,7 +4207,7 @@ class ExportDecl final : public Decl, public DeclContext { private: friend class ASTDeclReader; - /// \brief The source location for the right brace (if valid). + /// The source location for the right brace (if valid). SourceLocation RBraceLoc; ExportDecl(DeclContext *DC, SourceLocation ExportLoc) @@ -4077,7 +4245,7 @@ public: } }; -/// \brief Represents an empty-declaration. +/// Represents an empty-declaration. class EmptyDecl : public Decl { EmptyDecl(DeclContext *DC, SourceLocation L) : Decl(Empty, DC, L) {} @@ -4111,7 +4279,7 @@ template<typename decl_type> void Redeclarable<decl_type>::setPreviousDecl(decl_type *PrevDecl) { // Note: This routine is implemented here because we need both NamedDecl // and Redeclarable to be defined. - assert(RedeclLink.NextIsLatest() && + assert(RedeclLink.isFirst() && "setPreviousDecl on a decl already in a redeclaration chain"); if (PrevDecl) { @@ -4119,7 +4287,7 @@ void Redeclarable<decl_type>::setPreviousDecl(decl_type *PrevDecl) { // redeclaration, or we can build invalid chains. If the most recent // redeclaration is invalid, it won't be PrevDecl, but we want it anyway. First = PrevDecl->getFirstDecl(); - assert(First->RedeclLink.NextIsLatest() && "Expected first"); + assert(First->RedeclLink.isFirst() && "Expected first"); decl_type *MostRecent = First->getNextRedeclaration(); RedeclLink = PreviousDeclLink(cast<decl_type>(MostRecent)); @@ -4142,7 +4310,7 @@ void Redeclarable<decl_type>::setPreviousDecl(decl_type *PrevDecl) { // Inline function definitions. -/// \brief Check if the given decl is complete. +/// Check if the given decl is complete. /// /// We use this function to break a cycle between the inline definitions in /// Type.h and Decl.h. @@ -4150,7 +4318,7 @@ inline bool IsEnumDeclComplete(EnumDecl *ED) { return ED->isComplete(); } -/// \brief Check if the given decl is scoped. +/// Check if the given decl is scoped. /// /// We use this function to break a cycle between the inline definitions in /// Type.h and Decl.h. diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index f93c9f0b9aaa..f99bd627877c 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -19,7 +19,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" -#include "clang/Basic/VersionTuple.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" @@ -28,6 +27,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/VersionTuple.h" #include <algorithm> #include <cassert> #include <cstddef> @@ -67,7 +67,7 @@ class TemplateDecl; class TranslationUnitDecl; class UsingDirectiveDecl; -/// \brief Captures the result of checking the availability of a +/// Captures the result of checking the availability of a /// declaration. enum AvailabilityResult { AR_Available = 0, @@ -83,9 +83,9 @@ enum AvailabilityResult { /// (and its subclasses) in its Decl::operator new(). Proper alignment /// of all subclasses (not requiring more than the alignment of Decl) is /// asserted in DeclBase.cpp. -class LLVM_ALIGNAS(/*alignof(uint64_t)*/ 8) Decl { +class alignas(8) Decl { public: - /// \brief Lists the kind of concrete classes of Decl. + /// Lists the kind of concrete classes of Decl. enum Kind { #define DECL(DERIVED, BASE) DERIVED, #define ABSTRACT_DECL(DECL) @@ -96,7 +96,7 @@ public: #include "clang/AST/DeclNodes.inc" }; - /// \brief A placeholder type used to construct an empty shell of a + /// A placeholder type used to construct an empty shell of a /// decl-derived type that will be filled in later (e.g., by some /// deserialization method). struct EmptyShell {}; @@ -231,7 +231,7 @@ public: }; protected: - /// \brief The next declaration within the same lexical + /// The next declaration within the same lexical /// DeclContext. These pointers form the linked list that is /// traversed via DeclContext's decls_begin()/decls_end(). /// @@ -288,27 +288,28 @@ private: /// the implementation rather than explicitly written by the user. unsigned Implicit : 1; - /// \brief Whether this declaration was "used", meaning that a definition is + /// Whether this declaration was "used", meaning that a definition is /// required. unsigned Used : 1; - /// \brief Whether this declaration was "referenced". + /// Whether this declaration was "referenced". /// The difference with 'Used' is whether the reference appears in a /// evaluated context or not, e.g. functions used in uninstantiated templates /// are regarded as "referenced" but not "used". unsigned Referenced : 1; - /// \brief Whether this declaration is a top-level declaration (function, + /// Whether this declaration is a top-level declaration (function, /// global variable, etc.) that is lexically inside an objc container /// definition. unsigned TopLevelDeclInObjCContainer : 1; - /// \brief Whether statistic collection is enabled. + /// Whether statistic collection is enabled. static bool StatisticsEnabled; protected: friend class ASTDeclReader; friend class ASTDeclWriter; + friend class ASTNodeImporter; friend class ASTReader; friend class CXXClassMemberWrapper; friend class LinkageComputer; @@ -318,17 +319,17 @@ protected: // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum unsigned Access : 2; - /// \brief Whether this declaration was loaded from an AST file. + /// Whether this declaration was loaded from an AST file. unsigned FromASTFile : 1; /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in. unsigned IdentifierNamespace : 13; - /// \brief If 0, we have not computed the linkage of this declaration. + /// If 0, we have not computed the linkage of this declaration. /// Otherwise, it is the linkage + 1. mutable unsigned CacheValidAndLinkage : 3; - /// \brief Allocate memory for a deserialized declaration. + /// Allocate memory for a deserialized declaration. /// /// This routine must be used to allocate memory for any declaration that is /// deserialized from a module file. @@ -340,7 +341,7 @@ protected: void *operator new(std::size_t Size, const ASTContext &Ctx, unsigned ID, std::size_t Extra = 0); - /// \brief Allocate memory for a non-deserialized declaration. + /// Allocate memory for a non-deserialized declaration. void *operator new(std::size_t Size, const ASTContext &Ctx, DeclContext *Parent, std::size_t Extra = 0); @@ -384,7 +385,7 @@ protected: virtual ~Decl(); - /// \brief Update a potentially out-of-date declaration. + /// Update a potentially out-of-date declaration. void updateOutOfDate(IdentifierInfo &II) const; Linkage getCachedLinkage() const { @@ -400,7 +401,7 @@ protected: } public: - /// \brief Source range that this declaration covers. + /// Source range that this declaration covers. virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), getLocation()); } @@ -462,7 +463,7 @@ public: return AccessSpecifier(Access); } - /// \brief Retrieve the access specifier for this declaration, even though + /// Retrieve the access specifier for this declaration, even though /// it may not yet have been properly set. AccessSpecifier getAccessUnsafe() const { return AccessSpecifier(Access); @@ -551,7 +552,7 @@ public: bool isImplicit() const { return Implicit; } void setImplicit(bool I = true) { Implicit = I; } - /// \brief Whether *any* (re-)declaration of the entity was used, meaning that + /// Whether *any* (re-)declaration of the entity was used, meaning that /// a definition is required. /// /// \param CheckUsedAttr When true, also consider the "used" attribute @@ -559,28 +560,28 @@ public: /// whether the function is used. bool isUsed(bool CheckUsedAttr = true) const; - /// \brief Set whether the declaration is used, in the sense of odr-use. + /// Set whether the declaration is used, in the sense of odr-use. /// /// This should only be used immediately after creating a declaration. /// It intentionally doesn't notify any listeners. void setIsUsed() { getCanonicalDecl()->Used = true; } - /// \brief Mark the declaration used, in the sense of odr-use. + /// Mark the declaration used, in the sense of odr-use. /// /// This notifies any mutation listeners in addition to setting a bit /// indicating the declaration is used. void markUsed(ASTContext &C); - /// \brief Whether any declaration of this entity was referenced. + /// Whether any declaration of this entity was referenced. bool isReferenced() const; - /// \brief Whether this declaration was referenced. This should not be relied + /// Whether this declaration was referenced. This should not be relied /// upon for anything other than debugging. bool isThisDeclarationReferenced() const { return Referenced; } void setReferenced(bool R = true) { Referenced = R; } - /// \brief Whether this declaration is a top-level declaration (function, + /// Whether this declaration is a top-level declaration (function, /// global variable, etc.) that is lexically inside an objc container /// definition. bool isTopLevelDeclInObjCContainer() const { @@ -591,17 +592,17 @@ public: TopLevelDeclInObjCContainer = V; } - /// \brief Looks on this and related declarations for an applicable + /// Looks on this and related declarations for an applicable /// external source symbol attribute. ExternalSourceSymbolAttr *getExternalSourceSymbolAttr() const; - /// \brief Whether this declaration was marked as being private to the + /// Whether this declaration was marked as being private to the /// module in which it was defined. bool isModulePrivate() const { return getModuleOwnershipKind() == ModuleOwnershipKind::ModulePrivate; } - /// \brief Whether this declaration is exported (by virtue of being lexically + /// Whether this declaration is exported (by virtue of being lexically /// within an ExportDecl or by being a NamespaceDecl). bool isExported() const; @@ -613,7 +614,7 @@ public: const Attr *getDefiningAttr() const; protected: - /// \brief Specify that this declaration was marked as being private + /// Specify that this declaration was marked as being private /// to the module in which it was defined. void setModulePrivate() { // The module-private specifier has no effect on unowned declarations. @@ -623,14 +624,14 @@ protected: setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate); } - /// \brief Set the owning module ID. + /// Set the owning module ID. void setOwningModuleID(unsigned ID) { assert(isFromASTFile() && "Only works on a deserialized declaration"); *((unsigned*)this - 2) = ID; } public: - /// \brief Determine the availability of the given declaration. + /// Determine the availability of the given declaration. /// /// This routine will determine the most restrictive availability of /// the given declaration (e.g., preferring 'unavailable' to @@ -643,11 +644,16 @@ public: /// /// \param EnclosingVersion The version to compare with. If empty, assume the /// deployment target version. + /// + /// \param RealizedPlatform If non-NULL and the availability result is found + /// in an available attribute it will set to the platform which is written in + /// the available attribute. AvailabilityResult getAvailability(std::string *Message = nullptr, - VersionTuple EnclosingVersion = VersionTuple()) const; + VersionTuple EnclosingVersion = VersionTuple(), + StringRef *RealizedPlatform = nullptr) const; - /// \brief Retrieve the version of the target platform in which this + /// Retrieve the version of the target platform in which this /// declaration was introduced. /// /// \returns An empty version tuple if this declaration has no 'introduced' @@ -655,7 +661,7 @@ public: /// attribute otherwise. VersionTuple getVersionIntroduced() const; - /// \brief Determine whether this declaration is marked 'deprecated'. + /// Determine whether this declaration is marked 'deprecated'. /// /// \param Message If non-NULL and the declaration is deprecated, /// this will be set to the message describing why the declaration @@ -664,7 +670,7 @@ public: return getAvailability(Message) == AR_Deprecated; } - /// \brief Determine whether this declaration is marked 'unavailable'. + /// Determine whether this declaration is marked 'unavailable'. /// /// \param Message If non-NULL and the declaration is unavailable, /// this will be set to the message describing why the declaration @@ -673,7 +679,7 @@ public: return getAvailability(Message) == AR_Unavailable; } - /// \brief Determine whether this is a weak-imported symbol. + /// Determine whether this is a weak-imported symbol. /// /// Weak-imported symbols are typically marked with the /// 'weak_import' attribute, but may also be marked with an @@ -681,7 +687,7 @@ public: /// the introduction of this feature. bool isWeakImported() const; - /// \brief Determines whether this symbol can be weak-imported, + /// Determines whether this symbol can be weak-imported, /// e.g., whether it would be well-formed to add the weak_import /// attribute. /// @@ -689,11 +695,11 @@ public: /// declaration cannot be weak-imported because it has a definition. bool canBeWeakImported(bool &IsDefinition) const; - /// \brief Determine whether this declaration came from an AST file (such as + /// Determine whether this declaration came from an AST file (such as /// a precompiled header or module) rather than having been parsed. bool isFromASTFile() const { return FromASTFile; } - /// \brief Retrieve the global declaration ID associated with this + /// Retrieve the global declaration ID associated with this /// declaration, which specifies where this Decl was loaded from. unsigned getGlobalID() const { if (isFromASTFile()) @@ -701,7 +707,7 @@ public: return 0; } - /// \brief Retrieve the global ID of the module that owns this particular + /// Retrieve the global ID of the module that owns this particular /// declaration. unsigned getOwningModuleID() const { if (isFromASTFile()) @@ -716,7 +722,7 @@ protected: bool hasLocalOwningModuleStorage() const; public: - /// \brief Get the imported owning module, if this decl is from an imported + /// Get the imported owning module, if this decl is from an imported /// (non-local) module. Module *getImportedOwningModule() const { if (!isFromASTFile() || !hasOwningModule()) @@ -725,7 +731,7 @@ public: return getOwningModuleSlow(); } - /// \brief Get the local owning module, if known. Returns nullptr if owner is + /// Get the local owning module, if known. Returns nullptr if owner is /// not yet known or declaration is not from a module. Module *getLocalOwningModule() const { if (isFromASTFile() || !hasOwningModule()) @@ -759,7 +765,7 @@ public: /// all declarations in a global module fragment are unowned. Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const; - /// \brief Determine whether this declaration might be hidden from name + /// Determine whether this declaration might be hidden from name /// lookup. Note that the declaration might be visible even if this returns /// \c false, if the owning module is visible within the query context. // FIXME: Rename this to make it clearer what it does. @@ -774,12 +780,12 @@ public: setModuleOwnershipKind(ModuleOwnershipKind::Visible); } - /// \brief Get the kind of module ownership for this declaration. + /// Get the kind of module ownership for this declaration. ModuleOwnershipKind getModuleOwnershipKind() const { return NextInContextAndBits.getInt(); } - /// \brief Set whether this declaration is hidden from name lookup. + /// Set whether this declaration is hidden from name lookup. void setModuleOwnershipKind(ModuleOwnershipKind MOK) { assert(!(getModuleOwnershipKind() == ModuleOwnershipKind::Unowned && MOK != ModuleOwnershipKind::Unowned && !isFromASTFile() && @@ -836,6 +842,10 @@ public: void setLexicalDeclContext(DeclContext *DC); + /// Determine whether this declaration is a templated entity (whether it is + // within the scope of a template parameter). + bool isTemplated() const; + /// isDefinedOutsideFunctionOrMethod - This predicate returns true if this /// scoped decl is defined outside the current function or method. This is /// roughly global variables and functions, but also handles enums (which @@ -844,7 +854,7 @@ public: return getParentFunctionOrMethod() == nullptr; } - /// \brief Returns true if this declaration lexically is inside a function. + /// Returns true if this declaration lexically is inside a function. /// It recognizes non-defining declarations as well as members of local /// classes: /// \code @@ -853,7 +863,7 @@ public: /// \endcode bool isLexicallyWithinFunctionOrMethod() const; - /// \brief If this decl is defined inside a function/method/block it returns + /// If this decl is defined inside a function/method/block it returns /// the corresponding DeclContext, otherwise it returns null. const DeclContext *getParentFunctionOrMethod() const; DeclContext *getParentFunctionOrMethod() { @@ -861,32 +871,32 @@ public: const_cast<const Decl*>(this)->getParentFunctionOrMethod()); } - /// \brief Retrieves the "canonical" declaration of the given declaration. + /// Retrieves the "canonical" declaration of the given declaration. virtual Decl *getCanonicalDecl() { return this; } const Decl *getCanonicalDecl() const { return const_cast<Decl*>(this)->getCanonicalDecl(); } - /// \brief Whether this particular Decl is a canonical one. + /// Whether this particular Decl is a canonical one. bool isCanonicalDecl() const { return getCanonicalDecl() == this; } protected: - /// \brief Returns the next redeclaration or itself if this is the only decl. + /// Returns the next redeclaration or itself if this is the only decl. /// /// Decl subclasses that can be redeclared should override this method so that /// Decl::redecl_iterator can iterate over them. virtual Decl *getNextRedeclarationImpl() { return this; } - /// \brief Implementation of getPreviousDecl(), to be overridden by any + /// Implementation of getPreviousDecl(), to be overridden by any /// subclass that has a redeclaration chain. virtual Decl *getPreviousDeclImpl() { return nullptr; } - /// \brief Implementation of getMostRecentDecl(), to be overridden by any + /// Implementation of getMostRecentDecl(), to be overridden by any /// subclass that has a redeclaration chain. virtual Decl *getMostRecentDeclImpl() { return this; } public: - /// \brief Iterates through all the redeclarations of the same decl. + /// Iterates through all the redeclarations of the same decl. class redecl_iterator { /// Current - The current declaration. Decl *Current = nullptr; @@ -931,7 +941,7 @@ public: using redecl_range = llvm::iterator_range<redecl_iterator>; - /// \brief Returns an iterator range for all the redeclarations of the same + /// Returns an iterator range for all the redeclarations of the same /// decl. It will iterate at least once (when this decl is the only one). redecl_range redecls() const { return redecl_range(redecls_begin(), redecls_end()); @@ -943,26 +953,26 @@ public: redecl_iterator redecls_end() const { return redecl_iterator(); } - /// \brief Retrieve the previous declaration that declares the same entity + /// Retrieve the previous declaration that declares the same entity /// as this declaration, or NULL if there is no previous declaration. Decl *getPreviousDecl() { return getPreviousDeclImpl(); } - /// \brief Retrieve the most recent declaration that declares the same entity + /// 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 { return const_cast<Decl *>(this)->getPreviousDeclImpl(); } - /// \brief True if this is the first declaration in its redeclaration chain. + /// True if this is the first declaration in its redeclaration chain. bool isFirstDecl() const { return getPreviousDecl() == nullptr; } - /// \brief Retrieve the most recent declaration that declares the same entity + /// Retrieve the most recent declaration that declares the same entity /// as this declaration (which may be this declaration). Decl *getMostRecentDecl() { return getMostRecentDeclImpl(); } - /// \brief Retrieve the most recent declaration that declares the same entity + /// Retrieve the most recent declaration that declares the same entity /// as this declaration (which may be this declaration). const Decl *getMostRecentDecl() const { return const_cast<Decl *>(this)->getMostRecentDeclImpl(); @@ -973,7 +983,7 @@ public: /// top-level Stmt* of that body. Otherwise this method returns null. virtual Stmt* getBody() const { return nullptr; } - /// \brief Returns true if this \c Decl represents a declaration for a body of + /// Returns true if this \c Decl represents a declaration for a body of /// code, such as a function or method definition. /// Note that \c hasBody can also return true if any redeclaration of this /// \c Decl represents a declaration for a body of code. @@ -996,24 +1006,24 @@ public: /// template parameter pack. bool isTemplateParameterPack() const; - /// \brief Whether this declaration is a parameter pack. + /// Whether this declaration is a parameter pack. bool isParameterPack() const; - /// \brief returns true if this declaration is a template + /// returns true if this declaration is a template bool isTemplateDecl() const; - /// \brief Whether this declaration is a function or function template. + /// Whether this declaration is a function or function template. bool isFunctionOrFunctionTemplate() const { return (DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction) || DeclKind == FunctionTemplate; } - /// \brief If this is a declaration that describes some template, this + /// If this is a declaration that describes some template, this /// method returns that template declaration. TemplateDecl *getDescribedTemplate() const; - /// \brief Returns the function itself, or the templated function if this is a + /// Returns the function itself, or the templated function if this is a /// function template. FunctionDecl *getAsFunction() LLVM_READONLY; @@ -1021,7 +1031,7 @@ public: return const_cast<Decl *>(this)->getAsFunction(); } - /// \brief Changes the namespace of this declaration to reflect that it's + /// Changes the namespace of this declaration to reflect that it's /// a function-local extern declaration. /// /// These declarations appear in the lexical context of the extern @@ -1042,14 +1052,14 @@ public: IdentifierNamespace |= IDNS_Ordinary; } - /// \brief Determine whether this is a block-scope declaration with linkage. + /// Determine whether this is a block-scope declaration with linkage. /// This will either be a local variable declaration declared 'extern', or a /// local function declaration. bool isLocalExternDecl() { return IdentifierNamespace & IDNS_LocalExtern; } - /// \brief Changes the namespace of this declaration to reflect that it's + /// Changes the namespace of this declaration to reflect that it's /// the object of a friend declaration. /// /// These declarations appear in the lexical context of the friending @@ -1091,7 +1101,7 @@ public: FOK_Undeclared ///< A friend of a previously-undeclared entity. }; - /// \brief Determines whether this declaration is the object of a + /// Determines whether this declaration is the object of a /// friend declaration and, if so, what kind. /// /// There is currently no direct way to find the associated FriendDecl. @@ -1131,7 +1141,7 @@ public: void dump(raw_ostream &Out, bool Deserialize = false) const; - /// \brief Looks through the Decl's underlying type to extract a FunctionType + /// Looks through the Decl's underlying type to extract a FunctionType /// when possible. Will return null if the type underlying the Decl does not /// have a FunctionType. const FunctionType *getFunctionType(bool BlocksToo = true) const; @@ -1145,7 +1155,7 @@ protected: ASTMutationListener *getASTMutationListener() const; }; -/// \brief Determine whether two declarations declare the same entity. +/// Determine whether two declarations declare the same entity. inline bool declaresSameEntity(const Decl *D1, const Decl *D2) { if (!D1 || !D2) return false; @@ -1172,7 +1182,7 @@ public: void print(raw_ostream &OS) const override; }; -/// \brief The results of name lookup within a DeclContext. This is either a +/// The results of name lookup within a DeclContext. This is either a /// single result (with no stable storage) or a collection of results (with /// stable storage provided by the lookup table). class DeclContextLookupResult { @@ -1253,36 +1263,36 @@ class DeclContext { /// DeclKind - This indicates which class this is. unsigned DeclKind : 8; - /// \brief Whether this declaration context also has some external + /// Whether this declaration context also has some external /// storage that contains additional declarations that are lexically /// part of this context. mutable bool ExternalLexicalStorage : 1; - /// \brief Whether this declaration context also has some external + /// Whether this declaration context also has some external /// storage that contains additional declarations that are visible /// in this context. mutable bool ExternalVisibleStorage : 1; - /// \brief Whether this declaration context has had external visible + /// Whether this declaration context has had external visible /// storage added since the last lookup. In this case, \c LookupPtr's /// invariant may not hold and needs to be fixed before we perform /// another lookup. mutable bool NeedToReconcileExternalVisibleStorage : 1; - /// \brief If \c true, this context may have local lexical declarations + /// If \c true, this context may have local lexical declarations /// that are missing from the lookup table. mutable bool HasLazyLocalLexicalLookups : 1; - /// \brief If \c true, the external source may have lexical declarations + /// If \c true, the external source may have lexical declarations /// that are missing from the lookup table. mutable bool HasLazyExternalLexicalLookups : 1; - /// \brief If \c true, lookups should only return identifier from + /// If \c true, lookups should only return identifier from /// DeclContext scope (for example TranslationUnit). Used in /// LookupQualifiedName() mutable bool UseQualifiedLookup : 1; - /// \brief Pointer to the data structure used to lookup declarations + /// Pointer to the data structure used to lookup declarations /// within this context (or a DependentStoredDeclsMap if this is a /// dependent context). We maintain the invariant that, if the map /// contains an entry for a DeclarationName (and we haven't lazily @@ -1305,7 +1315,7 @@ protected: /// another pointer. mutable Decl *LastDecl = nullptr; - /// \brief Build up a chain of declarations. + /// Build up a chain of declarations. /// /// \returns the first/last pair of declarations. static std::pair<Decl *, Decl *> @@ -1388,7 +1398,7 @@ public: } |