diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-10-24 16:38:16 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2018-10-24 16:38:16 +0000 |
commit | ef9b88a1d4801c1c46ef5a2096f7135965ef9ab5 (patch) | |
tree | d157dbab1ff4b134199b77914dacaa5c5ccdb114 /clang | |
parent | c8c745106385b20ac9e87b11a642243e4f0af91b (diff) | |
download | bcm5719-llvm-ef9b88a1d4801c1c46ef5a2096f7135965ef9ab5.tar.gz bcm5719-llvm-ef9b88a1d4801c1c46ef5a2096f7135965ef9ab5.zip |
AST: unindent CFConstantStringDecl by inverting condition (NFC)
Unindent the body of the function by inverting check at the top. This is in
preparation for supporting CFString's new ABI with swift. NFC.
llvm-svn: 345159
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 8e7b74769c6..2a38d5e6049 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -5755,50 +5755,48 @@ int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) const { } TypedefDecl *ASTContext::getCFConstantStringDecl() const { - if (!CFConstantStringTypeDecl) { - assert(!CFConstantStringTagDecl && - "tag and typedef should be initialized together"); - CFConstantStringTagDecl = buildImplicitRecord("__NSConstantString_tag"); - CFConstantStringTagDecl->startDefinition(); - - QualType FieldTypes[4]; - const char *FieldNames[4]; - - // const int *isa; - FieldTypes[0] = getPointerType(IntTy.withConst()); - FieldNames[0] = "isa"; - // int flags; - FieldTypes[1] = IntTy; - FieldNames[1] = "flags"; - // const char *str; - FieldTypes[2] = getPointerType(CharTy.withConst()); - FieldNames[2] = "str"; - // long length; - FieldTypes[3] = LongTy; - FieldNames[3] = "length"; - - // Create fields - for (unsigned i = 0; i < 4; ++i) { - FieldDecl *Field = FieldDecl::Create(*this, CFConstantStringTagDecl, - SourceLocation(), - SourceLocation(), - &Idents.get(FieldNames[i]), - FieldTypes[i], /*TInfo=*/nullptr, - /*BitWidth=*/nullptr, - /*Mutable=*/false, - ICIS_NoInit); - Field->setAccess(AS_public); - CFConstantStringTagDecl->addDecl(Field); - } - - CFConstantStringTagDecl->completeDefinition(); - // This type is designed to be compatible with NSConstantString, but cannot - // use the same name, since NSConstantString is an interface. - auto tagType = getTagDeclType(CFConstantStringTagDecl); - CFConstantStringTypeDecl = - buildImplicitTypedef(tagType, "__NSConstantString"); + if (CFConstantStringTypeDecl) + return CFConstantStringTypeDecl; + + assert(!CFConstantStringTagDecl && + "tag and typedef should be initialized together"); + CFConstantStringTagDecl = buildImplicitRecord("__NSConstantString_tag"); + CFConstantStringTagDecl->startDefinition(); + + QualType FieldTypes[4]; + const char *FieldNames[4]; + + // const int *isa; + FieldTypes[0] = getPointerType(IntTy.withConst()); + FieldNames[0] = "isa"; + // int flags; + FieldTypes[1] = IntTy; + FieldNames[1] = "flags"; + // const char *str; + FieldTypes[2] = getPointerType(CharTy.withConst()); + FieldNames[2] = "str"; + // long length; + FieldTypes[3] = LongTy; + FieldNames[3] = "length"; + + // Create fields + for (unsigned i = 0; i < 4; ++i) { + FieldDecl *Field = + FieldDecl::Create(*this, CFConstantStringTagDecl, SourceLocation(), + SourceLocation(), &Idents.get(FieldNames[i]), + FieldTypes[i], /*TInfo=*/nullptr, + /*BitWidth=*/nullptr, /*Mutable=*/false, ICIS_NoInit); + Field->setAccess(AS_public); + CFConstantStringTagDecl->addDecl(Field); } + CFConstantStringTagDecl->completeDefinition(); + // This type is designed to be compatible with NSConstantString, but cannot + // use the same name, since NSConstantString is an interface. + auto tagType = getTagDeclType(CFConstantStringTagDecl); + CFConstantStringTypeDecl = + buildImplicitTypedef(tagType, "__NSConstantString"); + return CFConstantStringTypeDecl; } |