[cfe-commits] r44957 - in /cfe/trunk: AST/ Analysis/ Basic/ CodeGen/ Driver/ Lex/ Parse/ Sema/ include/clang/AST/ include/clang/Basic/ include/clang/Parse/
Ted Kremenek
kremenek at apple.com
Wed Dec 12 14:39:37 PST 2007
Author: kremenek
Date: Wed Dec 12 16:39:36 2007
New Revision: 44957
URL: http://llvm.org/viewvc/llvm-project?rev=44957&view=rev
Log:
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.
Modified:
cfe/trunk/AST/ASTContext.cpp
cfe/trunk/AST/Expr.cpp
cfe/trunk/Analysis/DeadStores.cpp
cfe/trunk/Analysis/UninitializedValues.cpp
cfe/trunk/Basic/Diagnostic.cpp
cfe/trunk/Basic/SourceLocation.cpp
cfe/trunk/Basic/TargetInfo.cpp
cfe/trunk/Basic/Targets.cpp
cfe/trunk/CodeGen/CodeGenModule.cpp
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/Driver/TextDiagnosticBuffer.cpp
cfe/trunk/Driver/TextDiagnosticBuffer.h
cfe/trunk/Driver/TextDiagnosticPrinter.cpp
cfe/trunk/Driver/TextDiagnosticPrinter.h
cfe/trunk/Driver/TextDiagnostics.cpp
cfe/trunk/Driver/TextDiagnostics.h
cfe/trunk/Driver/TranslationUnit.cpp
cfe/trunk/Driver/clang.cpp
cfe/trunk/Lex/LiteralSupport.cpp
cfe/trunk/Lex/PPExpressions.cpp
cfe/trunk/Lex/Preprocessor.cpp
cfe/trunk/Parse/Parser.cpp
cfe/trunk/Sema/Sema.cpp
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Parse/DeclSpec.h
Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Wed Dec 12 16:39:36 2007
@@ -128,7 +128,7 @@
// C99 6.2.5p2.
InitBuiltinType(BoolTy, BuiltinType::Bool);
// C99 6.2.5p3.
- if (Target.isCharSigned(SourceLocation()))
+ if (Target.isCharSigned(FullSourceLoc()))
InitBuiltinType(CharTy, BuiltinType::Char_S);
else
InitBuiltinType(CharTy, BuiltinType::Char_U);
@@ -213,26 +213,47 @@
default: assert(0 && "Unknown builtin type!");
case BuiltinType::Void:
assert(0 && "Incomplete types have no size!");
- case BuiltinType::Bool: Target.getBoolInfo(Size, Align, L); break;
+ case BuiltinType::Bool: Target.getBoolInfo(Size,Align,getFullLoc(L));
+ break;
+
case BuiltinType::Char_S:
case BuiltinType::Char_U:
case BuiltinType::UChar:
- case BuiltinType::SChar: Target.getCharInfo(Size, Align, L); break;
+ case BuiltinType::SChar: Target.getCharInfo(Size,Align,getFullLoc(L));
+ break;
+
case BuiltinType::UShort:
- case BuiltinType::Short: Target.getShortInfo(Size, Align, L); break;
+ case BuiltinType::Short: Target.getShortInfo(Size,Align,getFullLoc(L));
+ break;
+
case BuiltinType::UInt:
- case BuiltinType::Int: Target.getIntInfo(Size, Align, L); break;
+ case BuiltinType::Int: Target.getIntInfo(Size,Align,getFullLoc(L));
+ break;
+
case BuiltinType::ULong:
- case BuiltinType::Long: Target.getLongInfo(Size, Align, L); break;
+ case BuiltinType::Long: Target.getLongInfo(Size,Align,getFullLoc(L));
+ break;
+
case BuiltinType::ULongLong:
- case BuiltinType::LongLong: Target.getLongLongInfo(Size, Align, L); break;
- case BuiltinType::Float: Target.getFloatInfo(Size, Align, F, L); break;
- case BuiltinType::Double: Target.getDoubleInfo(Size, Align, F, L);break;
- case BuiltinType::LongDouble:Target.getLongDoubleInfo(Size,Align,F,L);break;
+ case BuiltinType::LongLong: Target.getLongLongInfo(Size,Align,
+ getFullLoc(L));
+ break;
+
+ case BuiltinType::Float: Target.getFloatInfo(Size,Align,F,
+ getFullLoc(L));
+ break;
+
+ case BuiltinType::Double: Target.getDoubleInfo(Size,Align,F,
+ getFullLoc(L));
+ break;
+
+ case BuiltinType::LongDouble: Target.getLongDoubleInfo(Size,Align,F,
+ getFullLoc(L));
+ break;
}
break;
}
- case Type::Pointer: Target.getPointerInfo(Size, Align, L); break;
+ case Type::Pointer: Target.getPointerInfo(Size, Align, getFullLoc(L)); break;
case Type::Reference:
// "When applied to a reference or a reference type, the result is the size
// of the referenced type." C++98 5.3.3p2: expr.sizeof.
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Wed Dec 12 16:39:36 2007
@@ -625,7 +625,9 @@
Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(),
Exp->getOperatorLoc());
} else {
- unsigned CharSize = Ctx.Target.getCharWidth(Exp->getOperatorLoc());
+ unsigned CharSize =
+ Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc()));
+
Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(),
Exp->getOperatorLoc()) / CharSize;
}
Modified: cfe/trunk/Analysis/DeadStores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/DeadStores.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Analysis/DeadStores.cpp (original)
+++ cfe/trunk/Analysis/DeadStores.cpp Wed Dec 12 16:39:36 2007
@@ -40,8 +40,8 @@
if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl()))
if (VD->hasLocalStorage() && !Live(VD,AD)) {
SourceRange R = B->getRHS()->getSourceRange();
- Diags.Report(DR->getSourceRange().getBegin(), diag::warn_dead_store,
- Ctx.getSourceManager(), 0, 0, &R, 1);
+ Diags.Report(Ctx.getFullLoc(DR->getSourceRange().getBegin()),
+ diag::warn_dead_store, 0, 0, &R, 1);
}
}
else if(DeclStmt* DS = dyn_cast<DeclStmt>(S))
@@ -62,8 +62,8 @@
if (!E->isConstantExpr(Ctx,NULL)) {
// Flag a warning.
SourceRange R = E->getSourceRange();
- Diags.Report(V->getLocation(), diag::warn_dead_store,
- Ctx.getSourceManager(), 0, 0, &R, 1);
+ Diags.Report(Ctx.getFullLoc(V->getLocation()),
+ diag::warn_dead_store, 0, 0, &R, 1);
}
}
}
Modified: cfe/trunk/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/Analysis/UninitializedValues.cpp Wed Dec 12 16:39:36 2007
@@ -222,8 +222,8 @@
if (V(VD,AD) == Uninitialized)
if (AlreadyWarned.insert(VD))
- Diags.Report(DR->getSourceRange().getBegin(), diag::warn_uninit_val,
- Ctx.getSourceManager());
+ Diags.Report(Ctx.getFullLoc(DR->getSourceRange().getBegin()),
+ diag::warn_uninit_val);
}
};
} // end anonymous namespace
Modified: cfe/trunk/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/Diagnostic.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/Basic/Diagnostic.cpp Wed Dec 12 16:39:36 2007
@@ -197,8 +197,7 @@
/// 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 @@
}
// 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;
}
Modified: cfe/trunk/Basic/SourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceLocation.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Basic/SourceLocation.cpp (original)
+++ cfe/trunk/Basic/SourceLocation.cpp Wed Dec 12 16:39:36 2007
@@ -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 @@
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());
+}
Modified: cfe/trunk/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/TargetInfo.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/Basic/TargetInfo.cpp Wed Dec 12 16:39:36 2007
@@ -29,20 +29,20 @@
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 @@
/// 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 @@
/// 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
Modified: cfe/trunk/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/Targets.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Basic/Targets.cpp (original)
+++ cfe/trunk/Basic/Targets.cpp Wed Dec 12 16:39:36 2007
@@ -699,8 +699,7 @@
/// 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 @@
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) {
Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Wed Dec 12 16:39:36 2007
@@ -40,7 +40,7 @@
"cannot codegen this %0 yet");
SourceRange Range = S->getSourceRange();
std::string Msg = Type;
- getDiags().Report(S->getLocStart(), DiagID, Context.getSourceManager(),
+ getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID,
&Msg, 1, &Range, 1);
}
@@ -559,7 +559,7 @@
if (MemCpyFn) return MemCpyFn;
llvm::Intrinsic::ID IID;
uint64_t Size; unsigned Align;
- Context.Target.getPointerInfo(Size, Align, SourceLocation());
+ Context.Target.getPointerInfo(Size, Align, FullSourceLoc());
switch (Size) {
default: assert(0 && "Unknown ptr width");
case 32: IID = llvm::Intrinsic::memcpy_i32; break;
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Dec 12 16:39:36 2007
@@ -911,8 +911,7 @@
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
"rewriter could not replace sub-expression due to macros");
SourceRange Range = Exp->getSourceRange();
- Diags.Report(Exp->getAtLoc(), DiagID, Context->getSourceManager(),
- 0, 0, &Range, 1);
+ Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
delete Replacement;
return Exp;
}
Modified: cfe/trunk/Driver/TextDiagnosticBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticBuffer.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnosticBuffer.cpp (original)
+++ cfe/trunk/Driver/TextDiagnosticBuffer.cpp Wed Dec 12 16:39:36 2007
@@ -19,9 +19,8 @@
///
void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags,
Diagnostic::Level Level,
- SourceLocation Pos,
+ FullSourceLoc Pos,
diag::kind ID,
- SourceManager* SrcMgr,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *,
@@ -29,12 +28,14 @@
switch (Level) {
default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
case Diagnostic::Warning:
- Warnings.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID,
- Strs, NumStrs)));
+ Warnings.push_back(std::make_pair(Pos.getLocation(),
+ FormatDiagnostic(Diags, Level, ID,
+ Strs, NumStrs)));
break;
case Diagnostic::Error:
- Errors.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID,
- Strs, NumStrs)));
+ Errors.push_back(std::make_pair(Pos.getLocation(),
+ FormatDiagnostic(Diags, Level, ID,
+ Strs, NumStrs)));
break;
}
}
Modified: cfe/trunk/Driver/TextDiagnosticBuffer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticBuffer.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnosticBuffer.h (original)
+++ cfe/trunk/Driver/TextDiagnosticBuffer.h Wed Dec 12 16:39:36 2007
@@ -38,10 +38,10 @@
const_iterator warn_begin() const { return Warnings.begin(); }
const_iterator warn_end() const { return Warnings.end(); }
- virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel,
- SourceLocation Pos,
+ virtual void HandleDiagnostic(Diagnostic &Diags,
+ Diagnostic::Level DiagLevel,
+ FullSourceLoc Pos,
diag::kind ID,
- SourceManager* SrcMgr,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
Modified: cfe/trunk/Driver/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/Driver/TextDiagnosticPrinter.cpp Wed Dec 12 16:39:36 2007
@@ -31,23 +31,23 @@
" diagnostics"));
void TextDiagnosticPrinter::
-PrintIncludeStack(SourceLocation Pos, SourceManager& SourceMgr) {
+PrintIncludeStack(FullSourceLoc Pos) {
if (Pos.isInvalid()) return;
- Pos = SourceMgr.getLogicalLoc(Pos);
+ Pos = Pos.getLogicalLoc();
// Print out the other include frames first.
- PrintIncludeStack(SourceMgr.getIncludeLoc(Pos),SourceMgr);
- unsigned LineNo = SourceMgr.getLineNumber(Pos);
+ PrintIncludeStack(Pos.getIncludeLoc());
+ unsigned LineNo = Pos.getLineNumber();
- std::cerr << "In file included from " << SourceMgr.getSourceName(Pos)
+ std::cerr << "In file included from " << Pos.getSourceName()
<< ":" << LineNo << ":\n";
}
/// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s)
/// any characters in LineNo that intersect the SourceRange.
void TextDiagnosticPrinter::HighlightRange(const SourceRange &R,
- SourceManager* SourceMgr,
+ SourceManager& SourceMgr,
unsigned LineNo,
std::string &CaratLine,
const std::string &SourceLine) {
@@ -55,16 +55,16 @@
"Expect a correspondence between source and carat line!");
if (!R.isValid()) return;
- unsigned StartLineNo = SourceMgr->getLogicalLineNumber(R.getBegin());
+ unsigned StartLineNo = SourceMgr.getLogicalLineNumber(R.getBegin());
if (StartLineNo > LineNo) return; // No intersection.
- unsigned EndLineNo = SourceMgr->getLogicalLineNumber(R.getEnd());
+ unsigned EndLineNo = SourceMgr.getLogicalLineNumber(R.getEnd());
if (EndLineNo < LineNo) return; // No intersection.
// Compute the column number of the start.
unsigned StartColNo = 0;
if (StartLineNo == LineNo) {
- StartColNo = SourceMgr->getLogicalColumnNumber(R.getBegin());
+ StartColNo = SourceMgr.getLogicalColumnNumber(R.getBegin());
if (StartColNo) --StartColNo; // Zero base the col #.
}
@@ -76,12 +76,12 @@
// Compute the column number of the end.
unsigned EndColNo = CaratLine.size();
if (EndLineNo == LineNo) {
- EndColNo = SourceMgr->getLogicalColumnNumber(R.getEnd());
+ EndColNo = SourceMgr.getLogicalColumnNumber(R.getEnd());
if (EndColNo) {
--EndColNo; // Zero base the col #.
// Add in the length of the token, so that we cover multi-char tokens.
- EndColNo += Lexer::MeasureTokenLength(R.getEnd(), *SourceMgr);
+ EndColNo += Lexer::MeasureTokenLength(R.getEnd(), SourceMgr);
} else {
EndColNo = CaratLine.size();
}
@@ -100,9 +100,8 @@
void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags,
Diagnostic::Level Level,
- SourceLocation Pos,
+ FullSourceLoc Pos,
diag::kind ID,
- SourceManager* SourceMgr,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
@@ -111,25 +110,25 @@
const char *LineStart = 0, *LineEnd = 0;
if (Pos.isValid()) {
- SourceLocation LPos = SourceMgr->getLogicalLoc(Pos);
- LineNo = SourceMgr->getLineNumber(LPos);
+ FullSourceLoc LPos = Pos.getLogicalLoc();
+ LineNo = LPos.getLineNumber();
// First, if this diagnostic is not in the main file, print out the
// "included from" lines.
- if (LastWarningLoc != SourceMgr->getIncludeLoc(LPos)) {
- LastWarningLoc = SourceMgr->getIncludeLoc(LPos);
- PrintIncludeStack(LastWarningLoc,*SourceMgr);
+ if (LastWarningLoc != LPos.getIncludeLoc()) {
+ LastWarningLoc = LPos.getIncludeLoc();
+ PrintIncludeStack(LastWarningLoc);
}
// Compute the column number. Rewind from the current position to the start
// of the line.
- ColNo = SourceMgr->getColumnNumber(LPos);
- const char *TokLogicalPtr = SourceMgr->getCharacterData(LPos);
+ ColNo = LPos.getColumnNumber();
+ const char *TokLogicalPtr = LPos.getCharacterData();
LineStart = TokLogicalPtr-ColNo+1; // Column # is 1-based
// Compute the line end. Scan forward from the error position to the end of
// the line.
- const llvm::MemoryBuffer *Buffer = SourceMgr->getBuffer(LPos.getFileID());
+ const llvm::MemoryBuffer *Buffer = LPos.getBuffer();
const char *BufEnd = Buffer->getBufferEnd();
LineEnd = TokLogicalPtr;
while (LineEnd != BufEnd &&
@@ -164,7 +163,7 @@
// Highlight all of the characters covered by Ranges with ~ characters.
for (unsigned i = 0; i != NumRanges; ++i)
- HighlightRange(Ranges[i], SourceMgr, LineNo, CaratLine, SourceLine);
+ HighlightRange(Ranges[i], Pos.getManager(),LineNo, CaratLine, SourceLine);
// Next, insert the carat itself.
if (ColNo-1 < CaratLine.size())
Modified: cfe/trunk/Driver/TextDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnosticPrinter.h (original)
+++ cfe/trunk/Driver/TextDiagnosticPrinter.h Wed Dec 12 16:39:36 2007
@@ -22,21 +22,22 @@
class SourceManager;
class TextDiagnosticPrinter : public TextDiagnostics {
- SourceLocation LastWarningLoc;
+ FullSourceLoc LastWarningLoc;
public:
TextDiagnosticPrinter() {}
- void PrintIncludeStack(SourceLocation Pos, SourceManager& SrcMgr);
+ void PrintIncludeStack(FullSourceLoc Pos);
+
void HighlightRange(const SourceRange &R,
- SourceManager* SrcMgr,
+ SourceManager& SrcMgr,
unsigned LineNo,
std::string &CaratLine,
const std::string &SourceLine);
- virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel,
- SourceLocation Pos,
+ virtual void HandleDiagnostic(Diagnostic &Diags,
+ Diagnostic::Level DiagLevel,
+ FullSourceLoc Pos,
diag::kind ID,
- SourceManager* SrcMgr,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
Modified: cfe/trunk/Driver/TextDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnostics.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnostics.cpp (original)
+++ cfe/trunk/Driver/TextDiagnostics.cpp Wed Dec 12 16:39:36 2007
@@ -40,13 +40,12 @@
}
bool TextDiagnostics::IgnoreDiagnostic(Diagnostic::Level Level,
- SourceLocation Pos,
- SourceManager* SourceMgr) {
+ FullSourceLoc Pos) {
if (Pos.isValid()) {
// If this is a warning or note, and if it a system header, suppress the
// diagnostic.
if (Level == Diagnostic::Warning || Level == Diagnostic::Note) {
- if (const FileEntry *F = SourceMgr->getFileEntryForLoc(Pos)) {
+ if (const FileEntry *F = Pos.getFileEntryForLoc()) {
DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
if (DirInfo == DirectoryLookup::SystemHeaderDir ||
DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
Modified: cfe/trunk/Driver/TextDiagnostics.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnostics.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TextDiagnostics.h (original)
+++ cfe/trunk/Driver/TextDiagnostics.h Wed Dec 12 16:39:36 2007
@@ -35,13 +35,11 @@
void setHeaderSearch(HeaderSearch &HS) { TheHeaderSearch = &HS; }
virtual bool IgnoreDiagnostic(Diagnostic::Level Level,
- SourceLocation Pos,
- SourceManager* SrcMgr);
+ FullSourceLoc Pos);
virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel,
- SourceLocation Pos,
+ FullSourceLoc Pos,
diag::kind ID,
- SourceManager* SrcMgr,
const std::string *Strs,
unsigned NumStrs,
const SourceRange *Ranges,
Modified: cfe/trunk/Driver/TranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/TranslationUnit.cpp (original)
+++ cfe/trunk/Driver/TranslationUnit.cpp Wed Dec 12 16:39:36 2007
@@ -184,7 +184,7 @@
assert (FoundBlock);
// Read the SourceManager.
- SourceManager& SrcMgr = *SourceManager::CreateAndRegister(Dezr,FMgr);
+ SourceManager::CreateAndRegister(Dezr,FMgr);
// Read the LangOptions.
TU->LangOpts.Read(Dezr);
@@ -193,8 +193,7 @@
llvm::SerializedPtrID PtrID = Dezr.ReadPtrID();
char* triple = Dezr.ReadCStr(NULL,0,true);
std::string Triple(triple);
- Dezr.RegisterPtr(PtrID,TargetInfo::CreateTargetInfo(SrcMgr,
- &Triple,
+ Dezr.RegisterPtr(PtrID,TargetInfo::CreateTargetInfo(&Triple,
&Triple+1));
delete [] triple;
}
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Dec 12 16:39:36 2007
@@ -1019,8 +1019,7 @@
// Create triples, and create the TargetInfo.
std::vector<std::string> triples;
CreateTargetTriples(triples);
- Target = TargetInfo::CreateTargetInfo(SourceMgr,
- &triples[0],
+ Target = TargetInfo::CreateTargetInfo(&triples[0],
&triples[0]+triples.size(),
&Diags);
Modified: cfe/trunk/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/LiteralSupport.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/Lex/LiteralSupport.cpp Wed Dec 12 16:39:36 2007
@@ -93,8 +93,10 @@
}
// See if any bits will be truncated when evaluated as a character.
- unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc)
- : PP.getTargetInfo().getCharWidth(Loc);
+ unsigned CharWidth = IsWide
+ ? PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc))
+ : PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc));
+
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
Overflow = true;
ResultChar &= ~0U >> (32-CharWidth);
@@ -122,8 +124,10 @@
ThisTokBuf[0] >= '0' && ThisTokBuf[0] <= '7');
// Check for overflow. Reject '\777', but not L'\777'.
- unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc)
- : PP.getTargetInfo().getCharWidth(Loc);
+ unsigned CharWidth = IsWide
+ ? PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc))
+ : PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc));
+
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
PP.Diag(Loc, diag::warn_octal_escape_too_large);
ResultChar &= ~0U >> (32-CharWidth);
@@ -453,13 +457,13 @@
// FIXME: This assumes that 'int' is 32-bits in overflow calculation, and the
// size of "value".
- assert(PP.getTargetInfo().getIntWidth(Loc) == 32 &&
+ assert(PP.getTargetInfo().getIntWidth(PP.getFullLoc(Loc)) == 32 &&
"Assumes sizeof(int) == 4 for now");
// FIXME: This assumes that wchar_t is 32-bits for now.
- assert(PP.getTargetInfo().getWCharWidth(Loc) == 32 &&
+ assert(PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc)) == 32 &&
"Assumes sizeof(wchar_t) == 4 for now");
// FIXME: This extensively assumes that 'char' is 8-bits.
- assert(PP.getTargetInfo().getCharWidth(Loc) == 8 &&
+ assert(PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc)) == 8 &&
"Assumes char is 8 bits");
bool isFirstChar = true;
@@ -505,7 +509,7 @@
// character constants are not sign extended in the this implementation:
// '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC.
if (!IsWide && !isMultiChar && (Value & 128) &&
- PP.getTargetInfo().isCharSigned(Loc))
+ PP.getTargetInfo().isCharSigned(PP.getFullLoc(Loc)))
Value = (signed char)Value;
}
@@ -583,7 +587,9 @@
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
wchar_tByteWidth = ~0U;
if (AnyWide) {
- wchar_tByteWidth = Target.getWCharWidth(StringToks[0].getLocation());
+ wchar_tByteWidth =
+ Target.getWCharWidth(PP.getFullLoc(StringToks[0].getLocation()));
+
assert((wchar_tByteWidth & 7) == 0 && "Assumes wchar_t is byte multiple!");
wchar_tByteWidth /= 8;
}
Modified: cfe/trunk/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/PPExpressions.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/Lex/PPExpressions.cpp Wed Dec 12 16:39:36 2007
@@ -112,15 +112,17 @@
if (Macro->isTargetSpecific()) {
// Don't warn on second use.
Macro->setIsTargetSpecific(false);
- PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(),
- diag::port_target_macro_use);
+ PP.getTargetInfo().DiagnoseNonPortability(
+ PP.getFullLoc(PeekTok.getLocation()),
+ diag::port_target_macro_use);
}
} else if (ValueLive) {
// Use of a target-specific macro for some other target? If so, warn.
if (II->isOtherTargetMacro()) {
II->setIsOtherTargetMacro(false); // Don't warn on second use.
- PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(),
- diag::port_target_macro_use);
+ PP.getTargetInfo().DiagnoseNonPortability(
+ PP.getFullLoc(PeekTok.getLocation()),
+ diag::port_target_macro_use);
}
}
@@ -211,16 +213,16 @@
TargetInfo &TI = PP.getTargetInfo();
unsigned NumBits;
if (Literal.isWide())
- NumBits = TI.getWCharWidth(PeekTok.getLocation());
+ NumBits = TI.getWCharWidth(PP.getFullLoc(PeekTok.getLocation()));
else
- NumBits = TI.getCharWidth(PeekTok.getLocation());
+ NumBits = TI.getCharWidth(PP.getFullLoc(PeekTok.getLocation()));
// Set the width.
llvm::APSInt Val(NumBits);
// Set the value.
Val = Literal.getValue();
// Set the signedness.
- Val.setIsUnsigned(!TI.isCharSigned(PeekTok.getLocation()));
+ Val.setIsUnsigned(!TI.isCharSigned(PP.getFullLoc(PeekTok.getLocation())));
if (Result.getBitWidth() > Val.getBitWidth()) {
if (Val.isSigned())
@@ -617,7 +619,9 @@
Lex(Tok);
// C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t.
- unsigned BitWidth = getTargetInfo().getIntMaxTWidth(Tok.getLocation());
+ unsigned BitWidth =
+ getTargetInfo().getIntMaxTWidth(getFullLoc(Tok.getLocation()));
+
llvm::APSInt ResVal(BitWidth);
DefinedTracker DT;
if (EvaluateValue(ResVal, Tok, DT, true, *this)) {
Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Wed Dec 12 16:39:36 2007
@@ -120,12 +120,12 @@
/// the specified Token's location, translating the token's start
/// position in the current buffer into a SourcePosition object for rendering.
void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID) {
- Diags.Report(Loc, DiagID, SourceMgr);
+ Diags.Report(getFullLoc(Loc), DiagID);
}
void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg) {
- Diags.Report(Loc, DiagID, SourceMgr, &Msg, 1);
+ Diags.Report(getFullLoc(Loc), DiagID, &Msg, 1);
}
void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
@@ -791,7 +791,7 @@
// If this is the first use of a target-specific macro, warn about it.
if (MI->isTargetSpecific()) {
MI->setIsTargetSpecific(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(Identifier.getLocation(),
+ getTargetInfo().DiagnoseNonPortability(getFullLoc(Identifier.getLocation()),
diag::port_target_macro_use);
}
@@ -1227,7 +1227,7 @@
// This diagnosic is only emitted when macro expansion is enabled, because
// the macro would not have been expanded for the other target either.
II.setIsOtherTargetMacro(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(Identifier.getLocation(),
+ getTargetInfo().DiagnoseNonPortability(getFullLoc(Identifier.getLocation()),
diag::port_target_macro_use);
}
@@ -2337,15 +2337,17 @@
// If this is the first use of a target-specific macro, warn about it.
if (MI->isTargetSpecific()) {
MI->setIsTargetSpecific(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(MacroNameTok.getLocation(),
- diag::port_target_macro_use);
+ getTargetInfo().DiagnoseNonPortability(
+ getFullLoc(MacroNameTok.getLocation()),
+ diag::port_target_macro_use);
}
} else {
// Use of a target-specific macro for some other target? If so, warn.
if (MII->isOtherTargetMacro()) {
MII->setIsOtherTargetMacro(false); // Don't warn on second use.
- getTargetInfo().DiagnoseNonPortability(MacroNameTok.getLocation(),
- diag::port_target_macro_use);
+ getTargetInfo().DiagnoseNonPortability(
+ getFullLoc(MacroNameTok.getLocation()),
+ diag::port_target_macro_use);
}
}
Modified: cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/Parser.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/trunk/Parse/Parser.cpp Wed Dec 12 16:39:36 2007
@@ -31,7 +31,7 @@
void Parser::Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg) {
- Diags.Report(Loc, DiagID, PP.getSourceManager(), &Msg, 1);
+ Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID, &Msg, 1);
}
/// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'),
Modified: cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/trunk/Sema/Sema.cpp Wed Dec 12 16:39:36 2007
@@ -118,54 +118,51 @@
//===----------------------------------------------------------------------===//
bool Sema::Diag(SourceLocation Loc, unsigned DiagID) {
- PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager());
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) {
- PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), &Msg, 1);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2) {
std::string MsgArr[] = { Msg1, Msg2 };
- PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), MsgArr, 2);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, SourceRange Range) {
- PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), 0,0, &Range,1);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, &Range,1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
SourceRange Range) {
- PP.getDiagnostics().Report(Loc,DiagID,PP.getSourceManager(),&Msg,1,&Range,1);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, &Range,1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
const std::string &Msg2, SourceRange Range) {
std::string MsgArr[] = { Msg1, Msg2 };
- PP.getDiagnostics().Report(Loc,DiagID,PP.getSourceManager(),
- MsgArr,2,&Range,1);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2, &Range, 1);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID,
SourceRange R1, SourceRange R2) {
SourceRange RangeArr[] = { R1, R2 };
- PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(),
- 0, 0, RangeArr, 2);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, RangeArr, 2);
return true;
}
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
SourceRange R1, SourceRange R2) {
SourceRange RangeArr[] = { R1, R2 };
- PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), &Msg,
- 1, RangeArr, 2);
+ PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, RangeArr, 2);
return true;
}
@@ -173,8 +170,7 @@
const std::string &Msg2, SourceRange R1, SourceRange R2) {
std::string MsgArr[] = { Msg1, Msg2 };
SourceRange RangeArr[] = { R1, R2 };
- PP.getDiagnostics().Report(Range, DiagID, PP.getSourceManager(), MsgArr, 2,
- RangeArr, 2);
+ PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID, MsgArr,2,RangeArr, 2);
return true;
}
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Wed Dec 12 16:39:36 2007
@@ -135,7 +135,7 @@
if (II->isNonPortableBuiltin()) {
// Only emit this diagnostic once for this builtin.
II->setNonPortableBuiltin(false);
- Context.Target.DiagnoseNonPortability(IdLoc,
+ Context.Target.DiagnoseNonPortability(Context.getFullLoc(IdLoc),
diag::port_target_builtin_use);
}
// If this is a builtin on this (or all) targets, create the decl.
@@ -1506,7 +1506,8 @@
// TODO: If the result value doesn't fit in an int, it must be a long or long
// long value. ISO C does not support this, but GCC does as an extension,
// emit a warning.
- unsigned IntWidth = Context.Target.getIntWidth(Enum->getLocation());
+ unsigned IntWidth =
+ Context.Target.getIntWidth(Context.getFullLoc(Enum->getLocation()));
// Verify that all the values are okay, compute the size of the values, and
@@ -1562,11 +1563,15 @@
BestType = Context.IntTy;
BestWidth = IntWidth;
} else {
- BestWidth = Context.Target.getLongWidth(Enum->getLocation());
+ BestWidth =
+ Context.Target.getLongWidth(Context.getFullLoc(Enum->getLocation()));
+
if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth)
BestType = Context.LongTy;
else {
- BestWidth = Context.Target.getLongLongWidth(Enum->getLocation());
+ BestWidth = Context.Target.getLongLongWidth(
+ Context.getFullLoc(Enum->getLocation()));
+
if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
Diag(Enum->getLocation(), diag::warn_enum_too_large);
BestType = Context.LongLongTy;
@@ -1579,10 +1584,14 @@
BestType = Context.UnsignedIntTy;
BestWidth = IntWidth;
} else if (NumPositiveBits <=
- (BestWidth = Context.Target.getLongWidth(Enum->getLocation())))
+ (BestWidth = Context.Target.getLongWidth(
+ Context.getFullLoc(Enum->getLocation()))))
+
BestType = Context.UnsignedLongTy;
else {
- BestWidth = Context.Target.getLongLongWidth(Enum->getLocation());
+ BestWidth =
+ Context.Target.getLongLongWidth(Context.getFullLoc(Enum->getLocation()));
+
assert(NumPositiveBits <= BestWidth &&
"How could an initializer get larger than ULL?");
BestType = Context.UnsignedLongLongTy;
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Dec 12 16:39:36 2007
@@ -181,13 +181,17 @@
if (Literal.isFloat) {
Ty = Context.FloatTy;
- Context.Target.getFloatInfo(Size, Align, Format, Tok.getLocation());
+ Context.Target.getFloatInfo(Size, Align, Format,
+ Context.getFullLoc(Tok.getLocation()));
+
} else if (Literal.isLong) {
Ty = Context.LongDoubleTy;
- Context.Target.getLongDoubleInfo(Size, Align, Format, Tok.getLocation());
+ Context.Target.getLongDoubleInfo(Size, Align, Format,
+ Context.getFullLoc(Tok.getLocation()));
} else {
Ty = Context.DoubleTy;
- Context.Target.getDoubleInfo(Size, Align, Format, Tok.getLocation());
+ Context.Target.getDoubleInfo(Size, Align, Format,
+ Context.getFullLoc(Tok.getLocation()));
}
// isExact will be set by GetFloatValue().
@@ -207,7 +211,8 @@
Diag(Tok.getLocation(), diag::ext_longlong);
// Get the value in the widest-possible width.
- llvm::APInt ResultVal(Context.Target.getIntMaxTWidth(Tok.getLocation()), 0);
+ llvm::APInt ResultVal(Context.Target.getIntMaxTWidth(
+ Context.getFullLoc(Tok.getLocation())), 0);
if (Literal.GetIntegerValue(ResultVal)) {
// If this value didn't fit into uintmax_t, warn and force to ull.
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Dec 12 16:39:36 2007
@@ -77,6 +77,10 @@
SelectorTable &Selectors;
SourceManager& getSourceManager() { return SourceMgr; }
+
+ FullSourceLoc getFullLoc(SourceLocation Loc) const {
+ return FullSourceLoc(Loc,SourceMgr);
+ }
/// This is intentionally not serialized. It is populated by the
/// ASTContext ctor, and there are no external pointers/references to
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Dec 12 16:39:36 2007
@@ -147,25 +147,17 @@
/// Report - Issue the message to the client. DiagID is a member of the
/// diag::kind enum.
- void Report(SourceLocation Pos, unsigned DiagID, SourceManager& SrcMgr,
+ void Report(FullSourceLoc Pos, unsigned DiagID,
const std::string *Strs = 0, unsigned NumStrs = 0,
- const SourceRange *Ranges = 0, unsigned NumRanges = 0) {
- Report(Pos,DiagID,&SrcMgr,Strs,NumStrs,Ranges,NumRanges);
- }
-
+ const SourceRange *Ranges = 0, unsigned NumRanges = 0);
/// Report - Issue the message to the client. DiagID is a member of the
/// diag::kind enum.
- void Report(unsigned DiagID, const std::string *Strs = 0,
- unsigned NumStrs = 0, const SourceRange *Ranges = 0,
- unsigned NumRanges = 0) {
- Report(SourceLocation(),DiagID,NULL,Strs,NumStrs,Ranges,NumRanges);
+ void Report(unsigned DiagID,
+ const std::string *Strs = 0, unsigned NumStrs = 0,
+ const SourceRange *Ranges = 0, unsigned NumRanges = 0) {
+ Report(FullSourceLoc(),DiagID,Strs,NumStrs,Ranges,NumRanges);
}
-
-private:
- void Report(SourceLocation Pos, unsigned DiagID, SourceManager* SrcMgr,
- const std::string *Strs, unsigned NumStrs,
- const SourceRange *Ranges, unsigned NumRanges);
};
/// DiagnosticClient - This is an abstract interface implemented by clients of
@@ -177,16 +169,17 @@
/// IgnoreDiagnostic - If the client wants to ignore this diagnostic, then
/// return true.
virtual bool IgnoreDiagnostic(Diagnostic::Level DiagLevel,
- SourceLocation Pos,
- SourceManager* SrcMgr) = 0;
+ FullSourceLoc Pos) = 0;
/// HandleDiagnostic - Handle this diagnostic, reporting it to the user or
/// capturing it to a log as needed.
virtual void HandleDiagnostic(Diagnostic &Diags,
- Diagnostic::Level DiagLevel, SourceLocation Pos,
- diag::kind ID, SourceManager* SrcMgr,
+ Diagnostic::Level DiagLevel,
+ FullSourceLoc Pos,
+ diag::kind ID,
const std::string *Strs,
- unsigned NumStrs, const SourceRange *Ranges,
+ unsigned NumStrs,
+ const SourceRange *Ranges,
unsigned NumRanges) = 0;
};
Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 16:39:36 2007
@@ -17,9 +17,14 @@
#include <cassert>
#include "llvm/Bitcode/SerializationFwd.h"
+namespace llvm {
+class MemoryBuffer;
+}
+
namespace clang {
class SourceManager;
+class FileEntry;
/// SourceLocation - This is a carefully crafted 32-bit identifier that encodes
/// a full include stack, line and column number information for a position in
@@ -206,25 +211,50 @@
/// that expect both objects.
class FullSourceLoc {
SourceLocation Loc;
- const SourceManager* SrcMgr;
+ SourceManager* SrcMgr;
public:
// Creates a FullSourceLoc where isValid() returns false.
explicit FullSourceLoc()
: Loc(SourceLocation()), SrcMgr((SourceManager*) 0) {}
- explicit FullSourceLoc(SourceLocation loc, const SourceManager& smgr)
- : Loc(loc), SrcMgr(&smgr) {
- assert (loc.isValid() && "SourceLocation must be valid!");
- }
+ explicit FullSourceLoc(SourceLocation loc, SourceManager& smgr)
+ : Loc(loc), SrcMgr(&smgr) {}
bool isValid() const { return Loc.isValid(); }
+ bool isInvalid() const { return Loc.isInvalid(); }
+
+ SourceLocation getLocation() const { return Loc; }
- SourceLocation getSourceLocation() const { return Loc; }
+ SourceManager& getManager() {
+ assert (SrcMgr && "SourceManager is NULL.");
+ return *SrcMgr;
+ }
const SourceManager& getManager() const {
assert (SrcMgr && "SourceManager is NULL.");
return *SrcMgr;
}
+
+ FullSourceLoc getLogicalLoc();
+ FullSourceLoc getIncludeLoc();
+
+ unsigned getLineNumber();
+ unsigned getColumnNumber();
+
+ const char *getCharacterData() const;
+
+ const llvm::MemoryBuffer* getBuffer() const;
+
+ const char* getSourceName() const;
+ const FileEntry* getFileEntryForLoc() const;
+
+ bool operator==(const FullSourceLoc& RHS) const {
+ return SrcMgr == RHS.SrcMgr && Loc == RHS.Loc;
+ }
+
+ bool operator!=(const FullSourceLoc& RHS) const {
+ return SrcMgr != RHS.SrcMgr || Loc != RHS.Loc;
+ }
};
} // end namespace clang
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Dec 12 16:39:36 2007
@@ -42,9 +42,6 @@
/// diagnostic info, but does expect them to be alive for as long as it is.
///
class TargetInfo {
- /// SrcMgr - The SourceManager associated with this TargetInfo.
- SourceManager& SrcMgr;
-
/// Primary - This tracks the primary target in the target set.
///
const TargetInfoImpl *PrimaryTarget;
@@ -69,8 +66,7 @@
// TargetInfo Construction.
//==----------------------------------------------------------------==/
- TargetInfo(SourceManager& SMgr, const TargetInfoImpl *Primary,
- Diagnostic *D = 0) : SrcMgr(SMgr) {
+ TargetInfo(const TargetInfoImpl *Primary, Diagnostic *D = 0) {
PrimaryTarget = Primary;
Diag = D;
NonPortable = false;
@@ -83,8 +79,7 @@
/// CreateTargetInfo - Create a TargetInfo object from a group of
/// target triples. The first target triple is considered the primary
/// target.
- static TargetInfo* CreateTargetInfo(SourceManager& SrcMgr,
- const std::string* TriplesBeg,
+ static TargetInfo* CreateTargetInfo(const std::string* TriplesBeg,
const std::string* TripledEnd,
Diagnostic* Diags = NULL);
@@ -114,7 +109,7 @@
/// DiagnoseNonPortability - Emit a diagnostic indicating that the current
/// translation unit is non-portable due to a construct at the specified
/// location. DiagKind indicates what went wrong.
- void DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind);
+ void DiagnoseNonPortability(FullSourceLoc Loc, unsigned DiagKind);
/// getTargetDefines - Appends the target-specific #define values for this
/// target set to the specified buffer.
@@ -123,70 +118,71 @@
/// isCharSigned - Return true if 'char' is 'signed char' or false if it is
/// treated as 'unsigned char'. This is implementation defined according to
/// C99 6.2.5p15. In our implementation, this is target-specific.
- bool isCharSigned(SourceLocation Loc) {
+ bool isCharSigned(FullSourceLoc Loc) {
// FIXME: implement correctly.
return true;
}
/// getPointerWidth - Return the width of pointers on this target, we
/// currently assume one pointer type.
- void getPointerInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getPointerInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) {
Size = 32; // FIXME: implement correctly.
Align = 32;
}
/// getBoolInfo - Return the size of '_Bool' and C++ 'bool' for this target,
/// in bits.
- void getBoolInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getBoolInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) {
Size = Align = 8; // FIXME: implement correctly: wrong for ppc32.
}
/// getCharInfo - Return the size of 'char', 'signed char' and
/// 'unsigned char' for this target, in bits.
- void getCharInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getCharInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) {
Size = Align = 8; // FIXME: implement correctly.
}
/// getShortInfo - Return the size of 'signed short' and 'unsigned short' for
/// this target, in bits.
- void getShortInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getShortInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) {
Size = Align = 16; // FIXME: implement correctly.
}
/// getIntInfo - Return the size of 'signed int' and 'unsigned int' for this
/// target, in bits.
- void getIntInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getIntInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) {
Size = Align = 32; // FIXME: implement correctly.
}
/// getLongInfo - Return the size of 'signed long' and 'unsigned long' for
/// this target, in bits.
- void getLongInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getLongInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) {
Size = Align = 32; // FIXME: implement correctly: wrong for ppc64/x86-64
}
/// getLongLongInfo - Return the size of 'signed long long' and
/// 'unsigned long long' for this target, in bits.
void getLongLongInfo(uint64_t &Size, unsigned &Align,
- SourceLocation Loc) {
+ FullSourceLoc Loc) {
Size = Align = 64; // FIXME: implement correctly.
}
/// getFloatInfo - Characterize 'float' for this target.
void getFloatInfo(uint64_t &Size, unsigned &Align,
- const llvm::fltSemantics *&Format, SourceLocation Loc);
+ const llvm::fltSemantics *&Format, FullSourceLoc Loc);
/// getDoubleInfo - Characterize 'double' for this target.
void getDoubleInfo(uint64_t &Size, unsigned &Align,
- const llvm::fltSemantics *&Format, SourceLocation Loc);
+ const llvm::fltSemantics *&Format, FullSourceLoc Loc);
/// getLongDoubleInfo - Characterize 'long double' for this target.
void getLongDoubleInfo(uint64_t &Size, unsigned &Align,
- const llvm::fltSemantics *&Format, SourceLocation Loc);
+ const llvm::fltSemantics *&Format, FullSourceLoc Loc);
/// getWCharInfo - Return the size of wchar_t in bits.
///
- void getWCharInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) {
+ void getWCharInfo(uint64_t &Size, unsigned &Align,
+ FullSourceLoc Loc) {
if (!WCharWidth) ComputeWCharInfo(Loc);
Size = WCharWidth;
Align = WCharAlign;
@@ -194,7 +190,7 @@
/// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
/// target, in bits.
- unsigned getIntMaxTWidth(SourceLocation Loc) {
+ unsigned getIntMaxTWidth(FullSourceLoc Loc) {
// FIXME: implement correctly.
return 64;
}
@@ -237,31 +233,31 @@
///===---- Some helper methods ------------------------------------------===//
- unsigned getCharWidth(SourceLocation Loc) {
+ unsigned getCharWidth(FullSourceLoc Loc) {
uint64_t Size; unsigned Align;
getCharInfo(Size, Align, Loc);
return static_cast<unsigned>(Size);
}
- unsigned getWCharWidth(SourceLocation Loc) {
+ unsigned getWCharWidth(FullSourceLoc Loc) {
uint64_t Size; unsigned Align;
getWCharInfo(Size, Align, Loc);
return static_cast<unsigned>(Size);
}
- unsigned getIntWidth(SourceLocation Loc) {
+ unsigned getIntWidth(FullSourceLoc Loc) {
uint64_t Size; unsigned Align;
getIntInfo(Size, Align, Loc);
return static_cast<unsigned>(Size);
}
- unsigned getLongWidth(SourceLocation Loc) {
+ unsigned getLongWidth(FullSourceLoc Loc) {
uint64_t Size; unsigned Align;
getLongInfo(Size, Align, Loc);
return static_cast<unsigned>(Size);
}
- unsigned getLongLongWidth(SourceLocation Loc) {
+ unsigned getLongLongWidth(FullSourceLoc Loc) {
uint64_t Size; unsigned Align;
getLongLongInfo(Size, Align, Loc);
return static_cast<unsigned>(Size);
@@ -281,7 +277,7 @@
32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128";
}
private:
- void ComputeWCharInfo(SourceLocation Loc);
+ void ComputeWCharInfo(FullSourceLoc Loc);
};
Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=44957&r1=44956&r2=44957&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Dec 12 16:39:36 2007
@@ -271,12 +271,12 @@
private:
void Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
unsigned DiagID) {
- D.Report(Loc, DiagID, SrcMgr);
+ D.Report(FullSourceLoc(Loc,SrcMgr), DiagID);
}
void Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
unsigned DiagID, const std::string &info) {
- D.Report(Loc, DiagID, SrcMgr, &info, 1);
+ D.Report(FullSourceLoc(Loc,SrcMgr), DiagID, &info, 1);
}
};
More information about the cfe-commits
mailing list