forked from OSchip/llvm-project
Move things around so that Sema.h no longer depends on even DeclBase.h.
It still depends on Type because DeclarationName.h does. llvm-svn: 112177
This commit is contained in:
parent
a9a0599b39
commit
b1be523752
|
@ -642,6 +642,25 @@ public:
|
||||||
virtual void print(llvm::raw_ostream &OS) const;
|
virtual void print(llvm::raw_ostream &OS) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DeclContextLookupResult : public std::pair<NamedDecl**,NamedDecl**> {
|
||||||
|
public:
|
||||||
|
DeclContextLookupResult(NamedDecl **I, NamedDecl **E) : pair(I, E) {}
|
||||||
|
DeclContextLookupResult() : pair() {}
|
||||||
|
|
||||||
|
using pair::operator=;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DeclContextLookupConstResult
|
||||||
|
: public std::pair<NamedDecl*const*, NamedDecl*const*> {
|
||||||
|
public:
|
||||||
|
DeclContextLookupConstResult(std::pair<NamedDecl**,NamedDecl**> R)
|
||||||
|
: pair(R) {}
|
||||||
|
DeclContextLookupConstResult(NamedDecl * const *I, NamedDecl * const *E)
|
||||||
|
: pair(I, E) {}
|
||||||
|
DeclContextLookupConstResult() : pair() {}
|
||||||
|
|
||||||
|
using pair::operator=;
|
||||||
|
};
|
||||||
|
|
||||||
/// DeclContext - This is used only as base class of specific decl types that
|
/// DeclContext - This is used only as base class of specific decl types that
|
||||||
/// can act as declaration contexts. These decls are (only the top classes
|
/// can act as declaration contexts. These decls are (only the top classes
|
||||||
|
@ -1063,9 +1082,8 @@ public:
|
||||||
/// access to the results of lookup up a name within this context.
|
/// access to the results of lookup up a name within this context.
|
||||||
typedef NamedDecl * const * lookup_const_iterator;
|
typedef NamedDecl * const * lookup_const_iterator;
|
||||||
|
|
||||||
typedef std::pair<lookup_iterator, lookup_iterator> lookup_result;
|
typedef DeclContextLookupResult lookup_result;
|
||||||
typedef std::pair<lookup_const_iterator, lookup_const_iterator>
|
typedef DeclContextLookupConstResult lookup_const_result;
|
||||||
lookup_const_result;
|
|
||||||
|
|
||||||
/// lookup - Find the declarations (if any) with the given Name in
|
/// lookup - Find the declarations (if any) with the given Name in
|
||||||
/// this context. Returns a range of iterators that contains all of
|
/// this context. Returns a range of iterators that contains all of
|
||||||
|
@ -1173,7 +1191,6 @@ inline bool Decl::isTemplateParameter() const {
|
||||||
getKind() == TemplateTemplateParm;
|
getKind() == TemplateTemplateParm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Specialization selected when ToTy is not a known subclass of DeclContext.
|
// Specialization selected when ToTy is not a known subclass of DeclContext.
|
||||||
template <class ToTy,
|
template <class ToTy,
|
||||||
bool IsKnownSubtype = ::llvm::is_base_of< DeclContext, ToTy>::value>
|
bool IsKnownSubtype = ::llvm::is_base_of< DeclContext, ToTy>::value>
|
||||||
|
|
|
@ -14,16 +14,23 @@
|
||||||
#ifndef LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
|
#ifndef LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
|
||||||
#define LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
|
#define LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
|
||||||
|
|
||||||
#include "clang/AST/DeclarationName.h"
|
|
||||||
#include "clang/AST/DeclBase.h"
|
|
||||||
#include "clang/AST/Type.h"
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
template <class T> class SmallVectorImpl;
|
||||||
|
}
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
class ASTConsumer;
|
class ASTConsumer;
|
||||||
|
class Decl;
|
||||||
|
class DeclContext;
|
||||||
|
class DeclContextLookupResult;
|
||||||
|
class DeclarationName;
|
||||||
class ExternalSemaSource; // layering violation required for downcasting
|
class ExternalSemaSource; // layering violation required for downcasting
|
||||||
|
class NamedDecl;
|
||||||
|
class Selector;
|
||||||
class Stmt;
|
class Stmt;
|
||||||
|
|
||||||
/// \brief Abstract interface for external sources of AST nodes.
|
/// \brief Abstract interface for external sources of AST nodes.
|
||||||
|
@ -90,7 +97,7 @@ public:
|
||||||
/// Generally the final step of this method is either to call
|
/// Generally the final step of this method is either to call
|
||||||
/// SetExternalVisibleDeclsForName or to recursively call lookup on
|
/// SetExternalVisibleDeclsForName or to recursively call lookup on
|
||||||
/// the DeclContext after calling SetExternalVisibleDecls.
|
/// the DeclContext after calling SetExternalVisibleDecls.
|
||||||
virtual DeclContext::lookup_result
|
virtual DeclContextLookupResult
|
||||||
FindExternalVisibleDeclsByName(const DeclContext *DC,
|
FindExternalVisibleDeclsByName(const DeclContext *DC,
|
||||||
DeclarationName Name) = 0;
|
DeclarationName Name) = 0;
|
||||||
|
|
||||||
|
@ -135,17 +142,17 @@ public:
|
||||||
virtual void PrintStats();
|
virtual void PrintStats();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static DeclContext::lookup_result
|
static DeclContextLookupResult
|
||||||
SetExternalVisibleDeclsForName(const DeclContext *DC,
|
SetExternalVisibleDeclsForName(const DeclContext *DC,
|
||||||
DeclarationName Name,
|
DeclarationName Name,
|
||||||
llvm::SmallVectorImpl<NamedDecl*> &Decls);
|
llvm::SmallVectorImpl<NamedDecl*> &Decls);
|
||||||
|
|
||||||
static DeclContext::lookup_result
|
static DeclContextLookupResult
|
||||||
SetNoExternalVisibleDeclsForName(const DeclContext *DC,
|
SetNoExternalVisibleDeclsForName(const DeclContext *DC,
|
||||||
DeclarationName Name);
|
DeclarationName Name);
|
||||||
|
|
||||||
void MaterializeVisibleDeclsForName(const DeclContext *DC,
|
void MaterializeVisibleDeclsForName(const DeclContext *DC,
|
||||||
DeclarationName Name,
|
DeclarationName Name,
|
||||||
llvm::SmallVectorImpl<NamedDecl*> &Decls);
|
llvm::SmallVectorImpl<NamedDecl*> &Decls);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "clang/Sema/IdentifierResolver.h"
|
#include "clang/Sema/IdentifierResolver.h"
|
||||||
#include "clang/Sema/ObjCMethodList.h"
|
#include "clang/Sema/ObjCMethodList.h"
|
||||||
#include "clang/AST/OperationKinds.h"
|
#include "clang/AST/OperationKinds.h"
|
||||||
#include "clang/AST/DeclBase.h"
|
|
||||||
#include "clang/AST/DeclarationName.h"
|
#include "clang/AST/DeclarationName.h"
|
||||||
#include "clang/AST/ExternalASTSource.h"
|
#include "clang/AST/ExternalASTSource.h"
|
||||||
#include "llvm/ADT/OwningPtr.h"
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
|
@ -65,11 +64,13 @@ namespace clang {
|
||||||
class DeclSpec;
|
class DeclSpec;
|
||||||
class DeclaratorDecl;
|
class DeclaratorDecl;
|
||||||
class DeducedTemplateArgument;
|
class DeducedTemplateArgument;
|
||||||
|
class DependentDiagnostic;
|
||||||
class DesignatedInitExpr;
|
class DesignatedInitExpr;
|
||||||
class EnumConstantDecl;
|
class EnumConstantDecl;
|
||||||
class Expr;
|
class Expr;
|
||||||
class ExtVectorType;
|
class ExtVectorType;
|
||||||
class ExternalSemaSource;
|
class ExternalSemaSource;
|
||||||
|
class FormatAttr;
|
||||||
class FriendDecl;
|
class FriendDecl;
|
||||||
class FullExpr;
|
class FullExpr;
|
||||||
class FunctionDecl;
|
class FunctionDecl;
|
||||||
|
@ -87,6 +88,7 @@ namespace clang {
|
||||||
class LookupResult;
|
class LookupResult;
|
||||||
class MultiLevelTemplateArgumentList;
|
class MultiLevelTemplateArgumentList;
|
||||||
class NamedDecl;
|
class NamedDecl;
|
||||||
|
class NonNullAttr;
|
||||||
class ObjCCategoryDecl;
|
class ObjCCategoryDecl;
|
||||||
class ObjCCategoryImplDecl;
|
class ObjCCategoryImplDecl;
|
||||||
class ObjCCompatibleAliasDecl;
|
class ObjCCompatibleAliasDecl;
|
||||||
|
@ -128,6 +130,7 @@ namespace clang {
|
||||||
class UsingShadowDecl;
|
class UsingShadowDecl;
|
||||||
class ValueDecl;
|
class ValueDecl;
|
||||||
class VarDecl;
|
class VarDecl;
|
||||||
|
class VisibilityAttr;
|
||||||
class VisibleDeclConsumer;
|
class VisibleDeclConsumer;
|
||||||
|
|
||||||
namespace sema {
|
namespace sema {
|
||||||
|
@ -1204,7 +1207,8 @@ public:
|
||||||
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
|
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
|
||||||
QualType T1, QualType T2,
|
QualType T1, QualType T2,
|
||||||
UnresolvedSetImpl &Functions);
|
UnresolvedSetImpl &Functions);
|
||||||
DeclContext::lookup_result LookupConstructors(CXXRecordDecl *Class);
|
|
||||||
|
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class);
|
||||||
CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
|
CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
|
||||||
|
|
||||||
void ArgumentDependentLookup(DeclarationName Name, bool Operator,
|
void ArgumentDependentLookup(DeclarationName Name, bool Operator,
|
||||||
|
@ -3768,15 +3772,14 @@ public:
|
||||||
/// FreePackedContext - Deallocate and null out PackContext.
|
/// FreePackedContext - Deallocate and null out PackContext.
|
||||||
void FreePackedContext();
|
void FreePackedContext();
|
||||||
|
|
||||||
|
/// PushVisibilityAttr - Note that we've entered a context with a
|
||||||
|
/// visibility attribute.
|
||||||
|
void PushVisibilityAttr(const VisibilityAttr *Attr);
|
||||||
|
|
||||||
/// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
|
/// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
|
||||||
/// add an appropriate visibility attribute.
|
/// add an appropriate visibility attribute.
|
||||||
void AddPushedVisibilityAttribute(Decl *RD);
|
void AddPushedVisibilityAttribute(Decl *RD);
|
||||||
|
|
||||||
/// PushPragmaVisibility - Push the top element of the visibility stack; used
|
|
||||||
/// for '#pragma GCC visibility' and visibility attributes on namespaces.
|
|
||||||
void PushPragmaVisibility(VisibilityAttr::VisibilityType type,
|
|
||||||
SourceLocation loc);
|
|
||||||
|
|
||||||
/// PopPragmaVisibility - Pop the top element of the visibility stack; used
|
/// PopPragmaVisibility - Pop the top element of the visibility stack; used
|
||||||
/// for '#pragma GCC visibility' and visibility attributes on namespaces.
|
/// for '#pragma GCC visibility' and visibility attributes on namespaces.
|
||||||
void PopPragmaVisibility();
|
void PopPragmaVisibility();
|
||||||
|
|
|
@ -315,6 +315,16 @@ void Sema::FreeVisContext() {
|
||||||
VisContext = 0;
|
VisContext = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PushPragmaVisibility(Sema &S, VisibilityAttr::VisibilityType type,
|
||||||
|
SourceLocation loc) {
|
||||||
|
// Put visibility on stack.
|
||||||
|
if (!S.VisContext)
|
||||||
|
S.VisContext = new VisStack;
|
||||||
|
|
||||||
|
VisStack *Stack = static_cast<VisStack*>(S.VisContext);
|
||||||
|
Stack->push_back(std::make_pair(type, loc));
|
||||||
|
}
|
||||||
|
|
||||||
void Sema::ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
|
void Sema::ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
|
||||||
SourceLocation PragmaLoc) {
|
SourceLocation PragmaLoc) {
|
||||||
if (IsPush) {
|
if (IsPush) {
|
||||||
|
@ -333,20 +343,14 @@ void Sema::ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
|
||||||
VisType->getName();
|
VisType->getName();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PushPragmaVisibility(type, PragmaLoc);
|
PushPragmaVisibility(*this, type, PragmaLoc);
|
||||||
} else {
|
} else {
|
||||||
PopPragmaVisibility();
|
PopPragmaVisibility();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sema::PushPragmaVisibility(VisibilityAttr::VisibilityType type,
|
void Sema::PushVisibilityAttr(const VisibilityAttr *Attr) {
|
||||||
SourceLocation loc) {
|
PushPragmaVisibility(*this, Attr->getVisibility(), Attr->getLocation());
|
||||||
// Put visibility on stack.
|
|
||||||
if (!VisContext)
|
|
||||||
VisContext = new VisStack;
|
|
||||||
|
|
||||||
VisStack *Stack = static_cast<VisStack*>(VisContext);
|
|
||||||
Stack->push_back(std::make_pair(type, loc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sema::PopPragmaVisibility() {
|
void Sema::PopPragmaVisibility() {
|
||||||
|
|
|
@ -3277,13 +3277,15 @@ Decl *Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
|
||||||
// Namespace Handling
|
// Namespace Handling
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// ActOnStartNamespaceDef - This is called at the start of a namespace
|
/// ActOnStartNamespaceDef - This is called at the start of a namespace
|
||||||
/// definition.
|
/// definition.
|
||||||
Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
|
Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
|
||||||
SourceLocation IdentLoc,
|
SourceLocation IdentLoc,
|
||||||
IdentifierInfo *II,
|
IdentifierInfo *II,
|
||||||
SourceLocation LBrace,
|
SourceLocation LBrace,
|
||||||
AttributeList *AttrList) {
|
AttributeList *AttrList) {
|
||||||
// anonymous namespace starts at its left brace
|
// anonymous namespace starts at its left brace
|
||||||
NamespaceDecl *Namespc = NamespaceDecl::Create(Context, CurContext,
|
NamespaceDecl *Namespc = NamespaceDecl::Create(Context, CurContext,
|
||||||
(II ? IdentLoc : LBrace) , II);
|
(II ? IdentLoc : LBrace) , II);
|
||||||
|
@ -3294,7 +3296,7 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
|
||||||
ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
|
ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
|
||||||
|
|
||||||
if (const VisibilityAttr *attr = Namespc->getAttr<VisibilityAttr>())
|
if (const VisibilityAttr *attr = Namespc->getAttr<VisibilityAttr>())
|
||||||
PushPragmaVisibility(attr->getVisibility(), attr->getLocation());
|
PushVisibilityAttr(attr);
|
||||||
|
|
||||||
if (II) {
|
if (II) {
|
||||||
// C++ [namespace.def]p2:
|
// C++ [namespace.def]p2:
|
||||||
|
|
Loading…
Reference in New Issue