diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-02-24 00:17:56 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-02-24 00:17:56 +0000 |
| commit | 90c9972fb2c388ad319b63ee43d82c81aca07e20 (patch) | |
| tree | 139d7bf33df51ae0d1d2cb3c04e130ea3e6d1b2a /clang/lib/Sema/DeclSpec.cpp | |
| parent | 60ed89dc549bf6b131c56d979d35e1debd6e3509 (diff) | |
| download | bcm5719-llvm-90c9972fb2c388ad319b63ee43d82c81aca07e20.tar.gz bcm5719-llvm-90c9972fb2c388ad319b63ee43d82c81aca07e20.zip | |
Teach CXXScopeSpec to handle the extension of a nested-name-specifier
with another component in the nested-name-specifiers, updating its
representation (a NestedNameSpecifier) and source-location information
(currently a SourceRange) simultaneously. This is groundwork for
adding source-location information to nested-name-specifiers.
llvm-svn: 126346
Diffstat (limited to 'clang/lib/Sema/DeclSpec.cpp')
| -rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index bc289ec42c9..39984974bfd 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -14,6 +14,8 @@ #include "clang/Parse/ParseDiagnostic.h" // FIXME: remove this back-dependency! #include "clang/Sema/DeclSpec.h" #include "clang/Sema/ParsedTemplate.h" +#include "clang/AST/NestedNameSpecifier.h" +#include "clang/AST/TypeLoc.h" #include "clang/Lex/Preprocessor.h" #include "clang/Basic/LangOptions.h" #include "llvm/ADT/STLExtras.h" @@ -44,6 +46,41 @@ void UnqualifiedId::setConstructorTemplateId(TemplateIdAnnotation *TemplateId) { EndLocation = TemplateId->RAngleLoc; } +void CXXScopeSpec::Extend(ASTContext &Context, SourceLocation TemplateKWLoc, + TypeLoc TL, SourceLocation ColonColonLoc) { + ScopeRep = NestedNameSpecifier::Create(Context, ScopeRep, + TemplateKWLoc.isValid(), + TL.getTypePtr()); + if (Range.getBegin().isInvalid()) + Range.setBegin(TL.getBeginLoc()); + Range.setEnd(ColonColonLoc); +} + +void CXXScopeSpec::Extend(ASTContext &Context, IdentifierInfo *Identifier, + SourceLocation IdentifierLoc, + SourceLocation ColonColonLoc) { + ScopeRep = NestedNameSpecifier::Create(Context, ScopeRep, Identifier); + if (Range.getBegin().isInvalid()) + Range.setBegin(IdentifierLoc); + Range.setEnd(ColonColonLoc); +} + +void CXXScopeSpec::Extend(ASTContext &Context, NamespaceDecl *Namespace, + SourceLocation NamespaceLoc, + SourceLocation ColonColonLoc) { + ScopeRep = NestedNameSpecifier::Create(Context, ScopeRep, Namespace); + if (Range.getBegin().isInvalid()) + Range.setBegin(NamespaceLoc); + Range.setEnd(ColonColonLoc); +} + +void CXXScopeSpec::MakeGlobal(ASTContext &Context, + SourceLocation ColonColonLoc) { + assert(!ScopeRep && "Already have a nested-name-specifier!?"); + ScopeRep = NestedNameSpecifier::GlobalSpecifier(Context); + Range = SourceRange(ColonColonLoc); +} + /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function. /// "TheDeclarator" is the declarator that this will be added to. DeclaratorChunk DeclaratorChunk::getFunction(const ParsedAttributes &attrs, |

