summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2016-11-11 01:29:18 +0000
committerJordan Rose <jordan_rose@apple.com>2016-11-11 01:29:18 +0000
commitbd1ee4830debd0c5b2622f25e2b9847b0f1d58e1 (patch)
treef4a8f5b36826284e7b06d59a1251374773497f1e /clang/lib/Sema
parent9f10af2aa2f6945a95cfc1af0ec5207e42d72dab (diff)
downloadbcm5719-llvm-bd1ee4830debd0c5b2622f25e2b9847b0f1d58e1.tar.gz
bcm5719-llvm-bd1ee4830debd0c5b2622f25e2b9847b0f1d58e1.zip
Don't require nullability on 'va_list', even when it's a pointer.
Take 3! This should finally fix the Hexagon, PPC, and Windows bots. rdar://problem/25846421 llvm-svn: 286542
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaType.cpp63
1 files changed, 35 insertions, 28 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index e98737946b7..2f776f9fa49 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -3827,6 +3827,23 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
}
}
+ // Local function that returns true if its argument looks like a va_list.
+ auto isVaList = [&S](QualType T) -> bool {
+ auto *typedefTy = T->getAs<TypedefType>();
+ if (!typedefTy)
+ return false;
+ TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl();
+ do {
+ if (typedefTy->getDecl() == vaListTypedef)
+ return true;
+ if (auto *name = typedefTy->getDecl()->getIdentifier())
+ if (name->isStr("va_list"))
+ return true;
+ typedefTy = typedefTy->desugar()->getAs<TypedefType>();
+ } while (typedefTy);
+ return false;
+ };
+
// Local function that checks the nullability for a given pointer declarator.
// Returns true if _Nonnull was inferred.
auto inferPointerNullability = [&](SimplePointerKind pointerKind,
@@ -3905,37 +3922,27 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// nullability and perform consistency checking.
if (S.ActiveTemplateInstantiations.empty()) {
if (T->canHaveNullability() && !T->getNullability(S.Context)) {
- SimplePointerKind pointerKind = SimplePointerKind::Pointer;
- if (T->isBlockPointerType())
- pointerKind = SimplePointerKind::BlockPointer;
- else if (T->isMemberPointerType())
- pointerKind = SimplePointerKind::MemberPointer;
-
- if (auto *attr = inferPointerNullability(
- pointerKind, D.getDeclSpec().getTypeSpecTypeLoc(),
- D.getMutableDeclSpec().getAttributes().getListRef())) {
- T = Context.getAttributedType(
- AttributedType::getNullabilityAttrKind(*inferNullability), T, T);
- attr->setUsedAsTypeAttr();
+ if (isVaList(T)) {
+ // Record that we've seen a pointer, but do nothing else.
+ if (NumPointersRemaining > 0)
+ --NumPointersRemaining;
+ } else {
+ SimplePointerKind pointerKind = SimplePointerKind::Pointer;
+ if (T->isBlockPointerType())
+ pointerKind = SimplePointerKind::BlockPointer;
+ else if (T->isMemberPointerType())
+ pointerKind = SimplePointerKind::MemberPointer;
+
+ if (auto *attr = inferPointerNullability(
+ pointerKind, D.getDeclSpec().getTypeSpecTypeLoc(),
+ D.getMutableDeclSpec().getAttributes().getListRef())) {
+ T = Context.getAttributedType(
+ AttributedType::getNullabilityAttrKind(*inferNullability),T,T);
+ attr->setUsedAsTypeAttr();
+ }
}
}
- auto isVaList = [&S](QualType T) -> bool {
- auto *typedefTy = T->getAs<TypedefType>();
- if (!typedefTy)
- return false;
- TypedefDecl *vaListTypedef = S.Context.getBuiltinVaListDecl();
- do {
- if (typedefTy->getDecl() == vaListTypedef)
- return true;
- if (auto *name = typedefTy->getDecl()->getIdentifier())
- if (name->isStr("va_list"))
- return true;
- typedefTy = typedefTy->desugar()->getAs<TypedefType>();
- } while (typedefTy);
- return false;
- };
-
if (complainAboutMissingNullability == CAMN_Yes &&
T->isArrayType() && !T->getNullability(S.Context) && !isVaList(T) &&
D.isPrototypeContext() &&
OpenPOWER on IntegriCloud