summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseObjc.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2015-06-19 18:25:57 +0000
committerDouglas Gregor <dgregor@apple.com>2015-06-19 18:25:57 +0000
commit2a20bd1a945705e3a3845e3d4ef6c3cb68d938c7 (patch)
treefdda46a505a45931089192a51a5c231fe66f7298 /clang/lib/Parse/ParseObjc.cpp
parent849ebc269fe17def169c812f929746cb98955664 (diff)
downloadbcm5719-llvm-2a20bd1a945705e3a3845e3d4ef6c3cb68d938c7.tar.gz
bcm5719-llvm-2a20bd1a945705e3a3845e3d4ef6c3cb68d938c7.zip
Introduced pragmas for audited nullability regions.
Introduce the clang pragmas "assume_nonnull begin" and "assume_nonnull end" in which we make default assumptions about the nullability of many unannotated pointers: - Single-level pointers are inferred to __nonnull - NSError** in a (function or method) parameter list is inferred to NSError * __nullable * __nullable. - CFErrorRef * in a (function or method) parameter list is inferred to CFErrorRef __nullable * __nullable. - Other multi-level pointers are never inferred to anything. Implements rdar://problem/19191042. llvm-svn: 240156
Diffstat (limited to 'clang/lib/Parse/ParseObjc.cpp')
-rw-r--r--clang/lib/Parse/ParseObjc.cpp55
1 files changed, 17 insertions, 38 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 83236602df7..a3cf4831e44 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -308,25 +308,6 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
return ClsType;
}
-IdentifierInfo *Parser::getNullabilityKeyword(NullabilityKind nullability) {
- switch (nullability) {
- case NullabilityKind::NonNull:
- if (!Ident___nonnull)
- Ident___nonnull = PP.getIdentifierInfo("__nonnull");
- return Ident___nonnull;
-
- case NullabilityKind::Nullable:
- if (!Ident___nullable)
- Ident___nullable = PP.getIdentifierInfo("__nullable");
- return Ident___nullable;
-
- case NullabilityKind::Unspecified:
- if (!Ident___null_unspecified)
- Ident___null_unspecified = PP.getIdentifierInfo("__null_unspecified");
- return Ident___null_unspecified;
- }
-}
-
/// Add an attribute for a context-sensitive type nullability to the given
/// declarator.
static void addContextSensitiveTypeNullability(Parser &P,
@@ -1063,31 +1044,28 @@ ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS,
SourceLocation loc = ConsumeToken();
Ty = Actions.ActOnObjCInstanceType(loc);
+ // Synthesize an abstract declarator so we can use Sema::ActOnTypeName.
+ bool addedToDeclSpec = false;
+ const char *prevSpec;
+ unsigned diagID;
+ DeclSpec declSpec(AttrFactory);
+ declSpec.setObjCQualifiers(&DS);
+ declSpec.SetTypeSpecType(DeclSpec::TST_typename, loc, prevSpec, diagID,
+ Ty,
+ Actions.getASTContext().getPrintingPolicy());
+ declSpec.SetRangeEnd(loc);
+ Declarator declarator(declSpec, context);
+
// Map a nullability specifier to a context-sensitive keyword attribute.
- if (DS.getObjCDeclQualifier() & ObjCDeclSpec::DQ_CSNullability) {
- // Synthesize an abstract declarator so we can use Sema::ActOnTypeName.
- bool addedToDeclSpec = false;
- const char *prevSpec;
- unsigned diagID;
- DeclSpec declSpec(AttrFactory);
- declSpec.setObjCQualifiers(&DS);
- declSpec.SetTypeSpecType(DeclSpec::TST_typename, loc, prevSpec, diagID,
- Ty,
- Actions.getASTContext().getPrintingPolicy());
- declSpec.SetRangeEnd(loc);
- Declarator declarator(declSpec, context);
-
- // Add the context-sensitive keyword attribute.
+ if (DS.getObjCDeclQualifier() & ObjCDeclSpec::DQ_CSNullability)
addContextSensitiveTypeNullability(*this, declarator,
DS.getNullability(),
DS.getNullabilityLoc(),
addedToDeclSpec);
-
- TypeResult type = Actions.ActOnTypeName(getCurScope(), declarator);
- if (!type.isInvalid())
- Ty = type.get();
- }
+ TypeResult type = Actions.ActOnTypeName(getCurScope(), declarator);
+ if (!type.isInvalid())
+ Ty = type.get();
}
}
@@ -1491,6 +1469,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl,
auto ObjCIvarCallback = [&](ParsingFieldDeclarator &FD) {
Actions.ActOnObjCContainerStartDefinition(interfaceDecl);
// Install the declarator into the interface decl.
+ FD.D.setObjCIvar(true);
Decl *Field = Actions.ActOnIvar(
getCurScope(), FD.D.getDeclSpec().getSourceRange().getBegin(), FD.D,
FD.BitfieldSize, visibility);
OpenPOWER on IntegriCloud