return !(LHS == RHS);
}
friend llvm::hash_code hash_value(const LValueBase &Base);
- friend struct llvm::DenseMapInfo<LValueBase>;
private:
PtrTy Ptr;
public:
LValuePathEntry() : Value() {}
- LValuePathEntry(BaseOrMemberType BaseOrMember);
+ LValuePathEntry(BaseOrMemberType BaseOrMember)
+ : Value{reinterpret_cast<uintptr_t>(BaseOrMember.getOpaqueValue())} {}
static LValuePathEntry ArrayIndex(uint64_t Index) {
LValuePathEntry Result;
Result.Value = Index;
"Type is insufficiently aligned");
APValue::LValueBase::LValueBase(const ValueDecl *P, unsigned I, unsigned V)
- : Ptr(P ? cast<ValueDecl>(P->getCanonicalDecl()) : nullptr), Local{I, V} {}
+ : Ptr(P), Local{I, V} {}
APValue::LValueBase::LValueBase(const Expr *P, unsigned I, unsigned V)
: Ptr(P), Local{I, V} {}
const APValue::LValueBase &RHS) {
if (LHS.Ptr != RHS.Ptr)
return false;
- if (LHS.is<TypeInfoLValue>() || LHS.is<DynamicAllocLValue>())
+ if (LHS.is<TypeInfoLValue>())
return true;
return LHS.Local.CallIndex == RHS.Local.CallIndex &&
LHS.Local.Version == RHS.Local.Version;
}
}
-APValue::LValuePathEntry::LValuePathEntry(BaseOrMemberType BaseOrMember) {
- if (const Decl *D = BaseOrMember.getPointer())
- BaseOrMember.setPointer(D->getCanonicalDecl());
- Value = reinterpret_cast<uintptr_t>(BaseOrMember.getOpaqueValue());
-}
-
namespace {
struct LVBase {
APValue::LValueBase Base;
clang::APValue::LValueBase
llvm::DenseMapInfo<clang::APValue::LValueBase>::getEmptyKey() {
- clang::APValue::LValueBase B;
- B.Ptr = DenseMapInfo<const ValueDecl*>::getEmptyKey();
- return B;
+ return clang::APValue::LValueBase(
+ DenseMapInfo<const ValueDecl*>::getEmptyKey());
}
clang::APValue::LValueBase
llvm::DenseMapInfo<clang::APValue::LValueBase>::getTombstoneKey() {
- clang::APValue::LValueBase B;
- B.Ptr = DenseMapInfo<const ValueDecl*>::getTombstoneKey();
- return B;
+ return clang::APValue::LValueBase(
+ DenseMapInfo<const ValueDecl*>::getTombstoneKey());
}
namespace clang {
assert(isAbsent() && "Bad state change");
MemberPointerData *MPD = new ((void*)(char*)Data.buffer) MemberPointerData;
Kind = MemberPointer;
- MPD->MemberAndIsDerivedMember.setPointer(
- Member ? cast<ValueDecl>(Member->getCanonicalDecl()) : nullptr);
+ MPD->MemberAndIsDerivedMember.setPointer(Member);
MPD->MemberAndIsDerivedMember.setInt(IsDerivedMember);
MPD->resizePath(Path.size());
- for (unsigned I = 0; I != Path.size(); ++I)
- MPD->getPath()[I] = Path[I]->getCanonicalDecl();
+ memcpy(MPD->getPath(), Path.data(), Path.size()*sizeof(const CXXRecordDecl*));
}
void ValueDecl::anchor() {}
bool ValueDecl::isWeak() const {
- for (const auto *I : getMostRecentDecl()->attrs())
+ for (const auto *I : attrs())
if (isa<WeakAttr>(I) || isa<WeakRefAttr>(I))
return true;
if (!canBeWeakImported(IsDefinition))
return false;
- for (const auto *A : getMostRecentDecl()->attrs()) {
+ for (const auto *A : attrs()) {
if (isa<WeakImportAttr>(A))
return true;
return false;
if (A.getLValueBase().getOpaqueValue() !=
- B.getLValueBase().getOpaqueValue())
- return false;
+ B.getLValueBase().getOpaqueValue()) {
+ const Decl *ADecl = GetLValueBaseDecl(A);
+ if (!ADecl)
+ return false;
+ const Decl *BDecl = GetLValueBaseDecl(B);
+ if (!BDecl || ADecl->getCanonicalDecl() != BDecl->getCanonicalDecl())
+ return false;
+ }
- return A.getLValueCallIndex() == B.getLValueCallIndex() &&
- A.getLValueVersion() == B.getLValueVersion();
+ return IsGlobalLValue(A.getLValueBase()) ||
+ (A.getLValueCallIndex() == B.getLValueCallIndex() &&
+ A.getLValueVersion() == B.getLValueVersion());
}
static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
// If we're currently evaluating the initializer of this declaration, use that
// in-flight value.
- if (declaresSameEntity(Info.EvaluatingDecl.dyn_cast<const ValueDecl *>(),
- VD)) {
+ if (Info.EvaluatingDecl.dyn_cast<const ValueDecl*>() == VD) {
Result = Info.EvaluatingDeclValue;
return true;
}
constexpr int nc1 = i; // expected-error {{constexpr variable 'nc1' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
constexpr C nc2 = C(); // expected-error {{cannot have non-literal type 'const C'}}
-int &f(); // expected-note 2{{declared here}}
+int &f(); // expected-note {{declared here}}
constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
constexpr int nc4(i); // expected-error {{constexpr variable 'nc4' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
constexpr C nc5((C())); // expected-error {{cannot have non-literal type 'const C'}}
+int &f(); // expected-note {{here}}
constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f'}}
struct pixel {
}
int foo();
-#if __cplusplus >= 201103L
-// expected-note@-2 {{declared here}}
-#endif
template <class T>
T foo() {
int foo() {
#if __cplusplus >= 201103L
-// expected-note@-2 {{declared here}}
+// expected-note@-2 2 {{declared here}}
#endif
int k;
#pragma omp for ordered