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 {
|
namespace llvm {
|
||||||
class BumpPtrAllocator;
|
class BumpPtrAllocator;
|
||||||
|
class SourceMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace swift {
|
namespace swift {
|
||||||
@@ -30,9 +31,12 @@ class ASTContext {
|
|||||||
void operator=(const ASTContext&); // DO NOT IMPLEMENT
|
void operator=(const ASTContext&); // DO NOT IMPLEMENT
|
||||||
llvm::BumpPtrAllocator *Allocator;
|
llvm::BumpPtrAllocator *Allocator;
|
||||||
public:
|
public:
|
||||||
ASTContext();
|
ASTContext(llvm::SourceMgr &SourceMgr);
|
||||||
~ASTContext();
|
~ASTContext();
|
||||||
|
|
||||||
|
/// SourceMgr - The source manager object.
|
||||||
|
llvm::SourceMgr &SourceMgr;
|
||||||
|
|
||||||
Type * const VoidType; /// VoidType - This is 'void'.
|
Type * const VoidType; /// VoidType - This is 'void'.
|
||||||
Type * const IntType; /// IntType - This is 'int'.
|
Type * const IntType; /// IntType - This is 'int'.
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Parser {
|
|||||||
Parser(const Parser&); // DO NOT IMPLEMENT
|
Parser(const Parser&); // DO NOT IMPLEMENT
|
||||||
void operator=(const Parser&); // DO NOT IMPLEMENT
|
void operator=(const Parser&); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
Parser(unsigned BufferID, llvm::SourceMgr &SM, ASTContext &Context);
|
Parser(unsigned BufferID, ASTContext &Context);
|
||||||
~Parser();
|
~Parser();
|
||||||
|
|
||||||
void ParseTranslationUnit();
|
void ParseTranslationUnit();
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ protected:
|
|||||||
public:
|
public:
|
||||||
SemaBase(Sema &s);
|
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
|
} // end namespace swift
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
using namespace swift;
|
using namespace swift;
|
||||||
|
|
||||||
ASTContext::ASTContext()
|
ASTContext::ASTContext(llvm::SourceMgr &sourcemgr)
|
||||||
: Allocator(new llvm::BumpPtrAllocator()),
|
: Allocator(new llvm::BumpPtrAllocator()),
|
||||||
|
SourceMgr(sourcemgr),
|
||||||
VoidType(new (*this) BuiltinType(BuiltinVoidKind)),
|
VoidType(new (*this) BuiltinType(BuiltinVoidKind)),
|
||||||
IntType(new (*this) BuiltinType(BuiltinIntKind)) {
|
IntType(new (*this) BuiltinType(BuiltinIntKind)) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ using llvm::SMLoc;
|
|||||||
// Setup and Helper Methods
|
// Setup and Helper Methods
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
Parser::Parser(unsigned BufferID, llvm::SourceMgr &SM, ASTContext &Context)
|
Parser::Parser(unsigned BufferID, ASTContext &Context)
|
||||||
: SourceMgr(SM),
|
: SourceMgr(Context.SourceMgr),
|
||||||
L(*new Lexer(BufferID, SM)),
|
L(*new Lexer(BufferID, SourceMgr)),
|
||||||
S(*new Sema(Context)) {
|
S(*new Sema(Context)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,19 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "swift/Sema/SemaBase.h"
|
#include "swift/Sema/SemaBase.h"
|
||||||
|
#include "swift/Sema/Sema.h"
|
||||||
|
#include "llvm/Support/SourceMgr.h"
|
||||||
using namespace swift;
|
using namespace swift;
|
||||||
|
|
||||||
SemaBase::SemaBase(Sema &s) : S(s) {
|
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