aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-15 02:19:31 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-15 02:19:31 +0000
commit4bb64e77dd3b22070e28b7f9ff99feb576eaf6ef (patch)
tree16f3627f41569fc6b55b89c3072e71d6c111ef33 /lib/Sema/SemaLookup.cpp
parent293b4af04ca37576d4b228adf09acd6cee3ddb16 (diff)
Deallocate the BasePaths structure that we allocate for LookupResult.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r--lib/Sema/SemaLookup.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index b85824382b..cc9a36ced2 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -127,6 +127,15 @@ bool Sema::LookupCriteria::isLookupResult(Decl *D) const {
return false;
}
+/// @brief Moves the name-lookup results from Other to the
+/// newly-constructed LookupResult.
+Sema::LookupResult::LookupResult(const LookupResult& Other)
+ : StoredKind(Other.StoredKind), First(Other.First), Last(Other.Last),
+ Context(Other.Context) {
+ Other.StoredKind = Dead;
+}
+
+/// @brief Moves the name-lookup results from Other to this LookupResult.
Sema::LookupResult::LookupResult(ASTContext &Context,
IdentifierResolver::iterator F,
IdentifierResolver::iterator L)
@@ -167,6 +176,25 @@ Sema::LookupResult::LookupResult(ASTContext &Context,
Last = 0;
}
+Sema::LookupResult::~LookupResult() {
+ if (StoredKind == AmbiguousLookup)
+ delete getBasePaths();
+}
+
+Sema::LookupResult& Sema::LookupResult::operator=(const LookupResult& Other) {
+ if (StoredKind == AmbiguousLookup)
+ delete getBasePaths();
+
+ StoredKind = Other.StoredKind;
+ First = Other.First;
+ Last = Other.Last;
+ Context = Other.Context;
+
+ Other.StoredKind = Dead;
+ return *this;
+}
+
+
/// @brief Determine the result of name lookup.
Sema::LookupResult::LookupKind Sema::LookupResult::getKind() const {
switch (StoredKind) {
@@ -179,6 +207,10 @@ Sema::LookupResult::LookupKind Sema::LookupResult::getKind() const {
case AmbiguousLookup:
return Last? AmbiguousBaseSubobjectTypes : AmbiguousBaseSubobjects;
+
+ case Dead:
+ assert(false && "Attempt to look at a dead LookupResult");
+ break;
}
// We can't ever get here.
@@ -217,6 +249,9 @@ Decl *Sema::LookupResult::getAsDecl() const {
assert(false &&
"Name lookup returned an ambiguity that could not be handled");
break;
+
+ case Dead:
+ assert(false && "Attempt to look at a dead LookupResult");
}
return 0;