Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit f42c1be

Browse files
AutomergerAutomerger
authored andcommitted
Propagating prior merge from 'llvm.org/master'.
2 parents 09d77bb + 48a2e9c commit f42c1be

29 files changed

Lines changed: 626 additions & 256 deletions

include/clang/AST/Decl.h

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,11 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext,
16321632
/// skipped.
16331633
unsigned HasSkippedBody : 1;
16341634

1635+
/// Indicates if the function declaration will have a body, once we're done
1636+
/// parsing it. (We don't set it to false when we're done parsing, in the
1637+
/// hopes this is simpler.)
1638+
unsigned WillHaveBody : 1;
1639+
16351640
/// \brief End part of this FunctionDecl's source range.
16361641
///
16371642
/// We could compute the full range in getSourceRange(). However, when we're
@@ -1701,25 +1706,21 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext,
17011706

17021707
protected:
17031708
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
1704-
const DeclarationNameInfo &NameInfo,
1705-
QualType T, TypeSourceInfo *TInfo,
1706-
StorageClass S, bool isInlineSpecified,
1709+
const DeclarationNameInfo &NameInfo, QualType T,
1710+
TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
17071711
bool isConstexprSpecified)
1708-
: DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
1709-
StartLoc),
1710-
DeclContext(DK),
1711-
redeclarable_base(C),
1712-
ParamInfo(nullptr), Body(),
1713-
SClass(S),
1714-
IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified),
1715-
IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
1716-
HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false),
1717-
IsDefaulted(false), IsExplicitlyDefaulted(false),
1718-
HasImplicitReturnZero(false), IsLateTemplateParsed(false),
1719-
IsConstexpr(isConstexprSpecified), UsesSEHTry(false),
1720-
HasSkippedBody(false), EndRangeLoc(NameInfo.getEndLoc()),
1721-
TemplateOrSpecialization(),
1722-
DNLoc(NameInfo.getInfo()) {}
1712+
: DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
1713+
StartLoc),
1714+
DeclContext(DK), redeclarable_base(C), ParamInfo(nullptr), Body(),
1715+
SClass(S), IsInline(isInlineSpecified),
1716+
IsInlineSpecified(isInlineSpecified), IsVirtualAsWritten(false),
1717+
IsPure(false), HasInheritedPrototype(false), HasWrittenPrototype(true),
1718+
IsDeleted(false), IsTrivial(false), IsDefaulted(false),
1719+
IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
1720+
IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
1721+
UsesSEHTry(false), HasSkippedBody(false), WillHaveBody(false),
1722+
EndRangeLoc(NameInfo.getEndLoc()), TemplateOrSpecialization(),
1723+
DNLoc(NameInfo.getInfo()) {}
17231724

