[llvm-branch-commits] [cfe-branch] r123825 - in /cfe/branches/Apple/whitney: include/clang/Frontend/ASTUnit.h lib/Frontend/ASTUnit.cpp test/Index/warning-flags.c tools/libclang/CIndex.cpp

Daniel Dunbar daniel at zuster.org
Wed Jan 19 07:20:31 PST 2011


Author: ddunbar
Date: Wed Jan 19 09:20:31 2011
New Revision: 123825

URL: http://llvm.org/viewvc/llvm-project?rev=123825&view=rev
Log:
Merge r123793:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Wed Jan 19 01:02:47 2011 +0000

    Don't silently drop warning flags passed in to
    clang_createTranslationUnitFromSourceFile().

Added:
    cfe/branches/Apple/whitney/test/Index/warning-flags.c
Modified:
    cfe/branches/Apple/whitney/include/clang/Frontend/ASTUnit.h
    cfe/branches/Apple/whitney/lib/Frontend/ASTUnit.cpp
    cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp

Modified: cfe/branches/Apple/whitney/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Frontend/ASTUnit.h?rev=123825&r1=123824&r2=123825&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/branches/Apple/whitney/include/clang/Frontend/ASTUnit.h Wed Jan 19 09:20:31 2011
@@ -231,6 +231,7 @@
   bool ShouldCacheCodeCompletionResults;
   
   static void ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags,
+                             const char **ArgBegin, const char **ArgEnd,
                              ASTUnit &AST, bool CaptureDiagnostics);
 
 public:

Modified: cfe/branches/Apple/whitney/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Frontend/ASTUnit.cpp?rev=123825&r1=123824&r2=123825&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Frontend/ASTUnit.cpp Wed Jan 19 09:20:31 2011
@@ -473,6 +473,7 @@
 
 /// \brief Configure the diagnostics object for use with ASTUnit.
 void ASTUnit::ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags,
+                             const char **ArgBegin, const char **ArgEnd,
                              ASTUnit &AST, bool CaptureDiagnostics) {
   if (!Diags.getPtr()) {
     // No diagnostics engine was provided, so create our own diagnostics object
@@ -481,7 +482,8 @@
     DiagnosticClient *Client = 0;
     if (CaptureDiagnostics)
       Client = new StoredDiagnosticClient(AST.StoredDiagnostics);
-    Diags = CompilerInstance::createDiagnostics(DiagOpts, 0, 0, Client);
+    Diags = CompilerInstance::createDiagnostics(DiagOpts, ArgEnd- ArgBegin, 
+                                                ArgBegin, Client);
   } else if (CaptureDiagnostics) {
     Diags->setClient(new StoredDiagnosticClient(AST.StoredDiagnostics));
   }
@@ -495,7 +497,7 @@
                                   unsigned NumRemappedFiles,
                                   bool CaptureDiagnostics) {
   llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true));
-  ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+  ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
 
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;
@@ -1429,6 +1431,7 @@
   // We'll manage file buffers ourselves.
   Invocation->getPreprocessorOpts().RetainRemappedFileBuffers = true;
   Invocation->getFrontendOpts().DisableFree = false;
+  ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
 
   llvm::MemoryBuffer *OverrideMainBuffer = 0;
   if (PrecompilePreamble) {
@@ -1454,7 +1457,7 @@
   // Create the AST unit.
   llvm::OwningPtr<ASTUnit> AST;
   AST.reset(new ASTUnit(false));
-  ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+  ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
   AST->Diagnostics = Diags;
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;
@@ -1483,7 +1486,8 @@
     // No diagnostics engine was provided, so create our own diagnostics object
     // with the default options.
     DiagnosticOptions DiagOpts;
-    Diags = CompilerInstance::createDiagnostics(DiagOpts, 0, 0);
+    Diags = CompilerInstance::createDiagnostics(DiagOpts, ArgEnd - ArgBegin, 
+                                                ArgBegin);
   }
   
   llvm::SmallVector<const char *, 16> Args;
@@ -1559,7 +1563,7 @@
   // Create the AST unit.
   llvm::OwningPtr<ASTUnit> AST;
   AST.reset(new ASTUnit(false));
-  ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+  ConfigureDiags(Diags, ArgBegin, ArgEnd, *AST, CaptureDiagnostics);
   AST->Diagnostics = Diags;
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;

Added: cfe/branches/Apple/whitney/test/Index/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Index/warning-flags.c?rev=123825&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/Index/warning-flags.c (added)
+++ cfe/branches/Apple/whitney/test/Index/warning-flags.c Wed Jan 19 09:20:31 2011
@@ -0,0 +1,16 @@
+int foo() { }
+int *bar(float *f) { return f; }
+
+// RUN: c-index-test -test-load-source all %s 2>&1|FileCheck -check-prefix=CHECK-BOTH-WARNINGS %s
+// RUN: c-index-test -test-load-source-reparse 5 all %s 2>&1|FileCheck -check-prefix=CHECK-BOTH-WARNINGS %s
+// RUN: c-index-test -test-load-source all -Wno-return-type  %s 2>&1|FileCheck -check-prefix=CHECK-SECOND-WARNING %s
+// RUN: c-index-test -test-load-source-reparse 5 all -Wno-return-type %s 2>&1|FileCheck -check-prefix=CHECK-SECOND-WARNING %s
+// RUN: c-index-test -test-load-source all -w %s 2>&1|not grep warning:
+// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1|not grep warning:
+
+// CHECK-BOTH-WARNINGS: warning: control reaches end of non-void function
+// CHECK-BOTH-WARNINGS: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'
+
+// CHECK-SECOND-WARNING-NOT:control reaches end of non-void
+// CHECK-SECOND-WARNING: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'
+

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=123825&r1=123824&r2=123825&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Jan 19 09:20:31 2011
@@ -2194,7 +2194,8 @@
   // Configure the diagnostics.
   DiagnosticOptions DiagOpts;
   llvm::IntrusiveRefCntPtr<Diagnostic> Diags;
-  Diags = CompilerInstance::createDiagnostics(DiagOpts, 0, 0);
+  Diags = CompilerInstance::createDiagnostics(DiagOpts, num_command_line_args, 
+                                              command_line_args);
 
   llvm::SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
   for (unsigned I = 0; I != num_unsaved_files; ++I) {





More information about the llvm-branch-commits mailing list