[cfe-commits] r66789 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/Diagnostic.h include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticFrontendKinds.def include/clang/Basic/DiagnosticFrontendKinds.td include/clang/Frontend/FrontendDiagnostic.h lib/Basic/Diagnostic.cpp test/Analysis/CGColorSpace.c
Daniel Dunbar
daniel at zuster.org
Thu Mar 12 03:14:27 PDT 2009
Author: ddunbar
Date: Thu Mar 12 05:14:16 2009
New Revision: 66789
URL: http://llvm.org/viewvc/llvm-project?rev=66789&view=rev
Log:
Add Diagnostic files for Frontend and move a couple errors over.
- Notably, clang now exits with an error if it can't find a
file. This flushed out a bug in the CGColorSpace.c test case. :)
Added:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.def
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/test/Analysis/CGColorSpace.c
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=66789&r1=66788&r2=66789&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Mar 12 05:14:16 2009
@@ -25,8 +25,9 @@
#include "clang.h"
#include "ASTConsumers.h"
#include "clang/Frontend/CompileOptions.h"
-#include "clang/Frontend/PathDiagnosticClients.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/InitHeaderSearch.h"
+#include "clang/Frontend/PathDiagnosticClients.h"
#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Analysis/PathDiagnostic.h"
@@ -857,14 +858,16 @@
const FileEntry *File = FileMgr.getFile(InFile);
if (File) SourceMgr.createMainFileID(File, SourceLocation());
if (SourceMgr.getMainFileID().isInvalid()) {
- fprintf(stderr, "Error reading '%s'!\n",InFile.c_str());
+ PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading)
+ << InFile.c_str();
return true;
}
} else {
llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
if (SB) SourceMgr.createMainFileIDForMemBuffer(SB);
if (SourceMgr.getMainFileID().isInvalid()) {
- fprintf(stderr, "Error reading standard input! Empty?\n");
+ PP.getDiagnostics().Report(FullSourceLoc(),
+ diag::err_fe_error_reading_stdin);
return true;
}
}
@@ -1525,9 +1528,8 @@
llvm::OwningPtr<TargetInfo> Target(TargetInfo::CreateTargetInfo(Triple));
if (Target == 0) {
- fprintf(stderr, "Sorry, I don't know what target this is: %s\n",
- Triple.c_str());
- fprintf(stderr, "Please use -triple or -arch.\n");
+ Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple)
+ << Triple.c_str();
return 1;
}
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=66789&r1=66788&r2=66789&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Mar 12 05:14:16 2009
@@ -33,7 +33,8 @@
// Start position for diagnostics.
enum {
DIAG_START_DRIVER = 300,
- DIAG_START_LEX = DIAG_START_DRIVER + 100,
+ DIAG_START_FRONTEND = DIAG_START_DRIVER + 100,
+ DIAG_START_LEX = DIAG_START_FRONTEND + 100,
DIAG_START_PARSE = DIAG_START_LEX + 300,
DIAG_START_AST = DIAG_START_PARSE + 300,
DIAG_START_SEMA = DIAG_START_AST + 100,
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=66789&r1=66788&r2=66789&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Mar 12 05:14:16 2009
@@ -9,10 +9,10 @@
let Component = "Driver" in {
-def driver_no_such_file : Error<"no such file or directory: '%0'">
-def driver_unsupported_opt : Error<"unsupported option '%0'">
-def driver_unknown_stdin_type : Error<
+def err_drv_no_such_file : Error<"no such file or directory: '%0'">
+def err_drv_unsupported_opt : Error<"unsupported option '%0'">
+def err_drv_unknown_stdin_type : Error<
"-E or -x required when input is from standard input">
-def driver_unknown_language : Error<"language not recognized: '%0'">
+def err_drv_unknown_language : Error<"language not recognized: '%0'">
}
Added: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.def?rev=66789&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.def (added)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.def Thu Mar 12 05:14:16 2009
@@ -0,0 +1,20 @@
+//==--- DiagnosticFrontendKinds.def - frontend diagnostics ------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifdef FRONTENDSTART
+__FRONTENDSTART = DIAG_START_FRONTEND,
+#undef FRONTENDSTART
+#endif
+
+DIAG(err_fe_unknown_triple, ERROR,
+ "unknown target triple '%0', please use -triple or -arch")
+DIAG(err_fe_error_reading, ERROR,
+ "error reading '%0'")
+DIAG(err_fe_error_reading_stdin, ERROR,
+ "error reading stdin")
Added: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=66789&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (added)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Mar 12 05:14:16 2009
@@ -0,0 +1,15 @@
+//==--- DiagnosticFrontendKinds.td - frontend diagnostics -----------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+let Component = "Frontend" in {
+
+def err_fe_error_reading, Error< "error reading '%0'">
+def err_fe_error_reading_stdin : Error<"error reading stdin">
+
+}
Added: cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h?rev=66789&view=auto
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h (added)
+++ cfe/trunk/include/clang/Frontend/FrontendDiagnostic.h Thu Mar 12 05:14:16 2009
@@ -0,0 +1,27 @@
+//===--- DiagnosticFrontend.h - Diagnostics for frontend --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_FRONTENDDIAGNOSTIC_H
+#define LLVM_CLANG_FRONTENDDIAGNOSTIC_H
+
+#include "clang/Basic/Diagnostic.h"
+
+namespace clang {
+ namespace diag {
+ enum {
+#define DIAG(ENUM,FLAGS,DESC) ENUM,
+#define FRONTENDSTART
+#include "clang/Basic/DiagnosticFrontendKinds.def"
+#undef DIAG
+ NUM_BUILTIN_FRONTEND_DIAGNOSTICS
+ };
+ } // end namespace diag
+} // end namespace clang
+
+#endif
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=66789&r1=66788&r2=66789&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Mar 12 05:14:16 2009
@@ -48,6 +48,10 @@
#include "clang/Basic/DiagnosticDriverKinds.def"
0
};
+static unsigned char DiagnosticFlagsFrontend[] = {
+#include "clang/Basic/DiagnosticFrontendKinds.def"
+ 0
+};
static unsigned char DiagnosticFlagsLex[] = {
#include "clang/Basic/DiagnosticLexKinds.def"
0
@@ -78,8 +82,10 @@
unsigned res;
if (DiagID < diag::DIAG_START_DRIVER)
res = DiagnosticFlagsCommon[DiagID];
- else if (DiagID < diag::DIAG_START_LEX)
+ else if (DiagID < diag::DIAG_START_FRONTEND)
res = DiagnosticFlagsDriver[DiagID - diag::DIAG_START_DRIVER - 1];
+ else if (DiagID < diag::DIAG_START_LEX)
+ res = DiagnosticFlagsFrontend[DiagID - diag::DIAG_START_FRONTEND - 1];
else if (DiagID < diag::DIAG_START_PARSE)
res = DiagnosticFlagsLex[DiagID - diag::DIAG_START_LEX - 1];
else if (DiagID < diag::DIAG_START_AST)
@@ -104,6 +110,10 @@
#include "clang/Basic/DiagnosticDriverKinds.def"
0
};
+static const char * const DiagnosticTextFrontend[] = {
+#include "clang/Basic/DiagnosticFrontendKinds.def"
+ 0
+};
static const char * const DiagnosticTextLex[] = {
#include "clang/Basic/DiagnosticLexKinds.def"
0
@@ -249,8 +259,10 @@
const char *Diagnostic::getDescription(unsigned DiagID) const {
if (DiagID < diag::DIAG_START_DRIVER)
return DiagnosticTextCommon[DiagID];
- else if (DiagID < diag::DIAG_START_LEX)
+ else if (DiagID < diag::DIAG_START_FRONTEND)
return DiagnosticTextDriver[DiagID - diag::DIAG_START_DRIVER - 1];
+ else if (DiagID < diag::DIAG_START_LEX)
+ return DiagnosticTextFrontend[DiagID - diag::DIAG_START_FRONTEND - 1];
else if (DiagID < diag::DIAG_START_PARSE)
return DiagnosticTextLex[DiagID - diag::DIAG_START_LEX - 1];
else if (DiagID < diag::DIAG_START_AST)
Modified: cfe/trunk/test/Analysis/CGColorSpace.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/CGColorSpace.c?rev=66789&r1=66788&r2=66789&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/CGColorSpace.c (original)
+++ cfe/trunk/test/Analysis/CGColorSpace.c Thu Mar 12 05:14:16 2009
@@ -1,5 +1,5 @@
-// RUN: clang -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic verify %s &&
-// RUN: clang -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range verify %s &&
+// RUN: clang -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
+// RUN: clang -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
// RUN: clang -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
// RUN: clang -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
More information about the cfe-commits
mailing list