mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
give ASTContext a SourceMgr reference, add diagnostic hooks to SemaBase.
Swift SVN r39
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
namespace llvm {
|
||||
class BumpPtrAllocator;
|
||||
class SourceMgr;
|
||||
}
|
||||
|
||||
namespace swift {
|
||||
@@ -30,9 +31,12 @@ class ASTContext {
|
||||
void operator=(const ASTContext&); // DO NOT IMPLEMENT
|
||||
llvm::BumpPtrAllocator *Allocator;
|
||||
public:
|
||||
ASTContext();
|
||||
ASTContext(llvm::SourceMgr &SourceMgr);
|
||||
~ASTContext();
|
||||
|
||||
/// SourceMgr - The source manager object.
|
||||
llvm::SourceMgr &SourceMgr;
|
||||
|
||||
Type * const VoidType; /// VoidType - This is 'void'.
|
||||
Type * const IntType; /// IntType - This is 'int'.
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class Parser {
|
||||
Parser(const Parser&); // DO NOT IMPLEMENT
|
||||
void operator=(const Parser&); // DO NOT IMPLEMENT
|
||||
public:
|
||||
Parser(unsigned BufferID, llvm::SourceMgr &SM, ASTContext &Context);
|
||||
Parser(unsigned BufferID, ASTContext &Context);
|
||||
~Parser();
|
||||
|
||||
void ParseTranslationUnit();
|
||||
|
||||
@@ -37,7 +37,9 @@ protected:
|
||||
public:
|
||||
SemaBase(Sema &s);
|
||||
|
||||
// TODO: Diagnostics stuff.
|
||||
void Note(llvm::SMLoc Loc, const char *Message);
|
||||
void Warning(llvm::SMLoc Loc, const char *Message);
|
||||
void Error(llvm::SMLoc Loc, const char *Message);
|
||||
};
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
#include "llvm/Support/Allocator.h"
|
||||
using namespace swift;
|
||||
|
||||
ASTContext::ASTContext()
|
||||
ASTContext::ASTContext(llvm::SourceMgr &sourcemgr)
|
||||
: Allocator(new llvm::BumpPtrAllocator()),
|
||||
SourceMgr(sourcemgr),
|
||||
VoidType(new (*this) BuiltinType(BuiltinVoidKind)),
|
||||
IntType(new (*this) BuiltinType(BuiltinIntKind)) {
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ using llvm::SMLoc;
|
||||
// Setup and Helper Methods
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Parser::Parser(unsigned BufferID, llvm::SourceMgr &SM, ASTContext &Context)
|
||||
: SourceMgr(SM),
|
||||
L(*new Lexer(BufferID, SM)),
|
||||
Parser::Parser(unsigned BufferID, ASTContext &Context)
|
||||
: SourceMgr(Context.SourceMgr),
|
||||
L(*new Lexer(BufferID, SourceMgr)),
|
||||
S(*new Sema(Context)) {
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/Sema/SemaBase.h"
|
||||
#include "swift/Sema/Sema.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
using namespace swift;
|
||||
|
||||
SemaBase::SemaBase(Sema &s) : S(s) {
|
||||
}
|
||||
|
||||
void SemaBase::Note(llvm::SMLoc Loc, const char *Message) {
|
||||
S.Context.SourceMgr.PrintMessage(Loc, Message, "note");
|
||||
}
|
||||
void SemaBase::Warning(llvm::SMLoc Loc, const char *Message) {
|
||||
S.Context.SourceMgr.PrintMessage(Loc, Message, "warning");
|
||||
}
|
||||
void SemaBase::Error(llvm::SMLoc Loc, const char *Message) {
|
||||
S.Context.SourceMgr.PrintMessage(Loc, Message, "error");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user