17241725
typedef Redeclarable<FunctionDecl> redeclarable_base;
17251726
FunctionDecl *getNextRedeclarationImpl() override {
@@ -2001,6 +2002,10 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext,
20012002
bool hasSkippedBody() const { return HasSkippedBody; }
20022003
void setHasSkippedBody(bool Skipped = true) { HasSkippedBody = Skipped; }
20032004

2005+
/// True if this function will eventually have a body, once it's fully parsed.
2006+
bool willHaveBody() const { return WillHaveBody; }
2007+
void setWillHaveBody(bool V = true) { WillHaveBody = V; }
2008+
20042009
void setPreviousDeclaration(FunctionDecl * PrevDecl);
20052010

20062011
FunctionDecl *getCanonicalDecl() override;

include/clang/AST/DeclCXX.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,11 +2957,10 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl {
29572957
dyn_cast<ConstructorUsingShadowDecl>(Target)),
29582958
ConstructedBaseClassShadowDecl(NominatedBaseClassShadowDecl),
29592959
IsVirtual(TargetInVirtualBase) {
2960-
// If we found a constructor for a non-virtual base class, but it chains to
2961-
// a constructor for a virtual base, we should directly call the virtual
2962-
// base constructor instead.
2960+
// If we found a constructor that chains to a constructor for a virtual
2961+
// base, we should directly call that virtual base constructor instead.
29632962
// FIXME: This logic belongs in Sema.
2964-
if (!TargetInVirtualBase && NominatedBaseClassShadowDecl &&
2963+
if (NominatedBaseClassShadowDecl &&
29652964
NominatedBaseClassShadowDecl->constructsVirtualBase()) {
29662965
ConstructedBaseClassShadowDecl =
29672966
NominatedBaseClassShadowDecl->ConstructedBaseClassShadowDecl;

include/clang/Basic/BuiltinsPPC.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ BUILTIN(__builtin_altivec_vctzh, "V8UsV8Us", "")
272272
BUILTIN(__builtin_altivec_vctzw, "V4UiV4Ui", "")
273273
BUILTIN(__builtin_altivec_vctzd, "V2ULLiV2ULLi", "")
274274

275+
BUILTIN(__builtin_altivec_vclzlsbb, "SiV16Uc", "")
276+
BUILTIN(__builtin_altivec_vctzlsbb, "SiV16Uc", "")
277+
BUILTIN(__builtin_altivec_vprtybw, "V4UiV4Ui", "")
278+
BUILTIN(__builtin_altivec_vprtybd, "V2ULLiV2ULLi", "")
279+
BUILTIN(__builtin_altivec_vprtybq, "V1ULLLiV1ULLLi", "")
280+
275281
// Vector population count built-ins
276282
BUILTIN(__builtin_altivec_vpopcntb, "V16UcV16Uc", "")
277283
BUILTIN(__builtin_altivec_vpopcnth, "V8UsV8Us", "")

include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8156,8 +8156,6 @@ def err_atomic_init_constant : Error<
81568156
" in the declaration statement in the program scope">;
81578157
def err_opencl_implicit_vector_conversion : Error<
81588158
"implicit conversions between vector types (%0 and %1) are not permitted">;
8159-
def err_opencl_block_proto_variadic : Error<
8160-
"invalid block prototype, variadic arguments are not allowed in OpenCL">;
81618159
def err_opencl_invalid_type_array : Error<
81628160
"array of %0 type is invalid in OpenCL">;
81638161
def err_opencl_ternary_with_block : Error<
@@ -8169,6 +8167,8 @@ def err_opencl_type_can_only_be_used_as_function_parameter : Error <
81698167
def warn_opencl_attr_deprecated_ignored : Warning <
81708168
"%0 attribute is deprecated and ignored in OpenCL version %1">,
81718169
InGroup<IgnoredAttributes>;
8170+
def err_opencl_variadic_function : Error<
8171+
"invalid prototype, variadic arguments are not allowed in OpenCL">;
81728172

81738173
// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
81748174
def err_opencl_builtin_pipe_first_arg : Error<

include/clang/Basic/OpenCLImageTypes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ IMAGE_READ_WRITE_TYPE(image3d, OCLImage3d)
7979
#undef GENERIC_IMAGE_TYPE
8080
#undef IMAGE_READ_TYPE
8181
#undef IMAGE_WRITE_TYPE
82-
#undef IMAGE_READ_WRITE_TYPE
82+
#undef IMAGE_READ_WRITE_TYPE

include/clang/Sema/DelayedDiagnostic.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ class AccessedEntity {
113113
/// the complete parsing of the current declaration.
114114
class DelayedDiagnostic {
115115
public:
116-
enum DDKind { Deprecation, Unavailable, Access, ForbiddenType };
116+
enum DDKind : unsigned char { Availability, Access, ForbiddenType };
117117

118-
unsigned char Kind; // actually a DDKind
118+
DDKind Kind;
119119
bool Triggered;
120120

121121
SourceLocation Loc;
@@ -164,17 +164,19 @@ class DelayedDiagnostic {
164164
return *reinterpret_cast<const AccessedEntity*>(AccessData);
165165
}
166166

167-
const NamedDecl *getDeprecationDecl() const {
168-
assert((Kind == Deprecation || Kind == Unavailable) &&
169-
"Not a deprecation diagnostic.");
170-
return DeprecationData.Decl;
167+
const NamedDecl *getAvailabilityDecl() const {
168+
assert(Kind == Availability && "Not an availability diagnostic.");
169+
return AvailabilityData.Decl;
171170
}
172171

173-
StringRef getDeprecationMessage() const {
174-
assert((Kind == Deprecation || Kind == Unavailable) &&
175-
"Not a deprecation diagnostic.");
176-
return StringRef(DeprecationData.Message,
177-
DeprecationData.MessageLen);
172+
StringRef getAvailabilityMessage() const {
173+
assert(Kind == Availability && "Not an availability diagnostic.");
174+
return StringRef(AvailabilityData.Message, AvailabilityData.MessageLen);
175+
}
176+
177+
AvailabilityResult getAvailabilityResult() const {
178+
assert(Kind == Availability && "Not an availability diagnostic.");
179+
return AvailabilityData.AR;
178180
}
179181

180182
/// The diagnostic ID to emit. Used like so:
@@ -195,27 +197,28 @@ class DelayedDiagnostic {
195197
assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
196198
return QualType::getFromOpaquePtr(ForbiddenTypeData.OperandType);
197199
}
198-
200+
199201
const ObjCInterfaceDecl *getUnknownObjCClass() const {
200-
return DeprecationData.UnknownObjCClass;
202+
return AvailabilityData.UnknownObjCClass;
201203
}
202204

203205
const ObjCPropertyDecl *getObjCProperty() const {
204-
return DeprecationData.ObjCProperty;
206+
return AvailabilityData.ObjCProperty;
205207
}
206-
208+
207209
bool getObjCPropertyAccess() const {
208-
return DeprecationData.ObjCPropertyAccess;
210+
return AvailabilityData.ObjCPropertyAccess;
209211
}
210-
212+
211213
private:
212214

213-
struct DD {
215+
struct AD {
214216
const NamedDecl *Decl;
215217
const ObjCInterfaceDecl *UnknownObjCClass;
216218
const ObjCPropertyDecl *ObjCProperty;
217219
const char *Message;
218220
size_t MessageLen;
221+
AvailabilityResult AR;
219222
bool ObjCPropertyAccess;
220223
};
221224

@@ -226,8 +229,7 @@ class DelayedDiagnostic {
226229
};
227230

228231
union {
229-
/// Deprecation
230-
struct DD DeprecationData;
232+
struct AD AvailabilityData;
231233
struct FTD ForbiddenTypeData;
232234

233235
/// Access control.

lib/AST/ASTDiagnostic.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,9 @@ class TemplateDiff {
936936
++(*this);
937937
}
938938

939+
/// Return true if the iterator is non-singular.
940+
bool isValid() const { return TST; }
941+
939942
/// isEnd - Returns true if the iterator is one past the end.
940943
bool isEnd() const {
941944
assert(TST && "InternalIterator is invalid with a null TST.");
@@ -995,21 +998,21 @@ class TemplateDiff {
995998
}
996999
};
9971000

998-
bool UseDesugaredIterator;
9991001
InternalIterator SugaredIterator;
10001002
InternalIterator DesugaredIterator;
10011003

10021004
public:
10031005
TSTiterator(ASTContext &Context, const TemplateSpecializationType *TST)
1004-
: UseDesugaredIterator(TST->isSugared() && !TST->isTypeAlias()),
1005-
SugaredIterator(TST),
1006+
: SugaredIterator(TST),
10061007
DesugaredIterator(
1007-
GetTemplateSpecializationType(Context, TST->desugar())) {}
1008+
(TST->isSugared() && !TST->isTypeAlias())
1009+
? GetTemplateSpecializationType(Context, TST->desugar())
1010+
: nullptr) {}
10081011

10091012
/// &operator++ - Increment the iterator to the next template argument.
10101013
TSTiterator &operator++() {
10111014
++SugaredIterator;
1012-
if (UseDesugaredIterator)
1015+
if (DesugaredIterator.isValid())
10131016
++DesugaredIterator;
10141017
return *this;
10151018
}
@@ -1032,12 +1035,12 @@ class TemplateDiff {
10321035
/// hasDesugaredTA - Returns true if there is another TemplateArgument
10331036
/// available.
10341037
bool hasDesugaredTA() const {
1035-
return UseDesugaredIterator && !DesugaredIterator.isEnd();
1038+
return DesugaredIterator.isValid() && !DesugaredIterator.isEnd();
10361039
}
10371040

10381041
/// getDesugaredTA - Returns the desugared TemplateArgument.
10391042
reference getDesugaredTA() const {
1040-
assert(UseDesugaredIterator &&
1043+
assert(DesugaredIterator.isValid() &&
10411044
"Desugared TemplateArgument should not be used.");
10421045
return *DesugaredIterator;
10431046
}

lib/AST/Decl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,8 @@ const Attr *FunctionDecl::getUnusedResultAttr() const {
30483048
/// an externally visible symbol, but "extern inline" will not create an
30493049
/// externally visible symbol.
30503050
bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
3051-
assert(doesThisDeclarationHaveABody() && "Must have the function definition");
3051+
assert(doesThisDeclarationHaveABody() ||
3052+
willHaveBody() && "Must be a function definition");
30523053
assert(isInlined() && "Function must be inline");
30533054
ASTContext &Context = getASTContext();
30543055

lib/AST/DeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
739739
}
740740

741741
if (!Field->hasInClassInitializer() && !Field->isMutable()) {
742-
if (CXXRecordDecl *FieldType = Field->getType()->getAsCXXRecordDecl()) {
742+
if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
743743
if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
744744
data().HasUninitializedFields = true;
745745
} else {

0 commit comments

Comments
 (0)