blob: abe568d60279320667455727ad8aecb4d8209983 [file] [log] [blame]
Chris Lattnera2f42b12008-04-11 07:06:57 +00001//===- IdentifierResolver.h - Lexical Scope Name lookup ---------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Argyrios Kyrtzidis321f2782008-04-12 01:50:47 +000010// This file defines the IdentifierResolver class, which is used for lexical
Chris Lattnera2f42b12008-04-11 07:06:57 +000011// scoped lookup, based on identifier.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_AST_SEMA_IDENTIFIERRESOLVER_H
16#define LLVM_CLANG_AST_SEMA_IDENTIFIERRESOLVER_H
17
18namespace clang {
19 class IdentifierInfo;
20 class NamedDecl;
21 class Scope;
22
23/// IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Argyrios Kyrtzidis321f2782008-04-12 01:50:47 +000024/// It manages the shadowing chains of identifiers and implements efficent decl
Chris Lattnera2f42b12008-04-11 07:06:57 +000025/// lookup based on an identifier.
26class IdentifierResolver {
27public:
28 IdentifierResolver();
29 ~IdentifierResolver();
30
Argyrios Kyrtzidis321f2782008-04-12 01:50:47 +000031 /// AddDecl - Link the decl to its shadowed decl chain.
Chris Lattnera2f42b12008-04-11 07:06:57 +000032 void AddDecl(NamedDecl *D, Scope *S);
33
Argyrios Kyrtzidis321f2782008-04-12 01:50:47 +000034 /// AddGlobalDecl - Link the decl at the top of the shadowed decl chain.
Chris Lattnera2f42b12008-04-11 07:06:57 +000035 void AddGlobalDecl(NamedDecl *D);
36
Argyrios Kyrtzidis321f2782008-04-12 01:50:47 +000037 /// RemoveDecl - Unlink the decl from its shadowed decl chain.
Chris Lattnera2f42b12008-04-11 07:06:57 +000038 /// The decl must already be part of the decl chain.
39 void RemoveDecl(NamedDecl *D);
40
Douglas Gregor2ce52f32008-04-13 21:07:44 +000041 /// Lookup - Find the non-shadowed decl that belongs to one or more
42 /// of the specified Decl::IdentifierNamespaces.
Chris Lattnera2f42b12008-04-11 07:06:57 +000043 NamedDecl *Lookup(const IdentifierInfo *II, unsigned NSI);
44
45private:
46 class IdDeclInfoMap;
47 IdDeclInfoMap &IdDeclInfos;
48};
49
50} // end namespace clang
51
52#endif