[clang] 7520cf0 - [clang] Reformat cindex. NFC.
Michael Kruse via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 25 09:12:29 PDT 2020
Author: Michael Kruse
Date: 2020-03-25T11:11:48-05:00
New Revision: 7520cf03eeb8b0ece8a151cee15145aea3049632
URL: https://github.com/llvm/llvm-project/commit/7520cf03eeb8b0ece8a151cee15145aea3049632
DIFF: https://github.com/llvm/llvm-project/commit/7520cf03eeb8b0ece8a151cee15145aea3049632.diff
LOG: [clang] Reformat cindex. NFC.
to reduce spurios changes in patches after clang-formatting them. In
particular, these files contain long enums that clang-format reformats
in their entirety if e.g. an element is added.
Reviews having this problem include https://reviews.llvm.org/D76342 and
https://reviews.llvm.org/D71447.
Added:
Modified:
clang/include/clang-c/Index.h
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
clang/tools/libclang/CXCursor.h
clang/tools/libclang/CursorVisitor.h
Removed:
################################################################################
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index ad2bb6a76c43..cca7198d2f9f 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -35,22 +35,17 @@
#define CINDEX_VERSION_MAJOR 0
#define CINDEX_VERSION_MINOR 59
-#define CINDEX_VERSION_ENCODE(major, minor) ( \
- ((major) * 10000) \
- + ((minor) * 1))
+#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
-#define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
- CINDEX_VERSION_MAJOR, \
- CINDEX_VERSION_MINOR )
+#define CINDEX_VERSION \
+ CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
-#define CINDEX_VERSION_STRINGIZE_(major, minor) \
- #major"."#minor
-#define CINDEX_VERSION_STRINGIZE(major, minor) \
- CINDEX_VERSION_STRINGIZE_(major, minor)
+#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor
+#define CINDEX_VERSION_STRINGIZE(major, minor) \
+ CINDEX_VERSION_STRINGIZE_(major, minor)
-#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE( \
- CINDEX_VERSION_MAJOR, \
- CINDEX_VERSION_MINOR)
+#define CINDEX_VERSION_STRING \
+ CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
LLVM_CLANG_C_EXTERN_C_BEGIN
@@ -382,7 +377,7 @@ typedef struct {
* \param outID stores the returned CXFileUniqueID.
* \returns If there was a failure getting the unique ID, returns non-zero,
* otherwise returns 0.
-*/
+ */
CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
/**
@@ -390,8 +385,8 @@ CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID);
* multiple inclusions, either with the conventional
* \#ifndef/\#define/\#endif macro guards or with \#pragma once.
*/
-CINDEX_LINKAGE unsigned
-clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
+CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu,
+ CXFile file);
/**
* Retrieve a file handle within the given translation unit.
@@ -496,8 +491,7 @@ CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
* in a particular translation unit.
*/
CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu,
- CXFile file,
- unsigned line,
+ CXFile file, unsigned line,
unsigned column);
/**
* Retrieves the source location associated with a given character offset
@@ -566,8 +560,7 @@ CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range);
* buffer to which the given source location points.
*/
CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
- CXFile *file,
- unsigned *line,
+ CXFile *file, unsigned *line,
unsigned *column,
unsigned *offset);
@@ -613,8 +606,7 @@ CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location,
*/
CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
CXString *filename,
- unsigned *line,
- unsigned *column);
+ unsigned *line, unsigned *column);
/**
* Legacy API to retrieve the file, line, column, and offset represented
@@ -625,8 +617,7 @@ CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location,
* details.
*/
CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
- CXFile *file,
- unsigned *line,
+ CXFile *file, unsigned *line,
unsigned *column,
unsigned *offset);
@@ -653,8 +644,7 @@ CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location,
* buffer to which the given source location points.
*/
CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
- CXFile *file,
- unsigned *line,
+ CXFile *file, unsigned *line,
unsigned *column,
unsigned *offset);
@@ -682,10 +672,8 @@ CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location,
* buffer to which the given source location points.
*/
CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location,
- CXFile *file,
- unsigned *line,
- unsigned *column,
- unsigned *offset);
+ CXFile *file, unsigned *line,
+ unsigned *column, unsigned *offset);
/**
* Retrieve a source location representing the first character within a
@@ -727,7 +715,8 @@ CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
* The preprocessor will skip lines when they are surrounded by an
* if/ifdef/ifndef directive whose condition does not evaluate to true.
*/
-CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
+CINDEX_LINKAGE CXSourceRangeList *
+clang_getAllSkippedRanges(CXTranslationUnit tu);
/**
* Destroy the given \c CXSourceRangeList.
@@ -758,7 +747,7 @@ enum CXDiagnosticSeverity {
* This diagnostic is a note that should be attached to the
* previous (non-note) diagnostic.
*/
- CXDiagnostic_Note = 1,
+ CXDiagnostic_Note = 1,
/**
* This diagnostic indicates suspicious code that may not be
@@ -769,14 +758,14 @@ enum CXDiagnosticSeverity {
/**
* This diagnostic indicates that the code is ill-formed.
*/
- CXDiagnostic_Error = 3,
+ CXDiagnostic_Error = 3,
/**
* This diagnostic indicates that the code is ill-formed such
* that future parser recovery is unlikely to produce useful
* results.
*/
- CXDiagnostic_Fatal = 4
+ CXDiagnostic_Fatal = 4
};
/**
@@ -849,9 +838,8 @@ enum CXLoadDiag_Error {
* \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These
* diagnostics should be released using clang_disposeDiagnosticSet().
*/
-CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(const char *file,
- enum CXLoadDiag_Error *error,
- CXString *errorString);
+CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics(
+ const char *file, enum CXLoadDiag_Error *error, CXString *errorString);
/**
* Release a CXDiagnosticSet and all of its contained diagnostics.
@@ -891,7 +879,7 @@ CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit,
* \param Unit the translation unit to query.
*/
CINDEX_LINKAGE CXDiagnosticSet
- clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
+clang_getDiagnosticSetFromTU(CXTranslationUnit Unit);
/**
* Destroy a diagnostic.
@@ -997,7 +985,7 @@ CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
* Determine the severity of the given diagnostic.
*/
CINDEX_LINKAGE enum CXDiagnosticSeverity
-clang_getDiagnosticSeverity(CXDiagnostic);
+ clang_getDiagnosticSeverity(CXDiagnostic);
/**
* Retrieve the source location of the given diagnostic.
@@ -1049,8 +1037,8 @@ CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic);
*
* \returns The name of the given diagnostic category.
*/
-CINDEX_DEPRECATED CINDEX_LINKAGE
-CXString clang_getDiagnosticCategoryName(unsigned Category);
+CINDEX_DEPRECATED CINDEX_LINKAGE CXString
+clang_getDiagnosticCategoryName(unsigned Category);
/**
* Retrieve the diagnostic category text for a given diagnostic.
@@ -1112,9 +1100,8 @@ CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic);
* \returns A string containing text that should be replace the source
* code indicated by the \c ReplacementRange.
*/
-CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(CXDiagnostic Diagnostic,
- unsigned FixIt,
- CXSourceRange *ReplacementRange);
+CINDEX_LINKAGE CXString clang_getDiagnosticFixIt(
+ CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange);
/**
* @}
@@ -1177,12 +1164,9 @@ clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit);
* guarantee their validity until the call to this function returns.
*/
CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
- CXIndex CIdx,
- const char *source_filename,
- int num_clang_command_line_args,
- const char * const *clang_command_line_args,
- unsigned num_unsaved_files,
- struct CXUnsavedFile *unsaved_files);
+ CXIndex CIdx, const char *source_filename, int num_clang_command_line_args,
+ const char *const *clang_command_line_args, unsigned num_unsaved_files,
+ struct CXUnsavedFile *unsaved_files);
/**
* Same as \c clang_createTranslationUnit2, but returns
@@ -1190,9 +1174,8 @@ CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
* routine returns a \c NULL \c CXTranslationUnit, without further detailed
* error codes.
*/
-CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
- CXIndex CIdx,
- const char *ast_filename);
+CINDEX_LINKAGE CXTranslationUnit
+clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename);
/**
* Create a translation unit from an AST file (\c -emit-ast).
@@ -1202,10 +1185,9 @@ CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(
*
* \returns Zero on success, otherwise returns an error code.
*/
-CINDEX_LINKAGE enum CXErrorCode clang_createTranslationUnit2(
- CXIndex CIdx,
- const char *ast_filename,
- CXTranslationUnit *out_TU);
+CINDEX_LINKAGE enum CXErrorCode
+clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename,
+ CXTranslationUnit *out_TU);
/**
* Flags that control the creation of translation units.
@@ -1383,14 +1365,11 @@ CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
* routine returns a \c NULL \c CXTranslationUnit, without further detailed
* error codes.
*/
-CINDEX_LINKAGE CXTranslationUnit
-clang_parseTranslationUnit(CXIndex CIdx,
- const char *source_filename,
- const char *const *command_line_args,
- int num_command_line_args,
- struct CXUnsavedFile *unsaved_files,
- unsigned num_unsaved_files,
- unsigned options);
+CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(
+ CXIndex CIdx, const char *source_filename,
+ const char *const *command_line_args, int num_command_line_args,
+ struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
+ unsigned options);
/**
* Parse the given source file and the translation unit corresponding
@@ -1436,15 +1415,11 @@ clang_parseTranslationUnit(CXIndex CIdx,
*
* \returns Zero on success, otherwise returns an error code.
*/
-CINDEX_LINKAGE enum CXErrorCode
-clang_parseTranslationUnit2(CXIndex CIdx,
- const char *source_filename,
- const char *const *command_line_args,
- int num_command_line_args,
- struct CXUnsavedFile *unsaved_files,
- unsigned num_unsaved_files,
- unsigned options,
- CXTranslationUnit *out_TU);
+CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2(
+ CXIndex CIdx, const char *source_filename,
+ const char *const *command_line_args, int num_command_line_args,
+ struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files,
+ unsigned options, CXTranslationUnit *out_TU);
/**
* Same as clang_parseTranslationUnit2 but requires a full command line
@@ -1623,14 +1598,14 @@ CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
* \c clang_disposeTranslationUnit(TU). The error codes returned by this
* routine are described by the \c CXErrorCode enum.
*/
-CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
- unsigned num_unsaved_files,
- struct CXUnsavedFile *unsaved_files,
- unsigned options);
+CINDEX_LINKAGE int
+clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files,
+ struct CXUnsavedFile *unsaved_files,
+ unsigned options);
/**
- * 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,
CXTUResourceUsage_Identifiers = 2,
@@ -1648,16 +1623,16 @@ enum CXTUResourceUsageKind {
CXTUResourceUsage_Preprocessor_HeaderSearch = 14,
CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST,
CXTUResourceUsage_MEMORY_IN_BYTES_END =
- CXTUResourceUsage_Preprocessor_HeaderSearch,
+ CXTUResourceUsage_Preprocessor_HeaderSearch,
CXTUResourceUsage_First = CXTUResourceUsage_AST,
CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch
};
/**
- * Returns the human-readable null-terminated C string that represents
- * the name of the memory category. This string should never be freed.
- */
+ * 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);
@@ -1670,8 +1645,8 @@ typedef struct CXTUResourceUsageEntry {
} CXTUResourceUsageEntry;
/**
- * The memory usage of a CXTranslationUnit, broken into categories.
- */
+ * The memory usage of a CXTranslationUnit, broken into categories.
+ */
typedef struct CXTUResourceUsage {
/* Private data member, used for queries. */
void *data;
@@ -1686,10 +1661,11 @@ typedef struct CXTUResourceUsage {
} CXTUResourceUsage;
/**
- * Return the memory usage of a translation unit. This object
- * should be released with clang_disposeCXTUResourceUsage().
- */
-CINDEX_LINKAGE CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU);
+ * Return the memory usage of a translation unit. This object
+ * should be released with clang_disposeCXTUResourceUsage().
+ */
+CINDEX_LINKAGE CXTUResourceUsage
+clang_getCXTUResourceUsage(CXTranslationUnit TU);
CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage);
@@ -1704,24 +1680,21 @@ clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit);
/**
* Destroy the CXTargetInfo object.
*/
-CINDEX_LINKAGE void
-clang_TargetInfo_dispose(CXTargetInfo Info);
+CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info);
/**
* Get the normalized target triple as a string.
*
* Returns the empty string in case of any error.
*/
-CINDEX_LINKAGE CXString
-clang_TargetInfo_getTriple(CXTargetInfo Info);
+CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info);
/**
* Get the pointer width of the target in bits.
*
* Returns -1 in case of error.
*/
-CINDEX_LINKAGE int
-clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
+CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info);
/**
* @}
@@ -1741,95 +1714,95 @@ enum CXCursorKind {
* spelling, find their definitions, etc. However, the specific kind
* of the declaration is not reported.
*/
- CXCursor_UnexposedDecl = 1,
+ CXCursor_UnexposedDecl = 1,
/** A C or C++ struct. */
- CXCursor_StructDecl = 2,
+ CXCursor_StructDecl = 2,
/** A C or C++ union. */
- CXCursor_UnionDecl = 3,
+ CXCursor_UnionDecl = 3,
/** A C++ class. */
- CXCursor_ClassDecl = 4,
+ CXCursor_ClassDecl = 4,
/** An enumeration. */
- CXCursor_EnumDecl = 5,
+ CXCursor_EnumDecl = 5,
/**
* A field (in C) or non-static data member (in C++) in a
* struct, union, or C++ class.
*/
- CXCursor_FieldDecl = 6,
+ CXCursor_FieldDecl = 6,
/** An enumerator constant. */
- CXCursor_EnumConstantDecl = 7,
+ CXCursor_EnumConstantDecl = 7,
/** A function. */
- CXCursor_FunctionDecl = 8,
+ CXCursor_FunctionDecl = 8,
/** A variable. */
- CXCursor_VarDecl = 9,
+ CXCursor_VarDecl = 9,
/** A function or method parameter. */
- CXCursor_ParmDecl = 10,
+ CXCursor_ParmDecl = 10,
/** An Objective-C \@interface. */
- CXCursor_ObjCInterfaceDecl = 11,
+ CXCursor_ObjCInterfaceDecl = 11,
/** An Objective-C \@interface for a category. */
- CXCursor_ObjCCategoryDecl = 12,
+ CXCursor_ObjCCategoryDecl = 12,
/** An Objective-C \@protocol declaration. */
- CXCursor_ObjCProtocolDecl = 13,
+ CXCursor_ObjCProtocolDecl = 13,
/** An Objective-C \@property declaration. */
- CXCursor_ObjCPropertyDecl = 14,
+ CXCursor_ObjCPropertyDecl = 14,
/** An Objective-C instance variable. */
- CXCursor_ObjCIvarDecl = 15,
+ CXCursor_ObjCIvarDecl = 15,
/** An Objective-C instance method. */
- CXCursor_ObjCInstanceMethodDecl = 16,
+ CXCursor_ObjCInstanceMethodDecl = 16,
/** An Objective-C class method. */
- CXCursor_ObjCClassMethodDecl = 17,
+ CXCursor_ObjCClassMethodDecl = 17,
/** An Objective-C \@implementation. */
- CXCursor_ObjCImplementationDecl = 18,
+ CXCursor_ObjCImplementationDecl = 18,
/** An Objective-C \@implementation for a category. */
- CXCursor_ObjCCategoryImplDecl = 19,
+ CXCursor_ObjCCategoryImplDecl = 19,
/** A typedef. */
- CXCursor_TypedefDecl = 20,
+ CXCursor_TypedefDecl = 20,
/** A C++ class method. */
- CXCursor_CXXMethod = 21,
+ CXCursor_CXXMethod = 21,
/** A C++ namespace. */
- CXCursor_Namespace = 22,
+ CXCursor_Namespace = 22,
/** A linkage specification, e.g. 'extern "C"'. */
- CXCursor_LinkageSpec = 23,
+ CXCursor_LinkageSpec = 23,
/** A C++ constructor. */
- CXCursor_Constructor = 24,
+ CXCursor_Constructor = 24,
/** A C++ destructor. */
- CXCursor_Destructor = 25,
+ CXCursor_Destructor = 25,
/** A C++ conversion function. */
- CXCursor_ConversionFunction = 26,
+ CXCursor_ConversionFunction = 26,
/** A C++ template type parameter. */
- CXCursor_TemplateTypeParameter = 27,
+ CXCursor_TemplateTypeParameter = 27,
/** A C++ non-type template parameter. */
- CXCursor_NonTypeTemplateParameter = 28,
+ CXCursor_NonTypeTemplateParameter = 28,
/** A C++ template template parameter. */
- CXCursor_TemplateTemplateParameter = 29,
+ CXCursor_TemplateTemplateParameter = 29,
/** A C++ function template. */
- CXCursor_FunctionTemplate = 30,
+ CXCursor_FunctionTemplate = 30,
/** A C++ class template. */
- CXCursor_ClassTemplate = 31,
+ CXCursor_ClassTemplate = 31,
/** A C++ class template partial specialization. */
CXCursor_ClassTemplatePartialSpecialization = 32,
/** A C++ namespace alias declaration. */
- CXCursor_NamespaceAlias = 33,
+ CXCursor_NamespaceAlias = 33,
/** A C++ using directive. */
- CXCursor_UsingDirective = 34,
+ CXCursor_UsingDirective = 34,
/** A C++ using declaration. */
- CXCursor_UsingDeclaration = 35,
+ CXCursor_UsingDeclaration = 35,
/** A C++ alias declaration */
- CXCursor_TypeAliasDecl = 36,
+ CXCursor_TypeAliasDecl = 36,
/** An Objective-C \@synthesize definition. */
- CXCursor_ObjCSynthesizeDecl = 37,
+ CXCursor_ObjCSynthesizeDecl = 37,
/** An Objective-C \@dynamic definition. */
- CXCursor_ObjCDynamicDecl = 38,
+ CXCursor_ObjCDynamicDecl = 38,
/** An access specifier. */
- CXCursor_CXXAccessSpecifier = 39,
+ CXCursor_CXXAccessSpecifier = 39,
- CXCursor_FirstDecl = CXCursor_UnexposedDecl,
- CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
+ CXCursor_FirstDecl = CXCursor_UnexposedDecl,
+ CXCursor_LastDecl = CXCursor_CXXAccessSpecifier,
/* References */
- CXCursor_FirstRef = 40, /* Decl references */
- CXCursor_ObjCSuperClassRef = 40,
- CXCursor_ObjCProtocolRef = 41,
- CXCursor_ObjCClassRef = 42,
+ CXCursor_FirstRef = 40, /* Decl references */
+ CXCursor_ObjCSuperClassRef = 40,
+ CXCursor_ObjCProtocolRef = 41,
+ CXCursor_ObjCClassRef = 42,
/**
* A reference to a type declaration.
*
@@ -1845,22 +1818,22 @@ enum CXCursorKind {
* while the type of the variable "size" is referenced. The cursor
* referenced by the type of size is the typedef for size_type.
*/
- CXCursor_TypeRef = 43,
- CXCursor_CXXBaseSpecifier = 44,
+ CXCursor_TypeRef = 43,
+ CXCursor_CXXBaseSpecifier = 44,
/**
* A reference to a class template, function template, template
* template parameter, or class template partial specialization.
*/
- CXCursor_TemplateRef = 45,
+ CXCursor_TemplateRef = 45,
/**
* A reference to a namespace or namespace alias.
*/
- CXCursor_NamespaceRef = 46,
+ CXCursor_NamespaceRef = 46,
/**
* 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,
+ CXCursor_MemberRef = 47,
/**
* A reference to a labeled statement.
*
@@ -1876,7 +1849,7 @@ enum CXCursorKind {
*
* A label reference cursor refers to a label statement.
*/
- CXCursor_LabelRef = 48,
+ CXCursor_LabelRef = 48,
/**
* A reference to a set of overloaded functions or function templates
@@ -1914,26 +1887,26 @@ enum CXCursorKind {
* \c clang_getOverloadedDecl() can be used to retrieve the definitions
* referenced by this cursor.
*/
- CXCursor_OverloadedDeclRef = 49,
+ CXCursor_OverloadedDeclRef = 49,
/**
* A reference to a variable that occurs in some non-expression
* context, e.g., a C++ lambda capture list.
*/
- CXCursor_VariableRef = 50,
+ CXCursor_VariableRef = 50,
- CXCursor_LastRef = CXCursor_VariableRef,
+ CXCursor_LastRef = CXCursor_VariableRef,
/* Error conditions */
- CXCursor_FirstInvalid = 70,
- CXCursor_InvalidFile = 70,
- CXCursor_NoDeclFound = 71,
- CXCursor_NotImplemented = 72,
- CXCursor_InvalidCode = 73,
- CXCursor_LastInvalid = CXCursor_InvalidCode,
+ CXCursor_FirstInvalid = 70,
+ CXCursor_InvalidFile = 70,
+ CXCursor_NoDeclFound = 71,
+ CXCursor_NotImplemented = 72,
+ CXCursor_InvalidCode = 73,
+ CXCursor_LastInvalid = CXCursor_InvalidCode,
/* Expressions */
- CXCursor_FirstExpr = 100,
+ CXCursor_FirstExpr = 100,
/**
* An expression whose specific kind is not exposed via this
@@ -1944,104 +1917,104 @@ enum CXCursorKind {
* spelling, children, etc. However, the specific kind of the
* expression is not reported.
*/
- CXCursor_UnexposedExpr = 100,
+ CXCursor_UnexposedExpr = 100,
/**
* An expression that refers to some value declaration, such
* as a function, variable, or enumerator.
*/
- CXCursor_DeclRefExpr = 101,
+ CXCursor_DeclRefExpr = 101,
/**
* An expression that refers to a member of a struct, union,
* class, Objective-C class, etc.
*/
- CXCursor_MemberRefExpr = 102,
+ CXCursor_MemberRefExpr = 102,
/** An expression that calls a function. */
- CXCursor_CallExpr = 103,
+ CXCursor_CallExpr = 103,
/** An expression that sends a message to an Objective-C
object or class. */
- CXCursor_ObjCMessageExpr = 104,
+ CXCursor_ObjCMessageExpr = 104,
/** An expression that represents a block literal. */
- CXCursor_BlockExpr = 105,
+ CXCursor_BlockExpr = 105,
/** An integer literal.
*/
- CXCursor_IntegerLiteral = 106,
+ CXCursor_IntegerLiteral = 106,
/** A floating point number literal.
*/
- CXCursor_FloatingLiteral = 107,
+ CXCursor_FloatingLiteral = 107,
/** An imaginary number literal.
*/
- CXCursor_ImaginaryLiteral = 108,
+ CXCursor_ImaginaryLiteral = 108,
/** A string literal.
*/
- CXCursor_StringLiteral = 109,
+ CXCursor_StringLiteral = 109,
/** A character literal.
*/
- CXCursor_CharacterLiteral = 110,
+ CXCursor_CharacterLiteral = 110,
/** A parenthesized expression, e.g. "(1)".
*
* This AST node is only formed if full location information is requested.
*/
- CXCursor_ParenExpr = 111,
+ CXCursor_ParenExpr = 111,
/** This represents the unary-expression's (except sizeof and
* alignof).
*/
- CXCursor_UnaryOperator = 112,
+ CXCursor_UnaryOperator = 112,
/** [C99 6.5.2.1] Array Subscripting.
*/
- CXCursor_ArraySubscriptExpr = 113,
+ CXCursor_ArraySubscriptExpr = 113,
/** A builtin binary operation expression such as "x + y" or
* "x <= y".
*/
- CXCursor_BinaryOperator = 114,
+ CXCursor_BinaryOperator = 114,
/** Compound assignment such as "+=".
*/
- CXCursor_CompoundAssignOperator = 115,
+ CXCursor_CompoundAssignOperator = 115,
/** The ?: ternary operator.
*/
- CXCursor_ConditionalOperator = 116,
+ CXCursor_ConditionalOperator = 116,
/** 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,
+ CXCursor_CStyleCastExpr = 117,
/** [C99 6.5.2.5]
*/
- CXCursor_CompoundLiteralExpr = 118,
+ CXCursor_CompoundLiteralExpr = 118,
/** Describes an C or C++ initializer list.
*/
- CXCursor_InitListExpr = 119,
+ CXCursor_InitListExpr = 119,
/** The GNU address of label extension, representing &&label.
*/
- CXCursor_AddrLabelExpr = 120,
+ CXCursor_AddrLabelExpr = 120,
/** This is the GNU Statement Expression extension: ({int X=4; X;})
*/
- CXCursor_StmtExpr = 121,
+ CXCursor_StmtExpr = 121,
/** Represents a C11 generic selection.
*/
- CXCursor_GenericSelectionExpr = 122,
+ CXCursor_GenericSelectionExpr = 122,
/** 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
@@ -2051,23 +2024,23 @@ enum CXCursorKind {
* NULL as __null in C++ rather than using 0 (which is an integer that may not
* match the size of a pointer).
*/
- CXCursor_GNUNullExpr = 123,
+ CXCursor_GNUNullExpr = 123,
/** C++'s static_cast<> expression.
*/
- CXCursor_CXXStaticCastExpr = 124,
+ CXCursor_CXXStaticCastExpr = 124,
/** C++'s dynamic_cast<> expression.
*/
- CXCursor_CXXDynamicCastExpr = 125,
+ CXCursor_CXXDynamicCastExpr = 125,
/** C++'s reinterpret_cast<> expression.
*/
- CXCursor_CXXReinterpretCastExpr = 126,
+ CXCursor_CXXReinterpretCastExpr = 126,
/** C++'s const_cast<> expression.
*/
- CXCursor_CXXConstCastExpr = 127,
+ CXCursor_CXXConstCastExpr = 127,
/** Represents an explicit C++ type conversion that uses "functional"
* notion (C++ [expr.type.conv]).
@@ -2077,60 +2050,60 @@ enum CXCursorKind {
* x = int(0.5);
* \endcode
*/
- CXCursor_CXXFunctionalCastExpr = 128,
+ CXCursor_CXXFunctionalCastExpr = 128,
/** A C++ typeid expression (C++ [expr.typeid]).
*/
- CXCursor_CXXTypeidExpr = 129,
+ CXCursor_CXXTypeidExpr = 129,
/** [C++ 2.13.5] C++ Boolean Literal.
*/
- CXCursor_CXXBoolLiteralExpr = 130,
+ CXCursor_CXXBoolLiteralExpr = 130,
/** [C++0x 2.14.7] C++ Pointer Literal.
*/
- CXCursor_CXXNullPtrLiteralExpr = 131,
+ CXCursor_CXXNullPtrLiteralExpr = 131,
/** Represents the "this" expression in C++
*/
- CXCursor_CXXThisExpr = 132,
+ CXCursor_CXXThisExpr = 132,
/** [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,
+ CXCursor_CXXThrowExpr = 133,
/** A new expression for memory allocation and constructor calls, e.g:
* "new CXXNewExpr(foo)".
*/
- CXCursor_CXXNewExpr = 134,
+ CXCursor_CXXNewExpr = 134,
/** A delete expression for memory deallocation and destructor calls,
* e.g. "delete[] pArray".
*/
- CXCursor_CXXDeleteExpr = 135,
+ CXCursor_CXXDeleteExpr = 135,
/** A unary expression. (noexcept, sizeof, or other traits)
*/
- CXCursor_UnaryExpr = 136,
+ CXCursor_UnaryExpr = 136,
/** An Objective-C string literal i.e. @"foo".
*/
- CXCursor_ObjCStringLiteral = 137,
+ CXCursor_ObjCStringLiteral = 137,
/** An Objective-C \@encode expression.
*/
- CXCursor_ObjCEncodeExpr = 138,
+ CXCursor_ObjCEncodeExpr = 138,
/** An Objective-C \@selector expression.
*/
- CXCursor_ObjCSelectorExpr = 139,
+ CXCursor_ObjCSelectorExpr = 139,
/** An Objective-C \@protocol expression.
*/
- CXCursor_ObjCProtocolExpr = 140,
+ CXCursor_ObjCProtocolExpr = 140,
/** An Objective-C "bridged" cast expression, which casts between
* Objective-C pointers and C pointers, transferring ownership in the process.
@@ -2139,7 +2112,7 @@ enum CXCursorKind {
* NSString *str = (__bridge_transfer NSString *)CFCreateString();
* \endcode
*/
- CXCursor_ObjCBridgedCastExpr = 141,
+ CXCursor_ObjCBridgedCastExpr = 141,
/** Represents a C++0x pack expansion that produces a sequence of
* expressions.
@@ -2154,7 +2127,7 @@ enum CXCursorKind {
* }
* \endcode
*/
- CXCursor_PackExpansionExpr = 142,
+ CXCursor_PackExpansionExpr = 142,
/** Represents an expression that computes the length of a parameter
* pack.
@@ -2166,7 +2139,7 @@ enum CXCursorKind {
* };
* \endcode
*/
- CXCursor_SizeOfPackExpr = 143,
+ CXCursor_SizeOfPackExpr = 143,
/* Represents a C++ lambda expression that produces a local function
* object.
@@ -2180,33 +2153,33 @@ enum CXCursorKind {
* }
* \endcode
*/
- CXCursor_LambdaExpr = 144,
+ CXCursor_LambdaExpr = 144,
/** Objective-c Boolean Literal.
*/
- CXCursor_ObjCBoolLiteralExpr = 145,
+ CXCursor_ObjCBoolLiteralExpr = 145,
/** Represents the "self" expression in an Objective-C method.
*/
- CXCursor_ObjCSelfExpr = 146,
+ CXCursor_ObjCSelfExpr = 146,
/** OpenMP 4.0 [2.4, Array Section].
*/
- CXCursor_OMPArraySectionExpr = 147,
+ CXCursor_OMPArraySectionExpr = 147,
/** Represents an @available(...) check.
*/
- CXCursor_ObjCAvailabilityCheckExpr = 148,
+ CXCursor_ObjCAvailabilityCheckExpr = 148,
/**
* Fixed point literal
*/
- CXCursor_FixedPointLiteral = 149,
+ CXCursor_FixedPointLiteral = 149,
- CXCursor_LastExpr = CXCursor_FixedPointLiteral,
+ CXCursor_LastExpr = CXCursor_FixedPointLiteral,
/* Statements */
- CXCursor_FirstStmt = 200,
+ CXCursor_FirstStmt = 200,
/**
* A statement whose specific kind is not exposed via this
* interface.
@@ -2216,7 +2189,7 @@ enum CXCursorKind {
* children, etc. However, the specific kind of the statement is not
* reported.
*/
- CXCursor_UnexposedStmt = 200,
+ CXCursor_UnexposedStmt = 200,
/** A labelled statement in a function.
*
@@ -2229,226 +2202,226 @@ enum CXCursorKind {
* \endcode
*
*/
- CXCursor_LabelStmt = 201,
+ CXCursor_LabelStmt = 201,
/** A group of statements like { stmt stmt }.
*
* This cursor kind is used to describe compound statements, e.g. function
* bodies.
*/
- CXCursor_CompoundStmt = 202,
+ CXCursor_CompoundStmt = 202,
/** A case statement.
*/
- CXCursor_CaseStmt = 203,
+ CXCursor_CaseStmt = 203,
/** A default statement.
*/
- CXCursor_DefaultStmt = 204,
+ CXCursor_DefaultStmt = 204,
/** An if statement
*/
- CXCursor_IfStmt = 205,
+ CXCursor_IfStmt = 205,
/** A switch statement.
*/
- CXCursor_SwitchStmt = 206,
+ CXCursor_SwitchStmt = 206,
/** A while statement.
*/
- CXCursor_WhileStmt = 207,
+ CXCursor_WhileStmt = 207,
/** A do statement.
*/
- CXCursor_DoStmt = 208,
+ CXCursor_DoStmt = 208,
/** A for statement.
*/
- CXCursor_ForStmt = 209,
+ CXCursor_ForStmt = 209,
/** A goto statement.
*/
- CXCursor_GotoStmt = 210,
+ CXCursor_GotoStmt = 210,
/** An indirect goto statement.
*/
- CXCursor_IndirectGotoStmt = 211,
+ CXCursor_IndirectGotoStmt = 211,
/** A continue statement.
*/
- CXCursor_ContinueStmt = 212,
+ CXCursor_ContinueStmt = 212,
/** A break statement.
*/
- CXCursor_BreakStmt = 213,
+ CXCursor_BreakStmt = 213,
/** A return statement.
*/
- CXCursor_ReturnStmt = 214,
+ CXCursor_ReturnStmt = 214,
/** A GCC inline assembly statement extension.
*/
- CXCursor_GCCAsmStmt = 215,
- CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
+ CXCursor_GCCAsmStmt = 215,
+ CXCursor_AsmStmt = CXCursor_GCCAsmStmt,
/** Objective-C's overall \@try-\@catch-\@finally statement.
*/
- CXCursor_ObjCAtTryStmt = 216,
+ CXCursor_ObjCAtTryStmt = 216,
/** Objective-C's \@catch statement.
*/
- CXCursor_ObjCAtCatchStmt = 217,
+ CXCursor_ObjCAtCatchStmt = 217,
/** Objective-C's \@finally statement.
*/
- CXCursor_ObjCAtFinallyStmt = 218,
+ CXCursor_ObjCAtFinallyStmt = 218,
/** Objective-C's \@throw statement.
*/
- CXCursor_ObjCAtThrowStmt = 219,
+ CXCursor_ObjCAtThrowStmt = 219,
/** Objective-C's \@synchronized statement.
*/
- CXCursor_ObjCAtSynchronizedStmt = 220,
+ CXCursor_ObjCAtSynchronizedStmt = 220,
/** Objective-C's autorelease pool statement.
*/
- CXCursor_ObjCAutoreleasePoolStmt = 221,
+ CXCursor_ObjCAutoreleasePoolStmt = 221,
/** Objective-C's collection statement.
*/
- CXCursor_ObjCForCollectionStmt = 222,
+ CXCursor_ObjCForCollectionStmt = 222,
/** C++'s catch statement.
*/
- CXCursor_CXXCatchStmt = 223,
+ CXCursor_CXXCatchStmt = 223,
/** C++'s try statement.
*/
- CXCursor_CXXTryStmt = 224,
+ CXCursor_CXXTryStmt = 224,
/** C++'s for (* : *) statement.
*/
- CXCursor_CXXForRangeStmt = 225,
+ CXCursor_CXXForRangeStmt = 225,
/** Windows Structured Exception Handling's try statement.
*/
- CXCursor_SEHTryStmt = 226,
+ CXCursor_SEHTryStmt = 226,
/** Windows Structured Exception Handling's except statement.
*/
- CXCursor_SEHExceptStmt = 227,
+ CXCursor_SEHExceptStmt = 227,
/** Windows Structured Exception Handling's finally statement.
*/
- CXCursor_SEHFinallyStmt = 228,
+ CXCursor_SEHFinallyStmt = 228,
/** A MS inline assembly statement extension.
*/
- CXCursor_MSAsmStmt = 229,
+ CXCursor_MSAsmStmt = 229,
/** The null statement ";": C99 6.8.3p3.
*
* This cursor kind is used to describe the null statement.
*/
- CXCursor_NullStmt = 230,
+ CXCursor_NullStmt = 230,
/** Adaptor class for mixing declarations with statements and
* expressions.
*/
- CXCursor_DeclStmt = 231,
+ CXCursor_DeclStmt = 231,
/** OpenMP parallel directive.
*/
- CXCursor_OMPParallelDirective = 232,
+ CXCursor_OMPParallelDirective = 232,
/** OpenMP SIMD directive.
*/
- CXCursor_OMPSimdDirective = 233,
+ CXCursor_OMPSimdDirective = 233,
/** OpenMP for directive.
*/
- CXCursor_OMPForDirective = 234,
+ CXCursor_OMPForDirective = 234,
/** OpenMP sections directive.
*/
- CXCursor_OMPSectionsDirective = 235,
+ CXCursor_OMPSectionsDirective = 235,
/** OpenMP section directive.
*/
- CXCursor_OMPSectionDirective = 236,
+ CXCursor_OMPSectionDirective = 236,
/** OpenMP single directive.
*/
- CXCursor_OMPSingleDirective = 237,
+ CXCursor_OMPSingleDirective = 237,
/** OpenMP parallel for directive.
*/
- CXCursor_OMPParallelForDirective = 238,
+ CXCursor_OMPParallelForDirective = 238,
/** OpenMP parallel sections directive.
*/
- CXCursor_OMPParallelSectionsDirective = 239,
+ CXCursor_OMPParallelSectionsDirective = 239,
/** OpenMP task directive.
*/
- CXCursor_OMPTaskDirective = 240,
+ CXCursor_OMPTaskDirective = 240,
/** OpenMP master directive.
*/
- CXCursor_OMPMasterDirective = 241,
+ CXCursor_OMPMasterDirective = 241,
/** OpenMP critical directive.
*/
- CXCursor_OMPCriticalDirective = 242,
+ CXCursor_OMPCriticalDirective = 242,
/** OpenMP taskyield directive.
*/
- CXCursor_OMPTaskyieldDirective = 243,
+ CXCursor_OMPTaskyieldDirective = 243,
/** OpenMP barrier directive.
*/
- CXCursor_OMPBarrierDirective = 244,
+ CXCursor_OMPBarrierDirective = 244,
/** OpenMP taskwait directive.
*/
- CXCursor_OMPTaskwaitDirective = 245,
+ CXCursor_OMPTaskwaitDirective = 245,
/** OpenMP flush directive.
*/
- CXCursor_OMPFlushDirective = 246,
+ CXCursor_OMPFlushDirective = 246,
/** Windows Structured Exception Handling's leave statement.
*/
- CXCursor_SEHLeaveStmt = 247,
+ CXCursor_SEHLeaveStmt = 247,
/** OpenMP ordered directive.
*/
- CXCursor_OMPOrderedDirective = 248,
+ CXCursor_OMPOrderedDirective = 248,
/** OpenMP atomic directive.
*/
- CXCursor_OMPAtomicDirective = 249,
+ CXCursor_OMPAtomicDirective = 249,
/** OpenMP for SIMD directive.
*/
- CXCursor_OMPForSimdDirective = 250,
+ CXCursor_OMPForSimdDirective = 250,
/** OpenMP parallel for SIMD directive.
*/
- CXCursor_OMPParallelForSimdDirective = 251,
+ CXCursor_OMPParallelForSimdDirective = 251,
/** OpenMP target directive.
*/
- CXCursor_OMPTargetDirective = 252,
+ CXCursor_OMPTargetDirective = 252,
/** OpenMP teams directive.
*/
- CXCursor_OMPTeamsDirective = 253,
+ CXCursor_OMPTeamsDirective = 253,
/** OpenMP taskgroup directive.
*/
- CXCursor_OMPTaskgroupDirective = 254,
+ CXCursor_OMPTaskgroupDirective = 254,
/** OpenMP cancellation point directive.
*/
@@ -2456,35 +2429,35 @@ enum CXCursorKind {
/** OpenMP cancel directive.
*/
- CXCursor_OMPCancelDirective = 256,
+ CXCursor_OMPCancelDirective = 256,
/** OpenMP target data directive.
*/
- CXCursor_OMPTargetDataDirective = 257,
+ CXCursor_OMPTargetDataDirective = 257,
/** OpenMP taskloop directive.
*/
- CXCursor_OMPTaskLoopDirective = 258,
+ CXCursor_OMPTaskLoopDirective = 258,
/** OpenMP taskloop simd directive.
*/
- CXCursor_OMPTaskLoopSimdDirective = 259,
+ CXCursor_OMPTaskLoopSimdDirective = 259,
/** OpenMP distribute directive.
*/
- CXCursor_OMPDistributeDirective = 260,
+ CXCursor_OMPDistributeDirective = 260,
/** OpenMP target enter data directive.
*/
- CXCursor_OMPTargetEnterDataDirective = 261,
+ CXCursor_OMPTargetEnterDataDirective = 261,
/** OpenMP target exit data directive.
*/
- CXCursor_OMPTargetExitDataDirective = 262,
+ CXCursor_OMPTargetExitDataDirective = 262,
/** OpenMP target parallel directive.
*/
- CXCursor_OMPTargetParallelDirective = 263,
+ CXCursor_OMPTargetParallelDirective = 263,
/** OpenMP target parallel for directive.
*/
@@ -2492,7 +2465,7 @@ enum CXCursorKind {
/** OpenMP target update directive.
*/
- CXCursor_OMPTargetUpdateDirective = 265,
+ CXCursor_OMPTargetUpdateDirective = 265,
/** OpenMP distribute parallel for directive.
*/
@@ -2564,23 +2537,23 @@ enum CXCursorKind {
/** OpenMP master taskloop simd directive.
*/
- CXCursor_OMPMasterTaskLoopSimdDirective = 283,
+ CXCursor_OMPMasterTaskLoopSimdDirective = 283,
/** OpenMP parallel master taskloop simd directive.
*/
- CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
+ CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284,
/** OpenMP parallel master directive.
*/
- CXCursor_OMPParallelMasterDirective = 285,
+ CXCursor_OMPParallelMasterDirective = 285,
/** OpenMP depobj directive.
*/
- CXCursor_OMPDepobjDirective = 286,
+ CXCursor_OMPDepobjDirective = 286,
/** OpenMP scan directive.
*/
- CXCursor_OMPScanDirective = 287,
+ CXCursor_OMPScanDirective = 287,
CXCursor_LastStmt = CXCursor_OMPScanDirective,
@@ -2590,89 +2563,89 @@ enum CXCursorKind {
* The translation unit cursor exists primarily to act as the root
* cursor for traversing the contents of a translation unit.
*/
- CXCursor_TranslationUnit = 300,
+ CXCursor_TranslationUnit = 300,
/* Attributes */
- CXCursor_FirstAttr = 400,
+ CXCursor_FirstAttr = 400,
/**
* An attribute whose specific kind is not exposed via this
* interface.
*/
- CXCursor_UnexposedAttr = 400,
-
- CXCursor_IBActionAttr = 401,
- CXCursor_IBOutletAttr = 402,
- CXCursor_IBOutletCollectionAttr = 403,
- CXCursor_CXXFinalAttr = 404,
- CXCursor_CXXOverrideAttr = 405,
- CXCursor_AnnotateAttr = 406,
- CXCursor_AsmLabelAttr = 407,
- CXCursor_PackedAttr = 408,
- CXCursor_PureAttr = 409,
- CXCursor_ConstAttr = 410,
- CXCursor_NoDuplicateAttr = 411,
- CXCursor_CUDAConstantAttr = 412,
- CXCursor_CUDADeviceAttr = 413,
- CXCursor_CUDAGlobalAttr = 414,
- CXCursor_CUDAHostAttr = 415,
- CXCursor_CUDASharedAttr = 416,
- CXCursor_VisibilityAttr = 417,
- CXCursor_DLLExport = 418,
- CXCursor_DLLImport = 419,
- CXCursor_NSReturnsRetained = 420,
- CXCursor_NSReturnsNotRetained = 421,
- CXCursor_NSReturnsAutoreleased = 422,
- CXCursor_NSConsumesSelf = 423,
- CXCursor_NSConsumed = 424,
- CXCursor_ObjCException = 425,
- CXCursor_ObjCNSObject = 426,
- CXCursor_ObjCIndependentClass = 427,
- CXCursor_ObjCPreciseLifetime = 428,
- CXCursor_ObjCReturnsInnerPointer = 429,
- CXCursor_ObjCRequiresSuper = 430,
- CXCursor_ObjCRootClass = 431,
- CXCursor_ObjCSubclassingRestricted = 432,
- CXCursor_ObjCExplicitProtocolImpl = 433,
- CXCursor_ObjCDesignatedInitializer = 434,
- CXCursor_ObjCRuntimeVisible = 435,
- CXCursor_ObjCBoxable = 436,
- CXCursor_FlagEnum = 437,
- CXCursor_ConvergentAttr = 438,
- CXCursor_WarnUnusedAttr = 439,
- CXCursor_WarnUnusedResultAttr = 440,
- CXCursor_AlignedAttr = 441,
- CXCursor_LastAttr = CXCursor_AlignedAttr,
+ CXCursor_UnexposedAttr = 400,
+
+ CXCursor_IBActionAttr = 401,
+ CXCursor_IBOutletAttr = 402,
+ CXCursor_IBOutletCollectionAttr = 403,
+ CXCursor_CXXFinalAttr = 404,
+ CXCursor_CXXOverrideAttr = 405,
+ CXCursor_AnnotateAttr = 406,
+ CXCursor_AsmLabelAttr = 407,
+ CXCursor_PackedAttr = 408,
+ CXCursor_PureAttr = 409,
+ CXCursor_ConstAttr = 410,
+ CXCursor_NoDuplicateAttr = 411,
+ CXCursor_CUDAConstantAttr = 412,
+ CXCursor_CUDADeviceAttr = 413,
+ CXCursor_CUDAGlobalAttr = 414,
+ CXCursor_CUDAHostAttr = 415,
+ CXCursor_CUDASharedAttr = 416,
+ CXCursor_VisibilityAttr = 417,
+ CXCursor_DLLExport = 418,
+ CXCursor_DLLImport = 419,
+ CXCursor_NSReturnsRetained = 420,
+ CXCursor_NSReturnsNotRetained = 421,
+ CXCursor_NSReturnsAutoreleased = 422,
+ CXCursor_NSConsumesSelf = 423,
+ CXCursor_NSConsumed = 424,
+ CXCursor_ObjCException = 425,
+ CXCursor_ObjCNSObject = 426,
+ CXCursor_ObjCIndependentClass = 427,
+ CXCursor_ObjCPreciseLifetime = 428,
+ CXCursor_ObjCReturnsInnerPointer = 429,
+ CXCursor_ObjCRequiresSuper = 430,
+ CXCursor_ObjCRootClass = 431,
+ CXCursor_ObjCSubclassingRestricted = 432,
+ CXCursor_ObjCExplicitProtocolImpl = 433,
+ CXCursor_ObjCDesignatedInitializer = 434,
+ CXCursor_ObjCRuntimeVisible = 435,
+ CXCursor_ObjCBoxable = 436,
+ CXCursor_FlagEnum = 437,
+ CXCursor_ConvergentAttr = 438,
+ CXCursor_WarnUnusedAttr = 439,
+ CXCursor_WarnUnusedResultAttr = 440,
+ CXCursor_AlignedAttr = 441,
+ CXCursor_LastAttr = CXCursor_AlignedAttr,
/* Preprocessing */
- CXCursor_PreprocessingDirective = 500,
- CXCursor_MacroDefinition = 501,
- CXCursor_MacroExpansion = 502,
- CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
- CXCursor_InclusionDirective = 503,
- CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
- CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
+ CXCursor_PreprocessingDirective = 500,
+ CXCursor_MacroDefinition = 501,
+ CXCursor_MacroExpansion = 502,
+ CXCursor_MacroInstantiation = CXCursor_MacroExpansion,
+ CXCursor_InclusionDirective = 503,
+ CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective,
+ CXCursor_LastPreprocessing = CXCursor_InclusionDirective,
/* Extra Declarations */
/**
* A module import declaration.
*/
- CXCursor_ModuleImportDecl = 600,
- CXCursor_TypeAliasTemplateDecl = 601,
+ CXCursor_ModuleImportDecl = 600,
+ CXCursor_TypeAliasTemplateDecl = 601,
/**
* A static_assert or _Static_assert node
*/
- CXCursor_StaticAssert = 602,
+ CXCursor_StaticAssert = 602,
/**
* a friend declaration.
*/
- CXCursor_FriendDecl = 603,
- CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
- CXCursor_LastExtraDecl = CXCursor_FriendDecl,
+ CXCursor_FriendDecl = 603,
+ CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
+ CXCursor_LastExtraDecl = CXCursor_FriendDecl,
/**
* A code completion overload candidate.
*/
- CXCursor_OverloadCandidate = 700
+ CXCursor_OverloadCandidate = 700
};
/**
@@ -2943,14 +2916,10 @@ typedef struct CXPlatformAvailability {
* platform-availability structures returned. There are
* \c min(N, availability_size) such structures.
*/
-CINDEX_LINKAGE int
-clang_getCursorPlatformAvailability(CXCursor cursor,
- int *always_deprecated,
- CXString *deprecated_message,
- int *always_unavailable,
- CXString *unavailable_message,
- CXPlatformAvailability *availability,
- int availability_size);
+CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
+ CXCursor cursor, int *always_deprecated, CXString *deprecated_message,
+ int *always_unavailable, CXString *unavailable_message,
+ CXPlatformAvailability *availability, int availability_size);
/**
* Free the memory associated with a \c CXPlatformAvailability structure.
@@ -2977,11 +2946,7 @@ CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
* Describe the "thread-local storage (TLS) kind" of the declaration
* referred to by a cursor.
*/
-enum CXTLSKind {
- CXTLS_None = 0,
- CXTLS_Dynamic,
- CXTLS_Static
-};
+enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static };
/**
* Determine the "thread-local storage (TLS) kind" of the declaration
@@ -3013,7 +2978,7 @@ CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset);
* Queries a CXCursorSet to see if it contains a specific CXCursor.
*
* \returns non-zero if the set contains the specified cursor.
-*/
+ */
CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
CXCursor cursor);
@@ -3021,7 +2986,7 @@ CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset,
* Inserts a CXCursor into a CXCursorSet.
*
* \returns zero if the CXCursor was already in the set, and non-zero otherwise.
-*/
+ */
CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset,
CXCursor cursor);
@@ -3441,9 +3406,9 @@ CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C);
* 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.
- * Since this is also potentially a valid constant value, the kind of the cursor
- * must be verified before calling this function.
+ * If the cursor does not reference an enum constant declaration, LLONG_MIN is
+ * returned. Since this is also potentially a valid constant value, the kind of
+ * the cursor must be verified before calling this function.
*/
CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
@@ -3451,11 +3416,12 @@ CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C);
* 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.
- * Since this is also potentially a valid constant value, the kind of the cursor
- * must be verified before calling this function.
+ * If the cursor does not reference an enum constant declaration, ULLONG_MAX is
+ * returned. Since this is also potentially a valid constant value, the kind of
+ * the cursor must be verified before calling this function.
*/
-CINDEX_LINKAGE unsigned long long clang_getEnumConstantDeclUnsignedValue(CXCursor C);
+CINDEX_LINKAGE unsigned long long
+clang_getEnumConstantDeclUnsignedValue(CXCursor C);
/**
* Retrieve the bit width of a bit field declaration as an integer.
@@ -3536,8 +3502,8 @@ CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C);
* For I = 0, 1, and 2, Type, Integral, and Integral will be returned,
* respectively.
*/
-CINDEX_LINKAGE enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(
- CXCursor C, unsigned I);
+CINDEX_LINKAGE enum CXTemplateArgumentKind
+clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I);
/**
* Retrieve a CXType representing the type of a TemplateArgument of a
@@ -3597,8 +3563,8 @@ CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C,
* If called with I = 1 or 2, 2147483649 or true will be returned, respectively.
* For I == 0, this function's behavior is undefined.
*/
-CINDEX_LINKAGE unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(
- CXCursor C, unsigned I);
+CINDEX_LINKAGE unsigned long long
+clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I);
/**
* Determine whether two CXTypes represent the same type.
@@ -3783,7 +3749,8 @@ CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C);
* 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.
+ * This only returns a valid result if the cursor refers to a function or
+ * method.
*/
CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C);
@@ -4011,7 +3978,8 @@ CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
* This function only returns template type arguments and does not handle
* template template arguments or variadic packs.
*/
-CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, unsigned i);
+CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T,
+ unsigned i);
/**
* Retrieve the ref-qualifier kind of a function or method.
@@ -4047,9 +4015,9 @@ enum CX_CXXAccessSpecifier {
/**
* 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
- * access specifier, the specifier itself is returned.
+ * 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 access specifier, the specifier itself is returned.
*/
CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor);
@@ -4200,7 +4168,7 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
CXCursorVisitor visitor,
CXClientData client_data);
#ifdef __has_feature
-# if __has_feature(blocks)
+#if __has_feature(blocks)
/**
* Visitor invoked for each cursor found by a traversal.
*
@@ -4211,16 +4179,16 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
* The visitor should return one of the \c CXChildVisitResult values
* to direct clang_visitChildrenWithBlock().
*/
-typedef enum CXChildVisitResult
- (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
+typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
+ CXCursor parent);
/**
* Visits the children of a cursor using the specified block. Behaves
* identically to clang_visitChildren() in all other respects.
*/
-CINDEX_LINKAGE unsigned clang_visitChildrenWithBlock(CXCursor parent,
- CXCursorVisitorBlock block);
-# endif
+CINDEX_LINKAGE unsigned
+clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
+#endif
#endif
/**
@@ -4257,15 +4225,14 @@ CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name);
/**
* Construct a USR for a specified Objective-C category.
*/
-CINDEX_LINKAGE CXString
- clang_constructUSR_ObjCCategory(const char *class_name,
- const char *category_name);
+CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory(
+ const char *class_name, const char *category_name);
/**
* Construct a USR for a specified Objective-C protocol.
*/
CINDEX_LINKAGE CXString
- clang_constructUSR_ObjCProtocol(const char *protocol_name);
+clang_constructUSR_ObjCProtocol(const char *protocol_name);
/**
* Construct a USR for a specified Objective-C instance variable and
@@ -4305,9 +4272,8 @@ CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor);
*
* \param options Reserved.
*/
-CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor,
- unsigned pieceIndex,
- unsigned options);
+CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange(
+ CXCursor, unsigned pieceIndex, unsigned options);
/**
* Opaque pointer representing a policy that controls pretty printing
@@ -4361,9 +4327,10 @@ clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy,
/**
* Set a property value for the given printing policy.
*/
-CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
- enum CXPrintingPolicyProperty Property,
- unsigned Value);
+CINDEX_LINKAGE void
+clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy,
+ enum CXPrintingPolicyProperty Property,
+ unsigned Value);
/**
* Retrieve the default policy for the cursor.
@@ -4511,18 +4478,18 @@ CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C);
* Property attributes for a \c CXCursor_ObjCPropertyDecl.
*/
typedef enum {
- CXObjCPropertyAttr_noattr = 0x00,
- CXObjCPropertyAttr_readonly = 0x01,
- CXObjCPropertyAttr_getter = 0x02,
- CXObjCPropertyAttr_assign = 0x04,
+ CXObjCPropertyAttr_noattr = 0x00,
+ CXObjCPropertyAttr_readonly = 0x01,
+ CXObjCPropertyAttr_getter = 0x02,
+ CXObjCPropertyAttr_assign = 0x04,
CXObjCPropertyAttr_readwrite = 0x08,
- CXObjCPropertyAttr_retain = 0x10,
- CXObjCPropertyAttr_copy = 0x20,
+ CXObjCPropertyAttr_retain = 0x10,
+ CXObjCPropertyAttr_copy = 0x20,
CXObjCPropertyAttr_nonatomic = 0x40,
- CXObjCPropertyAttr_setter = 0x80,
- CXObjCPropertyAttr_atomic = 0x100,
- CXObjCPropertyAttr_weak = 0x200,
- CXObjCPropertyAttr_strong = 0x400,
+ CXObjCPropertyAttr_setter = 0x80,
+ CXObjCPropertyAttr_atomic = 0x100,
+ CXObjCPropertyAttr_weak = 0x200,
+ CXObjCPropertyAttr_strong = 0x400,
CXObjCPropertyAttr_unsafe_unretained = 0x800,
CXObjCPropertyAttr_class = 0x1000
} CXObjCPropertyAttrKind;
@@ -4534,8 +4501,8 @@ typedef enum {
*
* \param reserved Reserved for future use, pass 0.
*/
-CINDEX_LINKAGE unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C,
- unsigned reserved);
+CINDEX_LINKAGE unsigned
+clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved);
/**
* Given a cursor that represents a property declaration, return the
@@ -4597,8 +4564,9 @@ CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
* non-zero if the 'generated_declaration' is set in the attribute.
*/
CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C,
- CXString *language, CXString *definedIn,
- unsigned *isGenerated);
+ CXString *language,
+ CXString *definedIn,
+ unsigned *isGenerated);
/**
* Given a cursor that represents a declaration, return the associated
@@ -4724,8 +4692,8 @@ CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit,
* \returns the specified top level header associated with the module.
*/
CINDEX_LINKAGE
-CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
- CXModule Module, unsigned Index);
+CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module,
+ unsigned Index);
/**
* @}
@@ -4743,7 +4711,8 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit,
/**
* Determine if a C++ constructor is a converting constructor.
*/
-CINDEX_LINKAGE unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C);
+CINDEX_LINKAGE unsigned
+clang_CXXConstructor_isConvertingConstructor(CXCursor C);
/**
* Determine if a C++ constructor is a copy constructor.
@@ -4873,9 +4842,8 @@ CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C);
* \returns The piece of the name pointed to by the given cursor. If there is no
* name, or if the PieceIndex is out-of-range, a null-cursor will be returned.
*/
-CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(CXCursor C,
- unsigned NameFlags,
- unsigned PieceIndex);
+CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange(
+ CXCursor C, unsigned NameFlags, unsigned PieceIndex);
enum CXNameRefFlags {
/**
@@ -5043,15 +5011,14 @@ CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
* \param Cursors an array of \p NumTokens cursors, whose contents will be
* replaced with the cursors corresponding to each token.
*/
-CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU,
- CXToken *Tokens, unsigned NumTokens,
- CXCursor *Cursors);
+CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
+ unsigned NumTokens, CXCursor *Cursors);
/**
* Free the given set of tokens.
*/
-CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
- CXToken *Tokens, unsigned NumTokens);
+CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
+ unsigned NumTokens);
/**
* @}
@@ -5068,15 +5035,11 @@ CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU,
/* for debug/testing */
CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind);
-CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
- const char **startBuf,
- const char **endBuf,
- unsigned *startLine,
- unsigned *startColumn,
- unsigned *endLine,
- unsigned *endColumn);
+CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(
+ CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine,
+ unsigned *startColumn, unsigned *endLine, unsigned *endColumn);
CINDEX_LINKAGE void clang_enableStackTraces(void);
-CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void*), void *user_data,
+CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size);
/**
@@ -5327,9 +5290,8 @@ clang_getCompletionChunkKind(CXCompletionString completion_string,
*
* \returns the text associated with the chunk at index \c chunk_number.
*/
-CINDEX_LINKAGE CXString
-clang_getCompletionChunkText(CXCompletionString completion_string,
- unsigned chunk_number);
+CINDEX_LINKAGE CXString clang_getCompletionChunkText(
+ CXCompletionString completion_string, unsigned chunk_number);
/**
* Retrieve the completion string associated with a particular chunk
@@ -5342,9 +5304,8 @@ clang_getCompletionChunkText(CXCompletionString completion_string,
* \returns the completion string associated with the chunk at index
* \c chunk_number.
*/
-CINDEX_LINKAGE CXCompletionString
-clang_getCompletionChunkCompletionString(CXCompletionString completion_string,
- unsigned chunk_number);
+CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString(
+ CXCompletionString completion_string, unsigned chunk_number);
/**
* Retrieve the number of chunks in the given code-completion string.
@@ -5401,9 +5362,8 @@ clang_getCompletionNumAnnotations(CXCompletionString completion_string);
* \returns annotation string associated with the completion at index
* \c annotation_number, or a NULL string if that annotation is not available.
*/
-CINDEX_LINKAGE CXString
-clang_getCompletionAnnotation(CXCompletionString completion_string,
- unsigned annotation_number);
+CINDEX_LINKAGE CXString clang_getCompletionAnnotation(
+ CXCompletionString completion_string, unsigned annotation_number);
/**
* Retrieve the parent context of the given completion string.
@@ -5421,9 +5381,8 @@ clang_getCompletionAnnotation(CXCompletionString completion_string,
* \returns The name of the completion parent, e.g., "NSObject" if
* the completion string represents a method in the NSObject class.
*/
-CINDEX_LINKAGE CXString
-clang_getCompletionParent(CXCompletionString completion_string,
- enum CXCursorKind *kind);
+CINDEX_LINKAGE CXString clang_getCompletionParent(
+ CXCompletionString completion_string, enum CXCursorKind *kind);
/**
* Retrieve the brief documentation comment attached to the declaration
@@ -5779,13 +5738,11 @@ CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void);
* completion fails, returns NULL.
*/
CINDEX_LINKAGE
-CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
- const char *complete_filename,
- unsigned complete_line,
- unsigned complete_column,
- struct CXUnsavedFile *unsaved_files,
- unsigned num_unsaved_files,
- unsigned options);
+CXCodeCompleteResults *
+clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename,
+ unsigned complete_line, unsigned complete_column,
+ struct CXUnsavedFile *unsaved_files,
+ unsigned num_unsaved_files, unsigned options);
/**
* Sort the code-completion results in case-insensitive alphabetical
@@ -5834,8 +5791,8 @@ CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results,
* along with the given code completion results.
*/
CINDEX_LINKAGE
-unsigned long long clang_codeCompleteGetContexts(
- CXCodeCompleteResults *Results);
+unsigned long long
+clang_codeCompleteGetContexts(CXCodeCompleteResults *Results);
/**
* Returns the cursor kind for the container for the current code
@@ -5854,9 +5811,9 @@ unsigned long long clang_codeCompleteGetContexts(
* container
*/
CINDEX_LINKAGE
-enum CXCursorKind clang_codeCompleteGetContainerKind(
- CXCodeCompleteResults *Results,
- unsigned *IsIncomplete);
+enum CXCursorKind
+clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results,
+ unsigned *IsIncomplete);
/**
* Returns the USR for the container for the current code completion
@@ -5908,19 +5865,19 @@ CINDEX_LINKAGE CXString clang_getClangVersion(void);
*/
CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled);
- /**
- * Visitor invoked for each file in a translation unit
- * (used with clang_getInclusions()).
- *
- * This visitor function will be invoked by clang_getInclusions() for each
- * file included (either at the top-level or by \#include directives) within
- * a translation unit. The first argument is the file being included, and
- * the second and third arguments provide the inclusion stack. The
- * array is sorted in order of immediate inclusion. For example,
- * the first element refers to the location that included 'included_file'.
- */
+/**
+ * Visitor invoked for each file in a translation unit
+ * (used with clang_getInclusions()).
+ *
+ * This visitor function will be invoked by clang_getInclusions() for each
+ * file included (either at the top-level or by \#include directives) within
+ * a translation unit. The first argument is the file being included, and
+ * the second and third arguments provide the inclusion stack. The
+ * array is sorted in order of immediate inclusion. For example,
+ * the first element refers to the location that included 'included_file'.
+ */
typedef void (*CXInclusionVisitor)(CXFile included_file,
- CXSourceLocation* inclusion_stack,
+ CXSourceLocation *inclusion_stack,
unsigned include_len,
CXClientData client_data);
@@ -5935,7 +5892,7 @@ CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu,
CXClientData client_data);
typedef enum {
- CXEval_Int = 1 ,
+ CXEval_Int = 1,
CXEval_Float = 2,
CXEval_ObjCStrLiteral = 3,
CXEval_StrLiteral = 4,
@@ -5944,12 +5901,12 @@ typedef enum {
CXEval_UnExposed = 0
-} CXEvalResultKind ;
+} CXEvalResultKind;
/**
* Evaluation result of a cursor
*/
-typedef void * CXEvalResult;
+typedef void *CXEvalResult;
/**
* If cursor is a statement declaration tries to evaluate the
@@ -5986,7 +5943,8 @@ CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
* 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);
+CINDEX_LINKAGE unsigned long long
+clang_EvalResult_getAsUnsigned(CXEvalResult E);
/**
* Returns the evaluation result as double if the
@@ -6000,7 +5958,7 @@ CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E);
* instead call clang_EvalResult_dispose on the CXEvalResult returned
* by clang_Cursor_Evaluate.
*/
-CINDEX_LINKAGE const char* clang_EvalResult_getAsStr(CXEvalResult E);
+CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E);
/**
* Disposes the created Eval memory.
@@ -6058,7 +6016,8 @@ CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
* is associated with.
*/
CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
- CXString *original, CXString *transformed);
+ CXString *original,
+ CXString *transformed);
/**
* Dispose the remapping.
@@ -6074,10 +6033,7 @@ CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
* @{
*/
-enum CXVisitorResult {
- CXVisit_Break,
- CXVisit_Continue
-};
+enum CXVisitorResult { CXVisit_Break, CXVisit_Continue };
typedef struct CXCursorAndRangeVisitor {
void *context;
@@ -6115,8 +6071,8 @@ typedef enum {
*
* \returns one of the CXResult enumerators.
*/
-CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
- CXCursorAndRangeVisitor visitor);
+CINDEX_LINKAGE CXResult clang_findReferencesInFile(
+ CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor);
/**
* Find #import/#include directives in a specific file.
@@ -6130,15 +6086,14 @@ CINDEX_LINKAGE CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
*
* \returns one of the CXResult enumerators.
*/
-CINDEX_LINKAGE CXResult clang_findIncludesInFile(CXTranslationUnit TU,
- CXFile file,
- CXCursorAndRangeVisitor visitor);
+CINDEX_LINKAGE CXResult clang_findIncludesInFile(
+ CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
#ifdef __has_feature
-# if __has_feature(blocks)
+#if __has_feature(blocks)
-typedef enum CXVisitorResult
- (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange);
+typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
+ CXSourceRange);
CINDEX_LINKAGE
CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
@@ -6148,7 +6103,7 @@ CINDEX_LINKAGE
CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
CXCursorAndRangeVisitorBlock);
-# endif
+#endif
#endif
/**
@@ -6231,46 +6186,46 @@ typedef struct {
} CXIdxImportedASTFileInfo;
typedef enum {
- CXIdxEntity_Unexposed = 0,
- CXIdxEntity_Typedef = 1,
- CXIdxEntity_Function = 2,
- CXIdxEntity_Variable = 3,
- CXIdxEntity_Field = 4,
- CXIdxEntity_EnumConstant = 5,
+ CXIdxEntity_Unexposed = 0,
+ CXIdxEntity_Typedef = 1,
+ CXIdxEntity_Function = 2,
+ CXIdxEntity_Variable = 3,
+ CXIdxEntity_Field = 4,
+ CXIdxEntity_EnumConstant = 5,
- CXIdxEntity_ObjCClass = 6,
- CXIdxEntity_ObjCProtocol = 7,
- CXIdxEntity_ObjCCategory = 8,
+ CXIdxEntity_ObjCClass = 6,
+ CXIdxEntity_ObjCProtocol = 7,
+ CXIdxEntity_ObjCCategory = 8,
CXIdxEntity_ObjCInstanceMethod = 9,
- CXIdxEntity_ObjCClassMethod = 10,
- CXIdxEntity_ObjCProperty = 11,
- CXIdxEntity_ObjCIvar = 12,
-
- CXIdxEntity_Enum = 13,
- CXIdxEntity_Struct = 14,
- CXIdxEntity_Union = 15,
-
- CXIdxEntity_CXXClass = 16,
- CXIdxEntity_CXXNamespace = 17,
- CXIdxEntity_CXXNamespaceAlias = 18,
- CXIdxEntity_CXXStaticVariable = 19,
- CXIdxEntity_CXXStaticMethod = 20,
- CXIdxEntity_CXXInstanceMethod = 21,
- CXIdxEntity_CXXConstructor = 22,
- CXIdxEntity_CXXDestructor = 23,
+ CXIdxEntity_ObjCClassMethod = 10,
+ CXIdxEntity_ObjCProperty = 11,
+ CXIdxEntity_ObjCIvar = 12,
+
+ CXIdxEntity_Enum = 13,
+ CXIdxEntity_Struct = 14,
+ CXIdxEntity_Union = 15,
+
+ CXIdxEntity_CXXClass = 16,
+ CXIdxEntity_CXXNamespace = 17,
+ CXIdxEntity_CXXNamespaceAlias = 18,
+ CXIdxEntity_CXXStaticVariable = 19,
+ CXIdxEntity_CXXStaticMethod = 20,
+ CXIdxEntity_CXXInstanceMethod = 21,
+ CXIdxEntity_CXXConstructor = 22,
+ CXIdxEntity_CXXDestructor = 23,
CXIdxEntity_CXXConversionFunction = 24,
- CXIdxEntity_CXXTypeAlias = 25,
- CXIdxEntity_CXXInterface = 26
+ CXIdxEntity_CXXTypeAlias = 25,
+ CXIdxEntity_CXXInterface = 26
} CXIdxEntityKind;
typedef enum {
CXIdxEntityLang_None = 0,
- CXIdxEntityLang_C = 1,
+ CXIdxEntityLang_C = 1,
CXIdxEntityLang_ObjC = 2,
- CXIdxEntityLang_CXX = 3,
- CXIdxEntityLang_Swift = 4
+ CXIdxEntityLang_CXX = 3,
+ CXIdxEntityLang_Swift = 4
} CXIdxEntityLanguage;
/**
@@ -6284,16 +6239,16 @@ typedef enum {
* CXIdxEntity_CXXTypeAlias
*/
typedef enum {
- CXIdxEntity_NonTemplate = 0,
- CXIdxEntity_Template = 1,
+ CXIdxEntity_NonTemplate = 0,
+ CXIdxEntity_Template = 1,
CXIdxEntity_TemplatePartialSpecialization = 2,
CXIdxEntity_TemplateSpecialization = 3
} CXIdxEntityCXXTemplateKind;
typedef enum {
- CXIdxAttr_Unexposed = 0,
- CXIdxAttr_IBAction = 1,
- CXIdxAttr_IBOutlet = 2,
+ CXIdxAttr_Unexposed = 0,
+ CXIdxAttr_IBAction = 1,
+ CXIdxAttr_IBOutlet = 2,
CXIdxAttr_IBOutletCollection = 3
} CXIdxAttrKind;
@@ -6325,9 +6280,7 @@ typedef struct {
CXIdxLoc classLoc;
} CXIdxIBOutletCollectionAttrInfo;
-typedef enum {
- CXIdxDeclFlag_Skipped = 0x1
-} CXIdxDeclInfoFlags;
+typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags;
typedef struct {
const CXIdxEntityInfo *entityInfo;
@@ -6496,11 +6449,10 @@ typedef struct {
/**
* Called at the end of indexing; passes the complete diagnostic set.
*/
- void (*diagnostic)(CXClientData client_data,
- CXDiagnosticSet, void *reserved);
+ void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved);
- CXIdxClientFile (*enteredMainFile)(CXClientData client_data,
- CXFile mainFile, void *reserved);
+ CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile,
+ void *reserved);
/**
* Called when a file gets \#included/\#imported.
@@ -6525,8 +6477,7 @@ typedef struct {
CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data,
void *reserved);
- void (*indexDeclaration)(CXClientData client_data,
- const CXIdxDeclInfo *);
+ void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *);
/**
* Called to index a reference of an entity.
@@ -6570,8 +6521,8 @@ clang_index_getClientContainer(const CXIdxContainerInfo *);
* For setting a custom CXIdxClientContainer attached to a
* container.
*/
-CINDEX_LINKAGE void
-clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
+CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *,
+ CXIdxClientContainer);
/**
* For retrieving a custom CXIdxClientEntity attached to an entity.
@@ -6582,8 +6533,8 @@ clang_index_getClientEntity(const CXIdxEntityInfo *);
/**
* For setting a custom CXIdxClientEntity attached to an entity.
*/
-CINDEX_LINKAGE void
-clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
+CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *,
+ CXIdxClientEntity);
/**
* An indexing action/session, to be applied to one or multiple
@@ -6671,18 +6622,12 @@ typedef enum {
*
* The rest of the parameters are the same as #clang_parseTranslationUnit.
*/
-CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
- CXClientData client_data,
- IndexerCallbacks *index_callbacks,
- unsigned index_callbacks_size,
- unsigned index_options,
- const char *source_filename,
- const char * const *command_line_args,
- int num_command_line_args,
- struct CXUnsavedFile *unsaved_files,
- unsigned num_unsaved_files,
- CXTranslationUnit *out_TU,
- unsigned TU_options);
+CINDEX_LINKAGE int clang_indexSourceFile(
+ CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
+ unsigned index_callbacks_size, unsigned index_options,
+ const char *source_filename, const char *const *command_line_args,
+ int num_command_line_args, struct CXUnsavedFile *unsaved_files,
+ unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options);
/**
* Same as clang_indexSourceFile but requires a full command line
@@ -6712,12 +6657,9 @@ CINDEX_LINKAGE int clang_indexSourceFileFullArgv(
* \returns If there is a failure from which there is no recovery, returns
* non-zero, otherwise returns 0.
*/
-CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
- CXClientData client_data,
- IndexerCallbacks *index_callbacks,
- unsigned index_callbacks_size,
- unsigned index_options,
- CXTranslationUnit);
+CINDEX_LINKAGE int clang_indexTranslationUnit(
+ CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks,
+ unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit);
/**
* Retrieve the CXIdxFile, file, line, column, and offset represented by
@@ -6729,8 +6671,7 @@ CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
*/
CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc,
CXIdxClientFile *indexFile,
- CXFile *file,
- unsigned *line,
+ CXFile *file, unsigned *line,
unsigned *column,
unsigned *offset);
@@ -6773,8 +6714,7 @@ typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C,
* \returns a non-zero value if the traversal was terminated
* prematurely by the visitor returning \c CXFieldVisit_Break.
*/
-CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T,
- CXFieldVisitor visitor,
+CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor,
CXClientData client_data);
/**
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index ae7fd4271799..c878f454aad0 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -105,8 +105,7 @@ cxtu::CXTUOwner::~CXTUOwner() {
/// Compare two source ranges to determine their relative position in
/// the translation unit.
-static RangeComparisonResult RangeCompare(SourceManager &SM,
- SourceRange R1,
+static RangeComparisonResult RangeCompare(SourceManager &SM, SourceRange R1,
SourceRange R2) {
assert(R1.isValid() && "First range is invalid?");
assert(R2.isValid() && "Second range is invalid?");
@@ -147,22 +146,20 @@ CXSourceRange cxloc::translateSourceRange(const SourceManager &SM,
// location accordingly.
SourceLocation EndLoc = R.getEnd();
bool IsTokenRange = R.isTokenRange();
- if (EndLoc.isValid() && EndLoc.isMacroID() && !SM.isMacroArgExpansion(EndLoc)) {
+ if (EndLoc.isValid() && EndLoc.isMacroID() &&
+ !SM.isMacroArgExpansion(EndLoc)) {
CharSourceRange Expansion = SM.getExpansionRange(EndLoc);
EndLoc = Expansion.getEnd();
IsTokenRange = Expansion.isTokenRange();
}
if (IsTokenRange && EndLoc.isValid()) {
- unsigned Length = Lexer::MeasureTokenLength(SM.getSpellingLoc(EndLoc),
- SM, LangOpts);
+ unsigned Length =
+ Lexer::MeasureTokenLength(SM.getSpellingLoc(EndLoc), SM, LangOpts);
EndLoc = EndLoc.getLocWithOffset(Length);
}
CXSourceRange Result = {
- { &SM, &LangOpts },
- R.getBegin().getRawEncoding(),
- EndLoc.getRawEncoding()
- };
+ {&SM, &LangOpts}, R.getBegin().getRawEncoding(), EndLoc.getRawEncoding()};
return Result;
}
@@ -197,7 +194,7 @@ bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
assert(0 && "Invalid declaration cursor");
return true; // abort.
}
-
+
// Ignore implicit declarations, unless it's an objc method because
// currently we should report implicit methods for properties when indexing.
if (D->isImplicit() && !isa<ObjCMethodDecl>(D))
@@ -236,10 +233,11 @@ static bool visitPreprocessedEntitiesInRange(SourceRange R,
CursorVisitor &Visitor) {
SourceManager &SM = Visitor.getASTUnit()->getSourceManager();
FileID FID;
-
+
if (!Visitor.shouldVisitIncludedEntities()) {
// If the begin/end of the range lie in the same FileID, do the optimization
- // where we skip preprocessed entities that do not come from the same FileID.
+ // where we skip preprocessed entities that do not come from the same
+ // FileID.
FID = SM.getFileID(SM.getFileLoc(R.getBegin()));
if (FID != SM.getFileID(SM.getFileLoc(R.getEnd())))
FID = FileID();
@@ -256,10 +254,11 @@ bool CursorVisitor::visitFileRegion() {
ASTUnit *Unit = cxtu::getASTUnit(TU);
SourceManager &SM = Unit->getSourceManager();
-
- std::pair<FileID, unsigned>
- Begin = SM.getDecomposedLoc(SM.getFileLoc(RegionOfInterest.getBegin())),
- End = SM.getDecomposedLoc(SM.getFileLoc(RegionOfInterest.getEnd()));
+
+ std::pair<FileID, unsigned> Begin = SM.getDecomposedLoc(
+ SM.getFileLoc(RegionOfInterest.getBegin())),
+ End = SM.getDecomposedLoc(
+ SM.getFileLoc(RegionOfInterest.getEnd()));
if (End.first != Begin.first) {
// If the end does not reside in the same file, try to recover by
@@ -271,7 +270,7 @@ bool CursorVisitor::visitFileRegion() {
assert(Begin.first == End.first);
if (Begin.second > End.second)
return false;
-
+
FileID File = Begin.first;
unsigned Offset = Begin.second;
unsigned Length = End.second - Begin.second;
@@ -293,16 +292,16 @@ static bool isInLexicalContext(Decl *D, DeclContext *DC) {
if (!DC)
return false;
- for (DeclContext *DeclDC = D->getLexicalDeclContext();
- DeclDC; DeclDC = DeclDC->getLexicalParent()) {
+ for (DeclContext *DeclDC = D->getLexicalDeclContext(); DeclDC;
+ DeclDC = DeclDC->getLexicalParent()) {
if (DeclDC == DC)
return true;
}
return false;
}
-bool CursorVisitor::visitDeclsFromFileRegion(FileID File,
- unsigned Offset, unsigned Length) {
+bool CursorVisitor::visitDeclsFromFileRegion(FileID File, unsigned Offset,
+ unsigned Length) {
ASTUnit *Unit = cxtu::getASTUnit(TU);
SourceManager &SM = Unit->getSourceManager();
SourceRange Range = RegionOfInterest;
@@ -350,7 +349,8 @@ bool CursorVisitor::visitDeclsFromFileRegion(FileID File,
if (!TD->isFreeStanding())
continue;
- RangeComparisonResult CompRes = RangeCompare(SM, D->getSourceRange(),Range);
+ RangeComparisonResult CompRes =
+ RangeCompare(SM, D->getSourceRange(), Range);
if (CompRes == RangeBefore)
continue;
if (CompRes == RangeAfter)
@@ -376,8 +376,9 @@ bool CursorVisitor::visitDeclsFromFileRegion(FileID File,
// No Decls overlapped with the range. Move up the lexical context until there
// is a context that contains the range or we reach the translation unit
// level.
- DeclContext *DC = DIt == Decls.begin() ? (*DIt)->getLexicalDeclContext()
- : (*(DIt-1))->getLexicalDeclContext();
+ DeclContext *DC = DIt == Decls.begin()
+ ? (*DIt)->getLexicalDeclContext()
+ : (*(DIt - 1))->getLexicalDeclContext();
while (DC && !DC->isTranslationUnit()) {
Decl *D = cast<Decl>(DC);
@@ -400,10 +401,9 @@ bool CursorVisitor::visitPreprocessedEntitiesInRegion() {
if (!AU->getPreprocessor().getPreprocessingRecord())
return false;
- PreprocessingRecord &PPRec
- = *AU->getPreprocessor().getPreprocessingRecord();
+ PreprocessingRecord &PPRec = *AU->getPreprocessor().getPreprocessingRecord();
SourceManager &SM = AU->getSourceManager();
-
+
if (RegionOfInterest.isValid()) {
SourceRange MappedRange = AU->mapRangeToPreamble(RegionOfInterest);
SourceLocation B = MappedRange.getBegin();
@@ -411,8 +411,8 @@ bool CursorVisitor::visitPreprocessedEntitiesInRegion() {
if (AU->isInPreambleFileID(B)) {
if (SM.isLoadedSourceLocation(E))
- return visitPreprocessedEntitiesInRange(SourceRange(B, E),
- PPRec, *this);
+ return visitPreprocessedEntitiesInRange(SourceRange(B, E), PPRec,
+ *this);
// Beginning of range lies in the preamble but it also extends beyond
// it into the main file. Split the range into 2 parts, one covering
@@ -420,22 +420,19 @@ bool CursorVisitor::visitPreprocessedEntitiesInRegion() {
// calls to visitPreprocessedEntitiesInRange to accept a source range that
// lies in the same FileID, allowing it to skip preprocessed entities that
// do not come from the same FileID.
- bool breaked =
- visitPreprocessedEntitiesInRange(
- SourceRange(B, AU->getEndOfPreambleFileID()),
- PPRec, *this);
- if (breaked) return true;
+ bool breaked = visitPreprocessedEntitiesInRange(
+ SourceRange(B, AU->getEndOfPreambleFileID()), PPRec, *this);
+ if (breaked)
+ return true;
return visitPreprocessedEntitiesInRange(
- SourceRange(AU->getStartOfMainFileID(), E),
- PPRec, *this);
+ SourceRange(AU->getStartOfMainFileID(), E), PPRec, *this);
}
return visitPreprocessedEntitiesInRange(SourceRange(B, E), PPRec, *this);
}
- bool OnlyLocalDecls
- = !AU->isMainFileAST() && AU->getOnlyLocalDecls();
-
+ bool OnlyLocalDecls = !AU->isMainFileAST() && AU->getOnlyLocalDecls();
+
if (OnlyLocalDecls)
return visitPreprocessedEntities(PPRec.local_begin(), PPRec.local_end(),
PPRec);
@@ -443,7 +440,7 @@ bool CursorVisitor::visitPreprocessedEntitiesInRegion() {
return visitPreprocessedEntities(PPRec.begin(), PPRec.end(), PPRec);
}
-template<typename InputIterator>
+template <typename InputIterator>
bool CursorVisitor::visitPreprocessedEntities(InputIterator First,
InputIterator Last,
PreprocessingRecord &PPRec,
@@ -469,11 +466,11 @@ bool CursorVisitor::visitPreprocessedEntities(InputIterator First,
continue;
}
-
+
if (InclusionDirective *ID = dyn_cast<InclusionDirective>(PPE)) {
if (Visit(MakeInclusionDirectiveCursor(ID, TU)))
return true;
-
+
continue;
}
}
@@ -482,11 +479,11 @@ bool CursorVisitor::visitPreprocessedEntities(InputIterator First,
}
/// Visit the children of the given cursor.
-///
+///
/// \returns true if the visitation should be aborted, false if it
/// should continue.
bool CursorVisitor::VisitChildren(CXCursor Cursor) {
- if (clang_isReference(Cursor.kind) &&
+ if (clang_isReference(Cursor.kind) &&
Cursor.kind != CXCursor_CXXBaseSpecifier) {
// By definition, references have no children.
return false;
@@ -521,14 +518,14 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
if (clang_isTranslationUnit(Cursor.kind)) {
CXTranslationUnit TU = getCursorTU(Cursor);
ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
-
- int VisitOrder[2] = { VisitPreprocessorLast, !VisitPreprocessorLast };
+
+ int VisitOrder[2] = {VisitPreprocessorLast, !VisitPreprocessorLast};
for (unsigned I = 0; I != 2; ++I) {
if (VisitOrder[I]) {
if (!CXXUnit->isMainFileAST() && CXXUnit->getOnlyLocalDecls() &&
RegionOfInterest.isInvalid()) {
for (ASTUnit::top_level_iterator TL = CXXUnit->top_level_begin(),
- TLEnd = CXXUnit->top_level_end();
+ TLEnd = CXXUnit->top_level_end();
TL != TLEnd; ++TL) {
const Optional<bool> V = handleDeclForVisitation(*TL);
if (!V.hasValue())
@@ -536,7 +533,7 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
return V.getValue();
}
} else if (VisitDeclContext(
- CXXUnit->getASTContext().getTranslationUnitDecl()))
+ CXXUnit->getASTContext().getTranslationUnitDecl()))
return true;
continue;
}
@@ -545,7 +542,7 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
if (CXXUnit->getPreprocessor().getPreprocessingRecord())
visitPreprocessedEntitiesInRegion();
}
-
+
return false;
}
@@ -559,7 +556,7 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
if (Cursor.kind == CXCursor_IBOutletCollectionAttr) {
const IBOutletCollectionAttr *A =
- cast<IBOutletCollectionAttr>(cxcursor::getCursorAttr(Cursor));
+ cast<IBOutletCollectionAttr>(cxcursor::getCursorAttr(Cursor));
if (const ObjCObjectType *ObjT = A->getInterface()->getAs<ObjCObjectType>())
return Visit(cxcursor::MakeCursorObjCClassRef(
ObjT->getInterface(),
@@ -587,7 +584,7 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
bool CursorVisitor::VisitBlockDecl(BlockDecl *B) {
if (TypeSourceInfo *TSInfo = B->getSignatureAsWritten())
if (Visit(TSInfo->getTypeLoc()))
- return true;
+ return true;
if (Stmt *Body = B->getBody())
return Visit(MakeCXCursor(Body, StmtParent, TU, RegionOfInterest));
@@ -600,7 +597,7 @@ Optional<bool> CursorVisitor::shouldVisitCursor(CXCursor Cursor) {
SourceRange Range = getFullCursorExtent(Cursor, AU->getSourceManager());
if (Range.isInvalid())
return None;
-
+
switch (CompareRegionOfInterest(Range)) {
case RangeBefore:
// This declaration comes before the region of interest; skip it.
@@ -623,10 +620,10 @@ bool CursorVisitor::VisitDeclContext(DeclContext *DC) {
// FIXME: Eventually remove. This part of a hack to support proper
// iteration over all Decls contained lexically within an ObjC container.
- SaveAndRestore<DeclContext::decl_iterator*> DI_saved(DI_current, &I);
+ SaveAndRestore<DeclContext::decl_iterator *> DI_saved(DI_current, &I);
SaveAndRestore<DeclContext::decl_iterator> DE_saved(DE_current, E);
- for ( ; I != E; ++I) {
+ for (; I != E; ++I) {
Decl *D = *I;
if (D->getLexicalDeclContext() != DC)
continue;
@@ -684,10 +681,10 @@ bool CursorVisitor::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
}
bool CursorVisitor::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
- if (VisitTemplateParameters(D->getTemplateParameters()))
- return true;
+ if (VisitTemplateParameters(D->getTemplateParameters()))
+ return true;
- return Visit(MakeCXCursor(D->getTemplatedDecl(), TU, RegionOfInterest));
+ return Visit(MakeCXCursor(D->getTemplatedDecl(), TU, RegionOfInterest));
}
bool CursorVisitor::VisitTypeAliasDecl(TypeAliasDecl *D) {
@@ -704,28 +701,26 @@ bool CursorVisitor::VisitTypedefDecl(TypedefDecl *D) {
return false;
}
-bool CursorVisitor::VisitTagDecl(TagDecl *D) {
- return VisitDeclContext(D);
-}
+bool CursorVisitor::VisitTagDecl(TagDecl *D) { return VisitDeclContext(D); }
bool CursorVisitor::VisitClassTemplateSpecializationDecl(
- ClassTemplateSpecializationDecl *D) {
+ ClassTemplateSpecializationDecl *D) {
bool ShouldVisitBody = false;
switch (D->getSpecializationKind()) {
case TSK_Undeclared:
case TSK_ImplicitInstantiation:
// Nothing to visit
return false;
-
+
case TSK_ExplicitInstantiationDeclaration:
case TSK_ExplicitInstantiationDefinition:
break;
-
+
case TSK_ExplicitSpecialization:
ShouldVisitBody = true;
break;
}
-
+
// Visit the template arguments used in the specialization.
if (TypeSourceInfo *SpecType = D->getTypeAsWritten()) {
TypeLoc TL = SpecType->getTypeLoc();
@@ -741,7 +736,7 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl(
}
bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl(
- ClassTemplatePartialSpecializationDecl *D) {
+ ClassTemplatePartialSpecializationDecl *D) {
// FIXME: Visit the "outer" template parameter lists on the TagDecl
// before visiting these template parameters.
if (VisitTemplateParameters(D->getTemplateParameters()))
@@ -753,7 +748,7 @@ bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl(
for (unsigned I = 0, N = Info->NumTemplateArgs; I != N; ++I)
if (VisitTemplateArgumentLoc(TemplateArgs[I]))
return true;
-
+
return VisitCXXRecordDecl(D);
}
@@ -768,7 +763,7 @@ bool CursorVisitor::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
if (TypeSourceInfo *DefArg = D->getDefaultArgumentInfo())
if (Visit(DefArg->getTypeLoc()))
return true;
-
+
return false;
}
@@ -781,7 +776,7 @@ bool CursorVisitor::VisitEnumConstantDecl(EnumConstantDecl *D) {
bool CursorVisitor::VisitDeclaratorDecl(DeclaratorDecl *DD) {
unsigned NumParamList = DD->getNumTemplateParameterLists();
for (unsigned i = 0; i < NumParamList; i++) {
- TemplateParameterList* Params = DD->getTemplateParameterList(i);
+ TemplateParameterList *Params = DD->getTemplateParameterList(i);
if (VisitTemplateParameters(Params))
return true;
}
@@ -817,7 +812,7 @@ static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X,
bool CursorVisitor::VisitFunctionDecl(FunctionDecl *ND) {
unsigned NumParamList = ND->getNumTemplateParameterLists();
for (unsigned i = 0; i < NumParamList; i++) {
- TemplateParameterList* Params = ND->getTemplateParameterList(i);
+ TemplateParameterList *Params = ND->getTemplateParameterList(i);
if (VisitTemplateParameters(Params))
return true;
}
@@ -828,7 +823,7 @@ bool CursorVisitor::VisitFunctionDecl(FunctionDecl *ND) {
TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens();
FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>();
const bool HasTrailingRT = HasTrailingReturnType(ND);
-
+
// If we have a function declared directly (without the use of a typedef),
// visit just the return type. Otherwise, just visit the function's type
// now.
@@ -841,14 +836,14 @@ bool CursorVisitor::VisitFunctionDecl(FunctionDecl *ND) {
if (NestedNameSpecifierLoc QualifierLoc = ND->getQualifierLoc())
if (VisitNestedNameSpecifierLoc(QualifierLoc))
return true;
-
+
// Visit the declaration name.
if (!isa<CXXDestructorDecl>(ND))
if (VisitDeclarationNameInfo(ND->getNameInfo()))
return true;
-
+
// FIXME: Visit explicitly-specified template arguments!
-
+
// Visit the function parameters, if we have a function type.
if (FTL && VisitFunctionTypeLoc(FTL, true))
return true;
@@ -859,7 +854,7 @@ bool CursorVisitor::VisitFunctionDecl(FunctionDecl *ND) {
// FIXME: Attributes?
}
-
+
if (ND->doesThisDeclarationHaveABody() && !ND->isLateTemplateParsed()) {
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(ND)) {
// Find the initializers that were written in the source.
@@ -867,14 +862,14 @@ bool CursorVisitor::VisitFunctionDecl(FunctionDecl *ND) {
for (auto *I : Constructor->inits()) {
if (!I->isWritten())
continue;
-
+
WrittenInits.push_back(I);
}
-
+
// Sort the initializers in source order
llvm::array_pod_sort(WrittenInits.begin(), WrittenInits.end(),
&CompareCXXCtorInitializers);
-
+
// Visit the initializers in source order
for (unsigned I = 0, N = WrittenInits.size(); I != N; ++I) {
CXXCtorInitializer *Init = WrittenInits[I];
@@ -886,14 +881,14 @@ bool CursorVisitor::VisitFunctionDecl(FunctionDecl *ND) {
if (Visit(TInfo->getTypeLoc()))
return true;
}
-
+
// Visit the initializer value.
if (Expr *Initializer = Init->getInit())
if (Visit(MakeCXCursor(Initializer, ND, TU, RegionOfInterest)))
return true;
- }
+ }
}
-
+
if (Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest)))
return true;
}
@@ -927,12 +922,12 @@ bool CursorVisitor::VisitVarDecl(VarDecl *D) {
bool CursorVisitor::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
if (VisitDeclaratorDecl(D))
return true;
-
+
if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited())
if (Expr *DefArg = D->getDefaultArgument())
return Visit(MakeCXCursor(DefArg, StmtParent, TU, RegionOfInterest));
-
- return false;
+
+ return false;
}
bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
@@ -940,8 +935,8 @@ bool CursorVisitor::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
// before visiting these template parameters.
if (VisitTemplateParameters(D->getTemplateParameters()))
return true;
-
- auto* FD = D->getTemplatedDecl();
+
+ auto *FD = D->getTemplatedDecl();
return VisitAttributes(FD) || VisitFunctionDecl(FD);
}
@@ -950,19 +945,19 @@ bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
// before visiting these template parameters.
if (VisitTemplateParameters(D->getTemplateParameters()))
return true;
-
- auto* CD = D->getTemplatedDecl();
+
+ auto *CD = D->getTemplatedDecl();
return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
}
bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
if (VisitTemplateParameters(D->getTemplateParameters()))
return true;
-
+
if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited() &&
VisitTemplateArgumentLoc(D->getDefaultArgument()))
return true;
-
+
return false;
}
@@ -1052,18 +1047,18 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) {
}
// Now sort the Decls so that they appear in lexical order.
- llvm::sort(DeclsInContainer,
- [&SM](Decl *A, Decl *B) {
- SourceLocation L_A = A->getBeginLoc();
- SourceLocation L_B = B->getBeginLoc();
- return L_A != L_B ? SM.isBeforeInTranslationUnit(L_A, L_B)
- : SM.isBeforeInTranslationUnit(A->getEndLoc(),
- B->getEndLoc());
- });
+ llvm::sort(DeclsInContainer, [&SM](Decl *A, Decl *B) {
+ SourceLocation L_A = A->getBeginLoc();
+ SourceLocation L_B = B->getBeginLoc();
+ return L_A != L_B
+ ? SM.isBeforeInTranslationUnit(L_A, L_B)
+ : SM.isBeforeInTranslationUnit(A->getEndLoc(), B->getEndLoc());
+ });
// Now visit the decls.
- for (SmallVectorImpl<Decl*>::iterator I = DeclsInContainer.begin(),
- E = DeclsInContainer.end(); I != E; ++I) {
+ for (SmallVectorImpl<Decl *>::iterator I = DeclsInContainer.begin(),
+ E = DeclsInContainer.end();
+ I != E; ++I) {
CXCursor Cursor = MakeCXCursor(*I, TU, RegionOfInterest);
const Optional<bool> &V = shouldVisitCursor(Cursor);
if (!V.hasValue())
@@ -1086,7 +1081,8 @@ bool CursorVisitor::VisitObjCCategoryDecl(ObjCCategoryDecl *ND) {
ObjCCategoryDecl::protocol_loc_iterator PL = ND->protocol_loc_begin();
for (ObjCCategoryDecl::protocol_iterator I = ND->protocol_begin(),
- E = ND->protocol_end(); I != E; ++I, ++PL)
+ E = ND->protocol_end();
+ I != E; ++I, ++PL)
if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
return true;
@@ -1096,10 +1092,11 @@ bool CursorVisitor::VisitObjCCategoryDecl(ObjCCategoryDecl *ND) {
bool CursorVisitor::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
if (!PID->isThisDeclarationADefinition())
return Visit(MakeCursorObjCProtocolRef(PID, PID->getLocation(), TU));
-
+
ObjCProtocolDecl::protocol_loc_iterator PL = PID->protocol_loc_begin();
for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(),
- E = PID->protocol_end(); I != E; ++I, ++PL)
+ E = PID->protocol_end();
+ I != E; ++I, ++PL)
if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
return true;
@@ -1122,9 +1119,8 @@ bool CursorVisitor::VisitObjCPropertyDecl(ObjCPropertyDecl *PD) {
return false;
IdentifierInfo *PropertyId = PD->getIdentifier();
- ObjCPropertyDecl *prevDecl =
- ObjCPropertyDecl::findPropertyDecl(cast<DeclContext>(ID), PropertyId,
- PD->getQueryKind());
+ ObjCPropertyDecl *prevDecl = ObjCPropertyDecl::findPropertyDecl(
+ cast<DeclContext>(ID), PropertyId, PD->getQueryKind());
if (!prevDecl)
return false;
@@ -1168,10 +1164,8 @@ bool CursorVisitor::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
return true;
// Issue callbacks for super class.
- if (D->getSuperClass() &&
- Visit(MakeCursorObjCSuperClassRef(D->getSuperClass(),
- D->getSuperClassLoc(),
- TU)))
+ if (D->getSuperClass() && Visit(MakeCursorObjCSuperClassRef(
+ D->getSuperClass(), D->getSuperClassLoc(), TU)))
return true;
if (TypeSourceInfo *SuperClassTInfo = D->getSuperClassTInfo())
@@ -1180,7 +1174,8 @@ bool CursorVisitor::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
ObjCInterfaceDecl::protocol_loc_iterator PL = D->protocol_loc_begin();
for (ObjCInterfaceDecl::protocol_iterator I = D->protocol_begin(),
- E = D->protocol_end(); I != E; ++I, ++PL)
+ E = D->protocol_end();
+ I != E; ++I, ++PL)
if (Visit(MakeCursorObjCProtocolRef(*I, *PL, TU)))
return true;
@@ -1218,7 +1213,7 @@ bool CursorVisitor::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PD) {
if (ObjCIvarDecl *Ivar = PD->getPropertyIvarDecl())
if (PD->isIvarNameSpecified())
return Visit(MakeCursorMemberRef(Ivar, PD->getPropertyIvarDeclLoc(), TU));
-
+
return false;
}
@@ -1231,8 +1226,8 @@ bool CursorVisitor::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
if (NestedNameSpecifierLoc QualifierLoc = D->getQualifierLoc())
if (VisitNestedNameSpecifierLoc(QualifierLoc))
return true;
-
- return Visit(MakeCursorNamespaceRef(D->getAliasedNamespace(),
+
+ return Visit(MakeCursorNamespaceRef(D->getAliasedNamespace(),
D->getTargetNameLoc(), TU));
}
@@ -1242,10 +1237,10 @@ bool CursorVisitor::VisitUsingDecl(UsingDecl *D) {
if (VisitNestedNameSpecifierLoc(QualifierLoc))
return true;
}
-
+
if (Visit(MakeCursorOverloadedDeclRef(D, D->getLocation(), TU)))
return true;
-
+
return VisitDeclarationNameInfo(D->getNameInfo());
}
@@ -1270,12 +1265,12 @@ bool CursorVisitor::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
}
bool CursorVisitor::VisitUnresolvedUsingTypenameDecl(
- UnresolvedUsingTypenameDecl *D) {
+ UnresolvedUsingTypenameDecl *D) {
// Visit nested-name-specifier.
if (NestedNameSpecifierLoc QualifierLoc = D->getQualifierLoc())
if (VisitNestedNameSpecifierLoc(QualifierLoc))
return true;
-
+
return false;
}
@@ -1325,7 +1320,7 @@ bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
llvm_unreachable("Invalid DeclarationName::Kind!");
}
-bool CursorVisitor::VisitNestedNameSpecifier(NestedNameSpecifier *NNS,
+bool CursorVisitor::VisitNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range) {
// FIXME: This whole routine is a hack to work around the lack of proper
// source information in nested-name-specifiers (PR5791). Since we do have
@@ -1333,18 +1328,18 @@ bool CursorVisitor::VisitNestedNameSpecifier(NestedNameSpecifier *NNS,
// nested-name-specifier, if it's a single-token component.
if (!NNS)
return false;
-
+
// Get the first component in the nested-name-specifier.
while (NestedNameSpecifier *Prefix = NNS->getPrefix())
NNS = Prefix;
-
+
switch (NNS->getKind()) {
case NestedNameSpecifier::Namespace:
- return Visit(MakeCursorNamespaceRef(NNS->getAsNamespace(), Range.getBegin(),
- TU));
+ return Visit(
+ MakeCursorNamespaceRef(NNS->getAsNamespace(), Range.getBegin(), TU));
case NestedNameSpecifier::NamespaceAlias:
- return Visit(MakeCursorNamespaceRef(NNS->getAsNamespaceAlias(),
+ return Visit(MakeCursorNamespaceRef(NNS->getAsNamespaceAlias(),
Range.getBegin(), TU));
case NestedNameSpecifier::TypeSpec: {
@@ -1356,77 +1351,75 @@ bool CursorVisitor::VisitNestedNameSpecifier(NestedNameSpecifier *NNS,
return Visit(MakeCursorTypeRef(Typedef->getDecl(), Range.getBegin(), TU));
if (const TagType *Tag = dyn_cast<TagType>(T))
return Visit(MakeCursorTypeRef(Tag->getDecl(), Range.getBegin(), TU));
- if (const TemplateSpecializationType *TST
- = dyn_cast<TemplateSpecializationType>(T))
+ if (const TemplateSpecializationType *TST =
+ dyn_cast<TemplateSpecializationType>(T))
return VisitTemplateName(TST->getTemplateName(), Range.getBegin());
break;
}
-
+
case NestedNameSpecifier::TypeSpecWithTemplate:
case NestedNameSpecifier::Global:
case NestedNameSpecifier::Identifier:
case NestedNameSpecifier::Super:
- break;
+ break;
}
-
+
return false;
}
-bool
-CursorVisitor::VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier) {
+bool CursorVisitor::VisitNestedNameSpecifierLoc(
+ NestedNameSpecifierLoc Qualifier) {
SmallVector<NestedNameSpecifierLoc, 4> Qualifiers;
for (; Qualifier; Qualifier = Qualifier.getPrefix())
Qualifiers.push_back(Qualifier);
-
+
while (!Qualifiers.empty()) {
NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
NestedNameSpecifier *NNS = Q.getNestedNameSpecifier();
switch (NNS->getKind()) {
case NestedNameSpecifier::Namespace:
- if (Visit(MakeCursorNamespaceRef(NNS->getAsNamespace(),
- Q.getLocalBeginLoc(),
- TU)))
+ if (Visit(MakeCursorNamespaceRef(NNS->getAsNamespace(),
+ Q.getLocalBeginLoc(), TU)))
return true;
-
+
break;
-
+
case NestedNameSpecifier::NamespaceAlias:
- if (Visit(MakeCursorNamespaceRef(NNS->getAsNamespaceAlias(),
- Q.getLocalBeginLoc(),
- TU)))
+ if (Visit(MakeCursorNamespaceRef(NNS->getAsNamespaceAlias(),
+ Q.getLocalBeginLoc(), TU)))
return true;
-
+
break;
-
+
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
if (Visit(Q.getTypeLoc()))
return true;
-
+
break;
-
+
case NestedNameSpecifier::Global:
case NestedNameSpecifier::Identifier:
case NestedNameSpecifier::Super:
- break;
+ break;
}
}
-
+
return false;
}
bool CursorVisitor::VisitTemplateParameters(
- const TemplateParameterList *Params) {
+ const TemplateParameterList *Params) {
if (!Params)
return false;
-
+
for (TemplateParameterList::const_iterator P = Params->begin(),
- PEnd = Params->end();
+ PEnd = Params->end();
P != PEnd; ++P) {
if (Visit(MakeCXCursor(*P, TU, RegionOfInterest)))
return true;
}
-
+
return false;
}
@@ -1449,22 +1442,20 @@ bool CursorVisitor::VisitTemplateName(TemplateName Name, SourceLocation Loc) {
case TemplateName::DependentTemplate:
// FIXME: Visit nested-name-specifier.
return false;
-
+
case TemplateName::QualifiedTemplate:
// FIXME: Visit nested-name-specifier.
return Visit(MakeCursorTemplateRef(
- Name.getAsQualifiedTemplateName()->getDecl(),
- Loc, TU));
+ Name.getAsQualifiedTemplateName()->getDecl(), Loc, TU));
case TemplateName::SubstTemplateTemplateParm:
return Visit(MakeCursorTemplateRef(
- Name.getAsSubstTemplateTemplateParm()->getParameter(),
- Loc, TU));
-
+ Name.getAsSubstTemplateTemplateParm()->getParameter(), Loc, TU));
+
case TemplateName::SubstTemplateTemplateParmPack:
return Visit(MakeCursorTemplateRef(
- Name.getAsSubstTemplateTemplateParmPack()->getParameterPack(),
- Loc, TU));
+ Name.getAsSubstTemplateTemplateParmPack()->getParameterPack(), Loc,
+ TU));
}
llvm_unreachable("Invalid TemplateName::Kind!");
@@ -1476,12 +1467,12 @@ bool CursorVisitor::VisitTemplateArgumentLoc(const TemplateArgumentLoc &TAL) {
case TemplateArgument::Integral:
case TemplateArgument::Pack:
return false;
-
+
case TemplateArgument::Type:
if (TypeSourceInfo *TSInfo = TAL.getTypeSourceInfo())
return Visit(TSInfo->getTypeLoc());
return false;
-
+
case TemplateArgument::Declaration:
if (Expr *E = TAL.getSourceDeclExpression())
return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
@@ -1496,13 +1487,13 @@ bool CursorVisitor::VisitTemplateArgumentLoc(const TemplateArgumentLoc &TAL) {
if (Expr *E = TAL.getSourceExpression())
return Visit(MakeCXCursor(E, StmtParent, TU, RegionOfInterest));
return false;
-
+
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion:
if (VisitNestedNameSpecifierLoc(TAL.getTemplateQualifierLoc()))
return true;
-
- return VisitTemplateName(TAL.getArgument().getAsTemplateOrTemplatePattern(),
+
+ return VisitTemplateName(TAL.getArgument().getAsTemplateOrTemplatePattern(),
TAL.getTemplateNameLoc());
}
@@ -1528,19 +1519,17 @@ bool CursorVisitor::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
case BuiltinType::Void:
case BuiltinType::NullPtr:
case BuiltinType::Dependent:
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtTYpe, Id, Ext) \
- case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtTYpe, Id, Ext) case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
case BuiltinType::OCLQueue:
case BuiltinType::OCLReserveID:
-#define SVE_TYPE(Name, Id, SingletonId) \
- case BuiltinType::Id:
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define BUILTIN_TYPE(Id, SingletonId)
#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
@@ -1565,8 +1554,8 @@ bool CursorVisitor::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
if (!VisitType.isNull()) {
if (const TypedefType *Typedef = VisitType->getAs<TypedefType>())
- return Visit(MakeCursorTypeRef(Typedef->getDecl(), TL.getBuiltinLoc(),
- TU));
+ return Visit(
+ MakeCursorTypeRef(Typedef->getDecl(), TL.getBuiltinLoc(), TU));
}
return false;
@@ -1661,7 +1650,7 @@ bool CursorVisitor::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
return Visit(TL.getModifiedLoc());
}
-bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL,
+bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL,
bool SkipResultType) {
if (!SkipResultType && Visit(TL.getReturnLoc()))
return true;
@@ -1694,25 +1683,25 @@ bool CursorVisitor::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
bool CursorVisitor::VisitDeducedTemplateSpecializationTypeLoc(
DeducedTemplateSpecializationTypeLoc TL) {
- if (VisitTemplateName(TL.getTypePtr()->getTemplateName(),
+ if (VisitTemplateName(TL.getTypePtr()->getTemplateName(),
TL.getTemplateNameLoc()))
return true;
-
+
return false;
}
bool CursorVisitor::VisitTemplateSpecializationTypeLoc(
- TemplateSpecializationTypeLoc TL) {
+ TemplateSpecializationTypeLoc TL) {
// Visit the template name.
- if (VisitTemplateName(TL.getTypePtr()->getTemplateName(),
+ if (VisitTemplateName(TL.getTypePtr()->getTemplateName(),
TL.getTemplateNameLoc()))
return true;
-
+
// Visit the template arguments.
for (unsigned I = 0, N = TL.getNumArgs(); I != N; ++I)
if (VisitTemplateArgumentLoc(TL.getArgLoc(I)))
return true;
-
+
return false;
}
@@ -1739,12 +1728,11 @@ bool CursorVisitor::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
}
bool CursorVisitor::VisitDependentTemplateSpecializationTypeLoc(
- DependentTemplateSpecializationTypeLoc TL) {
+ DependentTemplateSpecializationTypeLoc TL) {
// Visit the nested-name-specifier, if there is one.
- if (TL.getQualifierLoc() &&
- VisitNestedNameSpecifierLoc(TL.getQualifierLoc()))
+ if (TL.getQualifierLoc() && VisitNestedNameSpecifierLoc(TL.getQualifierLoc()))
return true;
-
+
// Visit the template arguments.
for (unsigned I = 0, N = TL.getNumArgs(); I != N; ++I)
if (VisitTemplateArgumentLoc(TL.getArgLoc(I)))
@@ -1756,7 +1744,7 @@ bool CursorVisitor::VisitDependentTemplateSpecializationTypeLoc(
bool CursorVisitor::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
if (VisitNestedNameSpecifierLoc(TL.getQualifierLoc()))
return true;
-
+
return Visit(TL.getNamedTypeLoc());
}
@@ -1783,10 +1771,10 @@ bool CursorVisitor::VisitPipeTypeLoc(PipeTypeLoc TL) {
return Visit(TL.getValueLoc());
}
-#define DEFAULT_TYPELOC_IMPL(CLASS, PARENT) \
-bool CursorVisitor::Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
- return Visit##PARENT##Loc(TL); \
-}
+#define DEFAULT_TYPELOC_IMPL(CLASS, PARENT) \
+ bool CursorVisitor::Visit##CLASS##TypeLoc(CLASS##TypeLoc TL) { \
+ return Visit##PARENT##Loc(TL); \
+ }
DEFAULT_TYPELOC_IMPL(Complex, Type)
DEFAULT_TYPELOC_IMPL(ConstantArray, ArrayType)
@@ -1827,7 +1815,7 @@ bool CursorVisitor::VisitAttributes(Decl *D) {
if ((TU->ParsingOptions & CXTranslationUnit_VisitImplicitAttributes ||
!I->isImplicit()) &&
Visit(MakeCXCursor(I, D, TU)))
- return true;
+ return true;
return false;
}
@@ -1837,14 +1825,16 @@ bool CursorVisitor::VisitAttributes(Decl *D) {
//===----------------------------------------------------------------------===//
namespace {
-#define DEF_JOB(NAME, DATA, KIND)\
-class NAME : public VisitorJob {\
-public:\
- NAME(const DATA *d, CXCursor parent) : \
- VisitorJob(parent, VisitorJob::KIND, d) {} \
- static bool classof(const VisitorJob *VJ) { return VJ->getKind() == KIND; }\
- const DATA *get() const { return static_cast<const DATA*>(data[0]); }\
-};
+#define DEF_JOB(NAME, DATA, KIND) \
+ class NAME : public VisitorJob { \
+ public: \
+ NAME(const DATA *d, CXCursor parent) \
+ : VisitorJob(parent, VisitorJob::KIND, d) {} \
+ static bool classof(const VisitorJob *VJ) { \
+ return VJ->getKind() == KIND; \
+ } \
+ const DATA *get() const { return static_cast<const DATA *>(data[0]); } \
+ };
DEF_JOB(StmtVisit, Stmt, StmtVisitKind)
DEF_JOB(MemberExprParts, MemberExpr, MemberExprPartsKind)
@@ -1873,9 +1863,9 @@ class ExplicitTemplateArgsVisit : public VisitorJob {
};
class DeclVisit : public VisitorJob {
public:
- DeclVisit(const Decl *D, CXCursor parent, bool isFirst) :
- VisitorJob(parent, VisitorJob::DeclVisitKind,
- D, isFirst ? (void*) 1 : (void*) nullptr) {}
+ DeclVisit(const Decl *D, CXCursor parent, bool isFirst)
+ : VisitorJob(parent, VisitorJob::DeclVisitKind, D,
+ isFirst ? (void *)1 : (void *)nullptr) {}
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == DeclVisitKind;
}
@@ -1884,15 +1874,15 @@ class DeclVisit : public VisitorJob {
};
class TypeLocVisit : public VisitorJob {
public:
- TypeLocVisit(TypeLoc tl, CXCursor parent) :
- VisitorJob(parent, VisitorJob::TypeLocVisitKind,
- tl.getType().getAsOpaquePtr(), tl.getOpaqueData()) {}
+ TypeLocVisit(TypeLoc tl, CXCursor parent)
+ : VisitorJob(parent, VisitorJob::TypeLocVisitKind,
+ tl.getType().getAsOpaquePtr(), tl.getOpaqueData()) {}
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == TypeLocVisitKind;
}
- TypeLoc get() const {
+ TypeLoc get() const {
QualType T = QualType::getFromOpaquePtr(data[0]);
return TypeLoc(T, const_cast<void *>(data[1]));
}
@@ -1901,42 +1891,43 @@ class TypeLocVisit : public VisitorJob {
class LabelRefVisit : public VisitorJob {
public:
LabelRefVisit(LabelDecl *LD, SourceLocation labelLoc, CXCursor parent)
- : VisitorJob(parent, VisitorJob::LabelRefVisitKind, LD,
- labelLoc.getPtrEncoding()) {}
-
+ : VisitorJob(parent, VisitorJob::LabelRefVisitKind, LD,
+ labelLoc.getPtrEncoding()) {}
+
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == VisitorJob::LabelRefVisitKind;
}
const LabelDecl *get() const {
return static_cast<const LabelDecl *>(data[0]);
}
- SourceLocation getLoc() const {
- return SourceLocation::getFromPtrEncoding(data[1]); }
+ SourceLocation getLoc() const {
+ return SourceLocation::getFromPtrEncoding(data[1]);
+ }
};
-
+
class NestedNameSpecifierLocVisit : public VisitorJob {
public:
NestedNameSpecifierLocVisit(NestedNameSpecifierLoc Qualifier, CXCursor parent)
- : VisitorJob(parent, VisitorJob::NestedNameSpecifierLocVisitKind,
- Qualifier.getNestedNameSpecifier(),
- Qualifier.getOpaqueData()) { }
-
+ : VisitorJob(parent, VisitorJob::NestedNameSpecifierLocVisitKind,
+ Qualifier.getNestedNameSpecifier(),
+ Qualifier.getOpaqueData()) {}
+
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == VisitorJob::NestedNameSpecifierLocVisitKind;
}
-
+
NestedNameSpecifierLoc get() const {
return NestedNameSpecifierLoc(
- const_cast<NestedNameSpecifier *>(
- static_cast<const NestedNameSpecifier *>(data[0])),
- const_cast<void *>(data[1]));
+ const_cast<NestedNameSpecifier *>(
+ static_cast<const NestedNameSpecifier *>(data[0])),
+ const_cast<void *>(data[1]));
}
};
-
+
class DeclarationNameInfoVisit : public VisitorJob {
public:
DeclarationNameInfoVisit(const Stmt *S, CXCursor parent)
- : VisitorJob(parent, VisitorJob::DeclarationNameInfoVisitKind, S) {}
+ : VisitorJob(parent, VisitorJob::DeclarationNameInfoVisitKind, S) {}
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == VisitorJob::DeclarationNameInfoVisitKind;
}
@@ -1959,8 +1950,8 @@ class DeclarationNameInfoVisit : public VisitorJob {
class MemberRefVisit : public VisitorJob {
public:
MemberRefVisit(const FieldDecl *D, SourceLocation L, CXCursor parent)
- : VisitorJob(parent, VisitorJob::MemberRefVisitKind, D,
- L.getPtrEncoding()) {}
+ : VisitorJob(parent, VisitorJob::MemberRefVisitKind, D,
+ L.getPtrEncoding()) {}
static bool classof(const VisitorJob *VJ) {
return VJ->getKind() == VisitorJob::MemberRefVisitKind;
}
@@ -1968,22 +1959,24 @@ class MemberRefVisit : public VisitorJob {
return static_cast<const FieldDecl *>(data[0]);
}
SourceLocation getLoc() const {
- return SourceLocation::getFromRawEncoding((unsigned)(uintptr_t) data[1]);
+ return SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)data[1]);
}
};
class EnqueueVisitor : public ConstStmtVisitor<EnqueueVisitor, void> {
friend class OMPClauseEnqueue;
VisitorWorkList &WL;
CXCursor Parent;
+
public:
EnqueueVisitor(VisitorWorkList &wl, CXCursor parent)
- : WL(wl), Parent(parent) {}
+ : WL(wl), Parent(parent) {}
void VisitAddrLabelExpr(const AddrLabelExpr *E);
void VisitBlockExpr(const BlockExpr *B);
void VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
void VisitCompoundStmt(const CompoundStmt *S);
- void VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E) { /* Do nothing. */ }
+ void VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E) { /* Do nothing. */
+ }
void VisitMSDependentExistsStmt(const MSDependentExistsStmt *S);
void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E);
void VisitCXXNewExpr(const CXXNewExpr *E);
@@ -2106,7 +2099,7 @@ class EnqueueVisitor : public ConstStmtVisitor<EnqueueVisitor, void> {
void EnqueueChildren(const Stmt *S);
void EnqueueChildren(const OMPClause *S);
};
-} // end anonyous namespace
+} // namespace
void EnqueueVisitor::AddDeclarationNameInfo(const Stmt *S) {
// 'S' should always be non-null, since it comes from the
@@ -2114,8 +2107,8 @@ void EnqueueVisitor::AddDeclarationNameInfo(const Stmt *S) {
WL.push_back(DeclarationNameInfoVisit(S, Parent));
}
-void
-EnqueueVisitor::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc Qualifier) {
+void EnqueueVisitor::AddNestedNameSpecifierLoc(
+ NestedNameSpecifierLoc Qualifier) {
if (Qualifier)
WL.push_back(NestedNameSpecifierLocVisit(Qualifier, Parent));
}
@@ -2139,7 +2132,7 @@ void EnqueueVisitor::AddMemberRef(const FieldDecl *D, SourceLocation L) {
void EnqueueVisitor::AddTypeLoc(TypeSourceInfo *TI) {
if (TI)
WL.push_back(TypeLocVisit(TI->getTypeLoc(), Parent));
- }
+}
void EnqueueVisitor::EnqueueChildren(const Stmt *S) {
unsigned size = WL.size();
for (const Stmt *SubStmt : S->children()) {
@@ -2156,12 +2149,11 @@ namespace {
class OMPClauseEnqueue : public ConstOMPClauseVisitor<OMPClauseEnqueue> {
EnqueueVisitor *Visitor;
/// Process clauses with list of variables.
- template <typename T>
- void VisitOMPClauseList(T *Node);
+ template <typename T> void VisitOMPClauseList(T *Node);
+
public:
- OMPClauseEnqueue(EnqueueVisitor *Visitor) : Visitor(Visitor) { }
-#define OPENMP_CLAUSE(Name, Class) \
- void Visit##Class(const Class *C);
+ OMPClauseEnqueue(EnqueueVisitor *Visitor) : Visitor(Visitor) {}
+#define OPENMP_CLAUSE(Name, Class) void Visit##Class(const Class *C);
#include "clang/Basic/OpenMPKinds.def"
void VisitOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
void VisitOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
@@ -2208,9 +2200,9 @@ void OMPClauseEnqueue::VisitOMPCollapseClause(const OMPCollapseClause *C) {
Visitor->AddStmt(C->getNumForLoops());
}
-void OMPClauseEnqueue::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
+void OMPClauseEnqueue::VisitOMPDefaultClause(const OMPDefaultClause *C) {}
-void OMPClauseEnqueue::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
+void OMPClauseEnqueue::VisitOMPProcBindClause(const OMPProcBindClause *C) {}
void OMPClauseEnqueue::VisitOMPScheduleClause(const OMPScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
@@ -2281,7 +2273,8 @@ void OMPClauseEnqueue::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
Visitor->AddStmt(C->getNumTeams());
}
-void OMPClauseEnqueue::VisitOMPThreadLimitClause(const OMPThreadLimitClause *C) {
+void OMPClauseEnqueue::VisitOMPThreadLimitClause(
+ const OMPThreadLimitClause *C) {
VisitOMPClauseWithPreInit(C);
Visitor->AddStmt(C->getThreadLimit());
}
@@ -2302,8 +2295,7 @@ void OMPClauseEnqueue::VisitOMPHintClause(const OMPHintClause *C) {
Visitor->AddStmt(C->getHint());
}
-template<typename T>
-void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
+template <typename T> void OMPClauseEnqueue::VisitOMPClauseList(T *Node) {
for (const auto *I : Node->varlists()) {
Visitor->AddStmt(I);
}
@@ -2326,7 +2318,7 @@ void OMPClauseEnqueue::VisitOMPPrivateClause(const OMPPrivateClause *C) {
}
}
void OMPClauseEnqueue::VisitOMPFirstprivateClause(
- const OMPFirstprivateClause *C) {
+ const OMPFirstprivateClause *C) {
VisitOMPClauseList(C);
VisitOMPClauseWithPreInit(C);
for (const auto *E : C->private_copies()) {
@@ -2337,7 +2329,7 @@ void OMPClauseEnqueue::VisitOMPFirstprivateClause(
}
}
void OMPClauseEnqueue::VisitOMPLastprivateClause(
- const OMPLastprivateClause *C) {
+ const OMPLastprivateClause *C) {
VisitOMPClauseList(C);
VisitOMPClauseWithPostUpdate(C);
for (auto *E : C->private_copies()) {
@@ -2442,8 +2434,8 @@ void OMPClauseEnqueue::VisitOMPCopyinClause(const OMPCopyinClause *C) {
Visitor->AddStmt(E);
}
}
-void
-OMPClauseEnqueue::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
+void OMPClauseEnqueue::VisitOMPCopyprivateClause(
+ const OMPCopyprivateClause *C) {
VisitOMPClauseList(C);
for (auto *E : C->source_exprs()) {
Visitor->AddStmt(E);
@@ -2480,10 +2472,12 @@ void OMPClauseEnqueue::VisitOMPToClause(const OMPToClause *C) {
void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
VisitOMPClauseList(C);
}
-void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(
+ const OMPUseDevicePtrClause *C) {
VisitOMPClauseList(C);
}
-void OMPClauseEnqueue::VisitOMPIsDevicePtrClause(const OMPIsDevicePtrClause *C) {
+void OMPClauseEnqueue::VisitOMPIsDevicePtrClause(
+ const OMPIsDevicePtrClause *C) {
VisitOMPClauseList(C);
}
void OMPClauseEnqueue::VisitOMPNontemporalClause(
@@ -2493,7 +2487,7 @@ void OMPClauseEnqueue::VisitOMPNontemporalClause(
Visitor->AddStmt(E);
}
void OMPClauseEnqueue::VisitOMPOrderClause(const OMPOrderClause *C) {}
-}
+} // namespace
void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
unsigned size = WL.size();
@@ -2520,16 +2514,16 @@ void EnqueueVisitor::VisitCompoundStmt(const CompoundStmt *S) {
for (auto &I : llvm::reverse(S->body()))
AddStmt(I);
}
-void EnqueueVisitor::
-VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
+void EnqueueVisitor::VisitMSDependentExistsStmt(
+ const MSDependentExistsStmt *S) {
AddStmt(S->getSubStmt());
AddDeclarationNameInfo(S);
if (NestedNameSpecifierLoc QualifierLoc = S->getQualifierLoc())
AddNestedNameSpecifierLoc(QualifierLoc);
}
-void EnqueueVisitor::
-VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
+void EnqueueVisitor::VisitCXXDependentScopeMemberExpr(
+ const CXXDependentScopeMemberExpr *E) {
if (E->hasExplicitTemplateArgs())
AddExplicitTemplateArgs(E->getTemplateArgs(), E->getNumTemplateArgs());
AddDeclarationNameInfo(E);
@@ -2547,16 +2541,16 @@ void EnqueueVisitor::VisitCXXNewExpr(const CXXNewExpr *E) {
AddTypeLoc(E->getAllocatedTypeSourceInfo());
// Enqueue the placement arguments.
for (unsigned I = E->getNumPlacementArgs(); I > 0; --I)
- AddStmt(E->getPlacementArg(I-1));
+ AddStmt(E->getPlacementArg(I - 1));
}
void EnqueueVisitor::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *CE) {
for (unsigned I = CE->getNumArgs(); I > 1 /* Yes, this is 1 */; --I)
- AddStmt(CE->getArg(I-1));
+ AddStmt(CE->getArg(I - 1));
AddStmt(CE->getCallee());
AddStmt(CE->getArg(0));
}
void EnqueueVisitor::VisitCXXPseudoDestructorExpr(
- const CXXPseudoDestructorExpr *E) {
+ const CXXPseudoDestructorExpr *E) {
// Visit the name of the type being destroyed.
AddTypeLoc(E->getDestroyedTypeInfo());
// Visit the scope type that looks disturbingly like the nested-name-specifier
@@ -2569,11 +2563,11 @@ void EnqueueVisitor::VisitCXXPseudoDestructorExpr(
AddStmt(E->getBase());
}
void EnqueueVisitor::VisitCXXScalarValueInitExpr(
- const CXXScalarValueInitExpr *E) {
+ const CXXScalarValueInitExpr *E) {
AddTypeLoc(E->getTypeSourceInfo());
}
void EnqueueVisitor::VisitCXXTemporaryObjectExpr(
- const CXXTemporaryObjectExpr *E) {
+ const CXXTemporaryObjectExpr *E) {
EnqueueChildren(E);
AddTypeLoc(E->getTypeSourceInfo());
}
@@ -2584,7 +2578,7 @@ void EnqueueVisitor::VisitCXXTypeidExpr(const CXXTypeidExpr *E) {
}
void EnqueueVisitor::VisitCXXUnresolvedConstructExpr(
- const CXXUnresolvedConstructExpr *E) {
+ const CXXUnresolvedConstructExpr *E) {
EnqueueChildren(E);
AddTypeLoc(E->getTypeSourceInfo());
}
@@ -2611,7 +2605,7 @@ void EnqueueVisitor::VisitDeclRefExpr(const DeclRefExpr *DR) {
WL.push_back(DeclRefExprParts(DR, Parent));
}
void EnqueueVisitor::VisitDependentScopeDeclRefExpr(
- const DependentScopeDeclRefExpr *E) {
+ const DependentScopeDeclRefExpr *E) {
if (E->hasExplicitTemplateArgs())
AddExplicitTemplateArgs(E->getTemplateArgs(), E->getNumTemplateArgs());
AddDeclarationNameInfo(E);
@@ -2677,7 +2671,7 @@ void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
}
void EnqueueVisitor::VisitMemberExpr(const MemberExpr *M) {
WL.push_back(MemberExprParts(M, Parent));
-
+
// If the base of the member access expression is an implicit 'this', don't
// visit it.
// FIXME: If we ever want to show these implicit accesses, this will be
@@ -2708,7 +2702,7 @@ void EnqueueVisitor::VisitObjCMessageExpr(const ObjCMessageExpr *M) {
void EnqueueVisitor::VisitOffsetOfExpr(const OffsetOfExpr *E) {
// Visit the components of the offsetof expression.
for (unsigned N = E->getNumComponents(), I = N; I > 0; --I) {
- const OffsetOfNode &Node = E->getComponent(I-1);
+ const OffsetOfNode &Node = E->getComponent(I - 1);
switch (Node.getKind()) {
case OffsetOfNode::Array:
AddStmt(E->getIndexExpr(Node.getArrayExprIndex()));
@@ -2730,14 +2724,12 @@ void EnqueueVisitor::VisitOverloadExpr(const OverloadExpr *E) {
WL.push_back(OverloadExprParts(E, Parent));
}
void EnqueueVisitor::VisitUnaryExprOrTypeTraitExpr(
- const UnaryExprOrTypeTraitExpr *E) {
+ const UnaryExprOrTypeTraitExpr *E) {
EnqueueChildren(E);
if (E->isArgumentType())
AddTypeLoc(E->getArgumentTypeInfo());
}
-void EnqueueVisitor::VisitStmt(const Stmt *S) {
- EnqueueChildren(S);
-}
+void EnqueueVisitor::VisitStmt(const Stmt *S) { EnqueueChildren(S); }
void EnqueueVisitor::VisitSwitchStmt(const SwitchStmt *S) {
AddStmt(S->getBody());
AddStmt(S->getCond());
@@ -2752,7 +2744,7 @@ void EnqueueVisitor::VisitWhileStmt(const WhileStmt *W) {
void EnqueueVisitor::VisitTypeTraitExpr(const TypeTraitExpr *E) {
for (unsigned I = E->getNumArgs(); I > 0; --I)
- AddTypeLoc(E->getArg(I-1));
+ AddTypeLoc(E->getArg(I - 1));
}
void EnqueueVisitor::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E) {
@@ -2791,7 +2783,7 @@ void EnqueueVisitor::VisitPseudoObjectExpr(const PseudoObjectExpr *E) {
}
void EnqueueVisitor::VisitOMPExecutableDirective(
- const OMPExecutableDirective *D) {
+ const OMPExecutableDirective *D) {
EnqueueChildren(D);
for (ArrayRef<OMPClause *>::iterator I = D->clauses().begin(),
E = D->clauses().end();
@@ -2840,8 +2832,8 @@ void EnqueueVisitor::VisitOMPCriticalDirective(const OMPCriticalDirective *D) {
AddDeclarationNameInfo(D);
}
-void
-EnqueueVisitor::VisitOMPParallelForDirective(const OMPParallelForDirective *D) {
+void EnqueueVisitor::VisitOMPParallelForDirective(
+ const OMPParallelForDirective *D) {
VisitOMPLoopDirective(D);
}
@@ -2864,8 +2856,8 @@ void EnqueueVisitor::VisitOMPTaskDirective(const OMPTaskDirective *D) {
VisitOMPExecutableDirective(D);
}
-void
-EnqueueVisitor::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *D) {
+void EnqueueVisitor::VisitOMPTaskyieldDirective(
+ const OMPTaskyieldDirective *D) {
VisitOMPExecutableDirective(D);
}
@@ -3051,7 +3043,8 @@ void EnqueueVisitor::VisitOMPTargetTeamsDistributeSimdDirective(
}
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, const Stmt *S) {
- EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S);
+ EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU, RegionOfInterest))
+ .Visit(S);
}
bool CursorVisitor::IsInRegionOfInterest(CXCursor C) {
@@ -3070,199 +3063,199 @@ bool CursorVisitor::RunVisitorWorkList(VisitorWorkList &WL) {
// Set the Parent field, then back to its old value once we're done.
SetParentRAII SetParent(Parent, StmtParent, LI.getParent());
-
+
switch (LI.getKind()) {
- case VisitorJob::DeclVisitKind: {
- const Decl *D = cast<DeclVisit>(&LI)->get();
- if (!D)
- continue;
+ case VisitorJob::DeclVisitKind: {
+ const Decl *D = cast<DeclVisit>(&LI)->get();
+ if (!D)
+ continue;
- // For now, perform default visitation for Decls.
- if (Visit(MakeCXCursor(D, TU, RegionOfInterest,
- cast<DeclVisit>(&LI)->isFirst())))
- return true;
+ // For now, perform default visitation for Decls.
+ if (Visit(MakeCXCursor(D, TU, RegionOfInterest,
+ cast<DeclVisit>(&LI)->isFirst())))
+ return true;
- continue;
- }
- case VisitorJob::ExplicitTemplateArgsVisitKind: {
- for (const TemplateArgumentLoc &Arg :
- *cast<ExplicitTemplateArgsVisit>(&LI)) {
- if (VisitTemplateArgumentLoc(Arg))
- return true;
- }
- continue;
- }
- case VisitorJob::TypeLocVisitKind: {
- // Perform default visitation for TypeLocs.
- if (Visit(cast<TypeLocVisit>(&LI)->get()))
+ continue;
+ }
+ case VisitorJob::ExplicitTemplateArgsVisitKind: {
+ for (const TemplateArgumentLoc &Arg :
+ *cast<ExplicitTemplateArgsVisit>(&LI)) {
+ if (VisitTemplateArgumentLoc(Arg))
return true;
- continue;
}
- case VisitorJob::LabelRefVisitKind: {
- const LabelDecl *LS = cast<LabelRefVisit>(&LI)->get();
- if (LabelStmt *stmt = LS->getStmt()) {
- if (Visit(MakeCursorLabelRef(stmt, cast<LabelRefVisit>(&LI)->getLoc(),
- TU))) {
- return true;
- }
+ continue;
+ }
+ case VisitorJob::TypeLocVisitKind: {
+ // Perform default visitation for TypeLocs.
+ if (Visit(cast<TypeLocVisit>(&LI)->get()))
+ return true;
+ continue;
+ }
+ case VisitorJob::LabelRefVisitKind: {
+ const LabelDecl *LS = cast<LabelRefVisit>(&LI)->get();
+ if (LabelStmt *stmt = LS->getStmt()) {
+ if (Visit(MakeCursorLabelRef(stmt, cast<LabelRefVisit>(&LI)->getLoc(),
+ TU))) {
+ return true;
}
- continue;
}
+ continue;
+ }
- case VisitorJob::NestedNameSpecifierLocVisitKind: {
- NestedNameSpecifierLocVisit *V = cast<NestedNameSpecifierLocVisit>(&LI);
- if (VisitNestedNameSpecifierLoc(V->get()))
- return true;
+ case VisitorJob::NestedNameSpecifierLocVisitKind: {
+ NestedNameSpecifierLocVisit *V = cast<NestedNameSpecifierLocVisit>(&LI);
+ if (VisitNestedNameSpecifierLoc(V->get()))
+ return true;
+ continue;
+ }
+
+ case VisitorJob::DeclarationNameInfoVisitKind: {
+ if (VisitDeclarationNameInfo(cast<DeclarationNameInfoVisit>(&LI)->get()))
+ return true;
+ continue;
+ }
+ case VisitorJob::MemberRefVisitKind: {
+ MemberRefVisit *V = cast<MemberRefVisit>(&LI);
+ if (Visit(MakeCursorMemberRef(V->get(), V->getLoc(), TU)))
+ return true;
+ continue;
+ }
+ case VisitorJob::StmtVisitKind: {
+ const Stmt *S = cast<StmtVisit>(&LI)->get();
+ if (!S)
continue;
- }
-
- case VisitorJob::DeclarationNameInfoVisitKind: {
- if (VisitDeclarationNameInfo(cast<DeclarationNameInfoVisit>(&LI)
- ->get()))
- return true;
+
+ // Update the current cursor.
+ CXCursor Cursor = MakeCXCursor(S, StmtParent, TU, RegionOfInterest);
+ if (!IsInRegionOfInterest(Cursor))
continue;
+ switch (Visitor(Cursor, Parent, ClientData)) {
+ case CXChildVisit_Break:
+ return true;
+ case CXChildVisit_Continue:
+ break;
+ case CXChildVisit_Recurse:
+ if (PostChildrenVisitor)
+ WL.push_back(PostChildrenVisit(nullptr, Cursor));
+ EnqueueWorkList(WL, S);
+ break;
}
- case VisitorJob::MemberRefVisitKind: {
- MemberRefVisit *V = cast<MemberRefVisit>(&LI);
- if (Visit(MakeCursorMemberRef(V->get(), V->getLoc(), TU)))
+ continue;
+ }
+ case VisitorJob::MemberExprPartsKind: {
+ // Handle the other pieces in the MemberExpr besides the base.
+ const MemberExpr *M = cast<MemberExprParts>(&LI)->get();
+
+ // Visit the nested-name-specifier
+ if (NestedNameSpecifierLoc QualifierLoc = M->getQualifierLoc())
+ if (VisitNestedNameSpecifierLoc(QualifierLoc))
return true;
- continue;
- }
- case VisitorJob::StmtVisitKind: {
- const Stmt *S = cast<StmtVisit>(&LI)->get();
- if (!S)
- continue;
- // Update the current cursor.
- CXCursor Cursor = MakeCXCursor(S, StmtParent, TU, RegionOfInterest);
- if (!IsInRegionOfInterest(Cursor))
- continue;
- switch (Visitor(Cursor, Parent, ClientData)) {
- case CXChildVisit_Break: return true;
- case CXChildVisit_Continue: break;
- case CXChildVisit_Recurse:
- if (PostChildrenVisitor)
- WL.push_back(PostChildrenVisit(nullptr, Cursor));
- EnqueueWorkList(WL, S);
- break;
- }
- continue;
- }
- case VisitorJob::MemberExprPartsKind: {
- // Handle the other pieces in the MemberExpr besides the base.
- const MemberExpr *M = cast<MemberExprParts>(&LI)->get();
-
- // Visit the nested-name-specifier
- if (NestedNameSpecifierLoc QualifierLoc = M->getQualifierLoc())
- if (VisitNestedNameSpecifierLoc(QualifierLoc))
+ // Visit the declaration name.
+ if (VisitDeclarationNameInfo(M->getMemberNameInfo()))
+ return true;
+
+ // Visit the explicitly-specified template arguments, if any.
+ if (M->hasExplicitTemplateArgs()) {
+ for (const TemplateArgumentLoc *Arg = M->getTemplateArgs(),
+ *ArgEnd = Arg + M->getNumTemplateArgs();
+ Arg != ArgEnd; ++Arg) {
+ if (VisitTemplateArgumentLoc(*Arg))
return true;
-
- // Visit the declaration name.
- if (VisitDeclarationNameInfo(M->getMemberNameInfo()))
- return true;
-
- // Visit the explicitly-specified template arguments, if any.
- if (M->hasExplicitTemplateArgs()) {
- for (const TemplateArgumentLoc *Arg = M->getTemplateArgs(),
- *ArgEnd = Arg + M->getNumTemplateArgs();
- Arg != ArgEnd; ++Arg) {
- if (VisitTemplateArgumentLoc(*Arg))
- return true;
- }
}
- continue;
}
- case VisitorJob::DeclRefExprPartsKind: {
- const DeclRefExpr *DR = cast<DeclRefExprParts>(&LI)->get();
- // Visit nested-name-specifier, if present.
- if (NestedNameSpecifierLoc QualifierLoc = DR->getQualifierLoc())
- if (VisitNestedNameSpecifierLoc(QualifierLoc))
- return true;
- // Visit declaration name.
- if (VisitDeclarationNameInfo(DR->getNameInfo()))
+ continue;
+ }
+ case VisitorJob::DeclRefExprPartsKind: {
+ const DeclRefExpr *DR = cast<DeclRefExprParts>(&LI)->get();
+ // Visit nested-name-specifier, if present.
+ if (NestedNameSpecifierLoc QualifierLoc = DR->getQualifierLoc())
+ if (VisitNestedNameSpecifierLoc(QualifierLoc))
+ return true;
+ // Visit declaration name.
+ if (VisitDeclarationNameInfo(DR->getNameInfo()))
+ return true;
+ continue;
+ }
+ case VisitorJob::OverloadExprPartsKind: {
+ const OverloadExpr *O = cast<OverloadExprParts>(&LI)->get();
+ // Visit the nested-name-specifier.
+ if (NestedNameSpecifierLoc QualifierLoc = O->getQualifierLoc())
+ if (VisitNestedNameSpecifierLoc(QualifierLoc))
+ return true;
+ // Visit the declaration name.
+ if (VisitDeclarationNameInfo(O->getNameInfo()))
+ return true;
+ // Visit the overloaded declaration reference.
+ if (Visit(MakeCursorOverloadedDeclRef(O, TU)))
+ return true;
+ continue;
+ }
+ case VisitorJob::SizeOfPackExprPartsKind: {
+ const SizeOfPackExpr *E = cast<SizeOfPackExprParts>(&LI)->get();
+ NamedDecl *Pack = E->getPack();
+ if (isa<TemplateTypeParmDecl>(Pack)) {
+ if (Visit(MakeCursorTypeRef(cast<TemplateTypeParmDecl>(Pack),
+ E->getPackLoc(), TU)))
return true;
+
continue;
}
- case VisitorJob::OverloadExprPartsKind: {
- const OverloadExpr *O = cast<OverloadExprParts>(&LI)->get();
- // Visit the nested-name-specifier.
- if (NestedNameSpecifierLoc QualifierLoc = O->getQualifierLoc())
- if (VisitNestedNameSpecifierLoc(QualifierLoc))
- return true;
- // Visit the declaration name.
- if (VisitDeclarationNameInfo(O->getNameInfo()))
- return true;
- // Visit the overloaded declaration reference.
- if (Visit(MakeCursorOverloadedDeclRef(O, TU)))
+
+ if (isa<TemplateTemplateParmDecl>(Pack)) {
+ if (Visit(MakeCursorTemplateRef(cast<TemplateTemplateParmDecl>(Pack),
+ E->getPackLoc(), TU)))
return true;
+
continue;
}
- case VisitorJob::SizeOfPackExprPartsKind: {
- const SizeOfPackExpr *E = cast<SizeOfPackExprParts>(&LI)->get();
- NamedDecl *Pack = E->getPack();
- if (isa<TemplateTypeParmDecl>(Pack)) {
- if (Visit(MakeCursorTypeRef(cast<TemplateTypeParmDecl>(Pack),
- E->getPackLoc(), TU)))
- return true;
-
- continue;
- }
-
- if (isa<TemplateTemplateParmDecl>(Pack)) {
- if (Visit(MakeCursorTemplateRef(cast<TemplateTemplateParmDecl>(Pack),
- E->getPackLoc(), TU)))
- return true;
-
+
+ // Non-type template parameter packs and function parameter packs are
+ // treated like DeclRefExpr cursors.
+ continue;
+ }
+
+ case VisitorJob::LambdaExprPartsKind: {
+ // Visit non-init captures.
+ const LambdaExpr *E = cast<LambdaExprParts>(&LI)->get();
+ for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
+ CEnd = E->explicit_capture_end();
+ C != CEnd; ++C) {
+ if (!C->capturesVariable())
continue;
- }
-
- // Non-type template parameter packs and function parameter packs are
- // treated like DeclRefExpr cursors.
- continue;
+
+ if (Visit(MakeCursorVariableRef(C->getCapturedVar(), C->getLocation(),
+ TU)))
+ return true;
}
-
- case VisitorJob::LambdaExprPartsKind: {
- // Visit non-init captures.
- const LambdaExpr *E = cast<LambdaExprParts>(&LI)->get();
- for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
- CEnd = E->explicit_capture_end();
- C != CEnd; ++C) {
- if (!C->capturesVariable())
- continue;
-
- if (Visit(MakeCursorVariableRef(C->getCapturedVar(),
- C->getLocation(),
- TU)))
- return true;
+ // Visit init captures
+ for (auto InitExpr : E->capture_inits()) {
+ if (Visit(InitExpr))
+ return true;
+ }
+
+ TypeLoc TL = E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
+ // Visit parameters and return type, if present.
+ if (FunctionTypeLoc Proto = TL.getAs<FunctionProtoTypeLoc>()) {
+ if (E->hasExplicitParameters()) {
+ // Visit parameters.
+ for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
+ if (Visit(MakeCXCursor(Proto.getParam(I), TU)))
+ return true;
}
- // Visit init captures
- for (auto InitExpr : E->capture_inits()) {
- if (Visit(InitExpr))
+ if (E->hasExplicitResultType()) {
+ // Visit result type.
+ if (Visit(Proto.getReturnLoc()))
return true;
}
-
- TypeLoc TL = E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
- // Visit parameters and return type, if present.
- if (FunctionTypeLoc Proto = TL.getAs<FunctionProtoTypeLoc>()) {
- if (E->hasExplicitParameters()) {
- // Visit parameters.
- for (unsigned I = 0, N = Proto.getNumParams(); I != N; ++I)
- if (Visit(MakeCXCursor(Proto.getParam(I), TU)))
- return true;
- }
- if (E->hasExplicitResultType()) {
- // Visit result type.
- if (Visit(Proto.getReturnLoc()))
- return true;
- }
- }
- break;
}
+ break;
+ }
- case VisitorJob::PostChildrenVisitKind:
- if (PostChildrenVisitor(Parent, ClientData))
- return true;
- break;
+ case VisitorJob::PostChildrenVisitKind:
+ if (PostChildrenVisitor(Parent, ClientData))
+ return true;
+ break;
}
}
return false;
@@ -3274,8 +3267,7 @@ bool CursorVisitor::Visit(const Stmt *S) {
WL = WorkListFreeList.back();
WL->clear();
WorkListFreeList.pop_back();
- }
- else {
+ } else {
WL = new VisitorWorkList();
WorkListCache.push_back(WL);
}
@@ -3293,14 +3285,14 @@ RefNamePieces buildPieces(unsigned NameFlags, bool IsMemberRefExpr,
const bool WantQualifier = NameFlags & CXNameRange_WantQualifier;
const bool WantTemplateArgs = NameFlags & CXNameRange_WantTemplateArgs;
const bool WantSinglePiece = NameFlags & CXNameRange_WantSinglePiece;
-
+
const DeclarationName::NameKind Kind = NI.getName().getNameKind();
-
+
RefNamePieces Pieces;
if (WantQualifier && QLoc.isValid())
Pieces.push_back(QLoc);
-
+
if (Kind != DeclarationName::CXXOperatorName || IsMemberRefExpr)
Pieces.push_back(NI.getLoc());
@@ -3309,24 +3301,24 @@ RefNamePieces buildPieces(unsigned NameFlags, bool IsMemberRefExpr,
if (Kind == DeclarationName::CXXOperatorName) {
Pieces.push_back(SourceLocation::getFromRawEncoding(
- NI.getInfo().CXXOperatorName.BeginOpNameLoc));
+ NI.getInfo().CXXOperatorName.BeginOpNameLoc));
Pieces.push_back(SourceLocation::getFromRawEncoding(
- NI.getInfo().CXXOperatorName.EndOpNameLoc));
+ NI.getInfo().CXXOperatorName.EndOpNameLoc));
}
-
+
if (WantSinglePiece) {
SourceRange R(Pieces.front().getBegin(), Pieces.back().getEnd());
Pieces.clear();
Pieces.push_back(R);
- }
+ }
- return Pieces;
-}
+ return Pieces;
}
+} // namespace
//===----------------------------------------------------------------------===//
// Misc. API hooks.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
struct RegisterFatalErrorHandler {
@@ -3334,9 +3326,10 @@ struct RegisterFatalErrorHandler {
clang_install_aborting_llvm_fatal_error_handler();
}
};
-}
+} // namespace
-static llvm::ManagedStatic<RegisterFatalErrorHandler> RegisterFatalErrorHandlerOnce;
+static llvm::ManagedStatic<RegisterFatalErrorHandler>
+ RegisterFatalErrorHandlerOnce;
CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
int displayDiagnostics) {
@@ -3422,9 +3415,7 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
if (!CIdx || !ast_filename || !out_TU)
return CXError_InvalidArguments;
- LOG_FUNC_SECTION {
- *Log << ast_filename;
- }
+ LOG_FUNC_SECTION { *Log << ast_filename; }
CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
FileSystemOptions FileSystemOpts;
@@ -3433,10 +3424,8 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
CompilerInstance::createDiagnostics(new DiagnosticOptions());
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
ast_filename, CXXIdx->getPCHContainerOperations()->getRawReader(),
- ASTUnit::LoadEverything, Diags,
- FileSystemOpts, /*UseDebugInfo=*/false,
- CXXIdx->getOnlyLocalDecls(), None,
- CaptureDiagsKind::All,
+ ASTUnit::LoadEverything, Diags, FileSystemOpts, /*UseDebugInfo=*/false,
+ CXXIdx->getOnlyLocalDecls(), None, CaptureDiagsKind::All,
/*AllowPCHWithCompilerErrors=*/true,
/*UserFilesAreVolatile=*/true);
*out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
@@ -3444,22 +3433,18 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
}
unsigned clang_defaultEditingTranslationUnitOptions() {
- return CXTranslationUnit_PrecompiledPreamble |
+ return CXTranslationUnit_PrecompiledPreamble |
CXTranslationUnit_CacheCompletionResults;
}
-CXTranslationUnit
-clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
- const char *source_filename,
- int num_command_line_args,
- const char * const *command_line_args,
- unsigned num_unsaved_files,
- struct CXUnsavedFile *unsaved_files) {
+CXTranslationUnit clang_createTranslationUnitFromSourceFile(
+ CXIndex CIdx, const char *source_filename, int num_command_line_args,
+ const char *const *command_line_args, unsigned num_unsaved_files,
+ struct CXUnsavedFile *unsaved_files) {
unsigned Options = CXTranslationUnit_DetailedPreprocessingRecord;
- return clang_parseTranslationUnit(CIdx, source_filename,
- command_line_args, num_command_line_args,
- unsaved_files, num_unsaved_files,
- Options);
+ return clang_parseTranslationUnit(CIdx, source_filename, command_line_args,
+ num_command_line_args, unsaved_files,
+ num_unsaved_files, Options);
}
static CXErrorCode
@@ -3485,17 +3470,18 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
bool CreatePreambleOnFirstParse =
options & CXTranslationUnit_CreatePreambleOnFirstParse;
// FIXME: Add a flag for modules.
- TranslationUnitKind TUKind
- = (options & (CXTranslationUnit_Incomplete |
- CXTranslationUnit_SingleFileParse))? TU_Prefix : TU_Complete;
- bool CacheCodeCompletionResults
- = options & CXTranslationUnit_CacheCompletionResults;
- bool IncludeBriefCommentsInCodeCompletion
- = options & CXTranslationUnit_IncludeBriefCommentsInCodeCompletion;
+ TranslationUnitKind TUKind = (options & (CXTranslationUnit_Incomplete |
+ CXTranslationUnit_SingleFileParse))
+ ? TU_Prefix
+ : TU_Complete;
+ bool CacheCodeCompletionResults =
+ options & CXTranslationUnit_CacheCompletionResults;
+ bool IncludeBriefCommentsInCodeCompletion =
+ options & CXTranslationUnit_IncludeBriefCommentsInCodeCompletion;
bool SingleFileParse = options & CXTranslationUnit_SingleFileParse;
bool ForSerialization = options & CXTranslationUnit_ForSerialization;
- bool RetainExcludedCB = options &
- CXTranslationUnit_RetainExcludedConditionalBlocks;
+ bool RetainExcludedCB =
+ options & CXTranslationUnit_RetainExcludedConditionalBlocks;
SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None;
if (options & CXTranslationUnit_SkipFunctionBodies) {
SkipFunctionBodies =
@@ -3505,8 +3491,8 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
}
// Configure the diagnostics.
- IntrusiveRefCntPtr<DiagnosticsEngine>
- Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
+ CompilerInstance::createDiagnostics(new DiagnosticOptions));
if (options & CXTranslationUnit_KeepGoing)
Diags->setFatalsAsError(true);
@@ -3516,16 +3502,17 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
CaptureDiagnostics = CaptureDiagsKind::AllWithoutNonErrorsFromIncludes;
// Recover resources if we crash before exiting this function.
- llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
- llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine> >
- DiagCleanup(Diags.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<
+ DiagnosticsEngine,
+ llvm::CrashRecoveryContextReleaseRefCleanup<DiagnosticsEngine>>
+ DiagCleanup(Diags.get());
std::unique_ptr<std::vector<ASTUnit::RemappedFile>> RemappedFiles(
new std::vector<ASTUnit::RemappedFile>());
// Recover resources if we crash before exiting this function.
- llvm::CrashRecoveryContextCleanupRegistrar<
- std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<std::vector<ASTUnit::RemappedFile>>
+ RemappedCleanup(RemappedFiles.get());
for (auto &UF : unsaved_files) {
std::unique_ptr<llvm::MemoryBuffer> MB =
@@ -3537,12 +3524,12 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
new std::vector<const char *>());
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar<std::vector<const char*> >
- ArgsCleanup(Args.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<std::vector<const char *>>
+ ArgsCleanup(Args.get());
// Since the Clang C library is primarily used by batch tools dealing with
// (often very broken) source code, where spell-checking can have a
- // significant negative impact on performance (particularly when
+ // significant negative impact on performance (particularly when
// precompiled headers are involved), we disable it by default.
// Only do this if we haven't found a spell-checking-related argument.
bool FoundSpellCheckingArgument = false;
@@ -3625,13 +3612,11 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
}
CXTranslationUnit
-clang_parseTranslationUnit(CXIndex CIdx,
- const char *source_filename,
+clang_parseTranslationUnit(CXIndex CIdx, const char *source_filename,
const char *const *command_line_args,
int num_command_line_args,
struct CXUnsavedFile *unsaved_files,
- unsigned num_unsaved_files,
- unsigned options) {
+ unsigned num_unsaved_files, unsigned options) {
CXTranslationUnit TU;
enum CXErrorCode Result = clang_parseTranslationUnit2(
CIdx, source_filename, command_line_args, num_command_line_args,
@@ -3714,8 +3699,7 @@ CXString clang_Type_getObjCEncoding(CXType CT) {
CXTranslationUnit tu = static_cast<CXTranslationUnit>(CT.data[1]);
ASTContext &Ctx = getASTUnit(tu)->getASTContext();
std::string encoding;
- Ctx.getObjCEncodingForType(QualType::getFromOpaquePtr(CT.data[0]),
- encoding);
+ Ctx.getObjCEncodingForType(QualType::getFromOpaquePtr(CT.data[0]), encoding);
return cxstring::createDup(encoding);
}
@@ -3764,7 +3748,7 @@ unsigned clang_Cursor_isFunctionInlined(CXCursor C) {
return FD->isInlined();
}
-static StringLiteral* getCFSTR_value(CallExpr *callExpr) {
+static StringLiteral *getCFSTR_value(CallExpr *callExpr) {
if (callExpr->getNumArgs() != 1) {
return nullptr;
}
@@ -3775,7 +3759,7 @@ static StringLiteral* getCFSTR_value(CallExpr *callExpr) {
ImplicitCastExpr *I = static_cast<ImplicitCastExpr *>(arg);
auto *subExpr = I->getSubExprAsWritten();
- if(subExpr->getStmtClass() != Stmt::StringLiteralClass){
+ if (subExpr->getStmtClass() != Stmt::StringLiteralClass) {
return nullptr;
}
@@ -3824,7 +3808,7 @@ long long clang_EvalResult_getAsLongLong(CXEvalResult E) {
if (!E) {
return 0;
}
- ExprEvalResult *Result = (ExprEvalResult*)E;
+ ExprEvalResult *Result = (ExprEvalResult *)E;
if (Result->IsUnsignedInt)
return Result->EvalData.unsignedVal;
return Result->EvalData.intVal;
@@ -3839,7 +3823,7 @@ unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E) {
return 0;
}
- ExprEvalResult *Result = (ExprEvalResult*)E;
+ ExprEvalResult *Result = (ExprEvalResult *)E;
if (Result->IsUnsignedInt)
return Result->EvalData.unsignedVal;
return Result->EvalData.intVal;
@@ -3852,14 +3836,14 @@ double clang_EvalResult_getAsDouble(CXEvalResult E) {
return ((ExprEvalResult *)E)->EvalData.floatVal;
}
-const char* clang_EvalResult_getAsStr(CXEvalResult E) {
+const char *clang_EvalResult_getAsStr(CXEvalResult E) {
if (!E) {
return nullptr;
}
return ((ExprEvalResult *)E)->EvalData.stringVal;
}
-static const ExprEvalResult* evaluateExpr(Expr *expr, CXCursor C) {
+static const ExprEvalResult *evaluateExpr(Expr *expr, CXCursor C) {
Expr::EvalResult ER;
ASTContext &ctx = getCursorContext(C);
if (!expr)
@@ -3880,7 +3864,7 @@ static const ExprEvalResult* evaluateExpr(Expr *expr, CXCursor C) {
if (ER.Val.isInt()) {
result->EvalType = CXEval_Int;
- auto& val = ER.Val.getInt();
+ auto &val = ER.Val.getInt();
if (val.isUnsigned()) {
result->IsUnsignedInt = true;
result->EvalData.unsignedVal = val.getZExtValue();
@@ -4053,7 +4037,7 @@ unsigned clang_Cursor_hasAttrs(CXCursor C) {
}
unsigned clang_defaultSaveOptions(CXTranslationUnit TU) {
return CXSaveTranslationUnit_None;
-}
+}
static CXSaveError clang_saveTranslationUnit_Impl(CXTranslationUnit TU,
const char *FileName,
@@ -4068,9 +4052,7 @@ static CXSaveError clang_saveTranslationUnit_Impl(CXTranslationUnit TU,
int clang_saveTranslationUnit(CXTranslationUnit TU, const char *FileName,
unsigned options) {
- LOG_FUNC_SECTION {
- *Log << TU << ' ' << FileName;
- }
+ LOG_FUNC_SECTION { *Log << TU << ' ' << FileName; }
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
@@ -4162,7 +4144,7 @@ clang_reparseTranslationUnit_Impl(CXTranslationUnit TU,
}
// Reset the associated diagnostics.
- delete static_cast<CXDiagnosticSetImpl*>(TU->Diagnostics);
+ delete static_cast<CXDiagnosticSetImpl *>(TU->Diagnostics);
TU->Diagnostics = nullptr;
CIndexer *CXXIdx = TU->CIdx;
@@ -4176,8 +4158,8 @@ clang_reparseTranslationUnit_Impl(CXTranslationUnit TU,
new std::vector<ASTUnit::RemappedFile>());
// Recover resources if we crash before exiting this function.
- llvm::CrashRecoveryContextCleanupRegistrar<
- std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<std::vector<ASTUnit::RemappedFile>>
+ RemappedCleanup(RemappedFiles.get());
for (auto &UF : unsaved_files) {
std::unique_ptr<llvm::MemoryBuffer> MB =
@@ -4197,9 +4179,7 @@ int clang_reparseTranslationUnit(CXTranslationUnit TU,
unsigned num_unsaved_files,
struct CXUnsavedFile *unsaved_files,
unsigned options) {
- LOG_FUNC_SECTION {
- *Log << TU;
- }
+ LOG_FUNC_SECTION { *Log << TU; }
if (num_unsaved_files && !unsaved_files)
return CXError_InvalidArguments;
@@ -4222,7 +4202,6 @@ int clang_reparseTranslationUnit(CXTranslationUnit TU,
return result;
}
-
CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) {
if (isNotUsableTU(CTUnit)) {
LOG_BAD_TU(CTUnit);
@@ -4249,7 +4228,7 @@ CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit) {
return nullptr;
}
- CXTargetInfoImpl* impl = new CXTargetInfoImpl();
+ CXTargetInfoImpl *impl = new CXTargetInfoImpl();
impl->TranslationUnit = CTUnit;
return impl;
}
@@ -4264,7 +4243,7 @@ CXString clang_TargetInfo_getTriple(CXTargetInfo TargetInfo) {
ASTUnit *CXXUnit = cxtu::getASTUnit(CTUnit);
std::string Triple =
- CXXUnit->getASTContext().getTargetInfo().getTriple().normalize();
+ CXXUnit->getASTContext().getTargetInfo().getTriple().normalize();
return cxstring::createDup(Triple);
}
@@ -4343,8 +4322,7 @@ const char *clang_getFileContents(CXTranslationUnit TU, CXFile file,
return buf->getBufferStart();
}
-unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU,
- CXFile file) {
+unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU, CXFile file) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
return 0;
@@ -4355,8 +4333,9 @@ unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit TU,
ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
FileEntry *FEnt = static_cast<FileEntry *>(file);
- return CXXUnit->getPreprocessor().getHeaderSearchInfo()
- .isFileMultipleIncludeGuarded(FEnt);
+ return CXXUnit->getPreprocessor()
+ .getHeaderSearchInfo()
+ .isFileMultipleIncludeGuarded(FEnt);
}
int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID) {
@@ -4421,12 +4400,12 @@ static const Decl *getDeclFromExpr(const Stmt *E) {
if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E))
if (Expr *Src = OVE->getSourceExpr())
return getDeclFromExpr(Src);
-
+
if (const CallExpr *CE = dyn_cast<CallExpr>(E))
return getDeclFromExpr(CE->getCallee());
if (const CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E))
if (!CE->isElidable())
- return CE->getConstructor();
+ return CE->getConstructor();
if (const CXXInheritedCtorInitExpr *CE =
dyn_cast<CXXInheritedCtorInitExpr>(E))
return CE->getConstructor();
@@ -4435,11 +4414,11 @@ static const Decl *getDeclFromExpr(const Stmt *E) {
if (const ObjCProtocolExpr *PE = dyn_cast<ObjCProtocolExpr>(E))
return PE->getProtocol();
- if (const SubstNonTypeTemplateParmPackExpr *NTTP
- = dyn_cast<SubstNonTypeTemplateParmPackExpr>(E))
+ if (const SubstNonTypeTemplateParmPackExpr *NTTP =
+ dyn_cast<SubstNonTypeTemplateParmPackExpr>(E))
return NTTP->getParameterPack();
if (const SizeOfPackExpr *SizeOfPack = dyn_cast<SizeOfPackExpr>(E))
- if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
+ if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
isa<ParmVarDecl>(SizeOfPack->getPack()))
return SizeOfPack->getPack();
@@ -4451,7 +4430,7 @@ static SourceLocation getLocationFromExpr(const Expr *E) {
return getLocationFromExpr(CE->getSubExpr());
if (const ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E))
- return /*FIXME:*/Msg->getLeftLoc();
+ return /*FIXME:*/ Msg->getLeftLoc();
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
return DRE->getLocation();
if (const MemberExpr *Member = dyn_cast<MemberExpr>(E))
@@ -4468,8 +4447,7 @@ static SourceLocation getLocationFromExpr(const Expr *E) {
extern "C" {
-unsigned clang_visitChildren(CXCursor parent,
- CXCursorVisitor visitor,
+unsigned clang_visitChildren(CXCursor parent, CXCursorVisitor visitor,
CXClientData client_data) {
CursorVisitor CursorVis(getCursorTU(parent), visitor, client_data,
/*VisitPreprocessorLast=*/false);
@@ -4480,34 +4458,32 @@ unsigned clang_visitChildren(CXCursor parent,
#define __has_feature(x) 0
#endif
#if __has_feature(blocks)
-typedef enum CXChildVisitResult
- (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
+typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
+ CXCursor parent);
static enum CXChildVisitResult visitWithBlock(CXCursor cursor, CXCursor parent,
- CXClientData client_data) {
+ CXClientData client_data) {
CXCursorVisitorBlock block = (CXCursorVisitorBlock)client_data;
return block(cursor, parent);
}
#else
// If we are compiled with a compiler that doesn't have native blocks support,
-// define and call the block manually, so the
-typedef struct _CXChildVisitResult
-{
- void *isa;
- int flags;
- int reserved;
- enum CXChildVisitResult(*invoke)(struct _CXChildVisitResult*, CXCursor,
- CXCursor);
-} *CXCursorVisitorBlock;
+// define and call the block manually, so the
+typedef struct _CXChildVisitResult {
+ void *isa;
+ int flags;
+ int reserved;
+ enum CXChildVisitResult (*invoke)(struct _CXChildVisitResult *, CXCursor,
+ CXCursor);
+} * CXCursorVisitorBlock;
static enum CXChildVisitResult visitWithBlock(CXCursor cursor, CXCursor parent,
- CXClientData client_data) {
+ CXClientData client_data) {
CXCursorVisitorBlock block = (CXCursorVisitorBlock)client_data;
return block->invoke(block, cursor, parent);
}
#endif
-
unsigned clang_visitChildrenWithBlock(CXCursor parent,
CXCursorVisitorBlock block) {
return clang_visitChildren(parent, visitWithBlock, block);
@@ -4523,14 +4499,14 @@ static CXString getDeclSpelling(const Decl *D) {
dyn_cast<ObjCPropertyImplDecl>(D))
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
return cxstring::createDup(Property->getIdentifier()->getName());
-
+
if (const ImportDecl *ImportD = dyn_cast<ImportDecl>(D))
if (Module *Mod = ImportD->getImportedModule())
return cxstring::createDup(Mod->getFullModuleName());
return cxstring::createEmpty();
}
-
+
if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
return cxstring::createDup(OMD->getSelector().getAsString());
@@ -4542,11 +4518,11 @@ static CXString getDeclSpelling(const Decl *D) {
if (isa<UsingDirectiveDecl>(D))
return cxstring::createEmpty();
-
+
SmallString<1024> S;
llvm::raw_svector_ostream os(S);
ND->printName(os);
-
+
return cxstring::createDup(os.str());
}
@@ -4577,34 +4553,34 @@ CXString clang_getCursorSpelling(CXCursor C) {
const TypeDecl *Type = getCursorTypeRef(C).first;
assert(Type && "Missing type decl");
- return cxstring::createDup(getCursorContext(C).getTypeDeclType(Type).
- getAsString());
+ return cxstring::createDup(
+ getCursorContext(C).getTypeDeclType(Type).getAsString());
}
case CXCursor_TemplateRef: {
const TemplateDecl *Template = getCursorTemplateRef(C).first;
assert(Template && "Missing template decl");
-
+
return cxstring::createDup(Template->getNameAsString());
}
-
+
case CXCursor_NamespaceRef: {
const NamedDecl *NS = getCursorNamespaceRef(C).first;
assert(NS && "Missing namespace decl");
-
+
return cxstring::createDup(NS->getNameAsString());
}
case CXCursor_MemberRef: {
const FieldDecl *Field = getCursorMemberRef(C).first;
assert(Field && "Missing member decl");
-
+
return cxstring::createDup(Field->getNameAsString());
}
case CXCursor_LabelRef: {
const LabelStmt *Label = getCursorLabelRef(C).first;
assert(Label && "Missing label");
-
+
return cxstring::createRef(Label->getName());
}
@@ -4617,20 +4593,20 @@ CXString clang_getCursorSpelling(CXCursor C) {
}
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
return cxstring::createDup(E->getName().getAsString());
- OverloadedTemplateStorage *Ovl
- = Storage.get<OverloadedTemplateStorage*>();
+ OverloadedTemplateStorage *Ovl =
+ Storage.get<OverloadedTemplateStorage *>();
if (Ovl->size() == 0)
return cxstring::createEmpty();
return cxstring::createDup((*Ovl->begin())->getNameAsString());
}
-
+
case CXCursor_VariableRef: {
const VarDecl *Var = getCursorVariableRef(C).first;
assert(Var && "Missing variable decl");
-
+
return cxstring::createDup(Var->getNameAsString());
}
-
+
default:
return cxstring::createRef("<not implemented>");
}
@@ -4666,18 +4642,18 @@ CXString clang_getCursorSpelling(CXCursor C) {
return cxstring::createEmpty();
}
-
+
if (C.kind == CXCursor_MacroExpansion)
- return cxstring::createRef(getCursorMacroExpansion(C).getName()
- ->getNameStart());
+ return cxstring::createRef(
+ getCursorMacroExpansion(C).getName()->getNameStart());
if (C.kind == CXCursor_MacroDefinition)
- return cxstring::createRef(getCursorMacroDefinition(C)->getName()
- ->getNameStart());
+ return cxstring::createRef(
+ getCursorMacroDefinition(C)->getName()->getNameStart());
if (C.kind == CXCursor_InclusionDirective)
return cxstring::createDup(getCursorInclusionDirective(C)->getFileName());
-
+
if (clang_isDeclaration(C.kind))
return getDeclSpelling(getCursorDecl(C));
@@ -4711,8 +4687,7 @@ CXString clang_getCursorSpelling(CXCursor C) {
return cxstring::createEmpty();
}
-CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
- unsigned pieceIndex,
+CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C, unsigned pieceIndex,
unsigned options) {
if (clang_Cursor_isNull(C))
return clang_getNullRange();
@@ -4731,8 +4706,8 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
}
if (C.kind == CXCursor_ObjCMessageExpr) {
- if (const ObjCMessageExpr *
- ME = dyn_cast_or_null<ObjCMessageExpr>(getCursorExpr(C))) {
+ if (const ObjCMessageExpr *ME =
+ dyn_cast_or_null<ObjCMessageExpr>(getCursorExpr(C))) {
if (pieceIndex >= ME->getNumSelectorLocs())
return clang_getNullRange();
return cxloc::translateSourceRange(Ctx, ME->getSelectorLoc(pieceIndex));
@@ -4741,8 +4716,8 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
if (C.kind == CXCursor_ObjCInstanceMethodDecl ||
C.kind == CXCursor_ObjCClassMethodDecl) {
- if (const ObjCMethodDecl *
- MD = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(C))) {
+ if (const ObjCMethodDecl *MD =
+ dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(C))) {
if (pieceIndex >= MD->getNumSelectorLocs())
return clang_getNullRange();
return cxloc::translateSourceRange(Ctx, MD->getSelectorLoc(pieceIndex));
@@ -4753,11 +4728,11 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
C.kind == CXCursor_ObjCCategoryImplDecl) {
if (pieceIndex > 0)
return clang_getNullRange();
- if (const ObjCCategoryDecl *
- CD = dyn_cast_or_null<ObjCCategoryDecl>(getCursorDecl(C)))
+ if (const ObjCCategoryDecl *CD =
+ dyn_cast_or_null<ObjCCategoryDecl>(getCursorDecl(C)))
return cxloc::translateSourceRange(Ctx, CD->getCategoryNameLoc());
- if (const ObjCCategoryImplDecl *
- CID = dyn_cast_or_null<ObjCCategoryImplDecl>(getCursorDecl(C)))
+ if (const ObjCCategoryImplDecl *CID =
+ dyn_cast_or_null<ObjCCategoryImplDecl>(getCursorDecl(C)))
return cxloc::translateSourceRange(Ctx, CID->getCategoryNameLoc());
}
@@ -4768,8 +4743,8 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C,
dyn_cast_or_null<ImportDecl>(getCursorDecl(C))) {
ArrayRef<SourceLocation> Locs = ImportD->getIdentifierLocs();
if (!Locs.empty())
- return cxloc::translateSourceRange(Ctx,
- SourceRange(Locs.front(), Locs.back()));
+ return cxloc::translateSourceRange(
+ Ctx, SourceRange(Locs.front(), Locs.back()));
}
return clang_getNullRange();
}
@@ -5040,7 +5015,7 @@ CXString clang_getCursorPrettyPrinted(CXCursor C, CXPrintingPolicy cxPolicy) {
CXString clang_getCursorDisplayName(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return clang_getCursorSpelling(C);
-
+
const Decl *D = getCursorDecl(C);
if (!D)
return cxstring::createEmpty();
@@ -5048,7 +5023,7 @@ CXString clang_getCursorDisplayName(CXCursor C) {
PrintingPolicy Policy = getCursorContext(C).getPrintingPolicy();
if (const FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D))
D = FunTmpl->getTemplatedDecl();
-
+
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
SmallString<64> Str;
llvm::raw_svector_ostream OS(Str);
@@ -5061,7 +5036,7 @@ CXString clang_getCursorDisplayName(CXCursor C) {
OS << ", ";
OS << Function->getParamDecl(I)->getType().getAsString(Policy);
}
-
+
if (Function->isVariadic()) {
if (Function->getNumParams())
OS << ", ";
@@ -5070,7 +5045,7 @@ CXString clang_getCursorDisplayName(CXCursor C) {
OS << ")";
return cxstring::createDup(OS.str());
}
-
+
if (const ClassTemplateDecl *ClassTemplate = dyn_cast<ClassTemplateDecl>(D)) {
SmallString<64> Str;
llvm::raw_svector_ostream OS(Str);
@@ -5080,13 +5055,13 @@ CXString clang_getCursorDisplayName(CXCursor C) {
for (unsigned I = 0, N = Params->size(); I != N; ++I) {
if (I)
OS << ", ";
-
+
NamedDecl *Param = Params->getParam(I);
if (Param->getIdentifier()) {
OS << Param->getIdentifier()->getName();
continue;
}
-
+
// There is no parameter name, which makes this tricky. Try to come up
// with something useful that isn't too long.
if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
@@ -5095,20 +5070,20 @@ CXString clang_getCursorDisplayName(CXCursor C) {
if (TC->hasExplicitTemplateArgs())
OS << "<...>";
} else
- OS << (TTP->wasDeclaredWithTypename()? "typename" : "class");
- else if (NonTypeTemplateParmDecl *NTTP
- = dyn_cast<NonTypeTemplateParmDecl>(Param))
+ OS << (TTP->wasDeclaredWithTypename() ? "typename" : "class");
+ else if (NonTypeTemplateParmDecl *NTTP =
+ dyn_cast<NonTypeTemplateParmDecl>(Param))
OS << NTTP->getType().getAsString(Policy);
else
OS << "template<...> class";
}
-
+
OS << ">";
return cxstring::createDup(OS.str());
}
-
- if (const ClassTemplateSpecializationDecl *ClassSpec
- = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
+
+ if (const ClassTemplateSpecializationDecl *ClassSpec =
+ dyn_cast<ClassTemplateSpecializationDecl>(D)) {
// If the type was explicitly written, use that.
if (TypeSourceInfo *TSInfo = ClassSpec->getTypeAsWritten())
return cxstring::createDup(TSInfo->getType().getAsString(Policy));
@@ -5120,64 +5095,64 @@ CXString clang_getCursorDisplayName(CXCursor C) {
Policy);
return cxstring::createDup(OS.str());
}
-
+
return clang_getCursorSpelling(C);
}
-
+
CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
switch (Kind) {
case CXCursor_FunctionDecl:
- return cxstring::createRef("FunctionDecl");
+ return cxstring::createRef("FunctionDecl");
case CXCursor_TypedefDecl:
- return cxstring::createRef("TypedefDecl");
+ return cxstring::createRef("TypedefDecl");
case CXCursor_EnumDecl:
- return cxstring::createRef("EnumDecl");
+ return cxstring::createRef("EnumDecl");
case CXCursor_EnumConstantDecl:
- return cxstring::createRef("EnumConstantDecl");
+ return cxstring::createRef("EnumConstantDecl");
case CXCursor_StructDecl:
- return cxstring::createRef("StructDecl");
+ return cxstring::createRef("StructDecl");
case CXCursor_UnionDecl:
- return cxstring::createRef("UnionDecl");
+ return cxstring::createRef("UnionDecl");
case CXCursor_ClassDecl:
- return cxstring::createRef("ClassDecl");
+ return cxstring::createRef("ClassDecl");
case CXCursor_FieldDecl:
- return cxstring::createRef("FieldDecl");
+ return cxstring::createRef("FieldDecl");
case CXCursor_VarDecl:
- return cxstring::createRef("VarDecl");
+ return cxstring::createRef("VarDecl");
case CXCursor_ParmDecl:
- return cxstring::createRef("ParmDecl");
+ return cxstring::createRef("ParmDecl");
case CXCursor_ObjCInterfaceDecl:
- return cxstring::createRef("ObjCInterfaceDecl");
+ return cxstring::createRef("ObjCInterfaceDecl");
case CXCursor_ObjCCategoryDecl:
- return cxstring::createRef("ObjCCategoryDecl");
+ return cxstring::createRef("ObjCCategoryDecl");
case CXCursor_ObjCProtocolDecl:
- return cxstring::createRef("ObjCProtocolDecl");
+ return cxstring::createRef("ObjCProtocolDecl");
case CXCursor_ObjCPropertyDecl:
- return cxstring::createRef("ObjCPropertyDecl");
+ return cxstring::createRef("ObjCPropertyDecl");
case CXCursor_ObjCIvarDecl:
- return cxstring::createRef("ObjCIvarDecl");
+ return cxstring::createRef("ObjCIvarDecl");
case CXCursor_ObjCInstanceMethodDecl:
- return cxstring::createRef("ObjCInstanceMethodDecl");
+ return cxstring::createRef("ObjCInstanceMethodDecl");
case CXCursor_ObjCClassMethodDecl:
- return cxstring::createRef("ObjCClassMethodDecl");
+ return cxstring::createRef("ObjCClassMethodDecl");
case CXCursor_ObjCImplementationDecl:
- return cxstring::createRef("ObjCImplementationDecl");
+ return cxstring::createRef("ObjCImplementationDecl");
case CXCursor_ObjCCategoryImplDecl:
- return cxstring::createRef("ObjCCategoryImplDecl");
+ return cxstring::createRef("ObjCCategoryImplDecl");
case CXCursor_CXXMethod:
- return cxstring::createRef("CXXMethod");
+ return cxstring::createRef("CXXMethod");
case CXCursor_UnexposedDecl:
- return cxstring::createRef("UnexposedDecl");
+ return cxstring::createRef("UnexposedDecl");
case CXCursor_ObjCSuperClassRef:
- return cxstring::createRef("ObjCSuperClassRef");
+ return cxstring::createRef("ObjCSuperClassRef");
case CXCursor_ObjCProtocolRef:
- return cxstring::createRef("ObjCProtocolRef");
+ return cxstring::createRef("ObjCProtocolRef");
case CXCursor_ObjCClassRef:
- return cxstring::createRef("ObjCClassRef");
+ return cxstring::createRef("ObjCClassRef");
case CXCursor_TypeRef:
- return cxstring::createRef("TypeRef");
+ return cxstring::createRef("TypeRef");
case CXCursor_TemplateRef:
- return cxstring::createRef("TemplateRef");
+ return cxstring::createRef("TemplateRef");
case CXCursor_NamespaceRef:
return cxstring::createRef("NamespaceRef");
case CXCursor_MemberRef:
@@ -5189,195 +5164,195 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
case CXCursor_VariableRef:
return cxstring::createRef("VariableRef");
case CXCursor_IntegerLiteral:
- return cxstring::createRef("IntegerLiteral");
+ return cxstring::createRef("IntegerLiteral");
case CXCursor_FixedPointLiteral:
- return cxstring::createRef("FixedPointLiteral");
+ return cxstring::createRef("FixedPointLiteral");
case CXCursor_FloatingLiteral:
- return cxstring::createRef("FloatingLiteral");
+ return cxstring::createRef("FloatingLiteral");
case CXCursor_ImaginaryLiteral:
- return cxstring::createRef("ImaginaryLiteral");
+ return cxstring::createRef("ImaginaryLiteral");
case CXCursor_StringLiteral:
- return cxstring::createRef("StringLiteral");
+ return cxstring::createRef("StringLiteral");
case CXCursor_CharacterLiteral:
- return cxstring::createRef("CharacterLiteral");
+ return cxstring::createRef("CharacterLiteral");
case CXCursor_ParenExpr:
- return cxstring::createRef("ParenExpr");
+ return cxstring::createRef("ParenExpr");
case CXCursor_UnaryOperator:
- return cxstring::createRef("UnaryOperator");
+ return cxstring::createRef("UnaryOperator");
case CXCursor_ArraySubscriptExpr:
- return cxstring::createRef("ArraySubscriptExpr");
+ return cxstring::createRef("ArraySubscriptExpr");
case CXCursor_OMPArraySectionExpr:
- return cxstring::createRef("OMPArraySectionExpr");
+ return cxstring::createRef("OMPArraySectionExpr");
case CXCursor_BinaryOperator:
- return cxstring::createRef("BinaryOperator");
+ return cxstring::createRef("BinaryOperator");
case CXCursor_CompoundAssignOperator:
- return cxstring::createRef("CompoundAssignOperator");
+ return cxstring::createRef("CompoundAssignOperator");
case CXCursor_ConditionalOperator:
- return cxstring::createRef("ConditionalOperator");
+ return cxstring::createRef("ConditionalOperator");
case CXCursor_CStyleCastExpr:
- return cxstring::createRef("CStyleCastExpr");
+ return cxstring::createRef("CStyleCastExpr");
case CXCursor_CompoundLiteralExpr:
- return cxstring::createRef("CompoundLiteralExpr");
+ return cxstring::createRef("CompoundLiteralExpr");
case CXCursor_InitListExpr:
- return cxstring::createRef("InitListExpr");
+ return cxstring::createRef("InitListExpr");
case CXCursor_AddrLabelExpr:
- return cxstring::createRef("AddrLabelExpr");
+ return cxstring::createRef("AddrLabelExpr");
case CXCursor_StmtExpr:
- return cxstring::createRef("StmtExpr");
+ return cxstring::createRef("StmtExpr");
case CXCursor_GenericSelectionExpr:
- return cxstring::createRef("GenericSelectionExpr");
+ return cxstring::createRef("GenericSelectionExpr");
case CXCursor_GNUNullExpr:
- return cxstring::createRef("GNUNullExpr");
+ return cxstring::createRef("GNUNullExpr");
case CXCursor_CXXStaticCastExpr:
- return cxstring::createRef("CXXStaticCastExpr");
+ return cxstring::createRef("CXXStaticCastExpr");
case CXCursor_CXXDynamicCastExpr:
- return cxstring::createRef("CXXDynamicCastExpr");
+ return cxstring::createRef("CXXDynamicCastExpr");
case CXCursor_CXXReinterpretCastExpr:
- return cxstring::createRef("CXXReinterpretCastExpr");
+ return cxstring::createRef("CXXReinterpretCastExpr");
case CXCursor_CXXConstCastExpr:
- return cxstring::createRef("CXXConstCastExpr");
+ return cxstring::createRef("CXXConstCastExpr");
case CXCursor_CXXFunctionalCastExpr:
- return cxstring::createRef("CXXFunctionalCastExpr");
+ return cxstring::createRef("CXXFunctionalCastExpr");
case CXCursor_CXXTypeidExpr:
- return cxstring::createRef("CXXTypeidExpr");
+ return cxstring::createRef("CXXTypeidExpr");
case CXCursor_CXXBoolLiteralExpr:
- return cxstring::createRef("CXXBoolLiteralExpr");
+ return cxstring::createRef("CXXBoolLiteralExpr");
case CXCursor_CXXNullPtrLiteralExpr:
- return cxstring::createRef("CXXNullPtrLiteralExpr");
+ return cxstring::createRef("CXXNullPtrLiteralExpr");
case CXCursor_CXXThisExpr:
- return cxstring::createRef("CXXThisExpr");
+ return cxstring::createRef("CXXThisExpr");
case CXCursor_CXXThrowExpr:
- return cxstring::createRef("CXXThrowExpr");
+ return cxstring::createRef("CXXThrowExpr");
case CXCursor_CXXNewExpr:
- return cxstring::createRef("CXXNewExpr");
+ return cxstring::createRef("CXXNewExpr");
case CXCursor_CXXDeleteExpr:
- return cxstring::createRef("CXXDeleteExpr");
+ return cxstring::createRef("CXXDeleteExpr");
case CXCursor_UnaryExpr:
- return cxstring::createRef("UnaryExpr");
+ return cxstring::createRef("UnaryExpr");
case CXCursor_ObjCStringLiteral:
- return cxstring::createRef("ObjCStringLiteral");
+ return cxstring::createRef("ObjCStringLiteral");
case CXCursor_ObjCBoolLiteralExpr:
- return cxstring::createRef("ObjCBoolLiteralExpr");
+ return cxstring::createRef("ObjCBoolLiteralExpr");
case CXCursor_ObjCAvailabilityCheckExpr:
- return cxstring::createRef("ObjCAvailabilityCheckExpr");
+ return cxstring::createRef("ObjCAvailabilityCheckExpr");
case CXCursor_ObjCSelfExpr:
- return cxstring::createRef("ObjCSelfExpr");
+ return cxstring::createRef("ObjCSelfExpr");
case CXCursor_ObjCEncodeExpr:
- return cxstring::createRef("ObjCEncodeExpr");
+ return cxstring::createRef("ObjCEncodeExpr");
case CXCursor_ObjCSelectorExpr:
- return cxstring::createRef("ObjCSelectorExpr");
+ return cxstring::createRef("ObjCSelectorExpr");
case CXCursor_ObjCProtocolExpr:
- return cxstring::createRef("ObjCProtocolExpr");
+ return cxstring::createRef("ObjCProtocolExpr");
case CXCursor_ObjCBridgedCastExpr:
- return cxstring::createRef("ObjCBridgedCastExpr");
+ return cxstring::createRef("ObjCBridgedCastExpr");
case CXCursor_BlockExpr:
- return cxstring::createRef("BlockExpr");
+ return cxstring::createRef("BlockExpr");
case CXCursor_PackExpansionExpr:
- return cxstring::createRef("PackExpansionExpr");
+ return cxstring::createRef("PackExpansionExpr");
case CXCursor_SizeOfPackExpr:
- return cxstring::createRef("SizeOfPackExpr");
+ return cxstring::createRef("SizeOfPackExpr");
case CXCursor_LambdaExpr:
return cxstring::createRef("LambdaExpr");
case CXCursor_UnexposedExpr:
- return cxstring::createRef("UnexposedExpr");
+ return cxstring::createRef("UnexposedExpr");
case CXCursor_DeclRefExpr:
- return cxstring::createRef("DeclRefExpr");
+ return cxstring::createRef("DeclRefExpr");
case CXCursor_MemberRefExpr:
- return cxstring::createRef("MemberRefExpr");
+ return cxstring::createRef("MemberRefExpr");
case CXCursor_CallExpr:
- return cxstring::createRef("CallExpr");
+ return cxstring::createRef("CallExpr");
case CXCursor_ObjCMessageExpr:
- return cxstring::createRef("ObjCMessageExpr");
+ return cxstring::createRef("ObjCMessageExpr");
case CXCursor_BuiltinBitCastExpr:
return cxstring::createRef("BuiltinBitCastExpr");
case CXCursor_UnexposedStmt:
- return cxstring::createRef("UnexposedStmt");
+ return cxstring::createRef("UnexposedStmt");
case CXCursor_DeclStmt:
- return cxstring::createRef("DeclStmt");
+ return cxstring::createRef("DeclStmt");
case CXCursor_LabelStmt:
- return cxstring::createRef("LabelStmt");
+ return cxstring::createRef("LabelStmt");
case CXCursor_CompoundStmt:
- return cxstring::createRef("CompoundStmt");
+ return cxstring::createRef("CompoundStmt");
case CXCursor_CaseStmt:
- return cxstring::createRef("CaseStmt");
+ return cxstring::createRef("CaseStmt");
case CXCursor_DefaultStmt:
- return cxstring::createRef("DefaultStmt");
+ return cxstring::createRef("DefaultStmt");
case CXCursor_IfStmt:
- return cxstring::createRef("IfStmt");
+ return cxstring::createRef("IfStmt");
case CXCursor_SwitchStmt:
- return cxstring::createRef("SwitchStmt");
+ return cxstring::createRef("SwitchStmt");
case CXCursor_WhileStmt:
- return cxstring::createRef("WhileStmt");
+ return cxstring::createRef("WhileStmt");
case CXCursor_DoStmt:
- return cxstring::createRef("DoStmt");
+ return cxstring::createRef("DoStmt");
case CXCursor_ForStmt:
- return cxstring::createRef("ForStmt");
+ return cxstring::createRef("ForStmt");
case CXCursor_GotoStmt:
- return cxstring::createRef("GotoStmt");
+ return cxstring::createRef("GotoStmt");
case CXCursor_IndirectGotoStmt:
- return cxstring::createRef("IndirectGotoStmt");
+ return cxstring::createRef("IndirectGotoStmt");
case CXCursor_ContinueStmt:
- return cxstring::createRef("ContinueStmt");
+ return cxstring::createRef("ContinueStmt");
case CXCursor_BreakStmt:
- return cxstring::createRef("BreakStmt");
+ return cxstring::createRef("BreakStmt");
case CXCursor_ReturnStmt:
- return cxstring::createRef("ReturnStmt");
+ return cxstring::createRef("ReturnStmt");
case CXCursor_GCCAsmStmt:
- return cxstring::createRef("GCCAsmStmt");
+ return cxstring::createRef("GCCAsmStmt");
case CXCursor_MSAsmStmt:
- return cxstring::createRef("MSAsmStmt");
+ return cxstring::createRef("MSAsmStmt");
case CXCursor_ObjCAtTryStmt:
- return cxstring::createRef("ObjCAtTryStmt");
+ return cxstring::createRef("ObjCAtTryStmt");
case CXCursor_ObjCAtCatchStmt:
- return cxstring::createRef("ObjCAtCatchStmt");
+ return cxstring::createRef("ObjCAtCatchStmt");
case CXCursor_ObjCAtFinallyStmt:
- return cxstring::createRef("ObjCAtFinallyStmt");
+ return cxstring::createRef("ObjCAtFinallyStmt");
case CXCursor_ObjCAtThrowStmt:
- return cxstring::createRef("ObjCAtThrowStmt");
+ return cxstring::createRef("ObjCAtThrowStmt");
case CXCursor_ObjCAtSynchronizedStmt:
- return cxstring::createRef("ObjCAtSynchronizedStmt");
+ return cxstring::createRef("ObjCAtSynchronizedStmt");
case CXCursor_ObjCAutoreleasePoolStmt:
- return cxstring::createRef("ObjCAutoreleasePoolStmt");
+ return cxstring::createRef("ObjCAutoreleasePoolStmt");
case CXCursor_ObjCForCollectionStmt:
- return cxstring::createRef("ObjCForCollectionStmt");
+ return cxstring::createRef("ObjCForCollectionStmt");
case CXCursor_CXXCatchStmt:
- return cxstring::createRef("CXXCatchStmt");
+ return cxstring::createRef("CXXCatchStmt");
case CXCursor_CXXTryStmt:
- return cxstring::createRef("CXXTryStmt");
+ return cxstring::createRef("CXXTryStmt");
case CXCursor_CXXForRangeStmt:
- return cxstring::createRef("CXXForRangeStmt");
+ return cxstring::createRef("CXXForRangeStmt");
case CXCursor_SEHTryStmt:
- return cxstring::createRef("SEHTryStmt");
+ return cxstring::createRef("SEHTryStmt");
case CXCursor_SEHExceptStmt:
- return cxstring::createRef("SEHExceptStmt");
+ return cxstring::createRef("SEHExceptStmt");
case CXCursor_SEHFinallyStmt:
- return cxstring::createRef("SEHFinallyStmt");
+ return cxstring::createRef("SEHFinallyStmt");
case CXCursor_SEHLeaveStmt:
- return cxstring::createRef("SEHLeaveStmt");
+ return cxstring::createRef("SEHLeaveStmt");
case CXCursor_NullStmt:
- return cxstring::createRef("NullStmt");
+ return cxstring::createRef("NullStmt");
case CXCursor_InvalidFile:
- return cxstring::createRef("InvalidFile");
+ return cxstring::createRef("InvalidFile");
case CXCursor_InvalidCode:
return cxstring::createRef("InvalidCode");
case CXCursor_NoDeclFound:
- return cxstring::createRef("NoDeclFound");
+ return cxstring::createRef("NoDeclFound");
case CXCursor_NotImplemented:
- return cxstring::createRef("NotImplemented");
+ return cxstring::createRef("NotImplemented");
case CXCursor_TranslationUnit:
- return cxstring::createRef("TranslationUnit");
+ return cxstring::createRef("TranslationUnit");
case CXCursor_UnexposedAttr:
- return cxstring::createRef("UnexposedAttr");
+ return cxstring::createRef("UnexposedAttr");
case CXCursor_IBActionAttr:
- return cxstring::createRef("attribute(ibaction)");
+ return cxstring::createRef("attribute(ibaction)");
case CXCursor_IBOutletAttr:
- return cxstring::createRef("attribute(iboutlet)");
+ return cxstring::createRef("attribute(iboutlet)");
case CXCursor_IBOutletCollectionAttr:
- return cxstring::createRef("attribute(iboutletcollection)");
+ return cxstring::createRef("attribute(iboutletcollection)");
case CXCursor_CXXFinalAttr:
- return cxstring::createRef("attribute(final)");
+ return cxstring::createRef("attribute(final)");
case CXCursor_CXXOverrideAttr:
- return cxstring::createRef("attribute(override)");
+ return cxstring::createRef("attribute(override)");
case CXCursor_AnnotateAttr:
return cxstring::createRef("attribute(annotate)");
case CXCursor_AsmLabelAttr:
@@ -5433,7 +5408,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
case CXCursor_ObjCSubclassingRestricted:
return cxstring::createRef("attribute(objc_subclassing_restricted)");
case CXCursor_ObjCExplicitProtocolImpl:
- return cxstring::createRef("attribute(objc_protocol_requires_explicit_implementation)");
+ return cxstring::createRef(
+ "attribute(objc_protocol_requires_explicit_implementation)");
case CXCursor_ObjCDesignatedInitializer:
return cxstring::createRef("attribute(objc_designated_initializer)");
case CXCursor_ObjCRuntimeVisible:
@@ -5600,21 +5576,21 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
case CXCursor_OMPTargetTeamsDistributeSimdDirective:
return cxstring::createRef("OMPTargetTeamsDistributeSimdDirective");
case CXCursor_OverloadCandidate:
- return cxstring::createRef("OverloadCandidate");
+ return cxstring::createRef("OverloadCandidate");
case CXCursor_TypeAliasTemplateDecl:
- return cxstring::createRef("TypeAliasTemplateDecl");
+ return cxstring::createRef("TypeAliasTemplateDecl");
case CXCursor_StaticAssert:
- return cxstring::createRef("StaticAssert");
+ return cxstring::createRef("StaticAssert");
case CXCursor_FriendDecl:
- return cxstring::createRef("FriendDecl");
+ return cxstring::createRef("FriendDecl");
case CXCursor_ConvergentAttr:
- return cxstring::createRef("attribute(convergent)");
+ return cxstring::createRef("attribute(convergent)");
case CXCursor_WarnUnusedAttr:
- return cxstring::createRef("attribute(warn_unused)");
+ return cxstring::createRef("attribute(warn_unused)");
case CXCursor_WarnUnusedResultAttr:
- return cxstring::createRef("attribute(warn_unused_result)");
+ return cxstring::createRef("attribute(warn_unused_result)");
case CXCursor_AlignedAttr:
- return cxstring::createRef("attribute(aligned)");
+ return cxstring::createRef("attribute(aligned)");
}
llvm_unreachable("Unhandled CXCursorKind");
@@ -5627,17 +5603,16 @@ struct GetCursorData {
SourceLocation VisitedDeclaratorDeclStartLoc;
CXCursor &BestCursor;
- GetCursorData(SourceManager &SM,
- SourceLocation tokenBegin, CXCursor &outputCursor)
- : TokenBeginLoc(tokenBegin), BestCursor(outputCursor) {
+ GetCursorData(SourceManager &SM, SourceLocation tokenBegin,
+ CXCursor &outputCursor)
+ : TokenBeginLoc(tokenBegin), BestCursor(outputCursor) {
PointsAtMacroArgExpansion = SM.isMacroArgExpansion(tokenBegin);
VisitedObjCPropertyImplDecl = false;
}
};
-static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
- CXCursor parent,
- CXClientData client_data) {
+static enum CXChildVisitResult
+GetCursorVisitor(CXCursor cursor, CXCursor parent, CXClientData client_data) {
GetCursorData *Data = static_cast<GetCursorData *>(client_data);
CXCursor *BestCursor = &Data->BestCursor;
@@ -5646,16 +5621,16 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
// cursor.
if (cursor.kind == CXCursor_MacroExpansion && Data->PointsAtMacroArgExpansion)
return CXChildVisit_Recurse;
-
+
if (clang_isDeclaration(cursor.kind)) {
// Avoid having the implicit methods override the property decls.
- if (const ObjCMethodDecl *MD
- = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
+ if (const ObjCMethodDecl *MD =
+ dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
if (MD->isImplicit())
return CXChildVisit_Break;
- } else if (const ObjCInterfaceDecl *ID
- = dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(cursor))) {
+ } else if (const ObjCInterfaceDecl *ID =
+ dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(cursor))) {
// Check that when we have multiple @class references in the same line,
// that later ones do not override the previous ones.
// If we have:
@@ -5664,16 +5639,16 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
// 'Foo' even though the cursor location was at 'Foo'.
if (BestCursor->kind == CXCursor_ObjCInterfaceDecl ||
BestCursor->kind == CXCursor_ObjCClassRef)
- if (const ObjCInterfaceDecl *PrevID
- = dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(*BestCursor))){
- if (PrevID != ID &&
- !PrevID->isThisDeclarationADefinition() &&
- !ID->isThisDeclarationADefinition())
- return CXChildVisit_Break;
+ if (const ObjCInterfaceDecl *PrevID =
+ dyn_cast_or_null<ObjCInterfaceDecl>(
+ getCursorDecl(*BestCursor))) {
+ if (PrevID != ID && !PrevID->isThisDeclarationADefinition() &&
+ !ID->isThisDeclarationADefinition())
+ return CXChildVisit_Break;
}
- } else if (const DeclaratorDecl *DD
- = dyn_cast_or_null<DeclaratorDecl>(getCursorDecl(cursor))) {
+ } else if (const DeclaratorDecl *DD =
+ dyn_cast_or_null<DeclaratorDecl>(getCursorDecl(cursor))) {
SourceLocation StartLoc = DD->getSourceRange().getBegin();
// Check that when we have multiple declarators in the same line,
// that later ones do not override the previous ones.
@@ -5685,8 +5660,9 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
return CXChildVisit_Break;
Data->VisitedDeclaratorDeclStartLoc = StartLoc;
- } else if (const ObjCPropertyImplDecl *PropImp
- = dyn_cast_or_null<ObjCPropertyImplDecl>(getCursorDecl(cursor))) {
+ } else if (const ObjCPropertyImplDecl *PropImp =
+ dyn_cast_or_null<ObjCPropertyImplDecl>(
+ getCursorDecl(cursor))) {
(void)PropImp;
// Check that when we have multiple @synthesize in the same line,
// that later ones do not override the previous ones.
@@ -5707,15 +5683,16 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
// when the expression source range overlaps the declaration range.
// This can happen for C++ constructor expressions whose range generally
// include the variable declaration, e.g.:
- // MyCXXClass foo; // Make sure pointing at 'foo' returns a VarDecl cursor.
+ // MyCXXClass foo; // Make sure pointing at 'foo' returns a VarDecl
+ // cursor.
if (D->getLocation().isValid() && Data->TokenBeginLoc.isValid() &&
D->getLocation() == Data->TokenBeginLoc)
return CXChildVisit_Break;
}
}
- // If our current best cursor is the construction of a temporary object,
- // don't replace that cursor with a type reference, because we want
+ // If our current best cursor is the construction of a temporary object,
+ // don't replace that cursor with a type reference, because we want
// clang_getCursor() to point at the constructor.
if (clang_isExpression(BestCursor->kind) &&
isa<CXXTemporaryObjectExpr>(getCursorExpr(*BestCursor)) &&
@@ -5753,42 +5730,42 @@ CXCursor clang_getCursor(CXTranslationUnit TU, CXSourceLocation Loc) {
CXFile ResultFile;
unsigned ResultLine, ResultColumn;
CXString SearchFileName, ResultFileName, KindSpelling, USR;
- const char *IsDef = clang_isCursorDefinition(Result)? " (Definition)" : "";
+ const char *IsDef = clang_isCursorDefinition(Result) ? " (Definition)" : "";
CXSourceLocation ResultLoc = clang_getCursorLocation(Result);
clang_getFileLocation(Loc, &SearchFile, &SearchLine, &SearchColumn,
nullptr);
- clang_getFileLocation(ResultLoc, &ResultFile, &ResultLine,
- &ResultColumn, nullptr);
+ clang_getFileLocation(ResultLoc, &ResultFile, &ResultLine, &ResultColumn,
+ nullptr);
SearchFileName = clang_getFileName(SearchFile);
ResultFileName = clang_getFileName(ResultFile);
KindSpelling = clang_getCursorKindSpelling(Result.kind);
USR = clang_getCursorUSR(Result);
- *Log << llvm::format("(%s:%d:%d) = %s",
- clang_getCString(SearchFileName), SearchLine, SearchColumn,
- clang_getCString(KindSpelling))
- << llvm::format("(%s:%d:%d):%s%s",
- clang_getCString(ResultFileName), ResultLine, ResultColumn,
- clang_getCString(USR), IsDef);
+ *Log << llvm::format("(%s:%d:%d) = %s", clang_getCString(SearchFileName),
+ SearchLine, SearchColumn,
+ clang_getCString(KindSpelling))
+ << llvm::format("(%s:%d:%d):%s%s", clang_getCString(ResultFileName),
+ ResultLine, ResultColumn, clang_getCString(USR),
+ IsDef);
clang_disposeString(SearchFileName);
clang_disposeString(ResultFileName);
clang_disposeString(KindSpelling);
clang_disposeString(USR);
-
+
CXCursor Definition = clang_getCursorDefinition(Result);
if (!clang_equalCursors(Definition, clang_getNullCursor())) {
CXSourceLocation DefinitionLoc = clang_getCursorLocation(Definition);
- CXString DefinitionKindSpelling
- = clang_getCursorKindSpelling(Definition.kind);
+ CXString DefinitionKindSpelling =
+ clang_getCursorKindSpelling(Definition.kind);
CXFile DefinitionFile;
unsigned DefinitionLine, DefinitionColumn;
- clang_getFileLocation(DefinitionLoc, &DefinitionFile,
- &DefinitionLine, &DefinitionColumn, nullptr);
+ clang_getFileLocation(DefinitionLoc, &DefinitionFile, &DefinitionLine,
+ &DefinitionColumn, nullptr);
CXString DefinitionFileName = clang_getFileName(DefinitionFile);
*Log << llvm::format(" -> %s(%s:%d:%d)",
- clang_getCString(DefinitionKindSpelling),
- clang_getCString(DefinitionFileName),
- DefinitionLine, DefinitionColumn);
+ clang_getCString(DefinitionKindSpelling),
+ clang_getCString(DefinitionFileName), DefinitionLine,
+ DefinitionColumn);
clang_disposeString(DefinitionFileName);
clang_disposeString(DefinitionKindSpelling);
}
@@ -5821,9 +5798,9 @@ unsigned clang_hashCursor(CXCursor C) {
unsigned Index = 0;
if (clang_isExpression(C.kind) || clang_isStatement(C.kind))
Index = 1;
-
- return llvm::DenseMapInfo<std::pair<unsigned, const void*> >::getHashValue(
- std::make_pair(C.kind, C.data[Index]));
+
+ return llvm::DenseMapInfo<std::pair<unsigned, const void *>>::getHashValue(
+ std::make_pair(C.kind, C.data[Index]));
}
unsigned clang_isInvalid(enum CXCursorKind K) {
@@ -5857,7 +5834,7 @@ unsigned clang_isStatement(enum CXCursorKind K) {
}
unsigned clang_isAttribute(enum CXCursorKind K) {
- return K >= CXCursor_FirstAttr && K <= CXCursor_LastAttr;
+ return K >= CXCursor_FirstAttr && K <= CXCursor_LastAttr;
}
unsigned clang_isTranslationUnit(enum CXCursorKind K) {
@@ -5867,41 +5844,39 @@ unsigned clang_isTranslationUnit(enum CXCursorKind K) {
unsigned clang_isPreprocessing(enum CXCursorKind K) {
return K >= CXCursor_FirstPreprocessing && K <= CXCursor_LastPreprocessing;
}
-
+
unsigned clang_isUnexposed(enum CXCursorKind K) {
switch (K) {
- case CXCursor_UnexposedDecl:
- case CXCursor_UnexposedExpr:
- case CXCursor_UnexposedStmt:
- case CXCursor_UnexposedAttr:
- return true;
- default:
- return false;
+ case CXCursor_UnexposedDecl:
+ case CXCursor_UnexposedExpr:
+ case CXCursor_UnexposedStmt:
+ case CXCursor_UnexposedAttr:
+ return true;
+ default:
+ return false;
}
}
-CXCursorKind clang_getCursorKind(CXCursor C) {
- return C.kind;
-}
+CXCursorKind clang_getCursorKind(CXCursor C) { return C.kind; }
CXSourceLocation clang_getCursorLocation(CXCursor C) {
if (clang_isReference(C.kind)) {
switch (C.kind) {
case CXCursor_ObjCSuperClassRef: {
- std::pair<const ObjCInterfaceDecl *, SourceLocation> P
- = getCursorObjCSuperClassRef(C);
+ std::pair<const ObjCInterfaceDecl *, SourceLocation> P =
+ getCursorObjCSuperClassRef(C);
return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
}
case CXCursor_ObjCProtocolRef: {
- std::pair<const ObjCProtocolDecl *, SourceLocation> P
- = getCursorObjCProtocolRef(C);
+ std::pair<const ObjCProtocolDecl *, SourceLocation> P =
+ getCursorObjCProtocolRef(C);
return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
}
case CXCursor_ObjCClassRef: {
- std::pair<const ObjCInterfaceDecl *, SourceLocation> P
- = getCursorObjCClassRef(C);
+ std::pair<const ObjCInterfaceDecl *, SourceLocation> P =
+ getCursorObjCClassRef(C);
return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
}
@@ -5935,10 +5910,10 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
const CXXBaseSpecifier *BaseSpec = getCursorCXXBaseSpecifier(C);
if (!BaseSpec)
return clang_getNullLocation();
-
+
if (TypeSourceInfo *TSInfo = BaseSpec->getTypeSourceInfo())
- return cxloc::translateSourceLocation(getCursorContext(C),
- TSInfo->getTypeLoc().getBeginLoc());
+ return cxloc::translateSourceLocation(
+ getCursorContext(C), TSInfo->getTypeLoc().getBeginLoc());
return cxloc::translateSourceLocation(getCursorContext(C),
BaseSpec->getBeginLoc());
@@ -5950,8 +5925,8 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
}
case CXCursor_OverloadedDeclRef:
- return cxloc::translateSourceLocation(getCursorContext(C),
- getCursorOverloadedDeclRef(C).second);
+ return cxloc::translateSourceLocation(
+ getCursorContext(C), getCursorOverloadedDeclRef(C).second);
default:
// FIXME: Need a way to enumerate all non-reference cases.
@@ -5960,8 +5935,8 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
}
if (clang_isExpression(C.kind))
- return cxloc::translateSourceLocation(getCursorContext(C),
- getLocationFromExpr(getCursorExpr(C)));
+ return cxloc::translateSourceLocation(
+ getCursorContext(C), getLocationFromExpr(getCursorExpr(C)));
if (clang_isStatement(C.kind))
return cxloc::translateSourceLocation(getCursorContext(C),
@@ -5973,8 +5948,8 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
}
if (C.kind == CXCursor_MacroExpansion) {
- SourceLocation L
- = cxcursor::getCursorMacroExpansion(C).getSourceRange().getBegin();
+ SourceLocation L =
+ cxcursor::getCursorMacroExpansion(C).getSourceRange().getBegin();
return cxloc::translateSourceLocation(getCursorContext(C), L);
}
@@ -5984,14 +5959,13 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
}
if (C.kind == CXCursor_InclusionDirective) {
- SourceLocation L
- = cxcursor::getCursorInclusionDirective(C)->getSourceRange().getBegin();
+ SourceLocation L =
+ cxcursor::getCursorInclusionDirective(C)->getSourceRange().getBegin();
return cxloc::translateSourceLocation(getCursorContext(C), L);
}
if (clang_isAttribute(C.kind)) {
- SourceLocation L
- = cxcursor::getCursorAttr(C)->getLocation();
+ SourceLocation L = cxcursor::getCursorAttr(C)->getLocation();
return cxloc::translateSourceLocation(getCursorContext(C), L);
}
@@ -6036,12 +6010,12 @@ CXCursor cxcursor::getCursor(CXTranslationUnit TU, SourceLocation SLoc) {
// the token under the cursor.
SLoc = Lexer::GetBeginningOfToken(SLoc, CXXUnit->getSourceManager(),
CXXUnit->getASTContext().getLangOpts());
-
+
CXCursor Result = MakeCXCursorInvalid(CXCursor_NoDeclFound);
if (SLoc.isValid()) {
GetCursorData ResultData(CXXUnit->getSourceManager(), SLoc, Result);
CursorVisitor CursorVis(TU, GetCursorVisitor, &ResultData,
- /*VisitPreprocessorLast=*/true,
+ /*VisitPreprocessorLast=*/true,
/*VisitIncludedEntities=*/false,
SourceLocation(SLoc));
CursorVis.visitFileRegion();
@@ -6054,7 +6028,7 @@ static SourceRange getRawCursorExtent(CXCursor C) {
if (clang_isReference(C.kind)) {
switch (C.kind) {
case CXCursor_ObjCSuperClassRef:
- return getCursorObjCSuperClassRef(C).second;
+ return getCursorObjCSuperClassRef(C).second;
case CXCursor_ObjCProtocolRef:
return getCursorObjCProtocolRef(C).second;
@@ -6085,7 +6059,7 @@ static SourceRange getRawCursorExtent(CXCursor C) {
case CXCursor_VariableRef:
return getCursorVariableRef(C).second;
-
+
default:
// FIXME: Need a way to enumerate all non-reference cases.
llvm_unreachable("Missed a reference kind");
@@ -6118,7 +6092,8 @@ static SourceRange getRawCursorExtent(CXCursor C) {
if (C.kind == CXCursor_InclusionDirective) {
ASTUnit *TU = getCursorASTUnit(C);
- SourceRange Range = cxcursor::getCursorInclusionDirective(C)->getSourceRange();
+ SourceRange Range =
+ cxcursor::getCursorInclusionDirective(C)->getSourceRange();
return TU->mapRangeFromPreamble(Range);
}
@@ -6185,9 +6160,9 @@ static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) {
R.setBegin(VD->getLocation());
}
- return R;
+ return R;
}
-
+
return getRawCursorExtent(C);
}
@@ -6214,10 +6189,10 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
dyn_cast<ObjCPropertyImplDecl>(D))
if (ObjCPropertyDecl *Property = PropImpl->getPropertyDecl())
return MakeCXCursor(Property, tu);
-
+
return C;
}
-
+
if (clang_isExpression(C.kind)) {
const Expr *E = getCursorExpr(C);
const Decl *D = getDeclFromExpr(E);
@@ -6227,10 +6202,10 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
declCursor);
return declCursor;
}
-
+
if (const OverloadExpr *Ovl = dyn_cast_or_null<OverloadExpr>(E))
return MakeCursorOverloadedDeclRef(Ovl, tu);
-
+
return clang_getNullCursor();
}
@@ -6239,7 +6214,7 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
if (const GotoStmt *Goto = dyn_cast_or_null<GotoStmt>(S))
if (LabelDecl *label = Goto->getLabel())
if (LabelStmt *labelS = label->getStmt())
- return MakeCXCursor(labelS, getCursorDecl(C), tu);
+ return MakeCXCursor(labelS, getCursorDecl(C), tu);
return clang_getNullCursor();
}
@@ -6254,60 +6229,58 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
return clang_getNullCursor();
switch (C.kind) {
- case CXCursor_ObjCSuperClassRef:
- return MakeCXCursor(getCursorObjCSuperClassRef(C).first, tu);
+ case CXCursor_ObjCSuperClassRef:
+ return MakeCXCursor(getCursorObjCSuperClassRef(C).first, tu);
- case CXCursor_ObjCProtocolRef: {
- const ObjCProtocolDecl *Prot = getCursorObjCProtocolRef(C).first;
- if (const ObjCProtocolDecl *Def = Prot->getDefinition())
- return MakeCXCursor(Def, tu);
+ case CXCursor_ObjCProtocolRef: {
+ const ObjCProtocolDecl *Prot = getCursorObjCProtocolRef(C).first;
+ if (const ObjCProtocolDecl *Def = Prot->getDefinition())
+ return MakeCXCursor(Def, tu);
- return MakeCXCursor(Prot, tu);
- }
+ return MakeCXCursor(Prot, tu);
+ }
- case CXCursor_ObjCClassRef: {
- const ObjCInterfaceDecl *Class = getCursorObjCClassRef(C).first;
- if (const ObjCInterfaceDecl *Def = Class->getDefinition())
- return MakeCXCursor(Def, tu);
+ case CXCursor_ObjCClassRef: {
+ const ObjCInterfaceDecl *Class = getCursorObjCClassRef(C).first;
+ if (const ObjCInterfaceDecl *Def = Class->getDefinition())
+ return MakeCXCursor(Def, tu);
- return MakeCXCursor(Class, tu);
- }
+ return MakeCXCursor(Class, tu);
+ }
- case CXCursor_TypeRef:
- return MakeCXCursor(getCursorTypeRef(C).first, tu );
+ case CXCursor_TypeRef:
+ return MakeCXCursor(getCursorTypeRef(C).first, tu);
- case CXCursor_TemplateRef:
- return MakeCXCursor(getCursorTemplateRef(C).first, tu );
+ case CXCursor_TemplateRef:
+ return MakeCXCursor(getCursorTemplateRef(C).first, tu);
- case CXCursor_NamespaceRef:
- return MakeCXCursor(getCursorNamespaceRef(C).first, tu );
+ case CXCursor_NamespaceRef:
+ return MakeCXCursor(getCursorNamespaceRef(C).first, tu);
- case CXCursor_MemberRef:
- return MakeCXCursor(getCursorMemberRef(C).first, tu );
+ case CXCursor_MemberRef:
+ return MakeCXCursor(getCursorMemberRef(C).first, tu);
- case CXCursor_CXXBaseSpecifier: {
- const CXXBaseSpecifier *B = cxcursor::getCursorCXXBaseSpecifier(C);
- return clang_getTypeDeclaration(cxtype::MakeCXType(B->getType(),
- tu ));
- }
+ case CXCursor_CXXBaseSpecifier: {
+ const CXXBaseSpecifier *B = cxcursor::getCursorCXXBaseSpecifier(C);
+ return clang_getTypeDeclaration(cxtype::MakeCXType(B->getType(), tu));
+ }
- case CXCursor_LabelRef:
- // FIXME: We end up faking the "parent" declaration here because we
- // don't want to make CXCursor larger.
- return MakeCXCursor(getCursorLabelRef(C).first,
- cxtu::getASTUnit(tu)->getASTContext()
- .getTranslationUnitDecl(),
- tu);
+ case CXCursor_LabelRef:
+ // FIXME: We end up faking the "parent" declaration here because we
+ // don't want to make CXCursor larger.
+ return MakeCXCursor(
+ getCursorLabelRef(C).first,
+ cxtu::getASTUnit(tu)->getASTContext().getTranslationUnitDecl(), tu);
- case CXCursor_OverloadedDeclRef:
- return C;
-
- case CXCursor_VariableRef:
- return MakeCXCursor(getCursorVariableRef(C).first, tu);
+ case CXCursor_OverloadedDeclRef:
+ return C;
- default:
- // We would prefer to enumerate all non-reference cursor kinds here.
- llvm_unreachable("Unhandled reference cursor kind");
+ case CXCursor_VariableRef:
+ return MakeCXCursor(getCursorVariableRef(C).first, tu);
+
+ default:
+ // We would prefer to enumerate all non-reference cursor kinds here.
+ llvm_unreachable("Unhandled reference cursor kind");
}
}
@@ -6363,7 +6336,7 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
case Decl::Block:
case Decl::Captured:
case Decl::OMPCapturedExpr:
- case Decl::Label: // FIXME: Is this right??
+ case Decl::Label: // FIXME: Is this right??
case Decl::ClassScopeFunctionSpecialization:
case Decl::CXXDeductionGuide:
case Decl::Import:
@@ -6439,8 +6412,8 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
}
case Decl::ClassTemplate: {
- if (RecordDecl *Def = cast<ClassTemplateDecl>(D)->getTemplatedDecl()
- ->getDefinition())
+ if (RecordDecl *Def =
+ cast<ClassTemplateDecl>(D)->getTemplatedDecl()->getDefinition())
return MakeCXCursor(cast<CXXRecordDecl>(Def)->getDescribedClassTemplate(),
TU);
return clang_getNullCursor();
@@ -6454,14 +6427,13 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
}
case Decl::Using:
- return MakeCursorOverloadedDeclRef(cast<UsingDecl>(D),
- D->getLocation(), TU);
+ return MakeCursorOverloadedDeclRef(cast<UsingDecl>(D), D->getLocation(),
+ TU);
case Decl::UsingShadow:
case Decl::ConstructorUsingShadow:
return clang_getCursorDefinition(
- MakeCXCursor(cast<UsingShadowDecl>(D)->getTargetDecl(),
- TU));
+ MakeCXCursor(cast<UsingShadowDecl>(D)->getTargetDecl(), TU));
case Decl::ObjCMethod: {
const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(D);
@@ -6471,11 +6443,11 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
// Dig out the method definition in the associated
// @implementation, if we have it.
// FIXME: The ASTs should make finding the definition easier.
- if (const ObjCInterfaceDecl *Class
- = dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext()))
+ if (const ObjCInterfaceDecl *Class =
+ dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext()))
if (ObjCImplementationDecl *ClassImpl = Class->getImplementation())
- if (ObjCMethodDecl *Def = ClassImpl->getMethod(Method->getSelector(),
- Method->isInstanceMethod()))
+ if (ObjCMethodDecl *Def = ClassImpl->getMethod(
+ Method->getSelector(), Method->isInstanceMethod()))
if (Def->isThisDeclarationADefinition())
return MakeCXCursor(Def, TU);
@@ -6483,13 +6455,14 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
}
case Decl::ObjCCategory:
- if (ObjCCategoryImplDecl *Impl
- = cast<ObjCCategoryDecl>(D)->getImplementation())
+ if (ObjCCategoryImplDecl *Impl =
+ cast<ObjCCategoryDecl>(D)->getImplementation())
return MakeCXCursor(Impl, TU);
return clang_getNullCursor();
case Decl::ObjCProtocol:
- if (const ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(D)->getDefinition())
+ if (const ObjCProtocolDecl *Def =
+ cast<ObjCProtocolDecl>(D)->getDefinition())
return MakeCXCursor(Def, TU);
return clang_getNullCursor();
@@ -6514,8 +6487,8 @@ CXCursor clang_getCursorDefinition(CXCursor C) {
return clang_getNullCursor();
case Decl::ObjCCompatibleAlias:
- if (const ObjCInterfaceDecl *Class
- = cast<ObjCCompatibleAliasDecl>(D)->getClassInterface())
+ if (const ObjCInterfaceDecl *Class =
+ cast<ObjCCompatibleAliasDecl>(D)->getClassInterface())
if (const ObjCInterfaceDecl *Def = Class->getDefinition())
return MakeCXCursor(Def, TU);
@@ -6545,9 +6518,10 @@ unsigned clang_isCursorDefinition(CXCursor C) {
CXCursor clang_getCanonicalCursor(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return C;
-
+
if (const Decl *D = getCursorDecl(C)) {
- if (const ObjCCategoryImplDecl *CatImplD = dyn_cast<ObjCCategoryImplDecl>(D))
+ if (const ObjCCategoryImplDecl *CatImplD =
+ dyn_cast<ObjCCategoryImplDecl>(D))
if (ObjCCategoryDecl *CatD = CatImplD->getCategoryDecl())
return MakeCXCursor(CatD, getCursorTU(C));
@@ -6557,30 +6531,30 @@ CXCursor clang_getCanonicalCursor(CXCursor C) {
return MakeCXCursor(D->getCanonicalDecl(), getCursorTU(C));
}
-
+
return C;
}
int clang_Cursor_getObjCSelectorIndex(CXCursor cursor) {
return cxcursor::getSelectorIdentifierIndexAndLoc(cursor).first;
}
-
+
unsigned clang_getNumOverloadedDecls(CXCursor C) {
if (C.kind != CXCursor_OverloadedDeclRef)
return 0;
-
+
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
return E->getNumDecls();
-
- if (OverloadedTemplateStorage *S
- = Storage.dyn_cast<OverloadedTemplateStorage*>())
+
+ if (OverloadedTemplateStorage *S =
+ Storage.dyn_cast<OverloadedTemplateStorage *>())
return S->size();
-
+
const Decl *D = Storage.get<const Decl *>();
if (const UsingDecl *Using = dyn_cast<UsingDecl>(D))
return Using->shadow_size();
-
+
return 0;
}
@@ -6590,16 +6564,16 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
if (index >= clang_getNumOverloadedDecls(cursor))
return clang_getNullCursor();
-
+
CXTranslationUnit TU = getCursorTU(cursor);
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(cursor).first;
if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
return MakeCXCursor(E->decls_begin()[index], TU);
-
- if (OverloadedTemplateStorage *S
- = Storage.dyn_cast<OverloadedTemplateStorage*>())
+
+ if (OverloadedTemplateStorage *S =
+ Storage.dyn_cast<OverloadedTemplateStorage *>())
return MakeCXCursor(S->begin()[index], TU);
-
+
const Decl *D = Storage.get<const Decl *>();
if (const UsingDecl *Using = dyn_cast<UsingDecl>(D)) {
// FIXME: This is, unfortunately, linear time.
@@ -6607,17 +6581,13 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
std::advance(Pos, index);
return MakeCXCursor(cast<UsingShadowDecl>(*Pos)->getTargetDecl(), TU);
}
-
+
return clang_getNullCursor();
}
-
-void clang_getDefinitionSpellingAndExtent(CXCursor C,
- const char **startBuf,
- const char **endBuf,
- unsigned *startLine,
- unsigned *startColumn,
- unsigned *endLine,
- unsigned *endColumn) {
+
+void clang_getDefinitionSpellingAndExtent(
+ CXCursor C, const char **startBuf, const char **endBuf, unsigned *startLine,
+ unsigned *startColumn, unsigned *endLine, unsigned *endColumn) {
assert(getCursorDecl(C) && "CXCursor has null decl");
const FunctionDecl *FD = dyn_cast<FunctionDecl>(getCursorDecl(C));
CompoundStmt *Body = dyn_cast<CompoundStmt>(FD->getBody());
@@ -6631,18 +6601,17 @@ void clang_getDefinitionSpellingAndExtent(CXCursor C,
*endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc());
}
-
CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, unsigned NameFlags,
unsigned PieceIndex) {
RefNamePieces Pieces;
-
+
switch (C.kind) {
case CXCursor_MemberRefExpr:
if (const MemberExpr *E = dyn_cast<MemberExpr>(getCursorExpr(C)))
Pieces = buildPieces(NameFlags, true, E->getMemberNameInfo(),
E->getQualifierLoc().getSourceRange());
break;
-
+
case CXCursor_DeclRefExpr:
if (const DeclRefExpr *E = dyn_cast<DeclRefExpr>(getCursorExpr(C))) {
SourceRange TemplateArgLoc(E->getLAngleLoc(), E->getRAngleLoc());
@@ -6651,10 +6620,10 @@ CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, unsigned NameFlags,
E->getQualifierLoc().getSourceRange(), &TemplateArgLoc);
}
break;
-
+
case CXCursor_CallExpr:
- if (const CXXOperatorCallExpr *OCE =
- dyn_cast<CXXOperatorCallExpr>(getCursorExpr(C))) {
+ if (const CXXOperatorCallExpr *OCE =
+ dyn_cast<CXXOperatorCallExpr>(getCursorExpr(C))) {
const Expr *Callee = OCE->getCallee();
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
Callee = ICE->getSubExpr();
@@ -6664,7 +6633,7 @@ CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, unsigned NameFlags,
DRE->getQualifierLoc().getSourceRange());
}
break;
-
+
default:
break;
}
@@ -6673,11 +6642,11 @@ CXSourceRange clang_getCursorReferenceNameRange(CXCursor C, unsigned NameFlags,
if (PieceIndex == 0)
return clang_getCursorExtent(C);
} else if (PieceIndex < Pieces.size()) {
- SourceRange R = Pieces[PieceIndex];
- if (R.isValid())
- return cxloc::translateSourceRange(getCursorContext(C), R);
+ SourceRange R = Pieces[PieceIndex];
+ if (R.isValid())
+ return cxloc::translateSourceRange(getCursorContext(C), R);
}
-
+
return clang_getNullRange();
}
@@ -6686,7 +6655,7 @@ void clang_enableStackTraces(void) {
llvm::sys::PrintStackTraceOnErrorSignal(StringRef());
}
-void clang_executeOnThread(void (*fn)(void*), void *user_data,
+void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size) {
llvm::llvm_execute_on_thread(fn, user_data,
stack_size == 0
@@ -6715,8 +6684,8 @@ CXString clang_getTokenSpelling(CXTranslationUnit TU, CXToken CXTok) {
case CXToken_Identifier:
case CXToken_Keyword:
// We know we have an IdentifierInfo*, so use that.
- return cxstring::createRef(static_cast<IdentifierInfo *>(CXTok.ptr_data)
- ->getNameStart());
+ return cxstring::createRef(
+ static_cast<IdentifierInfo *>(CXTok.ptr_data)->getNameStart());
case CXToken_Literal: {
// We have stashed the starting pointer in the ptr_data field. Use it.
@@ -6741,11 +6710,11 @@ CXString clang_getTokenSpelling(CXTranslationUnit TU, CXToken CXTok) {
return cxstring::createEmpty();
SourceLocation Loc = SourceLocation::getFromRawEncoding(CXTok.int_data[1]);
- std::pair<FileID, unsigned> LocInfo
- = CXXUnit->getSourceManager().getDecomposedSpellingLoc(Loc);
+ std::pair<FileID, unsigned> LocInfo =
+ CXXUnit->getSourceManager().getDecomposedSpellingLoc(Loc);
bool Invalid = false;
- StringRef Buffer
- = CXXUnit->getSourceManager().getBufferData(LocInfo.first, &Invalid);
+ StringRef Buffer =
+ CXXUnit->getSourceManager().getBufferData(LocInfo.first, &Invalid);
if (Invalid)
return cxstring::createEmpty();
@@ -6762,8 +6731,9 @@ CXSourceLocation clang_getTokenLocation(CXTranslationUnit TU, CXToken CXTok) {
if (!CXXUnit)
return clang_getNullLocation();
- return cxloc::translateSourceLocation(CXXUnit->getASTContext(),
- SourceLocation::getFromRawEncoding(CXTok.int_data[1]));
+ return cxloc::translateSourceLocation(
+ CXXUnit->getASTContext(),
+ SourceLocation::getFromRawEncoding(CXTok.int_data[1]));
}
CXSourceRange clang_getTokenExtent(CXTranslationUnit TU, CXToken CXTok) {
@@ -6776,17 +6746,18 @@ CXSourceRange clang_getTokenExtent(CXTranslationUnit TU, CXToken CXTok) {
if (!CXXUnit)
return clang_getNullRange();
- return cxloc::translateSourceRange(CXXUnit->getASTContext(),
- SourceLocation::getFromRawEncoding(CXTok.int_data[1]));
+ return cxloc::translateSourceRange(
+ CXXUnit->getASTContext(),
+ SourceLocation::getFromRawEncoding(CXTok.int_data[1]));
}
static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
SmallVectorImpl<CXToken> &CXTokens) {
SourceManager &SourceMgr = CXXUnit->getSourceManager();
- std::pair<FileID, unsigned> BeginLocInfo
- = SourceMgr.getDecomposedSpellingLoc(Range.getBegin());
- std::pair<FileID, unsigned> EndLocInfo
- = SourceMgr.getDecomposedSpellingLoc(Range.getEnd());
+ std::pair<FileID, unsigned> BeginLocInfo =
+ SourceMgr.getDecomposedSpellingLoc(Range.getBegin());
+ std::pair<FileID, unsigned> EndLocInfo =
+ SourceMgr.getDecomposedSpellingLoc(Range.getEnd());
// Cannot tokenize across files.
if (BeginLocInfo.first != EndLocInfo.first)
@@ -6794,14 +6765,13 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
// Create a lexer
bool Invalid = false;
- StringRef Buffer
- = SourceMgr.getBufferData(BeginLocInfo.first, &Invalid);
+ StringRef Buffer = SourceMgr.getBufferData(BeginLocInfo.first, &Invalid);
if (Invalid)
return;
-
+
Lexer Lex(SourceMgr.getLocForStartOfFile(BeginLocInfo.first),
- CXXUnit->getASTContext().getLangOpts(),
- Buffer.begin(), Buffer.data() + BeginLocInfo.second, Buffer.end());
+ CXXUnit->getASTContext().getLangOpts(), Buffer.begin(),
+ Buffer.data() + BeginLocInfo.second, Buffer.end());
Lex.SetCommentRetentionState(true);
// Lex tokens until we hit the end of the range.
@@ -6828,16 +6798,13 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
CXTok.ptr_data = const_cast<char *>(Tok.getLiteralData());
} else if (Tok.is(tok::raw_identifier)) {
// Lookup the identifier to determine whether we have a keyword.
- IdentifierInfo *II
- = CXXUnit->getPreprocessor().LookUpIdentifierInfo(Tok);
+ IdentifierInfo *II = CXXUnit->getPreprocessor().LookUpIdentifierInfo(Tok);
if ((II->getObjCKeywordID() != tok::objc_not_keyword) && previousWasAt) {
CXTok.int_data[0] = CXToken_Keyword;
- }
- else {
- CXTok.int_data[0] = Tok.is(tok::identifier)
- ? CXToken_Identifier
- : CXToken_Keyword;
+ } else {
+ CXTok.int_data[0] =
+ Tok.is(tok::identifier) ? CXToken_Identifier : CXToken_Keyword;
}
CXTok.ptr_data = II;
} else if (Tok.is(tok::comment)) {
@@ -6853,9 +6820,7 @@ static void getTokens(ASTUnit *CXXUnit, SourceRange Range,
}
CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
- LOG_FUNC_SECTION {
- *Log << TU << ' ' << Location;
- }
+ LOG_FUNC_SECTION { *Log << TU << ' ' << Location; }
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
@@ -6871,9 +6836,11 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
return NULL;
SourceManager &SM = CXXUnit->getSourceManager();
std::pair<FileID, unsigned> DecomposedEnd = SM.getDecomposedLoc(Begin);
- DecomposedEnd.second += Lexer::MeasureTokenLength(Begin, SM, CXXUnit->getLangOpts());
+ DecomposedEnd.second +=
+ Lexer::MeasureTokenLength(Begin, SM, CXXUnit->getLangOpts());
- SourceLocation End = SM.getComposedLoc(DecomposedEnd.first, DecomposedEnd.second);
+ SourceLocation End =
+ SM.getComposedLoc(DecomposedEnd.first, DecomposedEnd.second);
SmallVector<CXToken, 32> CXTokens;
getTokens(CXXUnit, SourceRange(Begin, End), CXTokens);
@@ -6888,11 +6855,9 @@ CXToken *clang_getToken(CXTranslationUnit TU, CXSourceLocation Location) {
return Token;
}
-void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
- CXToken **Tokens, unsigned *NumTokens) {
- LOG_FUNC_SECTION {
- *Log << TU << ' ' << Range;
- }
+void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, CXToken **Tokens,
+ unsigned *NumTokens) {
+ LOG_FUNC_SECTION { *Log << TU << ' ' << Range; }
if (Tokens)
*Tokens = nullptr;
@@ -6909,7 +6874,7 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
return;
ASTUnit::ConcurrencyCheck Check(*CXXUnit);
-
+
SourceRange R = cxloc::translateCXSourceRange(Range);
if (R.isInvalid())
return;
@@ -6926,8 +6891,8 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range,
*NumTokens = CXTokens.size();
}
-void clang_disposeTokens(CXTranslationUnit TU,
- CXToken *Tokens, unsigned NumTokens) {
+void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens,
+ unsigned NumTokens) {
free(Tokens);
}
@@ -6995,17 +6960,15 @@ class AnnotateTokensWorker {
public:
AnnotateTokensWorker(CXToken *tokens, CXCursor *cursors, unsigned numTokens,
CXTranslationUnit TU, SourceRange RegionOfInterest)
- : Tokens(tokens), Cursors(cursors),
- NumTokens(numTokens), TokIdx(0), PreprocessingTokIdx(0),
- AnnotateVis(TU,
- AnnotateTokensVisitor, this,
- /*VisitPreprocessorLast=*/true,
- /*VisitIncludedEntities=*/false,
- RegionOfInterest,
- /*VisitDeclsOnly=*/false,
- AnnotateTokensPostChildrenVisitor),
- SrcMgr(cxtu::getASTUnit(TU)->getSourceManager()),
- HasContextSensitiveKeywords(false) { }
+ : Tokens(tokens), Cursors(cursors), NumTokens(numTokens), TokIdx(0),
+ PreprocessingTokIdx(0),
+ AnnotateVis(TU, AnnotateTokensVisitor, this,
+ /*VisitPreprocessorLast=*/true,
+ /*VisitIncludedEntities=*/false, RegionOfInterest,
+ /*VisitDeclsOnly=*/false,
+ AnnotateTokensPostChildrenVisitor),
+ SrcMgr(cxtu::getASTUnit(TU)->getSourceManager()),
+ HasContextSensitiveKeywords(false) {}
void VisitChildren(CXCursor C) { AnnotateVis.VisitChildren(C); }
enum CXChildVisitResult Visit(CXCursor cursor, CXCursor parent);
@@ -7017,18 +6980,16 @@ class AnnotateTokensWorker {
void HandlePostPonedChildCursor(CXCursor Cursor, unsigned StartTokenIndex);
void AnnotateTokens();
-
- /// Determine whether the annotator saw any cursors that have
+
+ /// Determine whether the annotator saw any cursors that have
/// context-sensitive keywords.
bool hasContextSensitiveKeywords() const {
return HasContextSensitiveKeywords;
}
- ~AnnotateTokensWorker() {
- assert(PostChildrenInfos.empty());
- }
+ ~AnnotateTokensWorker() { assert(PostChildrenInfos.empty()); }
};
-}
+} // namespace
void AnnotateTokensWorker::AnnotateTokens() {
// Walk the AST within the region of interest, annotating tokens
@@ -7110,9 +7071,8 @@ static inline void updateCursorAnnotation(CXCursor &Cursor,
///
/// Pass RangeBefore to annotate tokens with a cursor until a range is reached.
/// Pass RangeOverlap to annotate tokens inside a range.
-void AnnotateTokensWorker::annotateAndAdvanceTokens(CXCursor updateC,
- RangeComparisonResult compResult,
- SourceRange range) {
+void AnnotateTokensWorker::annotateAndAdvanceTokens(
+ CXCursor updateC, RangeComparisonResult compResult, SourceRange range) {
while (MoreTokens()) {
const unsigned I = NextToken();
if (isFunctionMacroToken(I))
@@ -7132,9 +7092,7 @@ void AnnotateTokensWorker::annotateAndAdvanceTokens(CXCursor updateC,
/// Special annotation handling for macro argument tokens.
/// \returns true if it advanced beyond all macro tokens, false otherwise.
bool AnnotateTokensWorker::annotateAndAdvanceFunctionMacroTokens(
- CXCursor updateC,
- RangeComparisonResult compResult,
- SourceRange range) {
+ CXCursor updateC, RangeComparisonResult compResult, SourceRange range) {
assert(MoreTokens());
assert(isFunctionMacroToken(NextToken()) &&
"Should be called only for macro arg tokens");
@@ -7148,7 +7106,7 @@ bool AnnotateTokensWorker::annotateAndAdvanceFunctionMacroTokens(
// annotated by a subsequent annotation try.
bool atLeastOneCompFail = false;
-
+
unsigned I = NextToken();
for (; I < NumTokens && isFunctionMacroToken(I); ++I) {
SourceLocation TokLoc = getFunctionMacroTokenLoc(I);
@@ -7168,8 +7126,8 @@ bool AnnotateTokensWorker::annotateAndAdvanceFunctionMacroTokens(
return true;
}
-enum CXChildVisitResult
-AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
+enum CXChildVisitResult AnnotateTokensWorker::Visit(CXCursor cursor,
+ CXCursor parent) {
SourceRange cursorRange = getRawCursorExtent(cursor);
if (cursorRange.isInvalid())
return CXChildVisit_Recurse;
@@ -7180,15 +7138,16 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
if (!HasContextSensitiveKeywords) {
// Objective-C properties can have context-sensitive keywords.
if (cursor.kind == CXCursor_ObjCPropertyDecl) {
- if (const ObjCPropertyDecl *Property
- = dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(cursor)))
- HasContextSensitiveKeywords = Property->getPropertyAttributesAsWritten() != 0;
+ if (const ObjCPropertyDecl *Property =
+ dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(cursor)))
+ HasContextSensitiveKeywords =
+ Property->getPropertyAttributesAsWritten() != 0;
}
// Objective-C methods can have context-sensitive keywords.
else if (cursor.kind == CXCursor_ObjCInstanceMethodDecl ||
cursor.kind == CXCursor_ObjCClassMethodDecl) {
- if (const ObjCMethodDecl *Method
- = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
+ if (const ObjCMethodDecl *Method =
+ dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
if (Method->getObjCDeclQualifier())
HasContextSensitiveKeywords = true;
else {
@@ -7200,11 +7159,11 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
}
}
}
- }
+ }
// C++ methods can have context-sensitive keywords.
else if (cursor.kind == CXCursor_CXXMethod) {
- if (const CXXMethodDecl *Method
- = dyn_cast_or_null<CXXMethodDecl>(getCursorDecl(cursor))) {
+ if (const CXXMethodDecl *Method =
+ dyn_cast_or_null<CXXMethodDecl>(getCursorDecl(cursor))) {
if (Method->hasAttr<FinalAttr>() || Method->hasAttr<OverrideAttr>())
HasContextSensitiveKeywords = true;
}
@@ -7224,8 +7183,8 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
if (cursor.kind == CXCursor_ObjCInstanceMethodDecl &&
parent.kind == CXCursor_ObjCPropertyDecl)
return CXChildVisit_Continue;
-
- if (clang_isPreprocessing(cursor.kind)) {
+
+ if (clang_isPreprocessing(cursor.kind)) {
// Items in the preprocessing record are kept separate from items in
// declarations, so we keep a separate token index.
unsigned SavedTokIdx = TokIdx;
@@ -7246,7 +7205,7 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
}
break;
}
-
+
// Look at all of the tokens within this range.
while (MoreTokens()) {
const unsigned I = NextToken();
@@ -7288,10 +7247,11 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
const enum CXCursorKind cursorK = clang_getCursorKind(cursor);
const enum CXCursorKind K = clang_getCursorKind(parent);
const CXCursor updateC =
- (clang_isInvalid(K) || K == CXCursor_TranslationUnit ||
- // Attributes are annotated out-of-order, skip tokens until we reach it.
- clang_isAttribute(cursor.kind))
- ? clang_getNullCursor() : parent;
+ (clang_isInvalid(K) || K == CXCursor_TranslationUnit ||
+ // Attributes are annotated out-of-order, skip tokens until we reach it.
+ clang_isAttribute(cursor.kind))
+ ? clang_getNullCursor()
+ : parent;
annotateAndAdvanceTokens(updateC, RangeBefore, cursorRange);
@@ -7417,13 +7377,14 @@ void AnnotateTokensWorker::HandlePostPonedChildCursor(
static enum CXChildVisitResult AnnotateTokensVisitor(CXCursor cursor,
CXCursor parent,
CXClientData client_data) {
- return static_cast<AnnotateTokensWorker*>(client_data)->Visit(cursor, parent);
+ return static_cast<AnnotateTokensWorker *>(client_data)
+ ->Visit(cursor, parent);
}
static bool AnnotateTokensPostChildrenVisitor(CXCursor cursor,
CXClientData client_data) {
- return static_cast<AnnotateTokensWorker*>(client_data)->
- postVisitChildren(cursor);
+ return static_cast<AnnotateTokensWorker *>(client_data)
+ ->postVisitChildren(cursor);
}
namespace {
@@ -7436,11 +7397,11 @@ class MarkMacroArgTokensVisitor {
CXToken *Tokens;
unsigned NumTokens;
unsigned CurIdx;
-
+
public:
- MarkMacroArgTokensVisitor(SourceManager &SM,
- CXToken *tokens, unsigned numTokens)
- : SM(SM), Tokens(tokens), NumTokens(numTokens), CurIdx(0) { }
+ MarkMacroArgTokensVisitor(SourceManager &SM, CXToken *tokens,
+ unsigned numTokens)
+ : SM(SM), Tokens(tokens), NumTokens(numTokens), CurIdx(0) {}
CXChildVisitResult visit(CXCursor cursor, CXCursor parent) {
if (cursor.kind != CXCursor_MacroExpansion)
@@ -7455,7 +7416,7 @@ class MarkMacroArgTokensVisitor {
macroRange.getBegin()))
break;
}
-
+
if (CurIdx == NumTokens)
return CXChildVisit_Break;
@@ -7499,14 +7460,14 @@ class MarkMacroArgTokensVisitor {
static CXChildVisitResult
MarkMacroArgTokensVisitorDelegate(CXCursor cursor, CXCursor parent,
CXClientData client_data) {
- return static_cast<MarkMacroArgTokensVisitor*>(client_data)->visit(cursor,
- parent);
+ return static_cast<MarkMacroArgTokensVisitor *>(client_data)
+ ->visit(cursor, parent);
}
/// Used by \c annotatePreprocessorTokens.
/// \returns true if lexing was finished, false otherwise.
-static bool lexNext(Lexer &Lex, Token &Tok,
- unsigned &NextIdx, unsigned NumTokens) {
+static bool lexNext(Lexer &Lex, Token &Tok, unsigned &NextIdx,
+ unsigned NumTokens) {
if (NextIdx >= NumTokens)
return true;
@@ -7517,17 +7478,16 @@ static bool lexNext(Lexer &Lex, Token &Tok,
static void annotatePreprocessorTokens(CXTranslationUnit TU,
SourceRange RegionOfInterest,
- CXCursor *Cursors,
- CXToken *Tokens,
+ CXCursor *Cursors, CXToken *Tokens,
unsigned NumTokens) {
ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
Preprocessor &PP = CXXUnit->getPreprocessor();
SourceManager &SourceMgr = CXXUnit->getSourceManager();
- std::pair<FileID, unsigned> BeginLocInfo
- = SourceMgr.getDecomposedSpellingLoc(RegionOfInterest.getBegin());
- std::pair<FileID, unsigned> EndLocInfo
- = SourceMgr.getDecomposedSpellingLoc(RegionOfInterest.getEnd());
+ std::pair<FileID, unsigned> BeginLocInfo =
+ SourceMgr.getDecomposedSpellingLoc(RegionOfInterest.getBegin());
+ std::pair<FileID, unsigned> EndLocInfo =
+ SourceMgr.getDecomposedSpellingLoc(RegionOfInterest.getEnd());
if (BeginLocInfo.first != EndLocInfo.first)
return;
@@ -7539,11 +7499,10 @@ static void annotatePreprocessorTokens(CXTranslationUnit TU,
return;
Lexer Lex(SourceMgr.getLocForStartOfFile(BeginLocInfo.first),
- CXXUnit->getASTContext().getLangOpts(),
- Buffer.begin(), Buffer.data() + BeginLocInfo.second,
- Buffer.end());
+ CXXUnit->getASTContext().getLangOpts(), Buffer.begin(),
+ Buffer.data() + BeginLocInfo.second, Buffer.end());
Lex.SetCommentRetentionState(true);
-
+
unsigned NextIdx = 0;
// Lex tokens in raw mode until we hit the end of the range, to avoid
// entering #includes or expanding macros.
@@ -7551,10 +7510,10 @@ static void annotatePreprocessorTokens(CXTranslationUnit TU,
Token Tok;
if (lexNext(Lex, Tok, NextIdx, NumTokens))
break;
- unsigned TokIdx = NextIdx-1;
+ unsigned TokIdx = NextIdx - 1;
assert(Tok.getLocation() ==
- SourceLocation::getFromRawEncoding(Tokens[TokIdx].int_data[1]));
-
+ SourceLocation::getFromRawEncoding(Tokens[TokIdx].int_data[1]));
+
reprocess:
if (Tok.is(tok::hash) && Tok.isAtStartOfLine()) {
// We have found a preprocessing directive. Annotate the tokens
@@ -7601,7 +7560,7 @@ static void annotatePreprocessorTokens(CXTranslationUnit TU,
}
} while (!Tok.isAtStartOfLine());
- unsigned LastIdx = finished ? NextIdx-1 : NextIdx-2;
+ unsigned LastIdx = finished ? NextIdx - 1 : NextIdx - 2;
assert(TokIdx <= LastIdx);
SourceLocation EndLoc =
SourceLocation::getFromRawEncoding(Tokens[LastIdx].int_data[1]);
@@ -7610,7 +7569,7 @@ static void annotatePreprocessorTokens(CXTranslationUnit TU,
for (; TokIdx <= LastIdx; ++TokIdx)
updateCursorAnnotation(Cursors[TokIdx], Cursor);
-
+
if (finished)
break;
goto reprocess;
@@ -7629,10 +7588,9 @@ static void clang_annotateTokensImpl(CXTranslationUnit TU, ASTUnit *CXXUnit,
// Determine the region of interest, which contains all of the tokens.
SourceRange RegionOfInterest;
RegionOfInterest.setBegin(
- cxloc::translateSourceLocation(clang_getTokenLocation(TU, Tokens[0])));
- RegionOfInterest.setEnd(
- cxloc::translateSourceLocation(clang_getTokenLocation(TU,
- Tokens[NumTokens-1])));
+ cxloc::translateSourceLocation(clang_getTokenLocation(TU, Tokens[0])));
+ RegionOfInterest.setEnd(cxloc::translateSourceLocation(
+ clang_getTokenLocation(TU, Tokens[NumTokens - 1])));
// Relex the tokens within the source range to look for preprocessing
// directives.
@@ -7650,20 +7608,19 @@ static void clang_annotateTokensImpl(CXTranslationUnit TU, ASTUnit *CXXUnit,
if (CXXUnit->getPreprocessor().getPreprocessingRecord()) {
// Search and mark tokens that are macro argument expansions.
- MarkMacroArgTokensVisitor Visitor(CXXUnit->getSourceManager(),
- Tokens, NumTokens);
- CursorVisitor MacroArgMarker(TU,
- MarkMacroArgTokensVisitorDelegate, &Visitor,
- /*VisitPreprocessorLast=*/true,
- /*VisitIncludedEntities=*/false,
- RegionOfInterest);
+ MarkMacroArgTokensVisitor Visitor(CXXUnit->getSourceManager(), Tokens,
+ NumTokens);
+ CursorVisitor MacroArgMarker(
+ TU, MarkMacroArgTokensVisitorDelegate, &Visitor,
+ /*VisitPreprocessorLast=*/true,
+ /*VisitIncludedEntities=*/false, RegionOfInterest);
MacroArgMarker.visitPreprocessedEntitiesInRegion();
}
-
+
// Annotate all of the source locations in the region of interest that map to
// a specific cursor.
AnnotateTokensWorker W(Tokens, Cursors, NumTokens, TU, RegionOfInterest);
-
+
// FIXME: We use a ridiculous stack size here because the data-recursion
// algorithm uses a large stack frame than the non-data recursive version,
// and AnnotationTokensWorker currently transforms the data-recursion
@@ -7677,43 +7634,43 @@ static void clang_annotateTokensImpl(CXTranslationUnit TU, ASTUnit *CXXUnit,
for (unsigned I = 0; I != NumTokens; ++I) {
if (clang_getTokenKind(Tokens[I]) != CXToken_Identifier)
continue;
-
+
if (Cursors[I].kind == CXCursor_ObjCPropertyDecl) {
IdentifierInfo *II = static_cast<IdentifierInfo *>(Tokens[I].ptr_data);
- if (const ObjCPropertyDecl *Property
- = dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(Cursors[I]))) {
+ if (const ObjCPropertyDecl *Property =
+ dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(Cursors[I]))) {
if (Property->getPropertyAttributesAsWritten() != 0 &&
llvm::StringSwitch<bool>(II->getName())
- .Case("readonly", true)
- .Case("assign", true)
- .Case("unsafe_unretained", true)
- .Case("readwrite", true)
- .Case("retain", true)
- .Case("copy", true)
- .Case("nonatomic", true)
- .Case("atomic", true)
- .Case("getter", true)
- .Case("setter", true)
- .Case("strong", true)
- .Case("weak", true)
- .Case("class", true)
- .Default(false))
+ .Case("readonly", true)
+ .Case("assign", true)
+ .Case("unsafe_unretained", true)
+ .Case("readwrite", true)
+ .Case("retain", true)
+ .Case("copy", true)
+ .Case("nonatomic", true)
+ .Case("atomic", true)
+ .Case("getter", true)
+ .Case("setter", true)
+ .Case("strong", true)
+ .Case("weak", true)
+ .Case("class", true)
+ .Default(false))
Tokens[I].int_data[0] = CXToken_Keyword;
}
continue;
}
-
+
if (Cursors[I].kind == CXCursor_ObjCInstanceMethodDecl ||
Cursors[I].kind == CXCursor_ObjCClassMethodDecl) {
IdentifierInfo *II = static_cast<IdentifierInfo *>(Tokens[I].ptr_data);
if (llvm::StringSwitch<bool>(II->getName())
- .Case("in", true)
- .Case("out", true)
- .Case("inout", true)
- .Case("oneway", true)
- .Case("bycopy", true)
- .Case("byref", true)
- .Default(false))
+ .Case("in", true)
+ .Case("out", true)
+ .Case("inout", true)
+ .Case("oneway", true)
+ .Case("bycopy", true)
+ .Case("byref", true)
+ .Default(false))
Tokens[I].int_data[0] = CXToken_Keyword;
continue;
}
@@ -7727,9 +7684,8 @@ static void clang_annotateTokensImpl(CXTranslationUnit TU, ASTUnit *CXXUnit,
}
}
-void clang_annotateTokens(CXTranslationUnit TU,
- CXToken *Tokens, unsigned NumTokens,
- CXCursor *Cursors) {
+void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens,
+ unsigned NumTokens, CXCursor *Cursors) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
return;
@@ -7742,7 +7698,7 @@ void clang_annotateTokens(CXTranslationUnit TU,
LOG_FUNC_SECTION {
*Log << TU << ' ';
CXSourceLocation bloc = clang_getTokenLocation(TU, Tokens[0]);
- CXSourceLocation eloc = clang_getTokenLocation(TU, Tokens[NumTokens-1]);
+ CXSourceLocation eloc = clang_getTokenLocation(TU, Tokens[NumTokens - 1]);
*Log << clang_getRange(bloc, eloc);
}
@@ -7777,13 +7733,17 @@ CXLinkageKind clang_getCursorLinkage(CXCursor cursor) {
const Decl *D = cxcursor::getCursorDecl(cursor);
if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D))
switch (ND->getLinkageInternal()) {
- case NoLinkage:
- case VisibleNoLinkage: return CXLinkage_NoLinkage;
- case ModuleInternalLinkage:
- case InternalLinkage: return CXLinkage_Internal;
- case UniqueExternalLinkage: return CXLinkage_UniqueExternal;
- case ModuleLinkage:
- case ExternalLinkage: return CXLinkage_External;
+ case NoLinkage:
+ case VisibleNoLinkage:
+ return CXLinkage_NoLinkage;
+ case ModuleInternalLinkage:
+ case InternalLinkage:
+ return CXLinkage_Internal;
+ case UniqueExternalLinkage:
+ return CXLinkage_UniqueExternal;
+ case ModuleLinkage:
+ case ExternalLinkage:
+ return CXLinkage_External;
};
return CXLinkage_Invalid;
@@ -7800,9 +7760,12 @@ CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) {
const Decl *D = cxcursor::getCursorDecl(cursor);
if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D))
switch (ND->getVisibility()) {
- case HiddenVisibility: return CXVisibility_Hidden;
- case ProtectedVisibility: return CXVisibility_Protected;
- case DefaultVisibility: return CXVisibility_Default;
+ case HiddenVisibility:
+ return CXVisibility_Hidden;
+ case ProtectedVisibility:
+ return CXVisibility_Protected;
+ case DefaultVisibility:
+ return CXVisibility_Default;
};
return CXVisibility_Invalid;
@@ -7817,46 +7780,46 @@ static CXLanguageKind getDeclLanguage(const Decl *D) {
return CXLanguage_C;
switch (D->getKind()) {
- default:
- break;
- case Decl::ImplicitParam:
- case Decl::ObjCAtDefsField:
- case Decl::ObjCCategory:
- case Decl::ObjCCategoryImpl:
- case Decl::ObjCCompatibleAlias:
- case Decl::ObjCImplementation:
- case Decl::ObjCInterface:
- case Decl::ObjCIvar:
- case Decl::ObjCMethod:
- case Decl::ObjCProperty:
- case Decl::ObjCPropertyImpl:
- case Decl::ObjCProtocol:
- case Decl::ObjCTypeParam:
- return CXLanguage_ObjC;
- case Decl::CXXConstructor:
- case Decl::CXXConversion:
- case Decl::CXXDestructor:
- case Decl::CXXMethod:
- case Decl::CXXRecord:
- case Decl::ClassTemplate:
- case Decl::ClassTemplatePartialSpecialization:
- case Decl::ClassTemplateSpecialization:
- case Decl::Friend:
- case Decl::FriendTemplate:
- case Decl::FunctionTemplate:
- case Decl::LinkageSpec:
- case Decl::Namespace:
- case Decl::NamespaceAlias:
- case Decl::NonTypeTemplateParm:
- case Decl::StaticAssert:
- case Decl::TemplateTemplateParm:
- case Decl::TemplateTypeParm:
- case Decl::UnresolvedUsingTypename:
- case Decl::UnresolvedUsingValue:
- case Decl::Using:
- case Decl::UsingDirective:
- case Decl::UsingShadow:
- return CXLanguage_CPlusPlus;
+ default:
+ break;
+ case Decl::ImplicitParam:
+ case Decl::ObjCAtDefsField:
+ case Decl::ObjCCategory:
+ case Decl::ObjCCategoryImpl:
+ case Decl::ObjCCompatibleAlias:
+ case Decl::ObjCImplementation:
+ case Decl::ObjCInterface:
+ case Decl::ObjCIvar:
+ case Decl::ObjCMethod:
+ case Decl::ObjCProperty:
+ case Decl::ObjCPropertyImpl:
+ case Decl::ObjCProtocol:
+ case Decl::ObjCTypeParam:
+ return CXLanguage_ObjC;
+ case Decl::CXXConstructor:
+ case Decl::CXXConversion:
+ case Decl::CXXDestructor:
+ case Decl::CXXMethod:
+ case Decl::CXXRecord:
+ case Decl::ClassTemplate:
+ case Decl::ClassTemplatePartialSpecialization:
+ case Decl::ClassTemplateSpecialization:
+ case Decl::Friend:
+ case Decl::FriendTemplate:
+ case Decl::FunctionTemplate:
+ case Decl::LinkageSpec:
+ case Decl::Namespace:
+ case Decl::NamespaceAlias:
+ case Decl::NonTypeTemplateParm:
+ case Decl::StaticAssert:
+ case Decl::TemplateTemplateParm:
+ case Decl::TemplateTypeParm:
+ case Decl::UnresolvedUsingTypename:
+ case Decl::UnresolvedUsingValue:
+ case Decl::Using:
+ case Decl::UsingDirective:
+ case Decl::UsingShadow:
+ return CXLanguage_CPlusPlus;
}
return CXLanguage_C;
@@ -7865,7 +7828,7 @@ static CXLanguageKind getDeclLanguage(const Decl *D) {
static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
if (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isDeleted())
return CXAvailability_NotAvailable;
-
+
switch (D->getAvailability()) {
case AR_Available:
case AR_NotYetIntroduced:
@@ -7893,12 +7856,12 @@ enum CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) {
}
static CXVersion convertVersion(VersionTuple In) {
- CXVersion Out = { -1, -1, -1 };
+ CXVersion Out = {-1, -1, -1};
if (In.empty())
return Out;
Out.Major = In.getMajor();
-
+
Optional<unsigned> Minor = In.getMinor();
if (Minor.hasValue())
Out.Minor = *Minor;
@@ -7908,7 +7871,7 @@ static CXVersion convertVersion(VersionTuple In) {
Optional<unsigned> Subminor = In.getSubminor();
if (Subminor.hasValue())
Out.Subminor = *Subminor;
-
+
return Out;
}
@@ -7956,11 +7919,10 @@ static void getCursorPlatformAvailabilityForDecl(
if (AvailabilityAttrs.empty())
return;
- llvm::sort(AvailabilityAttrs,
- [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
- return LHS->getPlatform()->getName() <
- RHS->getPlatform()->getName();
- });
+ llvm::sort(
+ AvailabilityAttrs, [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+ return LHS->getPlatform()->getName() < RHS->getPlatform()->getName();
+ });
ASTContext &Ctx = D->getASTContext();
auto It = std::unique(
AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
@@ -8077,9 +8039,9 @@ CXTLSKind clang_getCursorTLSKind(CXCursor cursor) {
return CXTLS_None;
}
- /// If the given cursor is the "templated" declaration
- /// describing a class or function template, return the class or
- /// function template.
+/// If the given cursor is the "templated" declaration
+/// describing a class or function template, return the class or
+/// function template.
static const Decl *maybeGetTemplateCursor(const Decl *D) {
if (!D)
return nullptr;
@@ -8095,7 +8057,6 @@ static const Decl *maybeGetTemplateCursor(const Decl *D) {
return D;
}
-
enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor C) {
StorageClass sc = SC_None;
const Decl *D = getCursorDecl(C);
@@ -8134,16 +8095,16 @@ CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
if (!DC)
return clang_getNullCursor();
- return MakeCXCursor(maybeGetTemplateCursor(cast<Decl>(DC)),
+ return MakeCXCursor(maybeGetTemplateCursor(cast<Decl>(DC)),
getCursorTU(cursor));
}
}
-
+
if (clang_isStatement(cursor.kind) || clang_isExpression(cursor.kind)) {
if (const Decl *D = getCursorDecl(cursor))
return MakeCXCursor(D, getCursorTU(cursor));
}
-
+
return clang_getNullCursor();
}
@@ -8154,12 +8115,12 @@ CXCursor clang_getCursorLexicalParent(CXCursor cursor) {
if (!DC)
return clang_getNullCursor();
- return MakeCXCursor(maybeGetTemplateCursor(cast<Decl>(DC)),
+ return MakeCXCursor(maybeGetTemplateCursor(cast<Decl>(DC)),
getCursorTU(cursor));
}
}
- // FIXME: Note that we can't easily compute the lexical context of a
+ // FIXME: Note that we can't easily compute the lexical context of a
// statement or expression, so we return nothing.
return clang_getNullCursor();
}
@@ -8181,9 +8142,9 @@ unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved) {
ObjCPropertyDecl::PropertyAttributeKind Attr =
PD->getPropertyAttributesAsWritten();
-#define SET_CXOBJCPROP_ATTR(A) \
- if (Attr & ObjCPropertyDecl::OBJC_PR_##A) \
- Result |= CXObjCPropertyAttr_##A
+#define SET_CXOBJCPROP_ATTR(A) \
+ if (Attr & ObjCPropertyDecl::OBJC_PR_##A) \
+ Result |= CXObjCPropertyAttr_##A
SET_CXOBJCPROP_ATTR(readonly);
SET_CXOBJCPROP_ATTR(getter);
SET_CXOBJCPROP_ATTR(assign);
@@ -8240,12 +8201,18 @@ unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C) {
return CXObjCDeclQualifier_None;
unsigned Result = CXObjCDeclQualifier_None;
- if (QT & Decl::OBJC_TQ_In) Result |= CXObjCDeclQualifier_In;
- if (QT & Decl::OBJC_TQ_Inout) Result |= CXObjCDeclQualifier_Inout;
- if (QT & Decl::OBJC_TQ_Out) Result |= CXObjCDeclQualifier_Out;
- if (QT & Decl::OBJC_TQ_Bycopy) Result |= CXObjCDeclQualifier_Bycopy;
- if (QT & Decl::OBJC_TQ_Byref) Result |= CXObjCDeclQualifier_Byref;
- if (QT & Decl::OBJC_TQ_Oneway) Result |= CXObjCDeclQualifier_Oneway;
+ if (QT & Decl::OBJC_TQ_In)
+ Result |= CXObjCDeclQualifier_In;
+ if (QT & Decl::OBJC_TQ_Inout)
+ Result |= CXObjCDeclQualifier_Inout;
+ if (QT & Decl::OBJC_TQ_Out)
+ Result |= CXObjCDeclQualifier_Out;
+ if (QT & Decl::OBJC_TQ_Bycopy)
+ Result |= CXObjCDeclQualifier_Bycopy;
+ if (QT & Decl::OBJC_TQ_Byref)
+ Result |= CXObjCDeclQualifier_Byref;
+ if (QT & Decl::OBJC_TQ_Oneway)
+ Result |= CXObjCDeclQualifier_Oneway;
return Result;
}
@@ -8276,9 +8243,9 @@ unsigned clang_Cursor_isVariadic(CXCursor C) {
return 0;
}
-unsigned clang_Cursor_isExternalSymbol(CXCursor C,
- CXString *language, CXString *definedIn,
- unsigned *isGenerated) {
+unsigned clang_Cursor_isExternalSymbol(CXCursor C, CXString *language,
+ CXString *definedIn,
+ unsigned *isGenerated) {
if (!clang_isDeclaration(C.kind))
return 0;
@@ -8316,8 +8283,8 @@ CXString clang_Cursor_getRawCommentText(CXCursor C) {
const Decl *D = getCursorDecl(C);
ASTContext &Context = getCursorContext(C);
const RawComment *RC = Context.getRawCommentForAnyRedecl(D);
- StringRef RawText = RC ? RC->getRawText(Context.getSourceManager()) :
- StringRef();
+ StringRef RawText =
+ RC ? RC->getRawText(Context.getSourceManager()) : StringRef();
// Don't duplicate the string because RawText points directly into source
// code.
@@ -8361,46 +8328,46 @@ CXModule clang_getModuleForFile(CXTranslationUnit TU, CXFile File) {
if (!File)
return nullptr;
FileEntry *FE = static_cast<FileEntry *>(File);
-
+
ASTUnit &Unit = *cxtu::getASTUnit(TU);
HeaderSearch &HS = Unit.getPreprocessor().getHeaderSearchInfo();
ModuleMap::KnownHeader Header = HS.findModuleForHeader(FE);
-
+
return Header.getModule();
}
CXFile clang_Module_getASTFile(CXModule CXMod) {
if (!CXMod)
return nullptr;
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
return const_cast<FileEntry *>(Mod->getASTFile());
}
CXModule clang_Module_getParent(CXModule CXMod) {
if (!CXMod)
return nullptr;
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
return Mod->Parent;
}
CXString clang_Module_getName(CXModule CXMod) {
if (!CXMod)
return cxstring::createEmpty();
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
return cxstring::createDup(Mod->Name);
}
CXString clang_Module_getFullName(CXModule CXMod) {
if (!CXMod)
return cxstring::createEmpty();
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
return cxstring::createDup(Mod->getFullModuleName());
}
int clang_Module_isSystem(CXModule CXMod) {
if (!CXMod)
return 0;
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
return Mod->IsSystem;
}
@@ -8412,21 +8379,21 @@ unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit TU,
}
if (!CXMod)
return 0;
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager();
ArrayRef<const FileEntry *> TopHeaders = Mod->getTopHeaders(FileMgr);
return TopHeaders.size();
}
-CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
- CXModule CXMod, unsigned Index) {
+CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU, CXModule CXMod,
+ unsigned Index) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
return nullptr;
}
if (!CXMod)
return nullptr;
- Module *Mod = static_cast<Module*>(CXMod);
+ Module *Mod = static_cast<Module *>(CXMod);
FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager();
ArrayRef<const FileEntry *> TopHeaders = Mod->getTopHeaders(FileMgr);
@@ -8524,7 +8491,7 @@ unsigned clang_CXXMethod_isDefaulted(CXCursor C) {
unsigned clang_CXXMethod_isStatic(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;
-
+
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
@@ -8534,7 +8501,7 @@ unsigned clang_CXXMethod_isStatic(CXCursor C) {
unsigned clang_CXXMethod_isVirtual(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;
-
+
const Decl *D = cxcursor::getCursorDecl(C);
const CXXMethodDecl *Method =
D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
@@ -8568,11 +8535,11 @@ unsigned clang_EnumDecl_isScoped(CXCursor C) {
CXType clang_getIBOutletCollectionType(CXCursor C) {
if (C.kind != CXCursor_IBOutletCollectionAttr)
return cxtype::MakeCXType(QualType(), cxcursor::getCursorTU(C));
-
+
const IBOutletCollectionAttr *A =
- cast<IBOutletCollectionAttr>(cxcursor::getCursorAttr(C));
-
- return cxtype::MakeCXType(A->getInterface(), cxcursor::getCursorTU(C));
+ cast<IBOutletCollectionAttr>(cxcursor::getCursorAttr(C));
+
+ return cxtype::MakeCXType(A->getInterface(), cxcursor::getCursorTU(C));
}
//===----------------------------------------------------------------------===//
@@ -8582,57 +8549,57 @@ CXType clang_getIBOutletCollectionType(CXCursor C) {
typedef std::vector<CXTUResourceUsageEntry> MemUsageEntries;
static inline void createCXTUResourceUsageEntry(MemUsageEntries &entries,
- enum CXTUResourceUsageKind k,
- unsigned long amount) {
- CXTUResourceUsageEntry entry = { k, amount };
+ enum CXTUResourceUsageKind k,
+ unsigned long amount) {
+ CXTUResourceUsageEntry entry = {k, amount};
entries.push_back(entry);
}
const char *clang_getTUResourceUsageName(CXTUResourceUsageKind kind) {
const char *str = "";
switch (kind) {
- case CXTUResourceUsage_AST:
- str = "ASTContext: expressions, declarations, and types";
- break;
- case CXTUResourceUsage_Identifiers:
- str = "ASTContext: identifiers";
- break;
- case CXTUResourceUsage_Selectors:
- str = "ASTContext: selectors";
- break;
- case CXTUResourceUsage_GlobalCompletionResults:
- str = "Code completion: cached global results";
- break;
- case CXTUResourceUsage_SourceManagerContentCache:
- str = "SourceManager: content cache allocator";
- break;
- case CXTUResourceUsage_AST_SideTables:
- str = "ASTContext: side tables";
- break;
- case CXTUResourceUsage_SourceManager_Membuffer_Malloc:
- str = "SourceManager: malloc'ed memory buffers";
- break;
- case CXTUResourceUsage_SourceManager_Membuffer_MMap:
- str = "SourceManager: mmap'ed memory buffers";
- break;
- case CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc:
- str = "ExternalASTSource: malloc'ed memory buffers";
- break;
- case CXTUResourceUsage_ExternalASTSource_Membuffer_MMap:
- str = "ExternalASTSource: mmap'ed memory buffers";
- break;
- case CXTUResourceUsage_Preprocessor:
- str = "Preprocessor: malloc'ed memory";
- break;
- case CXTUResourceUsage_PreprocessingRecord:
- str = "Preprocessor: PreprocessingRecord";
- break;
- case CXTUResourceUsage_SourceManager_DataStructures:
- str = "SourceManager: data structures and tables";
- break;
- case CXTUResourceUsage_Preprocessor_HeaderSearch:
- str = "Preprocessor: header search tables";
- break;
+ case CXTUResourceUsage_AST:
+ str = "ASTContext: expressions, declarations, and types";
+ break;
+ case CXTUResourceUsage_Identifiers:
+ str = "ASTContext: identifiers";
+ break;
+ case CXTUResourceUsage_Selectors:
+ str = "ASTContext: selectors";
+ break;
+ case CXTUResourceUsage_GlobalCompletionResults:
+ str = "Code completion: cached global results";
+ break;
+ case CXTUResourceUsage_SourceManagerContentCache:
+ str = "SourceManager: content cache allocator";
+ break;
+ case CXTUResourceUsage_AST_SideTables:
+ str = "ASTContext: side tables";
+ break;
+ case CXTUResourceUsage_SourceManager_Membuffer_Malloc:
+ str = "SourceManager: malloc'ed memory buffers";
+ break;
+ case CXTUResourceUsage_SourceManager_Membuffer_MMap:
+ str = "SourceManager: mmap'ed memory buffers";
+ break;
+ case CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc:
+ str = "ExternalASTSource: malloc'ed memory buffers";
+ break;
+ case CXTUResourceUsage_ExternalASTSource_Membuffer_MMap:
+ str = "ExternalASTSource: mmap'ed memory buffers";
+ break;
+ case CXTUResourceUsage_Preprocessor:
+ str = "Preprocessor: malloc'ed memory";
+ break;
+ case CXTUResourceUsage_PreprocessingRecord:
+ str = "Preprocessor: PreprocessingRecord";
+ break;
+ case CXTUResourceUsage_SourceManager_DataStructures:
+ str = "SourceManager: data structures and tables";
+ break;
+ case CXTUResourceUsage_Preprocessor_HeaderSearch:
+ str = "Preprocessor: header search tables";
+ break;
}
return str;
}
@@ -8640,99 +8607,99 @@ const char *clang_getTUResourceUsageName(CXTUResourceUsageKind kind) {
CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) {
if (isNotUsableTU(TU)) {
LOG_BAD_TU(TU);
- CXTUResourceUsage usage = { (void*) nullptr, 0, nullptr };
+ CXTUResourceUsage usage = {(void *)nullptr, 0, nullptr};
return usage;
}
-
+
ASTUnit *astUnit = cxtu::getASTUnit(TU);
std::unique_ptr<MemUsageEntries> entries(new MemUsageEntries());
ASTContext &astContext = astUnit->getASTContext();
-
+
// How much memory is used by AST nodes and types?
- createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_AST,
- (unsigned long) astContext.getASTAllocatedMemory());
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_AST,
+ (unsigned long)astContext.getASTAllocatedMemory());
// How much memory is used by identifiers?
- createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_Identifiers,
- (unsigned long) astContext.Idents.getAllocator().getTotalMemory());
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_Identifiers,
+ (unsigned long)astContext.Idents.getAllocator().getTotalMemory());
// How much memory is used for selectors?
- createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_Selectors,
- (unsigned long) astContext.Selectors.getTotalMemory());
-
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_Selectors,
+ (unsigned long)astContext.Selectors.getTotalMemory());
+
// How much memory is used by ASTContext's side tables?
- createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_AST_SideTables,
- (unsigned long) astContext.getSideTableAllocatedMemory());
-
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_AST_SideTables,
+ (unsigned long)astContext.getSideTableAllocatedMemory());
+
// How much memory is used for caching global code completion results?
unsigned long completionBytes = 0;
if (GlobalCodeCompletionAllocator *completionAllocator =
- astUnit->getCachedCompletionAllocator().get()) {
+ astUnit->getCachedCompletionAllocator().get()) {
completionBytes = completionAllocator->getTotalMemory();
}
- createCXTUResourceUsageEntry(*entries,
- CXTUResourceUsage_GlobalCompletionResults,
- completionBytes);
-
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_GlobalCompletionResults, completionBytes);
+
// How much memory is being used by SourceManager's content cache?
- createCXTUResourceUsageEntry(*entries,
- CXTUResourceUsage_SourceManagerContentCache,
- (unsigned long) astContext.getSourceManager().getContentCacheSize());
-
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_SourceManagerContentCache,
+ (unsigned long)astContext.getSourceManager().getContentCacheSize());
+
// How much memory is being used by the MemoryBuffer's in SourceManager?
const SourceManager::MemoryBufferSizes &srcBufs =
- astUnit->getSourceManager().getMemoryBufferSizes();
-
+ astUnit->getSourceManager().getMemoryBufferSizes();
+
createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_SourceManager_Membuffer_Malloc,
- (unsigned long) srcBufs.malloc_bytes);
+ (unsigned long)srcBufs.malloc_bytes);
createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_SourceManager_Membuffer_MMap,
- (unsigned long) srcBufs.mmap_bytes);
- createCXTUResourceUsageEntry(*entries,
- CXTUResourceUsage_SourceManager_DataStructures,
- (unsigned long) astContext.getSourceManager()
- .getDataStructureSizes());
-
+ (unsigned long)srcBufs.mmap_bytes);
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_SourceManager_DataStructures,
+ (unsigned long)astContext.getSourceManager().getDataStructureSizes());
+
// How much memory is being used by the ExternalASTSource?
if (ExternalASTSource *esrc = astContext.getExternalSource()) {
const ExternalASTSource::MemoryBufferSizes &sizes =
- esrc->getMemoryBufferSizes();
-
- createCXTUResourceUsageEntry(*entries,
- CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc,
- (unsigned long) sizes.malloc_bytes);
- createCXTUResourceUsageEntry(*entries,
- CXTUResourceUsage_ExternalASTSource_Membuffer_MMap,
- (unsigned long) sizes.mmap_bytes);
+ esrc->getMemoryBufferSizes();
+
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc,
+ (unsigned long)sizes.malloc_bytes);
+ createCXTUResourceUsageEntry(
+ *entries, CXTUResourceUsage_ExternalASTSource_Membuffer_MMap,
+ (unsigned long)sizes.mmap_bytes);
}
-
+
// How much memory is being used by the Preprocessor?
Preprocessor &pp = astUnit->getPreprocessor();
- createCXTUResourceUsageEntry(*entries,
- CXTUResourceUsage_Preprocessor,
+ createCXTUResourceUsageEntry(*entries, CXTUResourceUsage_Preprocessor,
pp.getTotalMemory());
-
+
if (PreprocessingRecord *pRec = pp.getPreprocessingRecord()) {
createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_PreprocessingRecord,
- pRec->getTotalMemory());
+ pRec->getTotalMemory());
}
-
+
createCXTUResourceUsageEntry(*entries,
CXTUResourceUsage_Preprocessor_HeaderSearch,
pp.getHeaderSearchInfo().getTotalMemory());
- CXTUResourceUsage usage = { (void*) entries.get(),
- (unsigned) entries->size(),
- !entries->empty() ? &(*entries)[0] : nullptr };
+ CXTUResourceUsage usage = {(void *)entries.get(), (unsigned)entries->size(),
+ !entries->empty() ? &(*entries)[0] : nullptr};
(void)entries.release();
return usage;
}
void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage) {
if (usage.data)
- delete (MemUsageEntries*) usage.data;
+ delete (MemUsageEntries *)usage.data;
}
CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit TU, CXFile file) {
@@ -8749,7 +8716,8 @@ CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit TU, CXFile file) {
return skipped;
ASTUnit *astUnit = cxtu::getASTUnit(TU);
- PreprocessingRecord *ppRec = astUnit->getPreprocessor().getPreprocessingRecord();
+ PreprocessingRecord *ppRec =
+ astUnit->getPreprocessor().getPreprocessingRecord();
if (!ppRec)
return skipped;
@@ -8761,11 +8729,14 @@ CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit TU, CXFile file) {
const std::vector<SourceRange> &SkippedRanges = ppRec->getSkippedRanges();
std::vector<SourceRange> wantedRanges;
- for (std::vector<SourceRange>::const_iterator i = SkippedRanges.begin(), ei = SkippedRanges.end();
+ for (std::vector<SourceRange>::const_iterator i = SkippedRanges.begin(),
+ ei = SkippedRanges.end();
i != ei; ++i) {
- if (sm.getFileID(i->getBegin()) == wantedFileID || sm.getFileID(i->getEnd()) == wantedFileID)
+ if (sm.getFileID(i->getBegin()) == wantedFileID ||
+ sm.getFileID(i->getEnd()) == wantedFileID)
wantedRanges.push_back(*i);
- else if (isMainFile && (astUnit->isInPreambleFileID(i->getBegin()) || astUnit->isInPreambleFileID(i->getEnd())))
+ else if (isMainFile && (astUnit->isInPreambleFileID(i->getBegin()) ||
+ astUnit->isInPreambleFileID(i->getEnd())))
wantedRanges.push_back(*i);
}
@@ -8786,9 +8757,10 @@ CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit TU) {
LOG_BAD_TU(TU);
return skipped;
}
-
+
ASTUnit *astUnit = cxtu::getASTUnit(TU);
- PreprocessingRecord *ppRec = astUnit->getPreprocessor().getPreprocessingRecord();
+ PreprocessingRecord *ppRec =
+ astUnit->getPreprocessor().getPreprocessingRecord();
if (!ppRec)
return skipped;
@@ -8814,10 +8786,10 @@ void clang_disposeSourceRangeList(CXSourceRangeList *ranges) {
void clang::PrintLibclangResourceUsage(CXTranslationUnit TU) {
CXTUResourceUsage Usage = clang_getCXTUResourceUsage(TU);
for (unsigned I = 0; I != Usage.numEntries; ++I)
- fprintf(stderr, " %s: %lu\n",
+ fprintf(stderr, " %s: %lu\n",
clang_getTUResourceUsageName(Usage.entries[I].kind),
Usage.entries[I].amount);
-
+
clang_disposeCXTUResourceUsage(Usage);
}
@@ -8839,15 +8811,11 @@ bool RunSafely(llvm::CrashRecoveryContext &CRC, llvm::function_ref<void()> Fn,
return CRC.RunSafely(Fn);
}
-unsigned GetSafetyThreadStackSize() {
- return SafetyStackThreadSize;
-}
+unsigned GetSafetyThreadStackSize() { return SafetyStackThreadSize; }
-void SetSafetyThreadStackSize(unsigned Value) {
- SafetyStackThreadSize = Value;
-}
+void SetSafetyThreadStackSize(unsigned Value) { SafetyStackThreadSize = Value; }
-}
+} // namespace clang
void clang::setThreadBackgroundPriority() {
if (getenv("LIBCLANG_BGPRIO_DISABLE"))
@@ -8862,12 +8830,12 @@ void cxindex::printDiagsToStderr(ASTUnit *Unit) {
if (!Unit)
return;
- for (ASTUnit::stored_diag_iterator D = Unit->stored_diag_begin(),
- DEnd = Unit->stored_diag_end();
+ for (ASTUnit::stored_diag_iterator D = Unit->stored_diag_begin(),
+ DEnd = Unit->stored_diag_end();
D != DEnd; ++D) {
CXStoredDiagnostic Diag(*D, Unit->getLangOpts());
- CXString Msg = clang_formatDiagnostic(&Diag,
- clang_defaultDiagnosticDisplayOptions());
+ CXString Msg =
+ clang_formatDiagnostic(&Diag, clang_defaultDiagnosticDisplayOptions());
fprintf(stderr, "%s\n", clang_getCString(Msg));
clang_disposeString(Msg);
}
@@ -8881,7 +8849,7 @@ void cxindex::printDiagsToStderr(ASTUnit *Unit) {
MacroInfo *cxindex::getMacroInfo(const IdentifierInfo &II,
SourceLocation MacroDefLoc,
- CXTranslationUnit TU){
+ CXTranslationUnit TU) {
if (MacroDefLoc.isInvalid() || !TU)
return nullptr;
if (!II.hadMacroDefinition())
@@ -8891,8 +8859,8 @@ MacroInfo *cxindex::getMacroInfo(const IdentifierInfo &II,
Preprocessor &PP = Unit->getPreprocessor();
MacroDirective *MD = PP.getLocalMacroDirectiveHistory(&II);
if (MD) {
- for (MacroDirective::DefInfo
- Def = MD->getDefinition(); Def; Def = Def.getPreviousDefinition()) {
+ for (MacroDirective::DefInfo Def = MD->getDefinition(); Def;
+ Def = Def.getPreviousDefinition()) {
if (MacroDefLoc == Def.getMacroInfo()->getDefinitionLoc())
return Def.getMacroInfo();
}
@@ -9028,13 +8996,13 @@ Logger &cxindex::Logger::operator<<(CXSourceRange range) {
CXString BFileName = clang_getFileName(BFile);
if (BFile == EFile) {
*this << llvm::format("[%s %d:%d-%d:%d]", clang_getCString(BFileName),
- BLine, BColumn, ELine, EColumn);
+ BLine, BColumn, ELine, EColumn);
} else {
CXString EFileName = clang_getFileName(EFile);
- *this << llvm::format("[%s:%d:%d - ", clang_getCString(BFileName),
- BLine, BColumn)
- << llvm::format("%s:%d:%d]", clang_getCString(EFileName),
- ELine, EColumn);
+ *this << llvm::format("[%s:%d:%d - ", clang_getCString(BFileName), BLine,
+ BColumn)
+ << llvm::format("%s:%d:%d]", clang_getCString(EFileName), ELine,
+ EColumn);
clang_disposeString(EFileName);
}
clang_disposeString(BFileName);
diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp
index 147e3eaf4762..1f6304a08bca 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -12,9 +12,9 @@
//
//===----------------------------------------------------------------------===//
-#include "CXTranslationUnit.h"
#include "CXCursor.h"
#include "CXString.h"
+#include "CXTranslationUnit.h"
#include "CXType.h"
#include "clang-c/Index.h"
#include "clang/AST/Attr.h"
@@ -33,55 +33,97 @@ using namespace cxcursor;
CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU) {
assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid);
- CXCursor C = { K, 0, { nullptr, nullptr, TU } };
+ CXCursor C = {K, 0, {nullptr, nullptr, TU}};
return C;
}
static CXCursorKind GetCursorKind(const Attr *A) {
assert(A && "Invalid arguments!");
switch (A->getKind()) {
- default: break;
- case attr::IBAction: return CXCursor_IBActionAttr;
- case attr::IBOutlet: return CXCursor_IBOutletAttr;
- case attr::IBOutletCollection: return CXCursor_IBOutletCollectionAttr;
- case attr::Final: return CXCursor_CXXFinalAttr;
- case attr::Override: return CXCursor_CXXOverrideAttr;
- case attr::Annotate: return CXCursor_AnnotateAttr;
- case attr::AsmLabel: return CXCursor_AsmLabelAttr;
- case attr::Packed: return CXCursor_PackedAttr;
- case attr::Pure: return CXCursor_PureAttr;
- case attr::Const: return CXCursor_ConstAttr;
- case attr::NoDuplicate: return CXCursor_NoDuplicateAttr;
- case attr::CUDAConstant: return CXCursor_CUDAConstantAttr;
- case attr::CUDADevice: return CXCursor_CUDADeviceAttr;
- case attr::CUDAGlobal: return CXCursor_CUDAGlobalAttr;
- case attr::CUDAHost: return CXCursor_CUDAHostAttr;
- case attr::CUDAShared: return CXCursor_CUDASharedAttr;
- case attr::Visibility: return CXCursor_VisibilityAttr;
- case attr::DLLExport: return CXCursor_DLLExport;
- case attr::DLLImport: return CXCursor_DLLImport;
- case attr::NSReturnsRetained: return CXCursor_NSReturnsRetained;
- case attr::NSReturnsNotRetained: return CXCursor_NSReturnsNotRetained;
- case attr::NSReturnsAutoreleased: return CXCursor_NSReturnsAutoreleased;
- case attr::NSConsumesSelf: return CXCursor_NSConsumesSelf;
- case attr::NSConsumed: return CXCursor_NSConsumed;
- case attr::ObjCException: return CXCursor_ObjCException;
- case attr::ObjCNSObject: return CXCursor_ObjCNSObject;
- case attr::ObjCIndependentClass: return CXCursor_ObjCIndependentClass;
- case attr::ObjCPreciseLifetime: return CXCursor_ObjCPreciseLifetime;
- case attr::ObjCReturnsInnerPointer: return CXCursor_ObjCReturnsInnerPointer;
- case attr::ObjCRequiresSuper: return CXCursor_ObjCRequiresSuper;
- case attr::ObjCRootClass: return CXCursor_ObjCRootClass;
- case attr::ObjCSubclassingRestricted: return CXCursor_ObjCSubclassingRestricted;
- case attr::ObjCExplicitProtocolImpl: return CXCursor_ObjCExplicitProtocolImpl;
- case attr::ObjCDesignatedInitializer: return CXCursor_ObjCDesignatedInitializer;
- case attr::ObjCRuntimeVisible: return CXCursor_ObjCRuntimeVisible;
- case attr::ObjCBoxable: return CXCursor_ObjCBoxable;
- case attr::FlagEnum: return CXCursor_FlagEnum;
- case attr::Convergent: return CXCursor_ConvergentAttr;
- case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
- case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
- case attr::Aligned: return CXCursor_AlignedAttr;
+ default:
+ break;
+ case attr::IBAction:
+ return CXCursor_IBActionAttr;
+ case attr::IBOutlet:
+ return CXCursor_IBOutletAttr;
+ case attr::IBOutletCollection:
+ return CXCursor_IBOutletCollectionAttr;
+ case attr::Final:
+ return CXCursor_CXXFinalAttr;
+ case attr::Override:
+ return CXCursor_CXXOverrideAttr;
+ case attr::Annotate:
+ return CXCursor_AnnotateAttr;
+ case attr::AsmLabel:
+ return CXCursor_AsmLabelAttr;
+ case attr::Packed:
+ return CXCursor_PackedAttr;
+ case attr::Pure:
+ return CXCursor_PureAttr;
+ case attr::Const:
+ return CXCursor_ConstAttr;
+ case attr::NoDuplicate:
+ return CXCursor_NoDuplicateAttr;
+ case attr::CUDAConstant:
+ return CXCursor_CUDAConstantAttr;
+ case attr::CUDADevice:
+ return CXCursor_CUDADeviceAttr;
+ case attr::CUDAGlobal:
+ return CXCursor_CUDAGlobalAttr;
+ case attr::CUDAHost:
+ return CXCursor_CUDAHostAttr;
+ case attr::CUDAShared:
+ return CXCursor_CUDASharedAttr;
+ case attr::Visibility:
+ return CXCursor_VisibilityAttr;
+ case attr::DLLExport:
+ return CXCursor_DLLExport;
+ case attr::DLLImport:
+ return CXCursor_DLLImport;
+ case attr::NSReturnsRetained:
+ return CXCursor_NSReturnsRetained;
+ case attr::NSReturnsNotRetained:
+ return CXCursor_NSReturnsNotRetained;
+ case attr::NSReturnsAutoreleased:
+ return CXCursor_NSReturnsAutoreleased;
+ case attr::NSConsumesSelf:
+ return CXCursor_NSConsumesSelf;
+ case attr::NSConsumed:
+ return CXCursor_NSConsumed;
+ case attr::ObjCException:
+ return CXCursor_ObjCException;
+ case attr::ObjCNSObject:
+ return CXCursor_ObjCNSObject;
+ case attr::ObjCIndependentClass:
+ return CXCursor_ObjCIndependentClass;
+ case attr::ObjCPreciseLifetime:
+ return CXCursor_ObjCPreciseLifetime;
+ case attr::ObjCReturnsInnerPointer:
+ return CXCursor_ObjCReturnsInnerPointer;
+ case attr::ObjCRequiresSuper:
+ return CXCursor_ObjCRequiresSuper;
+ case attr::ObjCRootClass:
+ return CXCursor_ObjCRootClass;
+ case attr::ObjCSubclassingRestricted:
+ return CXCursor_ObjCSubclassingRestricted;
+ case attr::ObjCExplicitProtocolImpl:
+ return CXCursor_ObjCExplicitProtocolImpl;
+ case attr::ObjCDesignatedInitializer:
+ return CXCursor_ObjCDesignatedInitializer;
+ case attr::ObjCRuntimeVisible:
+ return CXCursor_ObjCRuntimeVisible;
+ case attr::ObjCBoxable:
+ return CXCursor_ObjCBoxable;
+ case attr::FlagEnum:
+ return CXCursor_FlagEnum;
+ case attr::Convergent:
+ return CXCursor_ConvergentAttr;
+ case attr::WarnUnused:
+ return CXCursor_WarnUnusedAttr;
+ case attr::WarnUnusedResult:
+ return CXCursor_WarnUnusedResultAttr;
+ case attr::Aligned:
+ return CXCursor_AlignedAttr;
}
return CXCursor_UnexposedAttr;
@@ -90,7 +132,7 @@ static CXCursorKind GetCursorKind(const Attr *A) {
CXCursor cxcursor::MakeCXCursor(const Attr *A, const Decl *Parent,
CXTranslationUnit TU) {
assert(A && Parent && TU && "Invalid arguments!");
- CXCursor C = { GetCursorKind(A), 0, { Parent, A, TU } };
+ CXCursor C = {GetCursorKind(A), 0, {Parent, A, TU}};
return C;
}
@@ -114,12 +156,13 @@ CXCursor cxcursor::MakeCXCursor(const Decl *D, CXTranslationUnit TU,
if (I != SelLocs.end())
SelectorIdIndex = I - SelLocs.begin();
}
- CXCursor C = { K, SelectorIdIndex,
- { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }};
+ CXCursor C = {K,
+ SelectorIdIndex,
+ {D, (void *)(intptr_t)(FirstInDeclGroup ? 1 : 0), TU}};
return C;
}
-
- CXCursor C = { K, 0, { D, (void*)(intptr_t) (FirstInDeclGroup ? 1 : 0), TU }};
+
+ CXCursor C = {K, 0, {D, (void *)(intptr_t)(FirstInDeclGroup ? 1 : 0), TU}};
return C;
}
@@ -128,59 +171,59 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
SourceRange RegionOfInterest) {
assert(S && TU && "Invalid arguments!");
CXCursorKind K = CXCursor_NotImplemented;
-
+
switch (S->getStmtClass()) {
case Stmt::NoStmtClass:
break;
-
+
case Stmt::CaseStmtClass:
K = CXCursor_CaseStmt;
break;
-
+
case Stmt::DefaultStmtClass:
K = CXCursor_DefaultStmt;
break;
-
+
case Stmt::IfStmtClass:
K = CXCursor_IfStmt;
break;
-
+
case Stmt::SwitchStmtClass:
K = CXCursor_SwitchStmt;
break;
-
+
case Stmt::WhileStmtClass:
K = CXCursor_WhileStmt;
break;
-
+
case Stmt::DoStmtClass:
K = CXCursor_DoStmt;
break;
-
+
case Stmt::ForStmtClass:
K = CXCursor_ForStmt;
break;
-
+
case Stmt::GotoStmtClass:
K = CXCursor_GotoStmt;
break;
-
+
case Stmt::IndirectGotoStmtClass:
K = CXCursor_IndirectGotoStmt;
break;
-
+
case Stmt::ContinueStmtClass:
K = CXCursor_ContinueStmt;
break;
-
+
case Stmt::BreakStmtClass:
K = CXCursor_BreakStmt;
break;
-
+
case Stmt::ReturnStmtClass:
K = CXCursor_ReturnStmt;
break;
-
+
case Stmt::GCCAsmStmtClass:
K = CXCursor_GCCAsmStmt;
break;
@@ -188,55 +231,55 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::MSAsmStmtClass:
K = CXCursor_MSAsmStmt;
break;
-
+
case Stmt::ObjCAtTryStmtClass:
K = CXCursor_ObjCAtTryStmt;
break;
-
+
case Stmt::ObjCAtCatchStmtClass:
K = CXCursor_ObjCAtCatchStmt;
break;
-
+
case Stmt::ObjCAtFinallyStmtClass:
K = CXCursor_ObjCAtFinallyStmt;
break;
-
+
case Stmt::ObjCAtThrowStmtClass:
K = CXCursor_ObjCAtThrowStmt;
break;
-
+
case Stmt::ObjCAtSynchronizedStmtClass:
K = CXCursor_ObjCAtSynchronizedStmt;
break;
-
+
case Stmt::ObjCAutoreleasePoolStmtClass:
K = CXCursor_ObjCAutoreleasePoolStmt;
break;
-
+
case Stmt::ObjCForCollectionStmtClass:
K = CXCursor_ObjCForCollectionStmt;
break;
-
+
case Stmt::CXXCatchStmtClass:
K = CXCursor_CXXCatchStmt;
break;
-
+
case Stmt::CXXTryStmtClass:
K = CXCursor_CXXTryStmt;
break;
-
+
case Stmt::CXXForRangeStmtClass:
K = CXCursor_CXXForRangeStmt;
break;
-
+
case Stmt::SEHTryStmtClass:
K = CXCursor_SEHTryStmt;
break;
-
+
case Stmt::SEHExceptStmtClass:
K = CXCursor_SEHExceptStmt;
break;
-
+
case Stmt::SEHFinallyStmtClass:
K = CXCursor_SEHFinallyStmt;
break;
@@ -303,8 +346,8 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
break;
case Stmt::PseudoObjectExprClass:
- return MakeCXCursor(cast<PseudoObjectExpr>(S)->getSyntacticForm(),
- Parent, TU, RegionOfInterest);
+ return MakeCXCursor(cast<PseudoObjectExpr>(S)->getSyntacticForm(), Parent,
+ TU, RegionOfInterest);
case Stmt::CompoundStmtClass:
K = CXCursor_CompoundStmt;
@@ -355,8 +398,8 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
break;
case Stmt::ConstantExprClass:
- return MakeCXCursor(cast<ConstantExpr>(S)->getSubExpr(),
- Parent, TU, RegionOfInterest);
+ return MakeCXCursor(cast<ConstantExpr>(S)->getSubExpr(), Parent, TU,
+ RegionOfInterest);
case Stmt::ParenExprClass:
K = CXCursor_ParenExpr;
@@ -483,7 +526,7 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::ObjCProtocolExprClass:
K = CXCursor_ObjCProtocolExpr;
break;
-
+
case Stmt::ObjCBoolLiteralExprClass:
K = CXCursor_ObjCBoolLiteralExpr;
break;
@@ -509,10 +552,10 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
break;
case Stmt::DeclRefExprClass:
- if (const ImplicitParamDecl *IPD =
- dyn_cast_or_null<ImplicitParamDecl>(cast<DeclRefExpr>(S)->getDecl())) {
+ if (const ImplicitParamDecl *IPD = dyn_cast_or_null<ImplicitParamDecl>(
+ cast<DeclRefExpr>(S)->getDecl())) {
if (const ObjCMethodDecl *MD =
- dyn_cast<ObjCMethodDecl>(IPD->getDeclContext())) {
+ dyn_cast<ObjCMethodDecl>(IPD->getDeclContext())) {
if (MD->getSelfDecl() == IPD) {
K = CXCursor_ObjCSelfExpr;
break;
@@ -531,34 +574,34 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::TypoExprClass: // A typo could actually be a DeclRef or a MemberRef
K = CXCursor_DeclRefExpr;
break;
-
+
case Stmt::CXXDependentScopeMemberExprClass:
case Stmt::CXXPseudoDestructorExprClass:
- case Stmt::MemberExprClass:
+ case Stmt::MemberExprClass:
case Stmt::MSPropertyRefExprClass:
case Stmt::ObjCIsaExprClass:
- case Stmt::ObjCIvarRefExprClass:
- case Stmt::ObjCPropertyRefExprClass:
+ case Stmt::ObjCIvarRefExprClass:
+ case Stmt::ObjCPropertyRefExprClass:
case Stmt::UnresolvedMemberExprClass:
K = CXCursor_MemberRefExpr;
break;
-
- case Stmt::CallExprClass:
+
+ case Stmt::CallExprClass:
case Stmt::CXXOperatorCallExprClass:
case Stmt::CXXMemberCallExprClass:
case Stmt::CUDAKernelCallExprClass:
- case Stmt::CXXConstructExprClass:
- case Stmt::CXXInheritedCtorInitExprClass:
+ case Stmt::CXXConstructExprClass:
+ case Stmt::CXXInheritedCtorInitExprClass:
case Stmt::CXXTemporaryObjectExprClass:
case Stmt::CXXUnresolvedConstructExprClass:
case Stmt::UserDefinedLiteralClass:
K = CXCursor_CallExpr;
break;
-
+
case Stmt::LambdaExprClass:
K = CXCursor_LambdaExpr;
break;
-
+
case Stmt::ObjCMessageExprClass: {
K = CXCursor_ObjCMessageExpr;
int SelectorIdIndex = -1;
@@ -572,10 +615,10 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
if (I != SelLocs.end())
SelectorIdIndex = I - SelLocs.begin();
}
- CXCursor C = { K, 0, { Parent, S, TU } };
+ CXCursor C = {K, 0, {Parent, S, TU}};
return getSelectorIdentifierCursor(SelectorIdIndex, C);
}
-
+
case Stmt::MSDependentExistsStmtClass:
K = CXCursor_UnexposedStmt;
break;
@@ -745,17 +788,17 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
K = CXCursor_BuiltinBitCastExpr;
}
- CXCursor C = { K, 0, { Parent, S, TU } };
+ CXCursor C = {K, 0, {Parent, S, TU}};
return C;
}
-CXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
- SourceLocation Loc,
+CXCursor cxcursor::MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
+ SourceLocation Loc,
CXTranslationUnit TU) {
assert(Super && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_ObjCSuperClassRef, 0, { Super, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_ObjCSuperClassRef, 0, {Super, RawLoc, TU}};
+ return C;
}
std::pair<const ObjCInterfaceDecl *, SourceLocation>
@@ -765,13 +808,13 @@ cxcursor::getCursorObjCSuperClassRef(CXCursor C) {
SourceLocation::getFromPtrEncoding(C.data[1]));
}
-CXCursor cxcursor::MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto,
- SourceLocation Loc,
+CXCursor cxcursor::MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto,
+ SourceLocation Loc,
CXTranslationUnit TU) {
assert(Proto && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_ObjCProtocolRef, 0, { Proto, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_ObjCProtocolRef, 0, {Proto, RawLoc, TU}};
+ return C;
}
std::pair<const ObjCProtocolDecl *, SourceLocation>
@@ -781,16 +824,16 @@ cxcursor::getCursorObjCProtocolRef(CXCursor C) {
SourceLocation::getFromPtrEncoding(C.data[1]));
}
-CXCursor cxcursor::MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class,
- SourceLocation Loc,
+CXCursor cxcursor::MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class,
+ SourceLocation Loc,
CXTranslationUnit TU) {
// 'Class' can be null for invalid code.
if (!Class)
return MakeCXCursorInvalid(CXCursor_InvalidCode);
assert(TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_ObjCClassRef, 0, { Class, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_ObjCClassRef, 0, {Class, RawLoc, TU}};
+ return C;
}
std::pair<const ObjCInterfaceDecl *, SourceLocation>
@@ -800,12 +843,12 @@ cxcursor::getCursorObjCClassRef(CXCursor C) {
SourceLocation::getFromPtrEncoding(C.data[1]));
}
-CXCursor cxcursor::MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc,
+CXCursor cxcursor::MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc,
CXTranslationUnit TU) {
assert(Type && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_TypeRef, 0, { Type, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_TypeRef, 0, {Type, RawLoc, TU}};
+ return C;
}
std::pair<const TypeDecl *, SourceLocation>
@@ -815,13 +858,13 @@ cxcursor::getCursorTypeRef(CXCursor C) {
SourceLocation::getFromPtrEncoding(C.data[1]));
}
-CXCursor cxcursor::MakeCursorTemplateRef(const TemplateDecl *Template,
+CXCursor cxcursor::MakeCursorTemplateRef(const TemplateDecl *Template,
SourceLocation Loc,
CXTranslationUnit TU) {
assert(Template && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_TemplateRef, 0, { Template, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_TemplateRef, 0, {Template, RawLoc, TU}};
+ return C;
}
std::pair<const TemplateDecl *, SourceLocation>
@@ -832,14 +875,14 @@ cxcursor::getCursorTemplateRef(CXCursor C) {
}
CXCursor cxcursor::MakeCursorNamespaceRef(const NamedDecl *NS,
- SourceLocation Loc,
+ SourceLocation Loc,
CXTranslationUnit TU) {
-
+
assert(NS && (isa<NamespaceDecl>(NS) || isa<NamespaceAliasDecl>(NS)) && TU &&
"Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_NamespaceRef, 0, { NS, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_NamespaceRef, 0, {NS, RawLoc, TU}};
+ return C;
}
std::pair<const NamedDecl *, SourceLocation>
@@ -849,12 +892,12 @@ cxcursor::getCursorNamespaceRef(CXCursor C) {
SourceLocation::getFromPtrEncoding(C.data[1]));
}
-CXCursor cxcursor::MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
+CXCursor cxcursor::MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
CXTranslationUnit TU) {
-
+
assert(Var && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_VariableRef, 0, { Var, RawLoc, TU } };
+ CXCursor C = {CXCursor_VariableRef, 0, {Var, RawLoc, TU}};
return C;
}
@@ -865,13 +908,14 @@ cxcursor::getCursorVariableRef(CXCursor C) {
SourceLocation::getFromPtrEncoding(C.data[1]));
}
-CXCursor cxcursor::MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
+CXCursor cxcursor::MakeCursorMemberRef(const FieldDecl *Field,
+ SourceLocation Loc,
CXTranslationUnit TU) {
-
+
assert(Field && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_MemberRef, 0, { Field, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_MemberRef, 0, {Field, RawLoc, TU}};
+ return C;
}
std::pair<const FieldDecl *, SourceLocation>
@@ -882,23 +926,22 @@ cxcursor::getCursorMemberRef(CXCursor C) {
}
CXCursor cxcursor::MakeCursorCXXBaseSpecifier(const CXXBaseSpecifier *B,
- CXTranslationUnit TU){
- CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, nullptr, TU } };
- return C;
+ CXTranslationUnit TU) {
+ CXCursor C = {CXCursor_CXXBaseSpecifier, 0, {B, nullptr, TU}};
+ return C;
}
const CXXBaseSpecifier *cxcursor::getCursorCXXBaseSpecifier(CXCursor C) {
assert(C.kind == CXCursor_CXXBaseSpecifier);
- return static_cast<const CXXBaseSpecifier*>(C.data[0]);
+ return static_cast<const CXXBaseSpecifier *>(C.data[0]);
}
-CXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range,
+CXCursor cxcursor::MakePreprocessingDirectiveCursor(SourceRange Range,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_PreprocessingDirective, 0,
- { Range.getBegin().getPtrEncoding(),
- Range.getEnd().getPtrEncoding(),
- TU }
- };
+ CXCursor C = {
+ CXCursor_PreprocessingDirective,
+ 0,
+ {Range.getBegin().getPtrEncoding(), Range.getEnd().getPtrEncoding(), TU}};
return C;
}
@@ -923,7 +966,7 @@ const MacroDefinitionRecord *cxcursor::getCursorMacroDefinition(CXCursor C) {
CXCursor cxcursor::MakeMacroExpansionCursor(MacroExpansion *MI,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_MacroExpansion, 0, { MI, nullptr, TU } };
+ CXCursor C = {CXCursor_MacroExpansion, 0, {MI, nullptr, TU}};
return C;
}
@@ -952,9 +995,9 @@ SourceRange cxcursor::MacroExpansionCursor::getSourceRange() const {
return getAsMacroExpansion()->getSourceRange();
}
-CXCursor cxcursor::MakeInclusionDirectiveCursor(InclusionDirective *ID,
+CXCursor cxcursor::MakeInclusionDirectiveCursor(InclusionDirective *ID,
CXTranslationUnit TU) {
- CXCursor C = { CXCursor_InclusionDirective, 0, { ID, nullptr, TU } };
+ CXCursor C = {CXCursor_InclusionDirective, 0, {ID, nullptr, TU}};
return C;
}
@@ -963,13 +1006,13 @@ const InclusionDirective *cxcursor::getCursorInclusionDirective(CXCursor C) {
return static_cast<const InclusionDirective *>(C.data[0]);
}
-CXCursor cxcursor::MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc,
+CXCursor cxcursor::MakeCursorLabelRef(LabelStmt *Label, SourceLocation Loc,
CXTranslationUnit TU) {
-
+
assert(Label && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
- CXCursor C = { CXCursor_LabelRef, 0, { Label, RawLoc, TU } };
- return C;
+ CXCursor C = {CXCursor_LabelRef, 0, {Label, RawLoc, TU}};
+ return C;
}
std::pair<const LabelStmt *, SourceLocation>
@@ -984,11 +1027,9 @@ CXCursor cxcursor::MakeCursorOverloadedDeclRef(const OverloadExpr *E,
assert(E && TU && "Invalid arguments!");
OverloadedDeclRefStorage Storage(E);
void *RawLoc = E->getNameLoc().getPtrEncoding();
- CXCursor C = {
- CXCursor_OverloadedDeclRef, 0,
- { Storage.getOpaqueValue(), RawLoc, TU }
- };
- return C;
+ CXCursor C = {
+ CXCursor_OverloadedDeclRef, 0, {Storage.getOpaqueValue(), RawLoc, TU}};
+ return C;
}
CXCursor cxcursor::MakeCursorOverloadedDeclRef(const Decl *D,
@@ -997,31 +1038,27 @@ CXCursor cxcursor::MakeCursorOverloadedDeclRef(const Decl *D,
assert(D && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
OverloadedDeclRefStorage Storage(D);
- CXCursor C = {
- CXCursor_OverloadedDeclRef, 0,
- { Storage.getOpaqueValue(), RawLoc, TU }
- };
- return C;
+ CXCursor C = {
+ CXCursor_OverloadedDeclRef, 0, {Storage.getOpaqueValue(), RawLoc, TU}};
+ return C;
}
-CXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name,
+CXCursor cxcursor::MakeCursorOverloadedDeclRef(TemplateName Name,
SourceLocation Loc,
CXTranslationUnit TU) {
assert(Name.getAsOverloadedTemplate() && TU && "Invalid arguments!");
void *RawLoc = Loc.getPtrEncoding();
OverloadedDeclRefStorage Storage(Name.getAsOverloadedTemplate());
- CXCursor C = {
- CXCursor_OverloadedDeclRef, 0,
- { Storage.getOpaqueValue(), RawLoc, TU }
- };
- return C;
+ CXCursor C = {
+ CXCursor_OverloadedDeclRef, 0, {Storage.getOpaqueValue(), RawLoc, TU}};
+ return C;
}
std::pair<cxcursor::OverloadedDeclRefStorage, SourceLocation>
cxcursor::getCursorOverloadedDeclRef(CXCursor C) {
assert(C.kind == CXCursor_OverloadedDeclRef);
return std::make_pair(OverloadedDeclRefStorage::getFromOpaqueValue(
- const_cast<void *>(C.data[0])),
+ const_cast<void *>(C.data[0])),
SourceLocation::getFromPtrEncoding(C.data[1]));
}
@@ -1058,11 +1095,11 @@ ASTUnit *cxcursor::getCursorASTUnit(CXCursor Cursor) {
}
CXTranslationUnit cxcursor::getCursorTU(CXCursor Cursor) {
- return static_cast<CXTranslationUnit>(const_cast<void*>(Cursor.data[2]));
+ return static_cast<CXTranslationUnit>(const_cast<void *>(Cursor.data[2]));
}
void cxcursor::getOverriddenCursors(CXCursor cursor,
- SmallVectorImpl<CXCursor> &overridden) {
+ SmallVectorImpl<CXCursor> &overridden) {
assert(clang_isDeclaration(cursor.kind));
const NamedDecl *D = dyn_cast_or_null<NamedDecl>(getCursorDecl(cursor));
if (!D)
@@ -1072,8 +1109,9 @@ void cxcursor::getOverriddenCursors(CXCursor cursor,
SmallVector<const NamedDecl *, 8> OverDecls;
D->getASTContext().getOverriddenMethods(D, OverDecls);
- for (SmallVectorImpl<const NamedDecl *>::iterator
- I = OverDecls.begin(), E = OverDecls.end(); I != E; ++I) {
+ for (SmallVectorImpl<const NamedDecl *>::iterator I = OverDecls.begin(),
+ E = OverDecls.end();
+ I != E; ++I) {
overridden.push_back(MakeCXCursor(*I, TU));
}
}
@@ -1084,13 +1122,13 @@ cxcursor::getSelectorIdentifierIndexAndLoc(CXCursor cursor) {
if (cursor.xdata != -1)
return std::make_pair(cursor.xdata,
cast<ObjCMessageExpr>(getCursorExpr(cursor))
- ->getSelectorLoc(cursor.xdata));
+ ->getSelectorLoc(cursor.xdata));
} else if (cursor.kind == CXCursor_ObjCClassMethodDecl ||
cursor.kind == CXCursor_ObjCInstanceMethodDecl) {
if (cursor.xdata != -1)
return std::make_pair(cursor.xdata,
cast<ObjCMethodDecl>(getCursorDecl(cursor))
- ->getSelectorLoc(cursor.xdata));
+ ->getSelectorLoc(cursor.xdata));
}
return std::make_pair(-1, SourceLocation());
@@ -1101,16 +1139,16 @@ CXCursor cxcursor::getSelectorIdentifierCursor(int SelIdx, CXCursor cursor) {
if (cursor.kind == CXCursor_ObjCMessageExpr) {
if (SelIdx == -1 ||
- unsigned(SelIdx) >= cast<ObjCMessageExpr>(getCursorExpr(cursor))
- ->getNumSelectorLocs())
+ unsigned(SelIdx) >=
+ cast<ObjCMessageExpr>(getCursorExpr(cursor))->getNumSelectorLocs())
newCursor.xdata = -1;
else
newCursor.xdata = SelIdx;
} else if (cursor.kind == CXCursor_ObjCClassMethodDecl ||
cursor.kind == CXCursor_ObjCInstanceMethodDecl) {
if (SelIdx == -1 ||
- unsigned(SelIdx) >= cast<ObjCMethodDecl>(getCursorDecl(cursor))
- ->getNumSelectorLocs())
+ unsigned(SelIdx) >=
+ cast<ObjCMethodDecl>(getCursorDecl(cursor))->getNumSelectorLocs())
newCursor.xdata = -1;
else
newCursor.xdata = SelIdx;
@@ -1128,11 +1166,11 @@ CXCursor cxcursor::getTypeRefCursor(CXCursor cursor) {
const Expr *E = getCursorExpr(cursor);
TypeSourceInfo *Type = nullptr;
- if (const CXXUnresolvedConstructExpr *
- UnCtor = dyn_cast<CXXUnresolvedConstructExpr>(E)) {
+ if (const CXXUnresolvedConstructExpr *UnCtor =
+ dyn_cast<CXXUnresolvedConstructExpr>(E)) {
Type = UnCtor->getTypeSourceInfo();
} else if (const CXXTemporaryObjectExpr *Tmp =
- dyn_cast<CXXTemporaryObjectExpr>(E)){
+ dyn_cast<CXXTemporaryObjectExpr>(E)) {
Type = Tmp->getTypeSourceInfo();
}
@@ -1169,7 +1207,7 @@ bool cxcursor::operator==(CXCursor X, CXCursor Y) {
// properly in the ASTs.
bool cxcursor::isFirstInDeclGroup(CXCursor C) {
assert(clang_isDeclaration(C.kind));
- return ((uintptr_t) (C.data[1])) != 0;
+ return ((uintptr_t)(C.data[1])) != 0;
}
//===----------------------------------------------------------------------===//
@@ -1224,15 +1262,13 @@ CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i) {
const Expr *E = cxcursor::getCursorExpr(C);
if (const CallExpr *CE = dyn_cast<CallExpr>(E)) {
if (i < CE->getNumArgs()) {
- return cxcursor::MakeCXCursor(CE->getArg(i),
- getCursorDecl(C),
+ return cxcursor::MakeCXCursor(CE->getArg(i), getCursorDecl(C),
cxcursor::getCursorTU(C));
}
}
if (const CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(E)) {
if (i < CE->getNumArgs()) {
- return cxcursor::MakeCXCursor(CE->getArg(i),
- getCursorDecl(C),
+ return cxcursor::MakeCXCursor(CE->getArg(i), getCursorDecl(C),
cxcursor::getCursorTU(C));
}
}
@@ -1246,13 +1282,13 @@ int clang_Cursor_getNumTemplateArguments(CXCursor C) {
return -1;
}
- const FunctionDecl *FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(
- getCursorDecl(C));
+ const FunctionDecl *FD =
+ llvm::dyn_cast_or_null<clang::FunctionDecl>(getCursorDecl(C));
if (!FD) {
return -1;
}
- const FunctionTemplateSpecializationInfo* SpecInfo =
+ const FunctionTemplateSpecializationInfo *SpecInfo =
FD->getTemplateSpecializationInfo();
if (!SpecInfo) {
return -1;
@@ -1278,19 +1314,19 @@ enum CXGetTemplateArgumentStatus {
CXGetTemplateArgumentStatus_InvalidIndex = -4
};
-static int clang_Cursor_getTemplateArgument(
- CXCursor C, unsigned I, TemplateArgument *TA) {
+static int clang_Cursor_getTemplateArgument(CXCursor C, unsigned I,
+ TemplateArgument *TA) {
if (clang_getCursorKind(C) != CXCursor_FunctionDecl) {
return CXGetTemplateArgumentStatus_CursorNotFunctionDecl;
}
- const FunctionDecl *FD = llvm::dyn_cast_or_null<clang::FunctionDecl>(
- getCursorDecl(C));
+ const FunctionDecl *FD =
+ llvm::dyn_cast_or_null<clang::FunctionDecl>(getCursorDecl(C));
if (!FD) {
return CXGetTemplateArgumentStatus_BadFunctionDeclCast;
}
- const FunctionTemplateSpecializationInfo* SpecInfo =
+ const FunctionTemplateSpecializationInfo *SpecInfo =
FD->getTemplateSpecializationInfo();
if (!SpecInfo) {
return CXGetTemplateArgumentStatus_NullTemplSpecInfo;
@@ -1312,17 +1348,24 @@ enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind(CXCursor C,
}
switch (TA.getKind()) {
- case TemplateArgument::Null: return CXTemplateArgumentKind_Null;
- case TemplateArgument::Type: return CXTemplateArgumentKind_Type;
- case TemplateArgument::Declaration:
- return CXTemplateArgumentKind_Declaration;
- case TemplateArgument::NullPtr: return CXTemplateArgumentKind_NullPtr;
- case TemplateArgument::Integral: return CXTemplateArgumentKind_Integral;
- case TemplateArgument::Template: return CXTemplateArgumentKind_Template;
- case TemplateArgument::TemplateExpansion:
- return CXTemplateArgumentKind_TemplateExpansion;
- case TemplateArgument::Expression: return CXTemplateArgumentKind_Expression;
- case TemplateArgument::Pack: return CXTemplateArgumentKind_Pack;
+ case TemplateArgument::Null:
+ return CXTemplateArgumentKind_Null;
+ case TemplateArgument::Type:
+ return CXTemplateArgumentKind_Type;
+ case TemplateArgument::Declaration:
+ return CXTemplateArgumentKind_Declaration;
+ case TemplateArgument::NullPtr:
+ return CXTemplateArgumentKind_NullPtr;
+ case TemplateArgument::Integral:
+ return CXTemplateArgumentKind_Integral;
+ case TemplateArgument::Template:
+ return CXTemplateArgumentKind_Template;
+ case TemplateArgument::TemplateExpansion:
+ return CXTemplateArgumentKind_TemplateExpansion;
+ case TemplateArgument::Expression:
+ return CXTemplateArgumentKind_Expression;
+ case TemplateArgument::Pack:
+ return CXTemplateArgumentKind_Pack;
}
return CXTemplateArgumentKind_Invalid;
@@ -1382,13 +1425,13 @@ unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C,
typedef llvm::DenseMap<CXCursor, unsigned> CXCursorSet_Impl;
static inline CXCursorSet packCXCursorSet(CXCursorSet_Impl *setImpl) {
- return (CXCursorSet) setImpl;
+ return (CXCursorSet)setImpl;
}
static inline CXCursorSet_Impl *unpackCXCursorSet(CXCursorSet set) {
- return (CXCursorSet_Impl*) set;
+ return (CXCursorSet_Impl *)set;
}
namespace llvm {
-template<> struct DenseMapInfo<CXCursor> {
+template <> struct DenseMapInfo<CXCursor> {
public:
static inline CXCursor getEmptyKey() {
return MakeCXCursorInvalid(CXCursor_InvalidFile);
@@ -1397,16 +1440,14 @@ template<> struct DenseMapInfo<CXCursor> {
return MakeCXCursorInvalid(CXCursor_NoDeclFound);
}
static inline unsigned getHashValue(const CXCursor &cursor) {
- return llvm::DenseMapInfo<std::pair<const void *, const void *> >
- ::getHashValue(std::make_pair(cursor.data[0], cursor.data[1]));
+ return llvm::DenseMapInfo<std::pair<const void *, const void *>>::
+ getHashValue(std::make_pair(cursor.data[0], cursor.data[1]));
}
static inline bool isEqual(const CXCursor &x, const CXCursor &y) {
- return x.kind == y.kind &&
- x.data[0] == y.data[0] &&
- x.data[1] == y.data[1];
+ return x.kind == y.kind && x.data[0] == y.data[0] && x.data[1] == y.data[1];
}
};
-}
+} // namespace llvm
CXCursorSet clang_createCXCursorSet() {
return packCXCursorSet(new CXCursorSet_Impl());
@@ -1437,7 +1478,7 @@ unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) {
entry = 1;
return flag;
}
-
+
CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
enum CXCursorKind kind = clang_getCursorKind(cursor);
if (clang_isDeclaration(kind)) {
@@ -1445,13 +1486,11 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
if (const NamedDecl *namedDecl = dyn_cast_or_null<NamedDecl>(decl)) {
ASTUnit *unit = getCursorASTUnit(cursor);
CodeCompletionResult Result(namedDecl, CCP_Declaration);
- CodeCompletionString *String
- = Result.CreateCodeCompletionString(unit->getASTContext(),
- unit->getPreprocessor(),
- CodeCompletionContext::CCC_Other,
- unit->getCodeCompletionTUInfo().getAllocator(),
- unit->getCodeCompletionTUInfo(),
- true);
+ CodeCompletionString *String = Result.CreateCodeCompletionString(
+ unit->getASTContext(), unit->getPreprocessor(),
+ CodeCompletionContext::CCC_Other,
+ unit->getCodeCompletionTUInfo().getAllocator(),
+ unit->getCodeCompletionTUInfo(), true);
return String;
}
} else if (kind == CXCursor_MacroDefinition) {
@@ -1472,58 +1511,57 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
}
namespace {
- struct OverridenCursorsPool {
- typedef SmallVector<CXCursor, 2> CursorVec;
- std::vector<CursorVec*> AllCursors;
- std::vector<CursorVec*> AvailableCursors;
-
- ~OverridenCursorsPool() {
- for (std::vector<CursorVec*>::iterator I = AllCursors.begin(),
- E = AllCursors.end(); I != E; ++I) {
- delete *I;
- }
+struct OverridenCursorsPool {
+ typedef SmallVector<CXCursor, 2> CursorVec;
+ std::vector<CursorVec *> AllCursors;
+ std::vector<CursorVec *> AvailableCursors;
+
+ ~OverridenCursorsPool() {
+ for (std::vector<CursorVec *>::iterator I = AllCursors.begin(),
+ E = AllCursors.end();
+ I != E; ++I) {
+ delete *I;
}
- };
-}
+ }
+};
+} // namespace
void *cxcursor::createOverridenCXCursorsPool() {
return new OverridenCursorsPool();
}
-
+
void cxcursor::disposeOverridenCXCursorsPool(void *pool) {
- delete static_cast<OverridenCursorsPool*>(pool);
+ delete static_cast<OverridenCursorsPool *>(pool);
}
-
-void clang_getOverriddenCursors(CXCursor cursor,
- CXCursor **overridden,
+
+void clang_getOverriddenCursors(CXCursor cursor, CXCursor **overridden,
unsigned *num_overridden) {
if (overridden)
*overridden = nullptr;
if (num_overridden)
*num_overridden = 0;
-
+
CXTranslationUnit TU = cxcursor::getCursorTU(cursor);
-
+
if (!overridden || !num_overridden || !TU)
return;
if (!clang_isDeclaration(cursor.kind))
return;
-
+
OverridenCursorsPool &pool =
- *static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool);
+ *static_cast<OverridenCursorsPool *>(TU->OverridenCursorsPool);
OverridenCursorsPool::CursorVec *Vec = nullptr;
if (!pool.AvailableCursors.empty()) {
Vec = pool.AvailableCursors.back();
pool.AvailableCursors.pop_back();
- }
- else {
+ } else {
Vec = new OverridenCursorsPool::CursorVec();
pool.AllCursors.push_back(Vec);
}
-
+
// Clear out the vector, but don't free the memory contents. This
// reduces malloc() traffic.
Vec->clear();
@@ -1537,7 +1575,7 @@ void clang_getOverriddenCursors(CXCursor cursor,
// Get the overridden cursors.
cxcursor::getOverriddenCursors(cursor, *Vec);
-
+
// Did we get any overridden cursors? If not, return Vec to the pool
// of available cursor vectors.
if (Vec->size() == 1) {
@@ -1554,7 +1592,7 @@ void clang_getOverriddenCursors(CXCursor cursor,
void clang_disposeOverriddenCursors(CXCursor *overridden) {
if (!overridden)
return;
-
+
// Use pointer arithmetic to get back the first faux entry
// which has a back-reference to the TU and the vector.
--overridden;
@@ -1562,12 +1600,12 @@ void clang_disposeOverriddenCursors(CXCursor *overridden) {
static_cast<OverridenCursorsPool::CursorVec *>(
const_cast<void *>(overridden->data[0]));
CXTranslationUnit TU = getCursorTU(*overridden);
-
+
assert(Vec && TU);
OverridenCursorsPool &pool =
- *static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool);
-
+ *static_cast<OverridenCursorsPool *>(TU->OverridenCursorsPool);
+
pool.AvailableCursors.push_back(Vec);
}
@@ -1600,8 +1638,8 @@ int clang_Cursor_isDynamicCall(CXCursor C) {
ME = dyn_cast_or_null<MemberExpr>(CE->getCallee());
if (ME) {
- if (const CXXMethodDecl *
- MD = dyn_cast_or_null<CXXMethodDecl>(ME->getMemberDecl()))
+ if (const CXXMethodDecl *MD =
+ dyn_cast_or_null<CXXMethodDecl>(ME->getMemberDecl()))
return MD->isVirtual() &&
ME->performsVirtualDispatch(
cxcursor::getCursorContext(C).getLangOpts());
diff --git a/clang/tools/libclang/CXCursor.h b/clang/tools/libclang/CXCursor.h
index 78e597b2bbea..1e4c0a05c9ef 100644
--- a/clang/tools/libclang/CXCursor.h
+++ b/clang/tools/libclang/CXCursor.h
@@ -58,39 +58,36 @@ CXCursor MakeCXCursor(const clang::Stmt *S, const clang::Decl *Parent,
CXCursor MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU = nullptr);
/// Create an Objective-C superclass reference at the given location.
-CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
- SourceLocation Loc,
- CXTranslationUnit TU);
+CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
+ SourceLocation Loc, CXTranslationUnit TU);
/// Unpack an ObjCSuperClassRef cursor into the interface it references
/// and optionally the location where the reference occurred.
std::pair<const ObjCInterfaceDecl *, SourceLocation>
- getCursorObjCSuperClassRef(CXCursor C);
+getCursorObjCSuperClassRef(CXCursor C);
/// Create an Objective-C protocol reference at the given location.
CXCursor MakeCursorObjCProtocolRef(const ObjCProtocolDecl *Proto,
- SourceLocation Loc,
- CXTranslationUnit TU);
+ SourceLocation Loc, CXTranslationUnit TU);
/// Unpack an ObjCProtocolRef cursor into the protocol it references
/// and optionally the location where the reference occurred.
std::pair<const ObjCProtocolDecl *, SourceLocation>
- getCursorObjCProtocolRef(CXCursor C);
+getCursorObjCProtocolRef(CXCursor C);
/// Create an Objective-C class reference at the given location.
CXCursor MakeCursorObjCClassRef(const ObjCInterfaceDecl *Class,
- SourceLocation Loc,
- CXTranslationUnit TU);
+ SourceLocation Loc, CXTranslationUnit TU);
/// Unpack an ObjCClassRef cursor into the class it references
/// and optionally the location where the reference occurred.
std::pair<const ObjCInterfaceDecl *, SourceLocation>
- getCursorObjCClassRef(CXCursor C);
+getCursorObjCClassRef(CXCursor C);
/// Create a type reference at the given location.
CXCursor MakeCursorTypeRef(const TypeDecl *Type, SourceLocation Loc,
CXTranslationUnit TU);
-
+
/// Unpack a TypeRef cursor into the class it references
/// and optionally the location where the reference occurred.
std::pair<const TypeDecl *, SourceLocation> getCursorTypeRef(CXCursor C);
@@ -102,9 +99,9 @@ CXCursor MakeCursorTemplateRef(const TemplateDecl *Template, SourceLocation Loc,
/// Unpack a TemplateRef cursor into the template it references and
/// the location where the reference occurred.
std::pair<const TemplateDecl *, SourceLocation>
- getCursorTemplateRef(CXCursor C);
+getCursorTemplateRef(CXCursor C);
-/// Create a reference to a namespace or namespace alias at the given
+/// Create a reference to a namespace or namespace alias at the given
/// location.
CXCursor MakeCursorNamespaceRef(const NamedDecl *NS, SourceLocation Loc,
CXTranslationUnit TU);
@@ -114,7 +111,7 @@ CXCursor MakeCursorNamespaceRef(const NamedDecl *NS, SourceLocation Loc,
std::pair<const NamedDecl *, SourceLocation> getCursorNamespaceRef(CXCursor C);
/// Create a reference to a variable at the given location.
-CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
+CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
CXTranslationUnit TU);
/// Unpack a VariableRef cursor into the variable it references and the
@@ -122,10 +119,10 @@ CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
std::pair<const VarDecl *, SourceLocation> getCursorVariableRef(CXCursor C);
/// Create a reference to a field at the given location.
-CXCursor MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
+CXCursor MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
CXTranslationUnit TU);
-/// Unpack a MemberRef cursor into the field it references and the
+/// Unpack a MemberRef cursor into the field it references and the
/// location where the reference occurred.
std::pair<const FieldDecl *, SourceLocation> getCursorMemberRef(CXCursor C);
@@ -223,7 +220,7 @@ CXCursor MakeCursorOverloadedDeclRef(const Decl *D, SourceLocation Location,
CXTranslationUnit TU);
/// Create a overloaded declaration reference cursor for a template name.
-CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
+CXCursor MakeCursorOverloadedDeclRef(TemplateName Template,
SourceLocation Location,
CXTranslationUnit TU);
@@ -235,7 +232,7 @@ typedef llvm::PointerUnion<const OverloadExpr *, const Decl *,
/// Unpack an overloaded declaration reference into an expression,
/// declaration, or template name along with the source location.
std::pair<OverloadedDeclRefStorage, SourceLocation>
- getCursorOverloadedDeclRef(CXCursor C);
+getCursorOverloadedDeclRef(CXCursor C);
const Decl *getCursorDecl(CXCursor Cursor);
const Expr *getCursorExpr(CXCursor Cursor);
@@ -284,14 +281,13 @@ bool getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf);
bool operator==(CXCursor X, CXCursor Y);
-inline bool operator!=(CXCursor X, CXCursor Y) {
- return !(X == Y);
-}
+inline bool operator!=(CXCursor X, CXCursor Y) { return !(X == Y); }
/// Return true if the cursor represents a declaration that is the
/// first in a declaration group.
bool isFirstInDeclGroup(CXCursor C);
-}} // end namespace: clang::cxcursor
+} // namespace cxcursor
+} // namespace clang
#endif
diff --git a/clang/tools/libclang/CursorVisitor.h b/clang/tools/libclang/CursorVisitor.h
index b0afa5a0b591..3337fecd0db3 100644
--- a/clang/tools/libclang/CursorVisitor.h
+++ b/clang/tools/libclang/CursorVisitor.h
@@ -16,43 +16,52 @@
#include "clang/AST/TypeLocVisitor.h"
namespace clang {
- class PreprocessingRecord;
- class ASTUnit;
+class PreprocessingRecord;
+class ASTUnit;
namespace cxcursor {
class VisitorJob {
public:
- enum Kind { DeclVisitKind, StmtVisitKind, MemberExprPartsKind,
- TypeLocVisitKind, OverloadExprPartsKind,
- DeclRefExprPartsKind, LabelRefVisitKind,
- ExplicitTemplateArgsVisitKind,
- NestedNameSpecifierLocVisitKind,
- DeclarationNameInfoVisitKind,
- MemberRefVisitKind, SizeOfPackExprPartsKind,
- LambdaExprPartsKind, PostChildrenVisitKind };
+ enum Kind {
+ DeclVisitKind,
+ StmtVisitKind,
+ MemberExprPartsKind,
+ TypeLocVisitKind,
+ OverloadExprPartsKind,
+ DeclRefExprPartsKind,
+ LabelRefVisitKind,
+ ExplicitTemplateArgsVisitKind,
+ NestedNameSpecifierLocVisitKind,
+ DeclarationNameInfoVisitKind,
+ MemberRefVisitKind,
+ SizeOfPackExprPartsKind,
+ LambdaExprPartsKind,
+ PostChildrenVisitKind
+ };
+
protected:
const void *data[3];
CXCursor parent;
Kind K;
VisitorJob(CXCursor C, Kind k, const void *d1, const void *d2 = nullptr,
const void *d3 = nullptr)
- : parent(C), K(k) {
+ : parent(C), K(k) {
data[0] = d1;
data[1] = d2;
data[2] = d3;
}
+
public:
Kind getKind() const { return K; }
const CXCursor &getParent() const { return parent; }
};
-
+
typedef SmallVector<VisitorJob, 10> VisitorWorkList;
// Cursor visitor.
class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
- public TypeLocVisitor<CursorVisitor, bool>
-{
+ public TypeLocVisitor<CursorVisitor, bool> {
public:
/// Callback called after child nodes of a cursor have been visited.
/// Return true to break visitation or false to continue.
@@ -79,14 +88,14 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
/// The opaque client data, to be passed along to the visitor.
CXClientData ClientData;
- /// Whether we should visit the preprocessing record entries last,
+ /// Whether we should visit the preprocessing record entries last,
/// after visiting other declarations.
bool VisitPreprocessorLast;
/// Whether we should visit declarations or preprocessing record
/// entries that are #included inside the \arg RegionOfInterest.
bool VisitIncludedEntities;
-
+
/// When valid, a source range to which the cursor should restrict
/// its search.
SourceRange RegionOfInterest;
@@ -103,8 +112,8 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
SmallVectorImpl<Decl *>::iterator FileDE_current;
// Cache of pre-allocated worklists for data-recursion walk of Stmts.
- SmallVector<VisitorWorkList*, 5> WorkListFreeList;
- SmallVector<VisitorWorkList*, 5> WorkListCache;
+ SmallVector<VisitorWorkList *, 5> WorkListFreeList;
+ SmallVector<VisitorWorkList *, 5> WorkListCache;
using DeclVisitor<CursorVisitor, bool>::Visit;
using TypeLocVisitor<CursorVisitor, bool>::Visit;
@@ -123,10 +132,8 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
CXCursor OldParent;
public:
- SetParentRAII(CXCursor &Parent, const Decl *&StmtParent,
- CXCursor NewParent)
- : Parent(Parent), StmtParent(StmtParent), OldParent(Parent)
- {
+ SetParentRAII(CXCursor &Parent, const Decl *&StmtParent, CXCursor NewParent)
+ : Parent(Parent), StmtParent(StmtParent), OldParent(Parent) {
Parent = NewParent;
if (clang_isDeclaration(Parent.kind))
StmtParent = getCursorDecl(Parent);
@@ -141,21 +148,17 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
public:
CursorVisitor(CXTranslationUnit TU, CXCursorVisitor Visitor,
- CXClientData ClientData,
- bool VisitPreprocessorLast,
+ CXClientData ClientData, bool VisitPreprocessorLast,
bool VisitIncludedPreprocessingEntries = false,
SourceRange RegionOfInterest = SourceRange(),
bool VisitDeclsOnly = false,
PostChildrenVisitorTy PostChildrenVisitor = nullptr)
- : TU(TU), AU(cxtu::getASTUnit(TU)),
- Visitor(Visitor), PostChildrenVisitor(PostChildrenVisitor),
- ClientData(ClientData),
- VisitPreprocessorLast(VisitPreprocessorLast),
- VisitIncludedEntities(VisitIncludedPreprocessingEntries),
- RegionOfInterest(RegionOfInterest),
- VisitDeclsOnly(VisitDeclsOnly),
- DI_current(nullptr), FileDI_current(nullptr)
- {
+ : TU(TU), AU(cxtu::getASTUnit(TU)), Visitor(Visitor),
+ PostChildrenVisitor(PostChildrenVisitor), ClientData(ClientData),
+ VisitPreprocessorLast(VisitPreprocessorLast),
+ VisitIncludedEntities(VisitIncludedPreprocessingEntries),
+ RegionOfInterest(RegionOfInterest), VisitDeclsOnly(VisitDeclsOnly),
+ DI_current(nullptr), FileDI_current(nullptr) {
Parent.kind = CXCursor_NoDeclFound;
Parent.data[0] = nullptr;
Parent.data[1] = nullptr;
@@ -165,8 +168,9 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
~CursorVisitor() {
// Free the pre-allocated worklists for data-recursion.
- for (SmallVectorImpl<VisitorWorkList*>::iterator
- I = WorkListCache.begin(), E = WorkListCache.end(); I != E; ++I) {
+ for (SmallVectorImpl<VisitorWorkList *>::iterator I = WorkListCache.begin(),
+ E = WorkListCache.end();
+ I != E; ++I) {
delete *I;
}
}
@@ -179,14 +183,12 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
/// Visit declarations and preprocessed entities for the file region
/// designated by \see RegionOfInterest.
bool visitFileRegion();
-
+
bool visitPreprocessedEntitiesInRegion();
- bool shouldVisitIncludedEntities() const {
- return VisitIncludedEntities;
- }
+ bool shouldVisitIncludedEntities() const { return VisitIncludedEntities; }
- template<typename InputIterator>
+ template <typename InputIterator>
bool visitPreprocessedEntities(InputIterator First, InputIterator Last,
PreprocessingRecord &PPRec,
FileID FID = FileID());
@@ -206,7 +208,7 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
bool VisitTagDecl(TagDecl *D);
bool VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D);
bool VisitClassTemplatePartialSpecializationDecl(
- ClassTemplatePartialSpecializationDecl *D);
+ ClassTemplatePartialSpecializationDecl *D);
bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
bool VisitEnumConstantDecl(EnumConstantDecl *D);
bool VisitDeclaratorDecl(DeclaratorDecl *DD);
@@ -244,16 +246,15 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
bool VisitNestedNameSpecifier(NestedNameSpecifier *NNS, SourceRange Range);
bool VisitNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
-
+
// Template visitors
bool VisitTemplateParameters(const TemplateParameterList *Params);
bool VisitTemplateName(TemplateName Name, SourceLocation Loc);
bool VisitTemplateArgumentLoc(const TemplateArgumentLoc &TAL);
-
+
// Type visitors
#define ABSTRACT_TYPELOC(CLASS, PARENT)
-#define TYPELOC(CLASS, PARENT) \
- bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
+#define TYPELOC(CLASS, PARENT) bool Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
#include "clang/AST/TypeLocNodes.def"
bool VisitTagTypeLoc(TagTypeLoc TL);
@@ -270,8 +271,7 @@ class CursorVisitor : public DeclVisitor<CursorVisitor, bool>,
Optional<bool> handleDeclForVisitation(const Decl *D);
};
-}
-}
+} // namespace cxcursor
+} // namespace clang
#endif
-
More information about the cfe-commits
mailing list