summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclarationName.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-17 20:34:05 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-17 20:34:05 +0000
commitae2fbad373e5fafc2d3a9633b80d12d653605762 (patch)
treea586d9834af1e771d95a5a788ec4ea71ebe084e1 /clang/lib/AST/DeclarationName.cpp
parent4f474b092ed1ce56fe38fffdaf552b78e3b5e43f (diff)
downloadbcm5719-llvm-ae2fbad373e5fafc2d3a9633b80d12d653605762.tar.gz
bcm5719-llvm-ae2fbad373e5fafc2d3a9633b80d12d653605762.zip
Updated IdentifierResolver to deal with DeclarationNames. The names of
C++ constructors, destructors, and conversion functions now have a FETokenInfo field that IdentifierResolver can access, so that these special names are handled just like ordinary identifiers. A few other Sema routines now use DeclarationNames instead of IdentifierInfo*'s. To validate this design, this code also implements parsing and semantic analysis for id-expressions that name conversion functions, e.g., return operator bool(); The new parser action ActOnConversionFunctionExpr takes the result of parsing "operator type-id" and turning it into an expression, using the IdentifierResolver with the DeclarationName of the conversion function. ActOnDeclarator pushes those conversion function names into scope so that the IdentifierResolver can find them, of course. llvm-svn: 59462
Diffstat (limited to 'clang/lib/AST/DeclarationName.cpp')
-rw-r--r--clang/lib/AST/DeclarationName.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp
index 96e194be8c9..4266ef5eaf8 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -25,8 +25,13 @@ namespace clang {
class CXXSpecialName
: public DeclarationNameExtra, public llvm::FoldingSetNode {
public:
+ /// Type - The type associated with this declaration name.
QualType Type;
+ /// FETokenInfo - Extra information associated with this declaration
+ /// name that can be used by the front end.
+ void *FETokenInfo;
+
void Profile(llvm::FoldingSetNodeID &ID) {
ID.AddInteger(ExtraKindOrNumArgs);
ID.AddPointer(Type.getAsOpaquePtr());
@@ -114,6 +119,39 @@ Selector DeclarationName::getObjCSelector() const {
return Selector();
}
+void *DeclarationName::getFETokenInfoAsVoid() const {
+ switch (getNameKind()) {
+ case Identifier:
+ return getAsIdentifierInfo()->getFETokenInfo<void>();
+
+ case CXXConstructorName:
+ case CXXDestructorName:
+ case CXXConversionFunctionName:
+ return getAsCXXSpecialName()->FETokenInfo;
+
+ default:
+ assert(false && "Declaration name has no FETokenInfo");
+ }
+ return 0;
+}
+
+void DeclarationName::setFETokenInfo(void *T) {
+ switch (getNameKind()) {
+ case Identifier:
+ getAsIdentifierInfo()->setFETokenInfo(T);
+ break;
+
+ case CXXConstructorName:
+ case CXXDestructorName:
+ case CXXConversionFunctionName:
+ getAsCXXSpecialName()->FETokenInfo = T;
+ break;
+
+ default:
+ assert(false && "Declaration name has no FETokenInfo");
+ }
+}
+
DeclarationNameTable::DeclarationNameTable() {
CXXSpecialNamesImpl = new llvm::FoldingSet<CXXSpecialName>;
}
@@ -159,6 +197,7 @@ DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
CXXSpecialName *SpecialName = new CXXSpecialName;
SpecialName->ExtraKindOrNumArgs = EKind;
SpecialName->Type = Ty;
+ SpecialName->FETokenInfo = 0;
SpecialNames->InsertNode(SpecialName, InsertPos);
return DeclarationName(SpecialName);
OpenPOWER on IntegriCloud