aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCXXScopeSpec.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-09-09 15:08:12 +0000
committerMike Stump <mrs@apple.com>2009-09-09 15:08:12 +0000
commit1eb4433ac451dc16f4133a88af2d002ac26c58ef (patch)
tree07065b80cb7787bb7b9ffcb985196007a57e86f7 /lib/Sema/SemaCXXScopeSpec.cpp
parent79d39f92590cf2e91bf81486b02cd1156d13ca54 (diff)
Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r--lib/Sema/SemaCXXScopeSpec.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp
index fb6c88ebc4..759b56ced2 100644
--- a/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/lib/Sema/SemaCXXScopeSpec.cpp
@@ -26,13 +26,13 @@ using namespace clang;
///
/// \param T the type for which we are attempting to find a DeclContext.
///
-/// \returns the declaration context represented by the type T,
+/// \returns the declaration context represented by the type T,
/// or NULL if the declaration context cannot be computed (e.g., because it is
/// dependent and not the current instantiation).
DeclContext *Sema::computeDeclContext(QualType T) {
if (const TagType *Tag = T->getAs<TagType>())
return Tag->getDecl();
-
+
return 0;
}
@@ -54,21 +54,21 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
if (!SS.isSet() || SS.isInvalid())
return 0;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
if (NNS->isDependent()) {
// If this nested-name-specifier refers to the current
// instantiation, return its DeclContext.
if (CXXRecordDecl *Record = getCurrentInstantiationOf(NNS))
return Record;
-
+
if (EnteringContext) {
if (const TemplateSpecializationType *SpecType
= dyn_cast_or_null<TemplateSpecializationType>(NNS->getAsType())) {
// We are entering the context of the nested name specifier, so try to
// match the nested name specifier to either a primary class template
// or a class template partial specialization.
- if (ClassTemplateDecl *ClassTemplate
+ if (ClassTemplateDecl *ClassTemplate
= dyn_cast_or_null<ClassTemplateDecl>(
SpecType->getTemplateName().getAsTemplateDecl())) {
QualType ContextType
@@ -80,7 +80,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
QualType Injected = ClassTemplate->getInjectedClassNameType(Context);
if (Context.hasSameType(Injected, ContextType))
return ClassTemplate->getTemplatedDecl();
-
+
// If the type of the nested name specifier is the same as the
// type of one of the class template's class template partial
// specializations, we're entering into the definition of that
@@ -89,13 +89,13 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
= ClassTemplate->findPartialSpecialization(ContextType))
return PartialSpec;
}
- } else if (const RecordType *RecordT
+ } else if (const RecordType *RecordT
= dyn_cast_or_null<RecordType>(NNS->getAsType())) {
// The nested name specifier refers to a member of a class template.
return RecordT->getDecl();
}
}
-
+
return 0;
}
@@ -126,7 +126,7 @@ bool Sema::isDependentScopeSpecifier(const CXXScopeSpec &SS) {
if (!SS.isSet() || SS.isInvalid())
return false;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return NNS->isDependent();
}
@@ -138,7 +138,7 @@ bool Sema::isUnknownSpecialization(const CXXScopeSpec &SS) {
if (!isDependentScopeSpecifier(SS))
return false;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return getCurrentInstantiationOf(NNS) == 0;
}
@@ -154,7 +154,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
if (!NNS->getAsType())
return 0;
-
+
QualType T = QualType(NNS->getAsType(), 0);
// If the nested name specifier does not refer to a type, then it
// does not refer to the current instantiation.
@@ -174,7 +174,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
if (!Record)
continue;
- // If this record type is not dependent,
+ // If this record type is not dependent,
if (!Record->isDependentType())
return 0;
@@ -192,13 +192,13 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
// enclosed in <>,
// -- in the definition of a nested class of a class template,
// the name of the nested class referenced as a member of
- // the current instantiation, or
+ // the current instantiation, or
// -- in the definition of a partial specialization, the name
// of the class template followed by the template argument
// list of the partial specialization enclosed in <>. If
// the nth template parameter is a parameter pack, the nth
// template argument is a pack expansion (14.6.3) whose
- // pattern is the name of the parameter pack.
+ // pattern is the name of the parameter pack.
// (FIXME: parameter packs)
//
// All of these options come down to having the
@@ -207,9 +207,9 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
// our context.
if (Context.getCanonicalType(Context.getTypeDeclType(Record)) == T)
return Record;
-
+
if (ClassTemplateDecl *Template = Record->getDescribedClassTemplate()) {
- QualType InjectedClassName
+ QualType InjectedClassName
= Template->getInjectedClassNameType(Context);
if (T == Context.getCanonicalType(InjectedClassName))
return Template->getTemplatedDecl();
@@ -232,7 +232,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) {
if (!SS.isSet() || SS.isInvalid())
return false;
-
+
DeclContext *DC = computeDeclContext(SS, true);
if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
// If we're currently defining this type, then lookup into the
@@ -263,14 +263,14 @@ Sema::CXXScopeTy *Sema::ActOnCXXGlobalScopeSpecifier(Scope *S,
bool isAcceptableNestedNameSpecifier(ASTContext &Context, NamedDecl *SD) {
if (!SD)
return false;
-
+
// Namespace and namespace aliases are fine.
if (isa<NamespaceDecl>(SD) || isa<NamespaceAliasDecl>(SD))
return true;
-
+
if (!isa<TypeDecl>(SD))
return false;
-
+
// Determine whether we have a class (or, in C++0x, an enum) or
// a typedef thereof. If so, build the nested-name-specifier.
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
@@ -278,10 +278,10 @@ bool isAcceptableNestedNameSpecifier(ASTContext &Context, NamedDecl *SD) {
return true;
else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(SD)) {
if (TD->getUnderlyingType()->isRecordType() ||
- (Context.getLangOptions().CPlusPlus0x &&
+ (Context.getLangOptions().CPlusPlus0x &&
TD->getUnderlyingType()->isEnumeralType()))
return true;
- } else if (isa<RecordDecl>(SD) ||
+ } else if (isa<RecordDecl>(SD) ||
(Context.getLangOptions().CPlusPlus0x && isa<EnumDecl>(SD)))
return true;
@@ -289,27 +289,27 @@ bool isAcceptableNestedNameSpecifier(ASTContext &Context, NamedDecl *SD) {
}
/// \brief If the given nested-name-specifier begins with a bare identifier
-/// (e.g., Base::), perform name lookup for that identifier as a
+/// (e.g., Base::), perform name lookup for that identifier as a
/// nested-name-specifier within the given scope, and return the result of that
/// name lookup.
NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) {
if (!S || !NNS)
return 0;
-
+
while (NNS->getPrefix())
NNS = NNS->getPrefix();
-
+
if (NNS->getKind() != NestedNameSpecifier::Identifier)
return 0;
-
- LookupResult Found
+
+ LookupResult Found
= LookupName(S, NNS->getAsIdentifier(), LookupNestedNameSpecifierName);
assert(!Found.isAmbiguous() && "Cannot handle ambiguities here yet");
NamedDecl *Result = Found;
if (isAcceptableNestedNameSpecifier(Context, Result))
return Result;
-
+
return 0;
}
@@ -328,9 +328,9 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
QualType ObjectType,
NamedDecl *ScopeLookupResult,
bool EnteringContext) {
- NestedNameSpecifier *Prefix
+ NestedNameSpecifier *Prefix
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
-
+
// Determine where to perform name lookup
DeclContext *LookupCtx = 0;
bool isDependent = false;
@@ -346,70 +346,70 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
LookupCtx = computeDeclContext(SS, EnteringContext);
isDependent = isDependentScopeSpecifier(SS);
}
-
+
LookupResult Found;
bool ObjectTypeSearchedInScope = false;
if (LookupCtx) {
- // Perform "qualified" name lookup into the declaration context we
+ // Perform "qualified" name lookup into the declaration context we
// computed, which is either the type of the base of a member access
- // expression or the declaration context associated with a prior
+ // expression or the declaration context associated with a prior
// nested-name-specifier.
-
+
// The declaration context must be complete.
if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(SS))
return 0;
-
+
Found = LookupQualifiedName(LookupCtx, &II, LookupNestedNameSpecifierName,
false);
-
+
if (!ObjectType.isNull() && Found.getKind() == LookupResult::NotFound) {
// C++ [basic.lookup.classref]p4:
// If the id-expression in a class member access is a qualified-id of
- // the form
+ // the form
//
// class-name-or-namespace-name::...
//
- // the class-name-or-namespace-name following the . or -> operator is
- // looked up both in the context of the entire postfix-expression and in
+ // the class-name-or-namespace-name following the . or -> operator is
+ // looked up both in the context of the entire postfix-expression and in
// the scope of the class of the object expression. If the name is found
- // only in the scope of the class of the object expression, the name
- // shall refer to a class-name. If the name is found only in the
+ // only in the scope of the class of the object expression, the name
+ // shall refer to a class-name. If the name is found only in the
// context of the entire postfix-expression, the name shall refer to a
// class-name or namespace-name. [...]
//
// Qualified name lookup into a class will not find a namespace-name,
- // so we do not need to diagnoste that case specifically. However,
+ // so we do not need to diagnoste that case specifically. However,
// this qualified name lookup may find nothing. In that case, perform
- // unqualified name lookup in the given scope (if available) or
+ // unqualified name lookup in the given scope (if available) or
// reconstruct the result from when name lookup was performed at template
// definition time.
if (S)
Found = LookupName(S, &II, LookupNestedNameSpecifierName);
else
Found = LookupResult::CreateLookupResult(Context, ScopeLookupResult);
-
+
ObjectTypeSearchedInScope = true;
}
} else if (isDependent) {
// We were not able to compute the declaration context for a dependent
- // base object type or prior nested-name-specifier, so this
+ // base object type or prior nested-name-specifier, so this
// nested-name-specifier refers to an unknown specialization. Just build
// a dependent nested-name-specifier.
if (!Prefix)
return NestedNameSpecifier::Create(Context, &II);
-
+
return NestedNameSpecifier::Create(Context, Prefix, &II);
} else {
// Perform unqualified name lookup in the current scope.
Found = LookupName(S, &II, LookupNestedNameSpecifierName);
}
-
+
// FIXME: Deal with ambiguities cleanly.
NamedDecl *SD = Found;
if (isAcceptableNestedNameSpecifier(Context, SD)) {
if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) {
// C++ [basic.lookup.classref]p4:
- // [...] If the name is found in both contexts, the
+ // [...] If the name is found in both contexts, the
// class-name-or-namespace-name shall refer to the same entity.
//
// We already found the name in the scope of the object. Now, look
@@ -420,9 +420,9 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
if (S)
FoundOuter = LookupName(S, &II, LookupNestedNameSpecifierName);
else
- FoundOuter = LookupResult::CreateLookupResult(Context,
+ FoundOuter = LookupResult::CreateLookupResult(Context,
ScopeLookupResult);
-
+
// FIXME: Handle ambiguities in FoundOuter!
NamedDecl *OuterDecl = FoundOuter;
if (isAcceptableNestedNameSpecifier(Context, OuterDecl) &&
@@ -436,50 +436,50 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
Diag(SD->getLocation(), diag::note_ambig_member_ref_object_type)
<< ObjectType;
Diag(OuterDecl->getLocation(), diag::note_ambig_member_ref_scope);
-
+
// Fall through so that we'll pick the name we found in the object type,
// since that's probably what the user wanted anyway.
}
}
-
+
if (NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(SD))
return NestedNameSpecifier::Create(Context, Prefix, Namespace);
-
+
// FIXME: It would be nice to maintain the namespace alias name, then
// see through that alias when resolving the nested-name-specifier down to
// a declaration context.
if (NamespaceAliasDecl *Alias = dyn_cast<NamespaceAliasDecl>(SD))
return NestedNameSpecifier::Create(Context, Prefix,
-
+
Alias->getNamespace());
-
+
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
return NestedNameSpecifier::Create(Context, Prefix, false,
T.getTypePtr());
}
-
+
// If we didn't find anything during our lookup, try again with
// ordinary name lookup, which can help us produce better error
// messages.
if (!SD)
SD = LookupName(S, &II, LookupOrdinaryName);
-
+
unsigned DiagID;
if (SD)
DiagID = diag::err_expected_class_or_namespace;
else if (SS.isSet()) {
- DiagnoseMissingMember(IdLoc, DeclarationName(&II),
- (NestedNameSpecifier *)SS.getScopeRep(),
+ DiagnoseMissingMember(IdLoc, DeclarationName(&II),
+ (NestedNameSpecifier *)SS.getScopeRep(),
SS.getRange());
return 0;
} else
DiagID = diag::err_undeclared_var_use;
-
+
if (SS.isSet())
Diag(IdLoc, DiagID) << &II << SS.getRange();
else
Diag(IdLoc, DiagID) << &II;
-
+
return 0;
}
@@ -496,7 +496,7 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
IdentifierInfo &II,
TypeTy *ObjectTypePtr,
bool EnteringContext) {
- return BuildCXXNestedNameSpecifier(S, SS, IdLoc, CCLoc, II,
+ return BuildCXXNestedNameSpecifier(S, SS, IdLoc, CCLoc, II,
QualType::getFromOpaquePtr(ObjectTypePtr),
/*ScopeLookupResult=*/0, EnteringContext);
}
@@ -506,7 +506,7 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
TypeTy *Ty,
SourceRange TypeRange,
SourceLocation CCLoc) {
- NestedNameSpecifier *Prefix
+ NestedNameSpecifier *Prefix
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
QualType T = GetTypeFromParser(Ty);
return NestedNameSpecifier::Create(Context, Prefix, /*FIXME:*/false,