[cfe-commits] r86760 - in /cfe/trunk: include/clang/Basic/Diagnostic.h include/clang/Driver/Driver.h lib/Frontend/Warnings.cpp lib/Lex/PTHLexer.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 10 15:55:23 PST 2009
Author: ddunbar
Date: Tue Nov 10 17:55:23 2009
New Revision: 86760
URL: http://llvm.org/viewvc/llvm-project?rev=86760&view=rev
Log:
Add Diagnostic::Report method for reporting diagnostics without a location.
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Frontend/Warnings.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=86760&r1=86759&r2=86760&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Nov 10 17:55:23 2009
@@ -386,6 +386,7 @@
/// @c Pos represents the source location associated with the diagnostic,
/// which can be an invalid location if no position information is available.
inline DiagnosticBuilder Report(FullSourceLoc Pos, unsigned DiagID);
+ inline DiagnosticBuilder Report(unsigned DiagID);
/// \brief Clear out the current diagnostic.
void Clear() { CurDiagID = ~0U; }
@@ -671,6 +672,9 @@
CurDiagID = DiagID;
return DiagnosticBuilder(this);
}
+inline DiagnosticBuilder Diagnostic::Report(unsigned DiagID) {
+ return Report(FullSourceLoc(), DiagID);
+}
//===----------------------------------------------------------------------===//
// DiagnosticInfo
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=86760&r1=86759&r2=86760&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Nov 10 17:55:23 2009
@@ -48,7 +48,7 @@
public:
// Diag - Forwarding function for diagnostics.
DiagnosticBuilder Diag(unsigned DiagID) const {
- return Diags.Report(FullSourceLoc(), DiagID);
+ return Diags.Report(DiagID);
}
// FIXME: Privatize once interface is stable.
Modified: cfe/trunk/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Warnings.cpp?rev=86760&r1=86759&r2=86760&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/Warnings.cpp (original)
+++ cfe/trunk/lib/Frontend/Warnings.cpp Tue Nov 10 17:55:23 2009
@@ -100,8 +100,7 @@
}
if (Diags.setDiagnosticGroupMapping(OptStart, Mapping))
- Diags.Report(FullSourceLoc(), diag::warn_unknown_warning_option)
- << ("-W" + Opt);
+ Diags.Report(diag::warn_unknown_warning_option) << ("-W" + Opt);
}
return false;
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=86760&r1=86759&r2=86760&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Tue Nov 10 17:55:23 2009
@@ -411,8 +411,7 @@
const char* Msg = 0) {
if (!Diags) return;
if (!Msg) Msg = "Invalid or corrupted PTH file";
- unsigned DiagID = Diags->getCustomDiagID(level, Msg);
- Diags->Report(FullSourceLoc(), DiagID);
+ Diags->Report(Diags->getCustomDiagID(level, Msg));
}
PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
@@ -423,9 +422,9 @@
if (!File) {
if (Diags) {
- unsigned DiagID = Diags->getCustomDiagID(level,
- "PTH file %0 could not be read");
- Diags->Report(FullSourceLoc(), DiagID) << file;
+ unsigned DiagID =Diags->getCustomDiagID(level,
+ "PTH file %0 could not be read");
+ Diags->Report(DiagID) << file;
}
return 0;
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86760&r1=86759&r2=86760&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Tue Nov 10 17:55:23 2009
@@ -862,16 +862,14 @@
const FileEntry *File = FileMgr.getFile(InFile);
if (File) SourceMgr.createMainFileID(File, SourceLocation());
if (SourceMgr.getMainFileID().isInvalid()) {
- PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading)
- << InFile.c_str();
+ PP.getDiagnostics().Report(diag::err_fe_error_reading) << InFile.c_str();
return true;
}
} else {
llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
SourceMgr.createMainFileIDForMemBuffer(SB);
if (SourceMgr.getMainFileID().isInvalid()) {
- PP.getDiagnostics().Report(FullSourceLoc(),
- diag::err_fe_error_reading_stdin);
+ PP.getDiagnostics().Report(diag::err_fe_error_reading_stdin);
return true;
}
}
@@ -1576,8 +1574,7 @@
Context));
if (!Consumer.get()) {
- PP.getDiagnostics().Report(FullSourceLoc(),
- diag::err_fe_invalid_ast_action);
+ PP.getDiagnostics().Report(diag::err_fe_invalid_ast_action);
return;
}
@@ -1804,8 +1801,7 @@
// Set up the creation routine for code-completion.
CreateCodeCompleter = BuildPrintingCodeCompleter;
} else {
- PP.getDiagnostics().Report(FullSourceLoc(),
- diag::err_fe_invalid_code_complete_file)
+ PP.getDiagnostics().Report(diag::err_fe_invalid_code_complete_file)
<< CodeCompletionAt.FileName;
}
}
@@ -1904,7 +1900,7 @@
std::string Error;
llvm::OwningPtr<ASTUnit> AST(ASTUnit::LoadFromPCHFile(InFile, &Error));
if (!AST) {
- Diags.Report(FullSourceLoc(), diag::err_fe_invalid_ast_file) << Error;
+ Diags.Report(diag::err_fe_invalid_ast_file) << Error;
return;
}
@@ -1917,7 +1913,7 @@
OutPath, Context));
if (!Consumer.get()) {
- Diags.Report(FullSourceLoc(), diag::err_fe_invalid_ast_action);
+ Diags.Report(diag::err_fe_invalid_ast_action);
return;
}
@@ -1960,7 +1956,7 @@
static void LLVMErrorHandler(void *UserData, const std::string &Message) {
Diagnostic &Diags = *static_cast<Diagnostic*>(UserData);
- Diags.Report(FullSourceLoc(), diag::err_fe_error_backend) << Message;
+ Diags.Report(diag::err_fe_error_backend) << Message;
// We cannot recover from llvm errors.
exit(1);
@@ -2131,16 +2127,14 @@
Target(TargetInfo::CreateTargetInfo(Triple.getTriple()));
if (Target == 0) {
- Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple)
- << Triple.getTriple().c_str();
+ Diags.Report(diag::err_fe_unknown_triple) << Triple.getTriple().c_str();
return 1;
}
// Set the target ABI if specified.
if (!TargetABI.empty()) {
if (!Target->setABI(TargetABI)) {
- Diags.Report(FullSourceLoc(), diag::err_fe_unknown_target_abi)
- << TargetABI;
+ Diags.Report(diag::err_fe_unknown_target_abi) << TargetABI;
return 1;
}
}
@@ -2195,15 +2189,14 @@
// Handle generating dependencies, if requested.
if (!DependencyFile.empty()) {
if (DependencyTargets.empty()) {
- Diags.Report(FullSourceLoc(), diag::err_fe_dependency_file_requires_MT);
+ Diags.Report(diag::err_fe_dependency_file_requires_MT);
continue;
}
std::string ErrStr;
llvm::raw_ostream *DependencyOS =
new llvm::raw_fd_ostream(DependencyFile.c_str(), ErrStr);
if (!ErrStr.empty()) {
- Diags.Report(FullSourceLoc(), diag::err_fe_error_opening)
- << DependencyFile << ErrStr;
+ Diags.Report(diag::err_fe_error_opening) << DependencyFile << ErrStr;
continue;
}
More information about the cfe-commits
mailing list