#define LLVM_CLANG_AST_SEMA_H
#include "clang/Parse/Action.h"
-#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include <vector>
#include <string>
/// This is only necessary for issuing pretty diagnostics.
llvm::SmallVector<TypedefDecl*, 24> OCUVectorDecls;
+ /// ObjcImplementations - Keep track of all of the classes with
+ /// @implementation's, so that we can emit errors on duplicates.
+ llvm::SmallPtrSet<IdentifierInfo*, 8> ObjcImplementations;
+
// Enum values used by KnownFunctionIDs (see below).
enum {
id_printf,
}
// Check that there is no duplicate implementation of this class.
- bool err = false;
- for (unsigned i = 0; i != Context.sizeObjcImplementationClass(); i++) {
- if (Context.getObjcImplementationClass(i)->getIdentifier() == ClassName) {
- Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName());
- err = true;
- break;
- }
- }
- if (!err)
- Context.setObjcImplementationClass(IMPDecl);
+ if (!ObjcImplementations.insert(ClassName))
+ Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName());
return IMPDecl;
}
namespace clang {
class TargetInfo;
- class ObjcImplementationDecl;
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
llvm::FoldingSet<FunctionTypeNoProto> FunctionTypeNoProtos;
llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos;
llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
- llvm::SmallVector<ObjcImplementationDecl*, 8> ImplementationClassInfo;
RecordDecl *CFConstantStringTypeDecl;
public:
/// position information.
const RecordLayout &getRecordLayout(const RecordDecl *D, SourceLocation L);
- ObjcImplementationDecl* getObjcImplementationClass(unsigned ix) {
- return ImplementationClassInfo[ix];
- }
- void setObjcImplementationClass(ObjcImplementationDecl* ImplDecl) {
- ImplementationClassInfo.push_back(ImplDecl);
- }
- unsigned sizeObjcImplementationClass() const {
- return ImplementationClassInfo.size();
- }
-
//===--------------------------------------------------------------------===//
// Type Operators
//===--------------------------------------------------------------------===//