diff options
| author | John McCall <rjmccall@apple.com> | 2010-03-15 10:12:16 +0000 | 
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-03-15 10:12:16 +0000 | 
| commit | 3e11ebebc83643747f15bcafa28b3b7e232f6cc1 (patch) | |
| tree | 5bc9d793fb1e75fccc7da56e4314642242d497d7 /clang/lib/Sema/SemaDecl.cpp | |
| parent | 1e3a1a7eff8549fbb5295e4c2014f9b9a7a7b30f (diff) | |
| download | bcm5719-llvm-3e11ebebc83643747f15bcafa28b3b7e232f6cc1.tar.gz bcm5719-llvm-3e11ebebc83643747f15bcafa28b3b7e232f6cc1.zip | |
Remember declaration scope qualifiers in the AST.  Imposes no memory overhead
on unqualified declarations.
Patch by Enea Zaffanella!  Minimal adjustments:  allocate the ExtInfo nodes
with the ASTContext and delete them during Destroy().  I audited a bunch of
Destroy methods at the same time, to ensure that the correct teardown was
being done.
llvm-svn: 98540
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7179f4bc6bb..dab7d883a1d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2262,6 +2262,13 @@ isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC,    return true;  } +static void SetNestedNameSpecifier(DeclaratorDecl *DD, Declarator &D) { +  CXXScopeSpec &SS = D.getCXXScopeSpec(); +  if (!SS.isSet()) return; +  DD->setQualifierInfo(static_cast<NestedNameSpecifier*>(SS.getScopeRep()), +                       SS.getRange()); +} +  NamedDecl*  Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,                                QualType R, TypeSourceInfo *TInfo, @@ -2371,6 +2378,8 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,    if (D.isInvalidType())      NewVD->setInvalidDecl(); +  SetNestedNameSpecifier(NewVD, D); +    if (D.getDeclSpec().isThreadSpecified()) {      if (NewVD->hasLocalStorage())        Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_thread_non_global); @@ -2799,6 +2808,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,    if (D.isInvalidType())      NewFD->setInvalidDecl(); +  SetNestedNameSpecifier(NewFD, D); +    // Set the lexical context. If the declarator has a C++    // scope specifier, or is the object of a friend declaration, the    // lexical context will be different from the semantic context. @@ -4847,6 +4858,13 @@ CreateNewDecl:                                 cast_or_null<RecordDecl>(PrevDecl));    } +  // Maybe add qualifier info. +  if (SS.isNotEmpty()) { +    NestedNameSpecifier *NNS +      = static_cast<NestedNameSpecifier*>(SS.getScopeRep()); +    New->setQualifierInfo(NNS, SS.getRange()); +  } +    if (Kind != TagDecl::TK_enum) {      // Handle #pragma pack: if the #pragma pack stack has non-default      // alignment, make up a packed attribute for this decl. These | 

