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

Commit

Permalink
Propagating prior merge from 'llvm.org/master'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Automerger authored and Automerger committed Oct 28, 2016
2 parents 09d77bb + 48a2e9c commit f42c1be
Show file tree
Hide file tree
Showing 29 changed files with 626 additions and 256 deletions.
41 changes: 23 additions & 18 deletions include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,11 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext,
/// skipped.
unsigned HasSkippedBody : 1;

/// Indicates if the function declaration will have a body, once we're done
/// parsing it. (We don't set it to false when we're done parsing, in the
/// hopes this is simpler.)
unsigned WillHaveBody : 1;

/// \brief End part of this FunctionDecl's source range.
///
/// We could compute the full range in getSourceRange(). However, when we're
Expand Down Expand Up @@ -1701,25 +1706,21 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext,

protected:
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
const DeclarationNameInfo &NameInfo,
QualType T, TypeSourceInfo *TInfo,
StorageClass S, bool isInlineSpecified,
const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified,
bool isConstexprSpecified)
: DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
StartLoc),
DeclContext(DK),
redeclarable_base(C),
ParamInfo(nullptr), Body(),
SClass(S),
IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified),
IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false),
IsDefaulted(false), IsExplicitlyDefaulted(false),
HasImplicitReturnZero(false), IsLateTemplateParsed(false),
IsConstexpr(isConstexprSpecified), UsesSEHTry(false),
HasSkippedBody(false), EndRangeLoc(NameInfo.getEndLoc()),
TemplateOrSpecialization(),
DNLoc(NameInfo.getInfo()) {}
: DeclaratorDecl(DK, DC, NameInfo.getLoc(), NameInfo.getName(), T, TInfo,
StartLoc),
DeclContext(DK), redeclarable_base(C), ParamInfo(nullptr), Body(),
SClass(S), IsInline(isInlineSpecified),
IsInlineSpecified(isInlineSpecified), IsVirtualAsWritten(false),
IsPure(false), HasInheritedPrototype(false), HasWrittenPrototype(true),
IsDeleted(false), IsTrivial(false), IsDefaulted(false),
IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
UsesSEHTry(false), HasSkippedBody(false), WillHaveBody(false),
EndRangeLoc(NameInfo.getEndLoc()), TemplateOrSpecialization(),
DNLoc(NameInfo.getInfo()) {}

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

/// True if this function will eventually have a body, once it's fully parsed.
bool willHaveBody() const { return WillHaveBody; }
void setWillHaveBody(bool V = true) { WillHaveBody = V; }

void setPreviousDeclaration(FunctionDecl * PrevDecl);

