@@ -1861,6 +1861,7 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
18611861 TypeTraitExprBits.Kind = Kind;
18621862 assert (static_cast <unsigned >(Kind) == TypeTraitExprBits.Kind &&
18631863 " TypeTraitExprBits.Kind overflow!" );
1864+ TypeTraitExprBits.IsBooleanTypeTrait = true ;
18641865 TypeTraitExprBits.Value = Value;
18651866 TypeTraitExprBits.NumArgs = Args.size ();
18661867 assert (Args.size () == TypeTraitExprBits.NumArgs &&
@@ -1873,19 +1874,54 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
18731874 setDependence (computeDependence (this ));
18741875}
18751876
1877+ TypeTraitExpr::TypeTraitExpr (QualType T, SourceLocation Loc, TypeTrait Kind,
1878+ ArrayRef<TypeSourceInfo *> Args,
1879+ SourceLocation RParenLoc, APValue Value)
1880+ : Expr(TypeTraitExprClass, T, VK_PRValue, OK_Ordinary), Loc(Loc),
1881+ RParenLoc(RParenLoc) {
1882+ assert (Kind <= TT_Last && " invalid enum value!" );
1883+ TypeTraitExprBits.Kind = Kind;
1884+ assert (static_cast <unsigned >(Kind) == TypeTraitExprBits.Kind &&
1885+ " TypeTraitExprBits.Kind overflow!" );
1886+ TypeTraitExprBits.IsBooleanTypeTrait = false ;
1887+ TypeTraitExprBits.NumArgs = Args.size ();
1888+ assert (Args.size () == TypeTraitExprBits.NumArgs &&
1889+ " TypeTraitExprBits.NumArgs overflow!" );
1890+
1891+ *getTrailingObjects<APValue>() = Value;
1892+
1893+ auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
1894+ for (unsigned I = 0 , N = Args.size (); I != N; ++I)
1895+ ToArgs[I] = Args[I];
1896+
1897+ setDependence (computeDependence (this ));
1898+ }
1899+
18761900TypeTraitExpr *TypeTraitExpr::Create (const ASTContext &C, QualType T,
18771901 SourceLocation Loc,
18781902 TypeTrait Kind,
18791903 ArrayRef<TypeSourceInfo *> Args,
18801904 SourceLocation RParenLoc,
18811905 bool Value) {
1882- void *Mem = C.Allocate (totalSizeToAlloc<TypeSourceInfo *>(Args.size ()));
1906+ void *Mem =
1907+ C.Allocate (totalSizeToAlloc<APValue, TypeSourceInfo *>(0 , Args.size ()));
1908+ return new (Mem) TypeTraitExpr (T, Loc, Kind, Args, RParenLoc, Value);
1909+ }
1910+
1911+ TypeTraitExpr *TypeTraitExpr::Create (const ASTContext &C, QualType T,
1912+ SourceLocation Loc, TypeTrait Kind,
1913+ ArrayRef<TypeSourceInfo *> Args,
1914+ SourceLocation RParenLoc, APValue Value) {
1915+ void *Mem =
1916+ C.Allocate (totalSizeToAlloc<APValue, TypeSourceInfo *>(1 , Args.size ()));
18831917 return new (Mem) TypeTraitExpr (T, Loc, Kind, Args, RParenLoc, Value);
18841918}
18851919
18861920TypeTraitExpr *TypeTraitExpr::CreateDeserialized (const ASTContext &C,
1921+ bool IsStoredAsBool,
18871922 unsigned NumArgs) {
1888- void *Mem = C.Allocate (totalSizeToAlloc<TypeSourceInfo *>(NumArgs));
1923+ void *Mem = C.Allocate (totalSizeToAlloc<APValue, TypeSourceInfo *>(
1924+ IsStoredAsBool ? 0 : 1 , NumArgs));
18891925 return new (Mem) TypeTraitExpr (EmptyShell ());
18901926}
18911927
0 commit comments