[cfe-commits] r84825 - /cfe/trunk/tools/CIndex/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Sun Oct 25 15:58:52 PDT 2009
Hi Ted,
The flush() calls on llvm::errs() should not be necessary?
- Daniel
On Wed, Oct 21, 2009 at 8:24 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Wed Oct 21 22:24:01 2009
> New Revision: 84825
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84825&view=rev
> Log:
> Add some explanatory diagnostics when clang_createTranslationUnitFromSource fails.
>
> Modified:
> cfe/trunk/tools/CIndex/CIndex.cpp
>
> Modified: cfe/trunk/tools/CIndex/CIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=84825&r1=84824&r2=84825&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/CIndex/CIndex.cpp (original)
> +++ cfe/trunk/tools/CIndex/CIndex.cpp Wed Oct 21 22:24:01 2009
> @@ -27,6 +27,7 @@
> #include "llvm/Support/MemoryBuffer.h"
> #include "llvm/System/Path.h"
> #include "llvm/System/Program.h"
> +#include "llvm/Support/raw_ostream.h"
>
> #include <cstdio>
> #include <vector>
> @@ -372,11 +373,19 @@
> std::string astName(ast_filename);
> std::string ErrMsg;
>
> - return ASTUnit::LoadFromPCHFile(astName, &ErrMsg,
> - CXXIdx->getDisplayDiagnostics() ?
> - NULL : new IgnoreDiagnosticsClient(),
> - CXXIdx->getOnlyLocalDecls(),
> - /* UseBumpAllocator = */ true);
> + CXTranslationUnit TU =
> + ASTUnit::LoadFromPCHFile(astName, &ErrMsg,
> + CXXIdx->getDisplayDiagnostics() ?
> + NULL : new IgnoreDiagnosticsClient(),
> + CXXIdx->getOnlyLocalDecls(),
> + /* UseBumpAllocator = */ true);
> +
> + if (CXXIdx->getDisplayDiagnostics() && !ErrMsg.empty()) {
> + (llvm::errs() << "clang_createTranslationUnit: " << ErrMsg
> + << '\n').flush();
> + }
> +
> + return TU;
> }
>
> CXTranslationUnit clang_createTranslationUnitFromSourceFile(
> @@ -429,10 +438,21 @@
>
> #ifndef LLVM_ON_WIN32
> llvm::sys::Path DevNull("/dev/null");
> + std::string ErrMsg;
> const llvm::sys::Path *Redirects[] = { &DevNull, &DevNull, &DevNull, NULL };
> - llvm::sys::Program::ExecuteAndWait(ClangPath, &argv[0], NULL,
> - !CXXIdx->getDisplayDiagnostics() ?
> - &Redirects[0] : NULL);
> + llvm::sys::Program::ExecuteAndWait(ClangPath, &argv[0], /* env */ NULL,
> + /* redirects */ !CXXIdx->getDisplayDiagnostics() ? &Redirects[0] : NULL,
> + /* secondsToWait */ 0, /* memoryLimits */ 0, &ErrMsg);
> +
> + if (CXXIdx->getDisplayDiagnostics() && !ErrMsg.empty()) {
> + llvm::errs() << "clang_createTranslationUnitFromSourceFile: " << ErrMsg
> + << '\n' << "Arguments: \n";
> + for (std::vector<const char*>::iterator I = argv.begin(), E = argv.end();
> + I!=E; ++I)
> + if (*I) llvm::errs() << ' ' << *I << '\n';
> +
> + (llvm::errs() << '\n').flush();
> + }
> #else
> // FIXME: I don't know what is the equivalent '/dev/null' redirect for
> // Windows for this API.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list