FunctionDecl *getCanonicalDecl() override;
Expand Down
7 changes: 3 additions & 4 deletions include/clang/AST/DeclCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -2957,11 +2957,10 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl {
dyn_cast<ConstructorUsingShadowDecl>(Target)),
ConstructedBaseClassShadowDecl(NominatedBaseClassShadowDecl),
IsVirtual(TargetInVirtualBase) {
// If we found a constructor for a non-virtual base class, but it chains to
// a constructor for a virtual base, we should directly call the virtual
// base constructor instead.
// If we found a constructor that chains to a constructor for a virtual
// base, we should directly call that virtual base constructor instead.
// FIXME: This logic belongs in Sema.
if (!TargetInVirtualBase && NominatedBaseClassShadowDecl &&
if (NominatedBaseClassShadowDecl &&
NominatedBaseClassShadowDecl->constructsVirtualBase()) {
ConstructedBaseClassShadowDecl =
NominatedBaseClassShadowDecl->ConstructedBaseClassShadowDecl;
Expand Down
6 changes: 6 additions & 0 deletions include/clang/Basic/BuiltinsPPC.def
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ BUILTIN(__builtin_altivec_vctzh, "V8UsV8Us", "")
BUILTIN(__builtin_altivec_vctzw, "V4UiV4Ui", "")
BUILTIN(__builtin_altivec_vctzd, "V2ULLiV2ULLi", "")

BUILTIN(__builtin_altivec_vclzlsbb, "SiV16Uc", "")
BUILTIN(__builtin_altivec_vctzlsbb, "SiV16Uc", "")
BUILTIN(__builtin_altivec_vprtybw, "V4UiV4Ui", "")
BUILTIN(__builtin_altivec_vprtybd, "V2ULLiV2ULLi", "")
BUILTIN(__builtin_altivec_vprtybq, "V1ULLLiV1ULLLi", "")

// Vector population count built-ins
BUILTIN(__builtin_altivec_vpopcntb, "V16UcV16Uc", "")
BUILTIN(__builtin_altivec_vpopcnth, "V8UsV8Us", "")
Expand Down
4 changes: 2 additions & 2 deletions include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -8156,8 +8156,6 @@ def err_atomic_init_constant : Error<
" in the declaration statement in the program scope">;
def err_opencl_implicit_vector_conversion : Error<
"implicit conversions between vector types (%0 and %1) are not permitted">;
def err_opencl_block_proto_variadic : Error<
"invalid block prototype, variadic arguments are not allowed in OpenCL">;
def err_opencl_invalid_type_array : Error<
"array of %0 type is invalid in OpenCL">;
def err_opencl_ternary_with_block : Error<
Expand All @@ -8169,6 +8167,8 @@ def err_opencl_type_can_only_be_used_as_function_parameter : Error <
def warn_opencl_attr_deprecated_ignored : Warning <
"%0 attribute is deprecated and ignored in OpenCL version %1">,
InGroup<IgnoredAttributes>;
def err_opencl_variadic_function : Error<
"invalid prototype, variadic arguments are not allowed in OpenCL">;

// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
def err_opencl_builtin_pipe_first_arg : Error<
Expand Down
2 changes: 1 addition & 1 deletion include/clang/Basic/OpenCLImageTypes.def
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ IMAGE_READ_WRITE_TYPE(image3d, OCLImage3d)
#undef GENERIC_IMAGE_TYPE
#undef IMAGE_READ_TYPE
#undef IMAGE_WRITE_TYPE
#undef IMAGE_READ_WRITE_TYPE
#undef IMAGE_READ_WRITE_TYPE
42 changes: 22 additions & 20 deletions include/clang/Sema/DelayedDiagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class AccessedEntity {
/// the complete parsing of the current declaration.
class DelayedDiagnostic {
public:
enum DDKind { Deprecation, Unavailable, Access, ForbiddenType };
enum DDKind : unsigned char { Availability, Access, ForbiddenType };

unsigned char Kind; // actually a DDKind
DDKind Kind;
bool Triggered;

SourceLocation Loc;
Expand Down Expand Up @@ -164,17 +164,19 @@ class DelayedDiagnostic {
return *reinterpret_cast<const AccessedEntity*>(AccessData);
}

const NamedDecl *getDeprecationDecl() const {
assert((Kind == Deprecation || Kind == Unavailable) &&
"Not a deprecation diagnostic.");
return DeprecationData.Decl;
const NamedDecl *getAvailabilityDecl() const {
assert(Kind == Availability && "Not an availability diagnostic.");
return AvailabilityData.Decl;
}

StringRef getDeprecationMessage() const {
assert((Kind == Deprecation || Kind == Unavailable) &&
"Not a deprecation diagnostic.");
return StringRef(DeprecationData.Message,
DeprecationData.MessageLen);
StringRef getAvailabilityMessage() const {
assert(Kind == Availability && "Not an availability diagnostic.");
return StringRef(AvailabilityData.Message, AvailabilityData.MessageLen);
}

AvailabilityResult getAvailabilityResult() const {
assert(Kind == Availability && "Not an availability diagnostic.");
return AvailabilityData.AR;
}

/// The diagnostic ID to emit. Used like so:
Expand All @@ -195,27 +197,28 @@ class DelayedDiagnostic {
assert(Kind == ForbiddenType && "not a forbidden-type diagnostic");
return QualType::getFromOpaquePtr(ForbiddenTypeData.OperandType);
}

const ObjCInterfaceDecl *getUnknownObjCClass() const {
return DeprecationData.UnknownObjCClass;
return AvailabilityData.UnknownObjCClass;
}

const ObjCPropertyDecl *getObjCProperty() const {
return DeprecationData.ObjCProperty;
return AvailabilityData.ObjCProperty;
}

bool getObjCPropertyAccess() const {
return DeprecationData.ObjCPropertyAccess;
return AvailabilityData.ObjCPropertyAccess;
}

private:

struct DD {
struct AD {
const NamedDecl *Decl;
const ObjCInterfaceDecl *UnknownObjCClass;
const ObjCPropertyDecl *ObjCProperty;
const char *Message;
size_t MessageLen;
AvailabilityResult AR;
bool ObjCPropertyAccess;
};

Expand All @@ -226,8 +229,7 @@ class DelayedDiagnostic {
};

union {
/// Deprecation
struct DD DeprecationData;
struct AD AvailabilityData;
struct FTD ForbiddenTypeData;

/// Access control.
Expand Down
17 changes: 10 additions & 7 deletions lib/AST/ASTDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,9 @@ class TemplateDiff {
++(*this);
}

/// Return true if the iterator is non-singular.
bool isValid() const { return TST; }

/// isEnd - Returns true if the iterator is one past the end.
bool isEnd() const {
assert(TST && "InternalIterator is invalid with a null TST.");
Expand Down Expand Up @@ -995,21 +998,21 @@ class TemplateDiff {
}
};

bool UseDesugaredIterator;
InternalIterator SugaredIterator;
InternalIterator DesugaredIterator;

public:
TSTiterator(ASTContext &Context, const TemplateSpecializationType *TST)
: UseDesugaredIterator(TST->isSugared() && !TST->isTypeAlias()),
SugaredIterator(TST),
: SugaredIterator(TST),
DesugaredIterator(
GetTemplateSpecializationType(Context, TST->desugar())) {}
(TST->isSugared() && !TST->isTypeAlias())
? GetTemplateSpecializationType(Context, TST->desugar())
: nullptr) {}

/// &operator++ - Increment the iterator to the next template argument.
TSTiterator &operator++() {
++SugaredIterator;
if (UseDesugaredIterator)
if (DesugaredIterator.isValid())
++DesugaredIterator;
return *this;
}
Expand All @@ -1032,12 +1035,12 @@ class TemplateDiff {
/// hasDesugaredTA - Returns true if there is another TemplateArgument
/// available.
bool hasDesugaredTA() const {
return UseDesugaredIterator && !DesugaredIterator.isEnd();
return DesugaredIterator.isValid() && !DesugaredIterator.isEnd();
}

/// getDesugaredTA - Returns the desugared TemplateArgument.
reference getDesugaredTA() const {
assert(UseDesugaredIterator &&
assert(DesugaredIterator.isValid() &&
"Desugared TemplateArgument should not be used.");
return *DesugaredIterator;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3048,7 +3048,8 @@ const Attr *FunctionDecl::getUnusedResultAttr() const {
/// an externally visible symbol, but "extern inline" will not create an
/// externally visible symbol.
bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
assert(doesThisDeclarationHaveABody() && "Must have the function definition");
assert(doesThisDeclarationHaveABody() ||
willHaveBody() && "Must be a function definition");
assert(isInlined() && "Function must be inline");
ASTContext &Context = getASTContext();

Expand Down
2 changes: 1 addition & 1 deletion lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
}

if (!Field->hasInClassInitializer() && !Field->isMutable()) {
if (CXXRecordDecl *FieldType = Field->getType()->getAsCXXRecordDecl()) {
if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
data().HasUninitializedFields = true;
} else {
Expand Down
Loading

0 comments on commit f42c1be

Please sign in to comment.