diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-04-30 16:49:04 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-04-30 16:49:04 +0000 |
commit | 05097246f352eca76207c9ebb08656c88bdf751a (patch) | |
tree | bfc4ec8250a939aaf4ade6fc6c528726183e5367 /lldb/source/Symbol/ClangASTContext.cpp | |
parent | add59c052dd6768fd54431e6a3bf045e7f25cb59 (diff) | |
download | bcm5719-llvm-05097246f352eca76207c9ebb08656c88bdf751a.tar.gz bcm5719-llvm-05097246f352eca76207c9ebb08656c88bdf751a.zip |
Reflow paragraphs in comments.
This is intended as a clean up after the big clang-format commit
(r280751), which unfortunately resulted in many of the comment
paragraphs in LLDB being very hard to read.
FYI, the script I used was:
import textwrap
import commands
import os
import sys
import re
tmp = "%s.tmp"%sys.argv[1]
out = open(tmp, "w+")
with open(sys.argv[1], "r") as f:
header = ""
text = ""
comment = re.compile(r'^( *//) ([^ ].*)$')
special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$')
for line in f:
match = comment.match(line)
if match and not special.match(match.group(2)):
# skip intentionally short comments.
if not text and len(match.group(2)) < 40:
out.write(line)
continue
if text:
text += " " + match.group(2)
else:
header = match.group(1)
text = match.group(2)
continue
if text:
filled = textwrap.wrap(text, width=(78-len(header)),
break_long_words=False)
for l in filled:
out.write(header+" "+l+'\n')
text = ""
out.write(line)
os.rename(tmp, sys.argv[1])
Differential Revision: https://reviews.llvm.org/D46144
llvm-svn: 331197
Diffstat (limited to 'lldb/source/Symbol/ClangASTContext.cpp')
-rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 220 |
1 files changed, 97 insertions, 123 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 0c389444208..a4d5256fd6a 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -163,8 +163,8 @@ bool ClangASTContext::IsOperator(const char *name, #undef OPERATOR_PREFIX #undef OPERATOR_PREFIX_LENGTH - // This is an operator, set the overloaded operator kind to invalid - // in case this is a conversion operator... + // This is an operator, set the overloaded operator kind to invalid in case + // this is a conversion operator... op_kind = clang::NUM_OVERLOADED_OPERATORS; switch (post_op_name[0]) { @@ -375,9 +375,9 @@ ClangASTContext::ConvertAccessTypeToAccessSpecifier(AccessType access) { static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { // FIXME: Cleanup per-file based stuff. - // Set some properties which depend solely on the input kind; it would be nice - // to move these to the language standard, and have the driver resolve the - // input kind + language standard. + // Set some properties which depend solely on the input kind; it would be + // nice to move these to the language standard, and have the driver resolve + // the input kind + language standard. if (IK.getLanguage() == InputKind::Asm) { Opts.AsmPreprocessor = 1; } else if (IK.isObjectiveC()) { @@ -440,8 +440,8 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { Opts.setValueVisibilityMode(DefaultVisibility); - // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs - // is specified, or -std is set to a conforming mode. + // Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs is + // specified, or -std is set to a conforming mode. Opts.Trigraphs = !Opts.GNUMode; Opts.CharIsSigned = ArchSpec(triple).CharIsSignedByDefault(); Opts.OptimizeSize = 0; @@ -662,8 +662,8 @@ ASTContext *ClangASTContext::getASTContext() { m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false); // This can be NULL if we don't know anything about the architecture or if - // the - // target for an architecture isn't enabled in the llvm/clang that we built + // the target for an architecture isn't enabled in the llvm/clang that we + // built TargetInfo *target_info = getTargetInfo(); if (target_info) m_ast_ap->InitBuiltinTypes(*target_info); @@ -1254,8 +1254,8 @@ CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) { } CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) { - // No need to call the getASTContext() accessor (which can create the AST - // if it isn't created yet, because we can't have created a decl in this + // No need to call the getASTContext() accessor (which can create the AST if + // it isn't created yet, because we can't have created a decl in this // AST if our AST didn't already exist... ASTContext *ast = &decl->getASTContext(); if (ast) @@ -1264,8 +1264,8 @@ CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) { } CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) { - // No need to call the getASTContext() accessor (which can create the AST - // if it isn't created yet, because we can't have created a decl in this + // No need to call the getASTContext() accessor (which can create the AST if + // it isn't created yet, because we can't have created a decl in this // AST if our AST didn't already exist... ASTContext *ast = &decl->getASTContext(); if (ast) @@ -1294,9 +1294,9 @@ CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx, } // NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and - // we will need to update this code. I was told to currently always use - // the CXXRecordDecl class since we often don't know from debug information - // if something is struct or a class, so we default to always use the more + // we will need to update this code. I was told to currently always use the + // CXXRecordDecl class since we often don't know from debug information if + // something is struct or a class, so we default to always use the more // complete definition just in case. bool is_anonymous = (!name) || (!name[0]); @@ -1499,9 +1499,9 @@ ClangASTContext::CreateTemplateTemplateParmDecl(const char *template_name) { ast, template_param_infos, template_param_decls); // LLDB needs to create those decls only to be able to display a - // type that includes a template template argument. Only the name - // matters for this purpose, so we use dummy values for the other - // characterisitcs of the type. + // type that includes a template template argument. Only the name matters for + // this purpose, so we use dummy values for the other characterisitcs of the + // type. return TemplateTemplateParmDecl::Create( *ast, decl_ctx, SourceLocation(), /*Depth*/ 0, /*Position*/ 0, @@ -1933,11 +1933,10 @@ ClangASTContext::GetDeclarationName(const char *name, return DeclarationName(&getASTContext()->Idents.get( name)); // Not operator, but a regular function. - // Check the number of operator parameters. Sometimes we have - // seen bad DWARF that doesn't correctly describe operators and - // if we try to create a method and add it to the class, clang - // will assert and crash, so we need to make sure things are - // acceptable. + // Check the number of operator parameters. Sometimes we have seen bad DWARF + // that doesn't correctly describe operators and if we try to create a method + // and add it to the class, clang will assert and crash, so we need to make + // sure things are acceptable. clang::QualType method_qual_type(ClangUtil::GetQualType(function_clang_type)); const clang::FunctionProtoType *function_type = llvm::dyn_cast<clang::FunctionProtoType>(method_qual_type.getTypePtr()); @@ -2247,8 +2246,8 @@ bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl, if (lhs_decl_kind == rhs_decl_kind) { //------------------------------------------------------------------ - // Now check that the decl contexts kinds are all equivalent - // before we have to check any names of the decl contexts... + // Now check that the decl contexts kinds are all equivalent before we + // have to check any names of the decl contexts... //------------------------------------------------------------------ clang::DeclContext *lhs_decl_ctx = lhs_decl->getDeclContext(); clang::DeclContext *rhs_decl_ctx = rhs_decl->getDeclContext(); @@ -2290,8 +2289,8 @@ bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl, return false; //-------------------------------------------------------------- - // We know that the decl context kinds all match, so now we need - // to make sure the names match as well + // We know that the decl context kinds all match, so now we need to + // make sure the names match as well //-------------------------------------------------------------- lhs_decl_ctx = lhs_decl->getDeclContext(); rhs_decl_ctx = rhs_decl->getDeclContext(); @@ -2561,8 +2560,7 @@ static bool GetCompleteQualType(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); // We currently can't complete objective C types through the newly added - // ASTContext - // because it only supports TagDecl objects right now... + // ASTContext because it only supports TagDecl objects right now... if (class_interface_decl) { if (class_interface_decl->getDefinition()) return true; @@ -2882,8 +2880,8 @@ bool ClangASTContext::IsCStringType(lldb::opaque_compiler_type_t type, if (type_flags.AnySet(eTypeIsArray | eTypeIsPointer)) { if (pointee_or_element_clang_type.IsCharType()) { if (type_flags.Test(eTypeIsArray)) { - // We know the size of the array and it could be a C string - // since it is an array of characters + // We know the size of the array and it could be a C string since it is + // an array of characters length = llvm::cast<clang::ConstantArrayType>( GetCanonicalQualType(type).getTypePtr()) ->getSize() @@ -3623,9 +3621,8 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type, if (success) { // Check to make sure what we are pointing too is a possible dynamic C++ - // type - // We currently accept any "void *" (in case we have a class that has been - // watered down to an opaque pointer) and virtual C++ classes. + // type We currently accept any "void *" (in case we have a class that + // has been watered down to an opaque pointer) and virtual C++ classes. const clang::Type::TypeClass pointee_type_class = pointee_qual_type.getCanonicalType()->getTypeClass(); switch (pointee_type_class) { @@ -4777,9 +4774,8 @@ ClangASTContext::CreateTypedef(lldb::opaque_compiler_type_t type, } // Check whether this declaration is an anonymous struct, union, or enum, - // hidden behind a typedef. If so, we - // try to check whether we have a typedef tag to attach to the original - // record declaration + // hidden behind a typedef. If so, we try to check whether we have a + // typedef tag to attach to the original record declaration if (tdecl && !tdecl->getIdentifier() && !tdecl->getTypedefNameForAnonDecl()) tdecl->setTypedefNameForAnonDecl(decl); @@ -5005,9 +5001,8 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type, break; } break; - // All pointer types are represented as unsigned integer encodings. - // We may nee to add a eEncodingPointer if we ever need to know the - // difference + // All pointer types are represented as unsigned integer encodings. We may + // nee to add a eEncodingPointer if we ever need to know the difference case clang::Type::ObjCObjectPointer: case clang::Type::BlockPointer: case clang::Type::Pointer: @@ -5324,10 +5319,9 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type, llvm::dyn_cast<clang::CXXRecordDecl>(record_decl); if (cxx_record_decl) { if (omit_empty_base_classes) { - // Check each base classes to see if it or any of its - // base classes contain any fields. This can help - // limit the noise in variable views by not having to - // show base classes that contain no members. + // Check each base classes to see if it or any of its base classes + // contain any fields. This can help limit the noise in variable + // views by not having to show base classes that contain no members. clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; for (base_class = cxx_record_decl->bases_begin(), @@ -5420,8 +5414,8 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type, CompilerType(getASTContext(), pointee_type) .GetNumChildren(omit_empty_base_classes); if (num_pointee_children == 0) { - // We have a pointer to a pointee type that claims it has no children. - // We will want to look at + // We have a pointer to a pointee type that claims it has no children. We + // will want to look at num_children = GetNumPointeeChildren(pointee_type); } else num_children = num_pointee_children; @@ -6615,15 +6609,12 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( child_byte_size = ivar_type_info.Width / 8; // Figure out the field offset within the current - // struct/union/class type - // For ObjC objects, we can't trust the bit offset we get from - // the Clang AST, since - // that doesn't account for the space taken up by unbacked - // properties, or from - // the changing size of base classes that are newer than this - // class. - // So if we have a process around that we can ask about this - // object, do so. + // struct/union/class type For ObjC objects, we can't trust the + // bit offset we get from the Clang AST, since that doesn't + // account for the space taken up by unbacked properties, or + // from the changing size of base classes that are newer than + // this class. So if we have a process around that we can ask + // about this object, do so. child_byte_offset = LLDB_INVALID_IVAR_OFFSET; Process *process = nullptr; if (exe_ctx) @@ -6651,9 +6642,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex( } // Note, the ObjC Ivar Byte offset is just that, it doesn't - // account for the bit offset - // of a bitfield within its containing object. So regardless of - // where we get the byte + // account for the bit offset of a bitfield within its + // containing object. So regardless of where we get the byte // offset from, we still need to get the bit offset for // bitfields from the layout. @@ -6925,8 +6915,8 @@ static uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, } // Look for a child member (doesn't include base classes, but it does include -// their members) in the type hierarchy. Returns an index path into "clang_type" -// on how to reach the appropriate member. +// their members) in the type hierarchy. Returns an index path into +// "clang_type" on how to reach the appropriate member. // // class A // { @@ -6949,16 +6939,13 @@ static uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl, // "m_b" in it: // // With omit_empty_base_classes == false we would get an integer array back -// with: -// { 1, 1 } -// The first index 1 is the child index for "class A" within class C -// The second index 1 is the child index for "m_b" within class A +// with: { 1, 1 } The first index 1 is the child index for "class A" within +// class C The second index 1 is the child index for "m_b" within class A // -// With omit_empty_base_classes == true we would get an integer array back with: -// { 0, 1 } -// The first index 0 is the child index for "class A" within class C (since -// class B doesn't have any members it doesn't count) -// The second index 1 is the child index for "m_b" within class A +// With omit_empty_base_classes == true we would get an integer array back +// with: { 0, 1 } The first index 0 is the child index for "class A" within +// class C (since class B doesn't have any members it doesn't count) The second +// index 1 is the child index for "m_b" within class A size_t ClangASTContext::GetIndexOfChildMemberWithName( lldb::opaque_compiler_type_t type, const char *name, @@ -7093,9 +7080,9 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName( } if (superclass_interface_decl) { - // The super class index is always zero for ObjC classes, - // so we push it onto the child indexes in case we find - // an ivar in our superclass... + // The super class index is always zero for ObjC classes, so we + // push it onto the child indexes in case we find an ivar in our + // superclass... child_indexes.push_back(0); CompilerType superclass_clang_type( @@ -7103,14 +7090,13 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName( superclass_interface_decl)); if (superclass_clang_type.GetIndexOfChildMemberWithName( name, omit_empty_base_classes, child_indexes)) { - // We did find an ivar in a superclass so just - // return the results! + // We did find an ivar in a superclass so just return the + // results! return child_indexes.size(); } - // We didn't find an ivar matching "name" in our - // superclass, pop the superclass zero index that - // we pushed on above. + // We didn't find an ivar matching "name" in our superclass, pop + // the superclass zero index that we pushed on above. child_indexes.pop_back(); } } @@ -7703,8 +7689,8 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType( clang::ICIS_NoInit); // HasInit if (!name) { - // Determine whether this field corresponds to an anonymous - // struct or union. + // Determine whether this field corresponds to an anonymous struct or + // union. if (const clang::TagType *TagT = field->getType()->getAs<clang::TagType>()) { if (clang::RecordDecl *Rec = @@ -7848,8 +7834,8 @@ void ClangASTContext::BuildIndirectFields(const CompilerType &type) { } } - // Check the last field to see if it has an incomplete array type as its - // last member and if it does, the tell the record decl about it + // Check the last field to see if it has an incomplete array type as its last + // member and if it does, the tell the record decl about it if (last_field_pos != field_end_pos) { if (last_field_pos->getType()->isIncompleteArrayType()) record_decl->hasFlexibleArrayMember(); @@ -7983,11 +7969,10 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType( if (IsOperator(name, op_kind)) { if (op_kind != clang::NUM_OVERLOADED_OPERATORS) { - // Check the number of operator parameters. Sometimes we have - // seen bad DWARF that doesn't correctly describe operators and - // if we try to create a method and add it to the class, clang - // will assert and crash, so we need to make sure things are - // acceptable. + // Check the number of operator parameters. Sometimes we have seen bad + // DWARF that doesn't correctly describe operators and if we try to + // create a method and add it to the class, clang will assert and + // crash, so we need to make sure things are acceptable. const bool is_method = true; if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount( is_method, op_kind, num_params)) @@ -8667,8 +8652,8 @@ bool ClangASTContext::CompleteTagDeclarationDefinition( clang::QualType qual_type(ClangUtil::GetQualType(type)); if (!qual_type.isNull()) { // Make sure we use the same methodology as - // ClangASTContext::StartTagDeclarationDefinition() - // as to how we start/end the definition. Previously we were calling + // ClangASTContext::StartTagDeclarationDefinition() as to how we start/end + // the definition. Previously we were calling const clang::TagType *tag_type = qual_type->getAs<clang::TagType>(); if (tag_type) { clang::TagDecl *tag_decl = tag_type->getDecl(); @@ -8938,9 +8923,8 @@ void ClangASTContext::DumpValue( for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx) { - // Print the starting squiggly bracket (if this is the - // first member) or comma (for member 2 and beyond) for - // the struct/union/class member. + // Print the starting squiggly bracket (if this is the first member) or + // comma (for member 2 and beyond) for the struct/union/class member. if (child_idx == 0) s->PutChar('{'); else @@ -8951,8 +8935,8 @@ void ClangASTContext::DumpValue( clang::QualType field_type = field->getType(); // Print the member type if requested - // Figure out the type byte size (field_type_info.first) and - // alignment (field_type_info.second) from the AST context. + // Figure out the type byte size (field_type_info.first) and alignment + // (field_type_info.second) from the AST context. clang::TypeInfo field_type_info = getASTContext()->getTypeInfo(field_type); assert(field_idx < record_layout.getFieldCount()); @@ -9023,8 +9007,8 @@ void ClangASTContext::DumpValue( return; } } - // If we have gotten here we didn't get find the enumerator in the - // enum decl, so just print the integer. + // If we have gotten here we didn't get find the enumerator in the enum + // decl, so just print the integer. s->Printf("%" PRIi64, enum_value); } return; @@ -9062,9 +9046,8 @@ void ClangASTContext::DumpValue( lldb::Format element_format = element_clang_type.GetFormat(); for (element_idx = 0; element_idx < element_count; ++element_idx) { - // Print the starting squiggly bracket (if this is the - // first member) or comman (for member 2 and beyong) for - // the struct/union/class member. + // Print the starting squiggly bracket (if this is the first member) or + // comman (for member 2 and beyong) for the struct/union/class member. if (element_idx == 0) s->PutChar('{'); else @@ -9260,8 +9243,8 @@ bool ClangASTContext::DumpTypeValue( } break; case clang::Type::Enum: - // If our format is enum or default, show the enumeration value as - // its enumeration string value, else just display it as requested. + // If our format is enum or default, show the enumeration value as its + // enumeration string value, else just display it as requested. if ((format == eFormatEnum || format == eFormatDefault) && GetCompleteType(type)) { const clang::EnumType *enutype = @@ -9553,9 +9536,9 @@ void ClangASTContext::DumpTypeName(const CompilerType &type) { if (objc_class_type) { clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); - // We currently can't complete objective C types through the newly added - // ASTContext - // because it only supports TagDecl objects right now... + // We currently can't complete objective C types through the newly + // added ASTContext because it only supports TagDecl objects right + // now... if (class_interface_decl) printf("@class %s", class_interface_decl->getName().str().c_str()); } @@ -9813,15 +9796,12 @@ std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName( // Look for child_decl_ctx's lookup scope in frame_decl_ctx and its parents, // and return the number of levels it took to find it, or -// LLDB_INVALID_DECL_LEVEL -// if not found. If the decl was imported via a using declaration, its name -// and/or -// type, if set, will be used to check that the decl found in the scope is a -// match. +// LLDB_INVALID_DECL_LEVEL if not found. If the decl was imported via a using +// declaration, its name and/or type, if set, will be used to check that the +// decl found in the scope is a match. // // The optional name is required by languages (like C++) to handle using -// declarations -// like: +// declarations like: // // void poo(); // namespace ns { @@ -9850,14 +9830,10 @@ std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName( // // NOTE: Because file statics are at the TranslationUnit along with globals, a // function at file scope will return the same level as a function at global -// scope. -// Ideally we'd like to treat the file scope as an additional scope just below -// the -// global scope. More work needs to be done to recognise that, if the decl -// we're -// trying to look up is static, we should compare its source file with that of -// the -// current scope and return a lower number for it. +// scope. Ideally we'd like to treat the file scope as an additional scope just +// below the global scope. More work needs to be done to recognise that, if +// the decl we're trying to look up is static, we should compare its source +// file with that of the current scope and return a lower number for it. uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name, @@ -9886,10 +9862,8 @@ uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx, continue; // Currently DWARF has one shared translation unit for all Decls at top - // level, so this - // would erroneously find using statements anywhere. So don't look at - // the top-level - // translation unit. + // level, so this would erroneously find using statements anywhere. So + // don't look at the top-level translation unit. // TODO fix this and add a testcase that depends on it. if (llvm::isa<clang::TranslationUnitDecl>(it->second)) |