summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.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/Sema/SemaDecl.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/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 48073694a32..ea2a3ad9a75 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -28,7 +28,7 @@
#include "llvm/ADT/StringExtras.h"
using namespace clang;
-Sema::TypeTy *Sema::isTypeName(const IdentifierInfo &II, Scope *S,
+Sema::TypeTy *Sema::isTypeName(IdentifierInfo &II, Scope *S,
const CXXScopeSpec *SS) {
DeclContext *DC = 0;
if (SS) {
@@ -113,7 +113,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) {
// We are pushing the name of a function, which might be an
// overloaded name.
IdentifierResolver::iterator
- I = IdResolver.begin(FD->getIdentifier(),
+ I = IdResolver.begin(FD->getDeclName(),
FD->getDeclContext(), false/*LookInParentCtx*/);
if (I != IdResolver.end() &&
IdResolver.isDeclInScope(*I, FD->getDeclContext(), S) &&
@@ -126,7 +126,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) {
// FunctionDecl and put it into an OverloadedFunctionDecl.
Ovl = OverloadedFunctionDecl::Create(Context,
FD->getDeclContext(),
- FD->getIdentifier());
+ FD->getDeclName());
Ovl->addOverload(dyn_cast<FunctionDecl>(*I));
// Remove the name binding to the existing FunctionDecl...
@@ -187,17 +187,17 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
/// LookupDecl - Look up the inner-most declaration in the specified
/// namespace.
-Decl *Sema::LookupDecl(const IdentifierInfo *II, unsigned NSI, Scope *S,
+Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
const DeclContext *LookupCtx,
bool enableLazyBuiltinCreation) {
- if (II == 0) return 0;
+ if (!Name) return 0;
unsigned NS = NSI;
if (getLangOptions().CPlusPlus && (NS & Decl::IDNS_Ordinary))
NS |= Decl::IDNS_Tag;
IdentifierResolver::iterator
- I = LookupCtx ? IdResolver.begin(II, LookupCtx, false/*LookInParentCtx*/) :
- IdResolver.begin(II, CurContext, true/*LookInParentCtx*/);
+ I = LookupCtx ? IdResolver.begin(Name, LookupCtx, false/*LookInParentCtx*/)
+ : IdResolver.begin(Name, CurContext, true/*LookInParentCtx*/);
// Scan up the scope chain looking for a decl that matches this identifier
// that is in the appropriate namespace. This search should not take long, as
// shadowing of names is uncommon, and deep shadowing is extremely uncommon.
@@ -209,13 +209,14 @@ Decl *Sema::LookupDecl(const IdentifierInfo *II, unsigned NSI, Scope *S,
// corresponds to a compiler builtin, create the decl object for the builtin
// now, injecting it into translation unit scope, and return it.
if (NS & Decl::IDNS_Ordinary) {
- if (enableLazyBuiltinCreation &&
+ IdentifierInfo *II = Name.getAsIdentifierInfo();
+ if (enableLazyBuiltinCreation && II &&
(LookupCtx == 0 || isa<TranslationUnitDecl>(LookupCtx))) {
// If this is a builtin on this (or all) targets, create the decl.
if (unsigned BuiltinID = II->getBuiltinID())
return LazilyCreateBuiltin((IdentifierInfo *)II, BuiltinID, S);
}
- if (getLangOptions().ObjC1) {
+ if (getLangOptions().ObjC1 && II) {
// @interface and @compatibility_alias introduce typedef-like names.
// Unlike typedef's, they can only be introduced at file-scope (and are
// therefore not scoped decls). They can, however, be shadowed by
@@ -1034,8 +1035,11 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
return ActOnConstructorDeclarator(Constructor);
else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(NewFD))
return ActOnDestructorDeclarator(Destructor);
- else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(NewFD))
- return ActOnConversionDeclarator(Conversion);
+
+ // Extra checking for conversion functions, including recording
+ // the conversion function in its class.
+ if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(NewFD))
+ ActOnConversionDeclarator(Conversion);
// Extra checking for C++ overloaded operators (C++ [over.oper]).
if (NewFD->isOverloadedOperator() &&
OpenPOWER on IntegriCloud