diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-12-12 22:39:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-12-12 22:39:36 +0000 |
commit | 9c728dc4d8da89c73fcae74c9e72d7a83ffd7b6d (patch) | |
tree | e89a3acd2ddb4a993e1d6bac53c05628b24f4f2b | |
parent | 5e71124dabe8017f17ce8996e4161a202694e3e6 (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
30 files changed, 291 insertions, 187 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index f50929de93..322f34ccf2 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -128,7 +128,7 @@ void ASTContext::InitBuiltinTypes() { // 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 @@ ASTContext::getTypeInfo(QualType T, SourceLocation L) { 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. diff --git a/AST/Expr.cpp b/AST/Expr.cpp index c6a6ab3601..11aef7f7d0 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -625,7 +625,9 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, 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; } diff --git a/Analysis/DeadStores.cpp b/Analysis/DeadStores.cpp index 80e5ba7b48..836701049f 100644 --- a/Analysis/DeadStores.cpp +++ b/Analysis/DeadStores.cpp @@ -40,8 +40,8 @@ public: 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 @@ public: 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); } } } diff --git a/Analysis/UninitializedValues.cpp b/Analysis/UninitializedValues.cpp index 4e2969659d..aec3197279 100644 --- a/Analysis/UninitializedValues.cpp +++ b/Analysis/UninitializedValues.cpp @@ -222,8 +222,8 @@ public: 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 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) { diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index cc8ecd585b..30e1547558 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -40,7 +40,7 @@ void CodeGenModule::WarnUnsupported(const Stmt *S, const char *Type) { "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 @@ llvm::Function *CodeGenModule::getMemCpyFn() { 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; diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 6edfcb17d7..7392016021 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -911,8 +911,7 @@ Stmt *RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) { 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; } diff --git a/Driver/TextDiagnosticBuffer.cpp b/Driver/TextDiagnosticBuffer.cpp index f644c3f660..9e7575242b 100644 --- a/Driver/TextDiagnosticBuffer.cpp +++ b/Driver/TextDiagnosticBuffer.cpp @@ -19,9 +19,8 @@ using namespace clang; /// 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 @@ void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags, 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; } } diff --git a/Driver/TextDiagnosticBuffer.h b/Driver/TextDiagnosticBuffer.h index 53a6cb7e60..60ad8c06b2 100644 --- a/Driver/TextDiagnosticBuffer.h +++ b/Driver/TextDiagnosticBuffer.h @@ -38,10 +38,10 @@ public: 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, diff --git a/Driver/TextDiagnosticPrinter.cpp b/Driver/TextDiagnosticPrinter.cpp index 3df15158ae..598270b016 100644 --- a/Driver/TextDiagnosticPrinter.cpp +++ b/Driver/TextDiagnosticPrinter.cpp @@ -31,23 +31,23 @@ NoCaretDiagnostics("fno-caret-diagnostics", " 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 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, "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 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, // 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::HighlightRange(const SourceRange &R, 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 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, 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 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, // 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()) diff --git a/Driver/TextDiagnosticPrinter.h b/Driver/TextDiagnosticPrinter.h index 1f0a52ce71..4149c65acf 100644 --- a/Driver/TextDiagnosticPrinter.h +++ b/Driver/TextDiagnosticPrinter.h @@ -22,21 +22,22 @@ namespace clang { 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, diff --git a/Driver/TextDiagnostics.cpp b/Driver/TextDiagnostics.cpp index 052ea6b98d..d9928341dc 100644 --- a/Driver/TextDiagnostics.cpp +++ b/Driver/TextDiagnostics.cpp @@ -40,13 +40,12 @@ std::string TextDiagnostics::FormatDiagnostic(Diagnostic &Diags, } 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) diff --git a/Driver/TextDiagnostics.h b/Driver/TextDiagnostics.h index 7741ab99b8..219f414a79 100644 --- a/Driver/TextDiagnostics.h +++ b/Driver/TextDiagnostics.h @@ -35,13 +35,11 @@ public: 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, diff --git a/Driver/TranslationUnit.cpp b/Driver/TranslationUnit.cpp index f5c6cfff20..62a27f55ac 100644 --- a/Driver/TranslationUnit.cpp +++ b/Driver/TranslationUnit.cpp @@ -184,7 +184,7 @@ TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr, 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 @@ TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr, 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; } diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 316b93a64d..e827c9e748 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -1019,8 +1019,7 @@ int main(int argc, char **argv) { // 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); diff --git a/Lex/LiteralSupport.cpp b/Lex/LiteralSupport.cpp index d00d9c3b16..03138232dc 100644 --- a/Lex/LiteralSupport.cpp +++ b/Lex/LiteralSupport.cpp @@ -93,8 +93,10 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf, } // See if any bits will be truncated when evaluated as a character. - unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc) - |