aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-19 03:51:16 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-19 03:51:16 +0000
commitbad351822117eaf280081494e3dbe4a06c0dbfcf (patch)
treee0207c1035354d16bc45f24a333aeefdecb584be /lib/AST/ExprCXX.cpp
parent6d898e8cf2b6dced49237b47cce57e3c6c4c431f (diff)
Generalize printing of nested-name-specifier sequences for use in both
QualifiedNameType and QualifiedDeclRefExpr. We now keep track of the exact nested-name-specifier spelling for a QualifiedDeclRefExpr, and use that spelling when printing ASTs. This fixes PR3493. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprCXX.cpp')
-rw-r--r--lib/AST/ExprCXX.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 1d4a3ba3a6..f18a288847 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -24,6 +24,31 @@ void CXXConditionDeclExpr::Destroy(ASTContext& C) {
C.Deallocate(this);
}
+QualifiedDeclRefExpr::QualifiedDeclRefExpr(NamedDecl *d, QualType t,
+ SourceLocation l, bool TD,
+ bool VD, SourceRange R,
+ const NestedNameSpecifier *Components,
+ unsigned NumComponents)
+ : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD),
+ QualifierRange(R), NumComponents(NumComponents) {
+ NestedNameSpecifier *Data
+ = reinterpret_cast<NestedNameSpecifier *>(this + 1);
+ for (unsigned I = 0; I < NumComponents; ++I)
+ Data[I] = Components[I];
+}
+
+QualifiedDeclRefExpr *
+QualifiedDeclRefExpr::Create(ASTContext &Context, NamedDecl *d, QualType t,
+ SourceLocation l, bool TD,
+ bool VD, SourceRange R,
+ const NestedNameSpecifier *Components,
+ unsigned NumComponents) {
+ void *Mem = Context.Allocate((sizeof(QualifiedDeclRefExpr) +
+ sizeof(NestedNameSpecifier) * NumComponents));
+ return new (Mem) QualifiedDeclRefExpr(d, t, l, TD, VD, R, Components,
+ NumComponents);
+}
+
//===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===//