aboutsummaryrefslogtreecommitdiff
path: root/Basic
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-12-12 22:39:36 +0000
committerTed Kremenek <kremenek@apple.com>2007-12-12 22:39:36 +0000
commit9c728dc4d8da89c73fcae74c9e72d7a83ffd7b6d (patch)
treee89a3acd2ddb4a993e1d6bac53c05628b24f4f2b /Basic
parent5e71124dabe8017f17ce8996e4161a202694e3e6 (diff)
TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation. Added many utility methods to FullSourceLoc to provide shorthand for: FullLoc.getManager().someMethod(FullLoc.getLocation()); instead we have: FullLoc.someMethod(); Modified TextDiagnostics (and related classes) to use this short-hand. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Basic')
-rw-r--r--Basic/Diagnostic.cpp7
-rw-r--r--Basic/SourceLocation.cpp42
-rw-r--r--Basic/TargetInfo.cpp13
-rw-r--r--Basic/Targets.cpp5
4 files changed, 54 insertions, 13 deletions
diff --git a/Basic/Diagnostic.cpp b/Basic/Diagnostic.cpp
index 36da1e2c5c..2d9981424a 100644
--- a/Basic/Diagnostic.cpp
+++ b/Basic/Diagnostic.cpp
@@ -197,8 +197,7 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
/// Report - Issue the message to the client. If the client wants us to stop
/// compilation, return true, otherwise return false. DiagID is a member of
/// the diag::kind enum.
-void Diagnostic::Report(SourceLocation Pos, unsigned DiagID,
- SourceManager* SrcMgr,
+void Diagnostic::Report(FullSourceLoc Pos, unsigned DiagID,
const std::string *Strs, unsigned NumStrs,
const SourceRange *Ranges, unsigned NumRanges) {
// Figure out the diagnostic level of this message.
@@ -214,11 +213,11 @@ void Diagnostic::Report(SourceLocation Pos, unsigned DiagID,
}
// Are we going to ignore this diagnosic?
- if (Client.IgnoreDiagnostic(DiagLevel, Pos, SrcMgr))
+ if (Client.IgnoreDiagnostic(DiagLevel, Pos))
return;
// Finally, report it.
- Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID, SrcMgr,
+ Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID,
Strs, NumStrs, Ranges, NumRanges);
++NumDiagnostics;
}
diff --git a/Basic/SourceLocation.cpp b/Basic/SourceLocation.cpp
index 75b4a99d45..d7f34567fb 100644
--- a/Basic/SourceLocation.cpp
+++ b/Basic/SourceLocation.cpp
@@ -8,10 +8,12 @@
//===----------------------------------------------------------------------===//
//
// This file defines serialization methods for the SourceLocation class.
+// This file defines accessor methods for the FullSourceLoc class.
//
//===----------------------------------------------------------------------===//
#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
#include "llvm/Bitcode/Serialize.h"
#include "llvm/Bitcode/Deserialize.h"
@@ -35,3 +37,43 @@ SourceRange SourceRange::ReadVal(llvm::Deserializer& D) {
SourceLocation B = SourceLocation::ReadVal(D);
return SourceRange(A,B);
}
+
+FullSourceLoc FullSourceLoc::getLogicalLoc() {
+ assert (isValid());
+ return FullSourceLoc(SrcMgr->getLogicalLoc(Loc),*SrcMgr);
+}
+
+FullSourceLoc FullSourceLoc::getIncludeLoc() {
+ assert (isValid());
+ return FullSourceLoc(SrcMgr->getIncludeLoc(Loc),*SrcMgr);
+}
+
+unsigned FullSourceLoc::getLineNumber() {
+ assert (isValid());
+ return SrcMgr->getLineNumber(Loc);
+}
+
+unsigned FullSourceLoc::getColumnNumber() {
+ assert (isValid());
+ return SrcMgr->getColumnNumber(Loc);
+}
+
+const char* FullSourceLoc::getSourceName() const {
+ assert (isValid());
+ return SrcMgr->getSourceName(Loc);
+}
+
+const FileEntry* FullSourceLoc::getFileEntryForLoc() const {
+ assert (isValid());
+ return SrcMgr->getFileEntryForLoc(Loc);
+}
+
+const char * FullSourceLoc::getCharacterData() const {
+ assert (isValid());
+ return SrcMgr->getCharacterData(Loc);
+}
+
+const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
+ assert (isValid());
+ return SrcMgr->getBuffer(Loc.getFileID());
+}
diff --git a/Basic/TargetInfo.cpp b/Basic/TargetInfo.cpp
index 63b3cf8462..4c9d1c8afe 100644
--- a/Basic/TargetInfo.cpp
+++ b/Basic/TargetInfo.cpp
@@ -29,20 +29,20 @@ void TargetInfoImpl::ANCHOR() {} // out-of-line virtual method for class.
void TargetInfo::getFloatInfo(uint64_t &Size, unsigned &Align,
const llvm::fltSemantics *&Format,
- SourceLocation Loc) {
+ FullSourceLoc Loc) {
Align = 32; // FIXME: implement correctly.
Size = 32;
Format = &llvm::APFloat::IEEEsingle;
}
void TargetInfo::getDoubleInfo(uint64_t &Size, unsigned &Align,
const llvm::fltSemantics *&Format,
- SourceLocation Loc) {
+ FullSourceLoc Loc) {
Size = Align = 64; // FIXME: implement correctly.
Format = &llvm::APFloat::IEEEdouble;
}
void TargetInfo::getLongDoubleInfo(uint64_t &Size, unsigned &Align,
const llvm::fltSemantics *&Format,
- SourceLocation Loc) {
+ FullSourceLoc Loc) {
Size = Align = 64; // FIXME: implement correctly.
Format = &llvm::APFloat::IEEEdouble;
//Size = 80; Align = 32; // FIXME: implement correctly.
@@ -63,9 +63,10 @@ const char *TargetInfo::getTargetPrefix() const {
/// DiagnoseNonPortability - When a use of a non-portable target feature is
/// used, this method emits the diagnostic and marks the translation unit as
/// non-portable.
-void TargetInfo::DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind) {
+void TargetInfo::DiagnoseNonPortability(FullSourceLoc Loc,
+ unsigned DiagKind) {
NonPortable = true;
- if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind, SrcMgr);
+ if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind);
}
/// GetTargetDefineMap - Get the set of target #defines in an associative
@@ -196,7 +197,7 @@ void TargetInfo::getTargetDefines(std::vector<char> &Buffer) {
/// ComputeWCharWidth - Determine the width of the wchar_t type for the primary
/// target, diagnosing whether this is non-portable across the secondary
/// targets.
-void TargetInfo::ComputeWCharInfo(SourceLocation Loc) {
+void TargetInfo::ComputeWCharInfo(FullSourceLoc Loc) {
PrimaryTarget->getWCharInfo(WCharWidth, WCharAlign);
// Check whether this is portable across the secondary targets if the T-U is
diff --git a/Basic/Targets.cpp b/Basic/Targets.cpp
index ed29c9000a..9b182901ca 100644
--- a/Basic/Targets.cpp
+++ b/Basic/Targets.cpp
@@ -699,8 +699,7 @@ static TargetInfoImpl *CreateTarget(const std::string& T) {
/// CreateTargetInfo - Return the set of target info objects as specified by
/// the -arch command line option.
-TargetInfo* TargetInfo::CreateTargetInfo(SourceManager& SrcMgr,
- const std::string* TriplesStart,
+TargetInfo* TargetInfo::CreateTargetInfo(const std::string* TriplesStart,
const std::string* TriplesEnd,
Diagnostic *Diags) {
@@ -710,7 +709,7 @@ TargetInfo* TargetInfo::CreateTargetInfo(SourceManager& SrcMgr,
if (!PrimaryTarget)
return NULL;
- TargetInfo *TI = new TargetInfo(SrcMgr, PrimaryTarget, Diags);
+ TargetInfo *TI = new TargetInfo(PrimaryTarget, Diags);
// Add all secondary targets.
for (const std::string* I=TriplesStart+1; I != TriplesEnd; ++I) {