summaryrefslogtreecommitdiffstats
path: root/clang/tools/CIndex
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-18 22:27:07 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-18 22:27:07 +0000
commit9773e3d077cbab5e4016f7fdb35e7aa30325a738 (patch)
tree949b6d16fc8512354f6935429d9c5c37b1fd87e0 /clang/tools/CIndex
parent42a7ba7a67fda0a594def3bf1480d07a8aec09d1 (diff)
downloadbcm5719-llvm-9773e3d077cbab5e4016f7fdb35e7aa30325a738.tar.gz
bcm5719-llvm-9773e3d077cbab5e4016f7fdb35e7aa30325a738.zip
Revert my CIndex diagnostic changes (r96603, 96606, 96607), which were
breaking the msvc9 builder for unknown reasons. llvm-svn: 96618
Diffstat (limited to 'clang/tools/CIndex')
-rw-r--r--clang/tools/CIndex/CIndex.cpp47
-rw-r--r--clang/tools/CIndex/CIndex.exports3
-rw-r--r--clang/tools/CIndex/CIndexDiagnostic.cpp75
-rw-r--r--clang/tools/CIndex/CIndexer.h12
4 files changed, 8 insertions, 129 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp
index 6e07ece4c35..8bb6a0a7c5f 100644
--- a/clang/tools/CIndex/CIndex.cpp
+++ b/clang/tools/CIndex/CIndex.cpp
@@ -27,7 +27,6 @@
#include "clang/Lex/Preprocessor.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Program.h"
-#include "llvm/System/Signals.h"
// Needed to define L_TMPNAM on some systems.
#include <cstdio>
@@ -904,13 +903,10 @@ bool CursorVisitor::VisitAttributes(Decl *D) {
}
extern "C" {
-CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
- int displayDiagnostics) {
+CXIndex clang_createIndex(int excludeDeclarationsFromPCH) {
CIndexer *CIdxr = new CIndexer();
if (excludeDeclarationsFromPCH)
CIdxr->setOnlyLocalDecls();
- if (displayDiagnostics)
- CIdxr->setDisplayDiagnostics();
return CIdxr;
}
@@ -997,18 +993,8 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
// FIXME: Until we have broader testing, just drop the entire AST if we
// encountered an error.
- if (NumErrors != Diags->getNumErrors()) {
- if (CXXIdx->getDisplayDiagnostics()) {
- for (ASTUnit::diag_iterator D = Unit->diag_begin(),
- DEnd = Unit->diag_end();
- D != DEnd; ++D) {
- CXStoredDiagnostic Diag(*D, Unit->getASTContext().getLangOptions());
- clang_displayDiagnostic(&Diag, stderr,
- clang_defaultDiagnosticDisplayOptions());
- }
- }
+ if (NumErrors != Diags->getNumErrors())
return 0;
- }
return Unit.take();
}
@@ -1099,35 +1085,18 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
RemappedFiles.data(),
RemappedFiles.size(),
/*CaptureDiagnostics=*/true);
+ if (ATU)
+ ATU->unlinkTemporaryFile();
+
+ // FIXME: Currently we don't report diagnostics on invalid ASTs.
if (ATU) {
LoadSerializedDiagnostics(DiagnosticsFile,
num_unsaved_files, unsaved_files,
ATU->getFileManager(),
ATU->getSourceManager(),
ATU->getDiagnostics());
- } else if (CXXIdx->getDisplayDiagnostics()) {
- // We failed to load the ASTUnit, but we can still deserialize the
- // diagnostics and emit them.
- FileManager FileMgr;
- SourceManager SourceMgr;
- // FIXME: Faked LangOpts!
- LangOptions LangOpts;
- llvm::SmallVector<StoredDiagnostic, 4> Diags;
- LoadSerializedDiagnostics(DiagnosticsFile,
- num_unsaved_files, unsaved_files,
- FileMgr, SourceMgr, Diags);
- for (llvm::SmallVector<StoredDiagnostic, 4>::iterator D = Diags.begin(),
- DEnd = Diags.end();
- D != DEnd; ++D) {
- CXStoredDiagnostic Diag(*D, LangOpts);
- clang_displayDiagnostic(&Diag, stderr,
- clang_defaultDiagnosticDisplayOptions());
- }
}
- if (ATU)
- ATU->unlinkTemporaryFile();
-
for (unsigned i = 0, e = TemporaryFiles.size(); i != e; ++i)
TemporaryFiles[i].eraseFromDisk();
@@ -1936,10 +1905,6 @@ void clang_getDefinitionSpellingAndExtent(CXCursor C,
*endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc());
}
-void clang_enableStackTraces(void) {
- llvm::sys::PrintStackTraceOnErrorSignal();
-}
-
} // end: extern "C"
//===----------------------------------------------------------------------===//
diff --git a/clang/tools/CIndex/CIndex.exports b/clang/tools/CIndex/CIndex.exports
index 449bb95a947..1c445b74aaa 100644
--- a/clang/tools/CIndex/CIndex.exports
+++ b/clang/tools/CIndex/CIndex.exports
@@ -5,15 +5,12 @@ _clang_codeCompleteGetNumDiagnostics
_clang_createIndex
_clang_createTranslationUnit
_clang_createTranslationUnitFromSourceFile
-_clang_defaultDiagnosticDisplayOptions
-_clang_displayDiagnostic
_clang_disposeCodeCompleteResults
_clang_disposeDiagnostic
_clang_disposeIndex
_clang_disposeString
_clang_disposeTokens
_clang_disposeTranslationUnit
-_clang_enableStackTraces
_clang_equalCursors
_clang_equalLocations
_clang_getClangVersion
diff --git a/clang/tools/CIndex/CIndexDiagnostic.cpp b/clang/tools/CIndex/CIndexDiagnostic.cpp
index 2933e6fd259..70676f0e141 100644
--- a/clang/tools/CIndex/CIndexDiagnostic.cpp
+++ b/clang/tools/CIndex/CIndexDiagnostic.cpp
@@ -47,81 +47,6 @@ void clang_disposeDiagnostic(CXDiagnostic Diagnostic) {
delete Stored;
}
-void clang_displayDiagnostic(CXDiagnostic Diagnostic, FILE *Out,
- unsigned Options) {
- if (!Diagnostic || !Out)
- return;
-
- CXDiagnosticSeverity Severity = clang_getDiagnosticSeverity(Diagnostic);
-
- // Ignore diagnostics that should be ignored.
- if (Severity == CXDiagnostic_Ignored)
- return;
-
- if (Options & CXDiagnostic_DisplaySourceLocation) {
- // Print source location (file:line), along with optional column
- // and source ranges.
- CXFile File;
- unsigned Line, Column;
- clang_getInstantiationLocation(clang_getDiagnosticLocation(Diagnostic),
- &File, &Line, &Column, 0);
- if (File) {
- CXString FName = clang_getFileName(File);
- fprintf(Out, "%s:%d:", clang_getCString(FName), Line);
- clang_disposeString(FName);
- if (Options & CXDiagnostic_DisplayColumn)
- fprintf(Out, "%d:", Column);
-
- if (Options & CXDiagnostic_DisplaySourceRanges) {
- unsigned N = clang_getDiagnosticNumRanges(Diagnostic);
- bool PrintedRange = false;
- for (unsigned I = 0; I != N; ++I) {
- CXFile StartFile, EndFile;
- CXSourceRange Range = clang_getDiagnosticRange(Diagnostic, I);
-
- unsigned StartLine, StartColumn, EndLine, EndColumn;
- clang_getInstantiationLocation(clang_getRangeStart(Range),
- &StartFile, &StartLine, &StartColumn,
- 0);
- clang_getInstantiationLocation(clang_getRangeEnd(Range),
- &EndFile, &EndLine, &EndColumn, 0);
-
- if (StartFile != EndFile || StartFile != File)
- continue;
-
- fprintf(Out, "{%d:%d-%d:%d}", StartLine, StartColumn,
- EndLine, EndColumn);
- PrintedRange = true;
- }
- if (PrintedRange)
- fprintf(Out, ":");
- }
- }
-
- fprintf(Out, " ");
- }
-
- /* Print warning/error/etc. */
- switch (Severity) {
- case CXDiagnostic_Ignored: assert(0 && "impossible"); break;
- case CXDiagnostic_Note: fprintf(Out, "note: "); break;
- case CXDiagnostic_Warning: fprintf(Out, "warning: "); break;
- case CXDiagnostic_Error: fprintf(Out, "error: "); break;
- case CXDiagnostic_Fatal: fprintf(Out, "fatal error: "); break;
- }
-
- CXString Text = clang_getDiagnosticSpelling(Diagnostic);
- if (clang_getCString(Text))
- fprintf(Out, "%s\n", clang_getCString(Text));
- else
- fprintf(Out, "<no diagnostic text>\n");
- clang_disposeString(Text);
-}
-
-unsigned clang_defaultDiagnosticDisplayOptions() {
- return CXDiagnostic_DisplaySourceLocation | CXDiagnostic_DisplayColumn;
-}
-
enum CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic Diag) {
CXStoredDiagnostic *StoredDiag = static_cast<CXStoredDiagnostic *>(Diag);
if (!StoredDiag)
diff --git a/clang/tools/CIndex/CIndexer.h b/clang/tools/CIndex/CIndexer.h
index 1fa3ca93876..d559f138647 100644
--- a/clang/tools/CIndex/CIndexer.h
+++ b/clang/tools/CIndex/CIndexer.h
@@ -34,14 +34,11 @@ namespace cxstring {
class CIndexer {
bool UseExternalASTGeneration;
bool OnlyLocalDecls;
- bool DisplayDiagnostics;
-
+
llvm::sys::Path ClangPath;
public:
- CIndexer()
- : UseExternalASTGeneration(false), OnlyLocalDecls(false),
- DisplayDiagnostics(false) { }
+ CIndexer() : UseExternalASTGeneration(false), OnlyLocalDecls(false) { }
/// \brief Whether we only want to see "local" declarations (that did not
/// come from a previous precompiled header). If false, we want to see all
@@ -49,11 +46,6 @@ public:
bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; }
- bool getDisplayDiagnostics() const { return DisplayDiagnostics; }
- void setDisplayDiagnostics(bool Display = true) {
- DisplayDiagnostics = Display;
- }
-
bool getUseExternalASTGeneration() const { return UseExternalASTGeneration; }
void setUseExternalASTGeneration(bool Value) {
UseExternalASTGeneration = Value;
OpenPOWER on IntegriCloud