r286542 - Don't require nullability on 'va_list', even when it's a pointer.
Jordan Rose via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 10 17:29:18 PST 2016
Author: jrose
Date: Thu Nov 10 19:29:18 2016
New Revision: 286542
URL: http://llvm.org/viewvc/llvm-project?rev=286542&view=rev
Log:
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
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286542&r1=286541&r2=286542&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Nov 10 19:29:18 2016
@@ -3827,6 +3827,23 @@ static TypeSourceInfo *GetFullTypeForDec
}
}
+ // 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 *GetFullTypeForDec
// 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() &&
More information about the cfe-commits
mailing list