зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1209227 - Part 1: Make the MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS analysis handle packs more correctly, r=ehsan
This commit is contained in:
Родитель
5404434320
Коммит
6dd5afa601
|
@ -319,6 +319,7 @@ public:
|
|||
private:
|
||||
bool hasLiteralAnnotation(QualType T) const;
|
||||
AnnotationReason directAnnotationReason(QualType T);
|
||||
AnnotationReason tmplArgAnnotationReason(ArrayRef<TemplateArgument> Args);
|
||||
|
||||
protected:
|
||||
// Allow subclasses to apply annotations to external code:
|
||||
|
@ -882,16 +883,10 @@ CustomTypeAnnotation::directAnnotationReason(QualType T) {
|
|||
if (Spec) {
|
||||
const TemplateArgumentList &Args = Spec->getTemplateArgs();
|
||||
|
||||
for (const TemplateArgument &Arg : Args.asArray()) {
|
||||
if (Arg.getKind() == TemplateArgument::Type) {
|
||||
QualType Type = Arg.getAsType();
|
||||
|
||||
if (hasEffectiveAnnotation(Type)) {
|
||||
AnnotationReason Reason = {Type, RK_TemplateInherited, nullptr};
|
||||
Cache[Key] = Reason;
|
||||
return Reason;
|
||||
}
|
||||
}
|
||||
AnnotationReason Reason = tmplArgAnnotationReason(Args.asArray());
|
||||
if (Reason.Kind != RK_None) {
|
||||
Cache[Key] = Reason;
|
||||
return Reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -903,6 +898,27 @@ CustomTypeAnnotation::directAnnotationReason(QualType T) {
|
|||
return Reason;
|
||||
}
|
||||
|
||||
CustomTypeAnnotation::AnnotationReason
|
||||
CustomTypeAnnotation::tmplArgAnnotationReason(ArrayRef<TemplateArgument> Args) {
|
||||
for (const TemplateArgument &Arg : Args) {
|
||||
if (Arg.getKind() == TemplateArgument::Type) {
|
||||
QualType Type = Arg.getAsType();
|
||||
if (hasEffectiveAnnotation(Type)) {
|
||||
AnnotationReason Reason = {Type, RK_TemplateInherited, nullptr};
|
||||
return Reason;
|
||||
}
|
||||
} else if (Arg.getKind() == TemplateArgument::Pack) {
|
||||
AnnotationReason Reason = tmplArgAnnotationReason(Arg.getPackAsArray());
|
||||
if (Reason.Kind != RK_None) {
|
||||
return Reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnnotationReason Reason = {QualType(), RK_None, nullptr};
|
||||
return Reason;
|
||||
}
|
||||
|
||||
bool isPlacementNew(const CXXNewExpr *Expr) {
|
||||
// Regular new expressions aren't placement new
|
||||
if (Expr->getNumPlacementArgs() == 0)
|
||||
|
|
|
@ -25,7 +25,9 @@ static ContainsTemplate e; // expected-error {{variable of type 'ContainsTemplat
|
|||
static Template<Normal> f;
|
||||
|
||||
template<class T>
|
||||
class MOZ_NEEDS_MEMMOVABLE_TYPE Mover { char mForceInstantiation[sizeof(T)]; }; // expected-error-re 5 {{Cannot instantiate 'Mover<{{.*}}>' with non-memmovable template argument '{{.*}}'}}
|
||||
class MOZ_NEEDS_MEMMOVABLE_TYPE Mover { // expected-error-re 8 {{Cannot instantiate 'Mover<{{.*}}>' with non-memmovable template argument '{{.*}}'}}
|
||||
char mForceInstantiation[sizeof(T)];
|
||||
};
|
||||
class IndirectTemplatePointery : Template<Pointery> {}; // expected-note {{'IndirectTemplatePointery' is a non-memmove()able type because it inherits from a non-memmove()able type 'Template<Pointery>'}}
|
||||
class ContainsTemplatePointery { Template<Pointery> m; }; // expected-note {{'ContainsTemplatePointery' is a non-memmove()able type because member 'm' is a non-memmove()able type 'Template<Pointery>'}}
|
||||
|
||||
|
@ -35,3 +37,10 @@ static Mover<Template<ContainsPointery>> p; // expected-note {{instantiation of
|
|||
static Mover<IndirectTemplatePointery> q; // expected-note {{instantiation of 'Mover<IndirectTemplatePointery>' requested here}}
|
||||
static Mover<ContainsTemplatePointery> r; // expected-note {{instantiation of 'Mover<ContainsTemplatePointery>' requested here}}
|
||||
static Mover<Template<Normal>> s;
|
||||
|
||||
template<class T, class... Ts>
|
||||
class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS ManyTs {}; // expected-note-re 3 {{'ManyTs<{{.*}}>' is a non-memmove()able type because it has a template argument non-memmove()able type '{{.*}}'}}
|
||||
|
||||
static Mover<ManyTs<Pointery>> t; // expected-note {{instantiation of 'Mover<ManyTs<Pointery> >' requested here}}
|
||||
static Mover<ManyTs<Normal, Pointery>> u; // expected-note {{instantiation of 'Mover<ManyTs<Normal, Pointery> >' requested here}}
|
||||
static Mover<ManyTs<Normal, Normal, Pointery>> v; // expected-note {{instantiation of 'Mover<ManyTs<Normal, Normal, Pointery> >' requested here}}
|
||||
|
|
Загрузка…
Ссылка в новой задаче