[cfe-commits] r106998 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/Frontend/PCHBitCodes.h lib/AST/ExprCXX.cpp lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp test/PCH/cxx-templates.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jun 28 02:31:57 PDT 2010
Author: akirtzidis
Date: Mon Jun 28 04:31:56 2010
New Revision: 106998
URL: http://llvm.org/viewvc/llvm-project?rev=106998&view=rev
Log:
Support DependentScopeDeclRefExpr for PCH.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
cfe/trunk/test/PCH/cxx-templates.h
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=106998&r1=106997&r2=106998&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Jun 28 04:31:56 2010
@@ -1656,18 +1656,25 @@
SourceLocation NameLoc,
const TemplateArgumentListInfo *TemplateArgs = 0);
+ static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C,
+ unsigned NumTemplateArgs);
+
/// \brief Retrieve the name that this expression refers to.
DeclarationName getDeclName() const { return Name; }
+ void setDeclName(DeclarationName N) { Name = N; }
/// \brief Retrieve the location of the name within the expression.
SourceLocation getLocation() const { return Loc; }
+ void setLocation(SourceLocation L) { Loc = L; }
/// \brief Retrieve the source range of the nested-name-specifier.
SourceRange getQualifierRange() const { return QualifierRange; }
+ void setQualifierRange(SourceRange R) { QualifierRange = R; }
/// \brief Retrieve the nested-name-specifier that qualifies this
/// declaration.
NestedNameSpecifier *getQualifier() const { return Qualifier; }
+ void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
/// Determines whether this lookup had explicit template arguments.
bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; }
@@ -1676,6 +1683,11 @@
// nodes, users are *forbidden* from calling these methods on objects
// without explicit template arguments.
+ ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
+ assert(hasExplicitTemplateArgs());
+ return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1);
+ }
+
/// Gets a reference to the explicit template argument list.
const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
assert(hasExplicitTemplateArgs());
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=106998&r1=106997&r2=106998&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Mon Jun 28 04:31:56 2010
@@ -772,6 +772,7 @@
EXPR_CXX_EXPR_WITH_TEMPORARIES, // CXXExprWithTemporaries
EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr
+ EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr
EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr
EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr
EXPR_CXX_UNRESOLVED_LOOKUP // UnresolvedLookupExpr
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=106998&r1=106997&r2=106998&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Jun 28 04:31:56 2010
@@ -290,6 +290,19 @@
return DRE;
}
+DependentScopeDeclRefExpr *
+DependentScopeDeclRefExpr::CreateEmpty(ASTContext &C,
+ unsigned NumTemplateArgs) {
+ std::size_t size = sizeof(DependentScopeDeclRefExpr);
+ if (NumTemplateArgs)
+ size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs);
+ void *Mem = C.Allocate(size);
+
+ return new (Mem) DependentScopeDeclRefExpr(QualType(), 0, SourceRange(),
+ DeclarationName(),SourceLocation(),
+ NumTemplateArgs != 0);
+}
+
StmtIterator DependentScopeDeclRefExpr::child_begin() {
return child_iterator();
}
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=106998&r1=106997&r2=106998&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Mon Jun 28 04:31:56 2010
@@ -147,6 +147,7 @@
unsigned VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
unsigned VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+ unsigned VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
unsigned VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
unsigned VisitOverloadExpr(OverloadExpr *E);
@@ -1185,6 +1186,26 @@
}
unsigned
+PCHStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
+ VisitExpr(E);
+ unsigned NumExprs = 0;
+
+ unsigned NumTemplateArgs = Record[Idx++];
+ assert((NumTemplateArgs != 0) == E->hasExplicitTemplateArgs() &&
+ "Read wrong record during creation ?");
+ if (E->hasExplicitTemplateArgs())
+ NumExprs
+ = ReadExplicitTemplateArgumentList(E->getExplicitTemplateArgs(),
+ NumTemplateArgs, StmtStack.end());
+
+ E->setDeclName(Reader.ReadDeclarationName(Record, Idx));
+ E->setLocation(Reader.ReadSourceLocation(Record, Idx));
+ E->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
+ E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
+ return NumExprs;
+}
+
+unsigned
PCHStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
VisitExpr(E);
assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
@@ -1635,6 +1656,11 @@
/*NumTemplateArgs=*/Record[PCHStmtReader::NumExprFields]);
break;
+ case pch::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
+ S = DependentScopeDeclRefExpr::CreateEmpty(*Context,
+ /*NumTemplateArgs=*/Record[PCHStmtReader::NumExprFields]);
+ break;
+
case pch::EXPR_CXX_UNRESOLVED_CONSTRUCT:
S = CXXUnresolvedConstructExpr::CreateEmpty(*Context,
/*NumArgs=*/Record[PCHStmtReader::NumExprFields]);
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=106998&r1=106997&r2=106998&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Mon Jun 28 04:31:56 2010
@@ -137,6 +137,7 @@
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+ void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
void VisitOverloadExpr(OverloadExpr *E);
@@ -1104,6 +1105,29 @@
}
void
+PCHStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
+ VisitExpr(E);
+
+ // Don't emit anything here, NumTemplateArgs must be emitted first.
+
+ if (E->hasExplicitTemplateArgs()) {
+ const ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
+ assert(Args.NumTemplateArgs &&
+ "Num of template args was zero! PCH reading will mess up!");
+ Record.push_back(Args.NumTemplateArgs);
+ AddExplicitTemplateArgumentList(Args);
+ } else {
+ Record.push_back(0);
+ }
+
+ Writer.AddDeclarationName(E->getDeclName(), Record);
+ Writer.AddSourceLocation(E->getLocation(), Record);
+ Writer.AddSourceRange(E->getQualifierRange(), Record);
+ Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
+ Code = pch::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
+}
+
+void
PCHStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
VisitExpr(E);
Record.push_back(E->arg_size());
Modified: cfe/trunk/test/PCH/cxx-templates.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.h?rev=106998&r1=106997&r2=106998&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-templates.h (original)
+++ cfe/trunk/test/PCH/cxx-templates.h Mon Jun 28 04:31:56 2010
@@ -51,5 +51,6 @@
template<typename T, typename A1>
inline T make_a(const A1& a1) {
+ T::depend_declref();
return T(a1);
}
More information about the cfe-commits
mailing list