[cfe-commits] r106832 - 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
Fri Jun 25 02:03:34 PDT 2010
Author: akirtzidis
Date: Fri Jun 25 04:03:34 2010
New Revision: 106832
URL: http://llvm.org/viewvc/llvm-project?rev=106832&view=rev
Log:
Support UnresolvedLookupExpr 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=106832&r1=106831&r2=106832&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Jun 25 04:03:34 2010
@@ -1497,6 +1497,11 @@
RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
{}
+ UnresolvedLookupExpr(EmptyShell Empty)
+ : OverloadExpr(UnresolvedLookupExprClass, Empty),
+ RequiresADL(false), Overloaded(false), NamingClass(0)
+ {}
+
public:
static UnresolvedLookupExpr *Create(ASTContext &C,
bool Dependent,
@@ -1528,17 +1533,23 @@
UnresolvedSetIterator Begin,
UnresolvedSetIterator End);
+ static UnresolvedLookupExpr *CreateEmpty(ASTContext &C,
+ unsigned NumTemplateArgs);
+
/// True if this declaration should be extended by
/// argument-dependent lookup.
bool requiresADL() const { return RequiresADL; }
+ void setRequiresADL(bool V) { RequiresADL = V; }
/// True if this lookup is overloaded.
bool isOverloaded() const { return Overloaded; }
+ void setOverloaded(bool V) { Overloaded = V; }
/// Gets the 'naming class' (in the sense of C++0x
/// [class.access.base]p5) of the lookup. This is the scope
/// that was looked in to find these results.
CXXRecordDecl *getNamingClass() const { return NamingClass; }
+ void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
// Note that, inconsistently with the explicit-template-argument AST
// nodes, users are *forbidden* from calling these methods on objects
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=106832&r1=106831&r2=106832&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Fri Jun 25 04:03:34 2010
@@ -771,7 +771,8 @@
EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr
EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr
- EXPR_CXX_UNRESOLVED_MEMBER // UnresolvedMemberExpr
+ EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr
+ EXPR_CXX_UNRESOLVED_LOOKUP // UnresolvedLookupExpr
};
/// \brief The kinds of designators that can occur in a
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=106832&r1=106831&r2=106832&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Fri Jun 25 04:03:34 2010
@@ -190,6 +190,18 @@
return ULE;
}
+UnresolvedLookupExpr *
+UnresolvedLookupExpr::CreateEmpty(ASTContext &C, unsigned NumTemplateArgs) {
+ std::size_t size = sizeof(UnresolvedLookupExpr);
+ if (NumTemplateArgs != 0)
+ size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs);
+
+ void *Mem = C.Allocate(size, llvm::alignof<UnresolvedLookupExpr>());
+ UnresolvedLookupExpr *E = new (Mem) UnresolvedLookupExpr(EmptyShell());
+ E->HasExplicitTemplateArgs = NumTemplateArgs != 0;
+ return E;
+}
+
OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C, QualType T,
bool Dependent, NestedNameSpecifier *Qualifier,
SourceRange QRange, DeclarationName Name,
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=106832&r1=106831&r2=106832&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Fri Jun 25 04:03:34 2010
@@ -143,6 +143,7 @@
unsigned VisitOverloadExpr(OverloadExpr *E);
unsigned VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
+ unsigned VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
};
}
@@ -1205,6 +1206,14 @@
return 1;
}
+unsigned PCHStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+ VisitOverloadExpr(E);
+ E->setRequiresADL(Record[Idx++]);
+ E->setOverloaded(Record[Idx++]);
+ E->setNamingClass(cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])));
+ return 0;
+}
+
// Within the bitstream, expressions are stored in Reverse Polish
// Notation, with each of the subexpressions preceding the
@@ -1602,6 +1611,11 @@
S = UnresolvedMemberExpr::CreateEmpty(*Context,
/*NumTemplateArgs=*/Record[PCHStmtReader::NumExprFields]);
break;
+
+ case pch::EXPR_CXX_UNRESOLVED_LOOKUP:
+ S = UnresolvedLookupExpr::CreateEmpty(*Context,
+ /*NumTemplateArgs=*/Record[PCHStmtReader::NumExprFields]);
+ break;
}
// We hit a STMT_STOP, so we're done with this expression.
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=106832&r1=106831&r2=106832&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Fri Jun 25 04:03:34 2010
@@ -138,6 +138,7 @@
void VisitOverloadExpr(OverloadExpr *E);
void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
+ void VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
};
}
@@ -1108,6 +1109,14 @@
Code = pch::EXPR_CXX_UNRESOLVED_MEMBER;
}
+void PCHStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+ VisitOverloadExpr(E);
+ Record.push_back(E->requiresADL());
+ Record.push_back(E->isOverloaded());
+ Writer.AddDeclRef(E->getNamingClass(), Record);
+ Code = pch::EXPR_CXX_UNRESOLVED_LOOKUP;
+}
+
//===----------------------------------------------------------------------===//
// PCHWriter Implementation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/test/PCH/cxx-templates.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.h?rev=106832&r1=106831&r2=106832&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-templates.h (original)
+++ cfe/trunk/test/PCH/cxx-templates.h Fri Jun 25 04:03:34 2010
@@ -20,6 +20,16 @@
return x;
}
+void govl(int);
+void govl(char);
+
+template <typename T>
+struct Unresolv {
+ void f() {
+ govl(T());
+ }
+};
+
template <typename T>
struct Dep {
typedef typename T::type Ty;
More information about the cfe-commits
mailing list