diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-24 17:54:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-24 17:54:50 +0000 |
commit | 869ad45f8f0e9019556463ff0fd9fab3d7127512 (patch) | |
tree | 12ee87ed78312514cde60e894b5add95a6f67517 /clang/lib/Sema/SemaCXXScopeSpec.cpp | |
parent | e721185799a59944f4ee3ff9cf367f51c296c70f (diff) | |
download | bcm5719-llvm-869ad45f8f0e9019556463ff0fd9fab3d7127512.tar.gz bcm5719-llvm-869ad45f8f0e9019556463ff0fd9fab3d7127512.zip |
Retain complete source-location information for C++
nested-name-specifiers throughout the parser, and provide a new class
(NestedNameSpecifierLoc) that contains a nested-name-specifier along
with its type-source information.
Right now, this information is completely useless, because we don't
actually store the source-location information anywhere in the
AST. Call this Step 1/N.
llvm-svn: 126391
Diffstat (limited to 'clang/lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCXXScopeSpec.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 9daec58d4ed..7ad4b459451 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -658,6 +658,41 @@ bool Sema::ActOnCXXNestedNameSpecifier(Scope *S, return false; } +namespace { + /// \brief A structure that stores a nested-name-specifier annotation, + /// including both the nested-name-specifier + struct NestedNameSpecifierAnnotation { + NestedNameSpecifier *NNS; + }; +} + +void *Sema::SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS) { + if (SS.isEmpty() || SS.isInvalid()) + return 0; + + void *Mem = Context.Allocate((sizeof(NestedNameSpecifierAnnotation) + + SS.location_size()), + llvm::alignOf<NestedNameSpecifierAnnotation>()); + NestedNameSpecifierAnnotation *Annotation + = new (Mem) NestedNameSpecifierAnnotation; + Annotation->NNS = SS.getScopeRep(); + memcpy(Annotation + 1, SS.location_data(), SS.location_size()); + return Annotation; +} + +void Sema::RestoreNestedNameSpecifierAnnotation(void *AnnotationPtr, + SourceRange AnnotationRange, + CXXScopeSpec &SS) { + if (!AnnotationPtr) { + SS.SetInvalid(AnnotationRange); + return; + } + + NestedNameSpecifierAnnotation *Annotation + = static_cast<NestedNameSpecifierAnnotation *>(AnnotationPtr); + SS.Adopt(NestedNameSpecifierLoc(Annotation->NNS, Annotation + 1)); +} + bool Sema::ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) { assert(SS.isSet() && "Parser passed invalid CXXScopeSpec."); |