[cfe-commits] r80337 - in /cfe/trunk/lib/Sema: Sema.h SemaDeclCXX.cpp
Anders Carlsson
andersca at mac.com
Thu Aug 27 22:40:36 PDT 2009
Author: andersca
Date: Fri Aug 28 00:40:36 2009
New Revision: 80337
URL: http://llvm.org/viewvc/llvm-project?rev=80337&view=rev
Log:
Factor declaration building out to Sema::BuildUsingDeclaration.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=80337&r1=80336&r2=80337&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Fri Aug 28 00:40:36 2009
@@ -1738,14 +1738,21 @@
SourceLocation IdentLoc,
IdentifierInfo *Ident);
+ NamedDecl *BuildUsingDeclaration(SourceLocation UsingLoc,
+ const CXXScopeSpec &SS,
+ SourceLocation IdentLoc,
+ DeclarationName Name,
+ AttributeList *AttrList,
+ bool IsTypeName);
+
virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
- SourceLocation UsingLoc,
- const CXXScopeSpec &SS,
- SourceLocation IdentLoc,
- IdentifierInfo *TargetName,
- OverloadedOperatorKind Op,
- AttributeList *AttrList,
- bool IsTypeName);
+ SourceLocation UsingLoc,
+ const CXXScopeSpec &SS,
+ SourceLocation IdentLoc,
+ IdentifierInfo *TargetName,
+ OverloadedOperatorKind Op,
+ AttributeList *AttrList,
+ bool IsTypeName);
/// AddCXXDirectInitializerToDecl - This action is called immediately after
/// ActOnDeclarator, when a C++ direct initializer is present.
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=80337&r1=80336&r2=80337&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Aug 28 00:40:36 2009
@@ -2101,29 +2101,42 @@
OverloadedOperatorKind Op,
AttributeList *AttrList,
bool IsTypeName) {
- assert(!SS.isInvalid() && "Invalid CXXScopeSpec.");
assert((TargetName || Op) && "Invalid TargetName.");
- assert(IdentLoc.isValid() && "Invalid TargetName location.");
assert(S->getFlags() & Scope::DeclScope && "Invalid Scope.");
-
- UsingDecl *UsingAlias = 0;
-
+
DeclarationName Name;
if (TargetName)
Name = TargetName;
else
Name = Context.DeclarationNames.getCXXOperatorName(Op);
+
+ NamedDecl *UD = BuildUsingDeclaration(UsingLoc, SS, IdentLoc,
+ Name, AttrList, IsTypeName);
+ if (UD)
+ PushOnScopeChains(UD, S);
+
+ return DeclPtrTy::make(UD);
+}
+
+NamedDecl *Sema::BuildUsingDeclaration(SourceLocation UsingLoc,
+ const CXXScopeSpec &SS,
+ SourceLocation IdentLoc,
+ DeclarationName Name,
+ AttributeList *AttrList,
+ bool IsTypeName) {
+ assert(!SS.isInvalid() && "Invalid CXXScopeSpec.");
+ assert(IdentLoc.isValid() && "Invalid TargetName location.");
// FIXME: Implement this properly!
if (isUnknownSpecialization(SS)) {
Diag(IdentLoc, diag::err_using_dependent_unsupported);
delete AttrList;
- return DeclPtrTy();
+ return 0;
}
if (SS.isEmpty()) {
Diag(IdentLoc, diag::err_using_requires_qualname);
- return DeclPtrTy();
+ return 0;
}
NestedNameSpecifier *NNS =
@@ -2143,7 +2156,7 @@
Diag(SS.getRange().getBegin(),
diag::err_using_decl_nested_name_specifier_is_not_a_base_class)
<< NNS << RD->getDeclName();
- return DeclPtrTy();
+ return 0;
}
LookupContext = cast<RecordType>(Ty)->getDecl();
@@ -2153,7 +2166,7 @@
if (NNS->getKind() == NestedNameSpecifier::TypeSpec) {
Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_class_member)
<< SS.getRange();
- return DeclPtrTy();
+ return 0;
}
// C++0x N2914 [namespace.udecl]p9:
@@ -2171,14 +2184,14 @@
if (!R) {
Diag(IdentLoc, diag::err_typecheck_no_member) << Name << SS.getRange();
- return DeclPtrTy();
+ return 0;
}
NamedDecl *ND = R.getAsDecl();
if (IsTypeName && !isa<TypeDecl>(ND)) {
Diag(IdentLoc, diag::err_using_typename_non_type);
- return DeclPtrTy();
+ return 0;
}
// C++0x N2914 [namespace.udecl]p6:
@@ -2186,17 +2199,14 @@
if (isa<NamespaceDecl>(ND)) {
Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
<< SS.getRange();
- return DeclPtrTy();
+ return 0;
}
- UsingAlias =
- UsingDecl::Create(Context, CurContext, IdentLoc, SS.getRange(),
- ND->getLocation(), UsingLoc, ND, NNS, IsTypeName);
- PushOnScopeChains(UsingAlias, S);
-
// FIXME: We ignore attributes for now.
delete AttrList;
- return DeclPtrTy::make(UsingAlias);
+
+ return UsingDecl::Create(Context, CurContext, IdentLoc, SS.getRange(),
+ ND->getLocation(), UsingLoc, ND, NNS, IsTypeName);
}
/// getNamespaceDecl - Returns the namespace a decl represents. If the decl
More information about the cfe-commits
mailing list