add a libDriver, for now only move the text diangostics stuff from Driver to there

llvm-svn: 54383
This commit is contained in:
Nico Weber 2008-08-05 23:33:20 +00:00
parent 829e988899
commit b5fc3c300a
11 changed files with 52 additions and 24 deletions

View File

@ -13,7 +13,7 @@
#include "clang.h"
#include "ASTConsumers.h"
#include "TextDiagnosticBuffer.h"
#include "clang/Driver/TextDiagnosticBuffer.h"
#include "clang/Sema/ParseAST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Basic/SourceManager.h"

View File

@ -4,7 +4,7 @@ CXXFLAGS = -fno-rtti
TOOLNAME = clang
USEDLIBS = clangCodeGen.a clangAnalysis.a clangRewrite.a clangSEMA.a \
clangAST.a clangParse.a clangLex.a clangBasic.a \
clangDriver.a clangAST.a clangParse.a clangLex.a clangBasic.a \
LLVMCore.a LLVMSupport.a LLVMSystem.a \
LLVMBitWriter.a LLVMBitReader.a LLVMCodeGen.a LLVMAnalysis.a \
LLVMTarget.a

View File

@ -24,9 +24,9 @@
#include "clang.h"
#include "ASTConsumers.h"
#include "TextDiagnosticBuffer.h"
#include "TextDiagnosticPrinter.h"
#include "HTMLDiagnostics.h"
#include "clang/Driver/TextDiagnosticBuffer.h"
#include "clang/Driver/TextDiagnosticPrinter.h"
#include "clang/Analysis/PathDiagnostic.h"
#include "clang/AST/TranslationUnit.h"
#include "clang/CodeGen/ModuleBuilder.h"
@ -143,6 +143,16 @@ HTMLDiag("html-diags",
llvm::cl::desc("Generate HTML to report diagnostics"),
llvm::cl::value_desc("HTML directory"));
static llvm::cl::opt<bool>
NoShowColumn("fno-show-column",
llvm::cl::desc("Do not include column number on diagnostics"));
static llvm::cl::opt<bool>
NoCaretDiagnostics("fno-caret-diagnostics",
llvm::cl::desc("Do not include source line and caret with"
" diagnostics"));
//===----------------------------------------------------------------------===//
// Analyzer Options
//===----------------------------------------------------------------------===//
@ -1392,7 +1402,8 @@ int main(int argc, char **argv) {
else { // Use Text diagnostics.
if (!VerifyDiagnostics) {
// Print diagnostics to stderr by default.
TextDiagClient = new TextDiagnosticPrinter();
TextDiagClient = new TextDiagnosticPrinter(!NoShowColumn,
!NoCaretDiagnostics);
} else {
// When checking diagnostics, just buffer them up.
TextDiagClient = new TextDiagnosticBuffer();

View File

@ -14,7 +14,7 @@
#ifndef DRIVER_TEXT_DIAGNOSTIC_BUFFER_H_
#define DRIVER_TEXT_DIAGNOSTIC_BUFFER_H_
#include "TextDiagnostics.h"
#include "clang/Driver/TextDiagnostics.h"
#include <vector>
namespace clang {

View File

@ -15,7 +15,7 @@
#ifndef TEXT_DIAGNOSTIC_PRINTER_H_
#define TEXT_DIAGNOSTIC_PRINTER_H_
#include "TextDiagnostics.h"
#include "clang/Driver/TextDiagnostics.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/Support/Streams.h"
@ -26,8 +26,12 @@ class TextDiagnosticPrinter : public TextDiagnostics {
FullSourceLoc LastWarningLoc;
FullSourceLoc LastLoc;
llvm::OStream OS;
bool ShowColumn;
bool CaretDiagnostics;
public:
TextDiagnosticPrinter(llvm::OStream &os = llvm::cerr) : OS(os) {}
TextDiagnosticPrinter(bool showColumn = true, bool caretDiagnistics = true,
llvm::OStream &os = llvm::cerr)
: OS(os), ShowColumn(showColumn), CaretDiagnostics(caretDiagnistics) {}
void PrintIncludeStack(FullSourceLoc Pos);

22
clang/lib/Driver/Makefile Normal file
View File

@ -0,0 +1,22 @@
##===- clang/lib/Analysis/Makefile -------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This implements analyses built on top of source-level CFGs.
#
##===----------------------------------------------------------------------===##
LEVEL = ../../../..
LIBRARYNAME := clangDriver
BUILD_ARCHIVE = 1
CXXFLAGS = -fno-rtti
CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include
include $(LEVEL)/Makefile.common

View File

@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
#include "TextDiagnosticBuffer.h"
#include "clang/Driver/TextDiagnosticBuffer.h"
#include "clang/Basic/SourceManager.h"
using namespace clang;

View File

@ -11,24 +11,15 @@
//
//===----------------------------------------------------------------------===//
#include "TextDiagnosticPrinter.h"
#include "clang/Driver/TextDiagnosticPrinter.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Lexer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include <string>
using namespace clang;
static llvm::cl::opt<bool>
NoShowColumn("fno-show-column",
llvm::cl::desc("Do not include column number on diagnostics"));
static llvm::cl::opt<bool>
NoCaretDiagnostics("fno-caret-diagnostics",
llvm::cl::desc("Do not include source line and caret with"
" diagnostics"));
void TextDiagnosticPrinter::
PrintIncludeStack(FullSourceLoc Pos) {
if (Pos.isInvalid()) return;
@ -144,7 +135,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags,
++LineEnd;
OS << Buffer->getBufferIdentifier() << ":" << LineNo << ":";
if (ColNo && !NoShowColumn)
if (ColNo && ShowColumn)
OS << ColNo << ":";
OS << " ";
}
@ -160,7 +151,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags,
OS << FormatDiagnostic(Diags, Level, ID, Strs, NumStrs) << "\n";
if (!NoCaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || Ranges)) {
if (CaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || Ranges)) {
// Cache the LastLoc, it allows us to omit duplicate source/caret spewage.
LastLoc = Pos;

View File

@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
#include "TextDiagnostics.h"
#include "clang/Driver/TextDiagnostics.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/HeaderSearch.h"

View File

@ -8,7 +8,7 @@
##===----------------------------------------------------------------------===##
LEVEL = ../../..
PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite
PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite Driver
include $(LEVEL)/Makefile.common