r271984 - Revert "[analyzer] Reapply r271907 (2nd try)."

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Jun  7 00:37:02 2016
New Revision: 271984

URL: http://llvm.org/viewvc/llvm-project?rev=271984=rev
Log:
Revert "[analyzer] Reapply r271907 (2nd try)."

Even with the fix in r271981, ASan is finding a stack use after return.

This reverts commits r271977 and r271981.

Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
cfe/trunk/test/Analysis/MPIMock.h
cfe/trunk/test/Analysis/MemRegion.cpp
cfe/trunk/test/Analysis/mpichecker.cpp
cfe/trunk/test/Analysis/mpicheckernotes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=271984=271983=271984=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Tue Jun  7 
00:37:02 2016
@@ -72,8 +72,6 @@ def Containers : Package<"containers">,
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
-def MPI : Package<"mpi">, InPackage;
-
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -579,12 +577,6 @@ def PluralMisuseChecker : Checker<"Plura
   DescFile<"LocalizationChecker.cpp">;
 }
 
-let ParentPackage = MPI in {
-  def MPIChecker : Checker<"MPI-Checker">,
-  HelpText<"Checks MPI code">,
-  DescFile<"MPIChecker.cpp">;
-}
-
 
//===--===//
 // Checkers for LLVM development.
 
//===--===//

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=271984=271983=271984=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Tue 
Jun  7 00:37:02 2016
@@ -150,28 +150,6 @@ public:
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
-
-
-  /// Get descriptive name for memory region. The name is obtained from
-  /// the variable/field declaration retrieved from the memory region.
-  /// Regions that point to an element of an array are returned as: "arr[0]".
-  /// Regions that point to a struct are returned as: "st.var".
-  //
-  /// \param UseQuotes Set if the name should be quoted.
-  ///
-  /// \returns variable name for memory region
-  std::string getDescriptiveName(bool UseQuotes = true) const;
-
-
-  /// Retrieve source range from memory region. The range retrieval
-  /// is based on the decl obtained from the memory region.
-  /// For a VarRegion the range of the base region is returned.
-  /// For a FieldRegion the range of the field is returned.
-  /// If no declaration is found, an empty source range is returned.
-  /// The client is responsible for checking if the returned range is valid.
-  ///
-  /// \returns source range for declaration retrieved from memory region
-  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=271984=271983=271984=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Tue Jun  7 00:37:02 
2016
@@ -41,9 +41,6 @@ add_clang_library(clangStaticAnalyzerChe
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
-  MPI-Checker/MPIBugReporter.cpp
-  MPI-Checker/MPIChecker.cpp
-  MPI-Checker/MPIFunctionClassifier.cpp
   NSAutoreleasePoolChecker.cpp
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp

Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
URL: 

Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-06-06 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Fixed the compilation issues with gcc in r271977  r271981, but it is still 
failing with Address Sanitizer diagnostics:




18751==ERROR: AddressSanitizer: stack-use-after-return on address 
0x7f0c695ebc70 at pc 0x0867b44c bp 0x7ffe3b01d6f0 sp 0x7ffe3b01d6e8
-

READ of size 8 at 0x7f0c695ebc70 thread T0

  #0 0x867b44b in getSourceManager 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:448:46
  #1 0x867b44b in 
clang::ento::BugReporter::emitReport(std::__1::unique_ptr) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3240
  #2 0x8636355 in 
clang::ento::mpi::MPIBugReporter::reportUnmatchedWait(clang::ento::CallEvent 
const&, clang::ento::MemRegion const*, clang::ento::ExplodedNode const*) const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp:82:3
  #3 0x843e1ee in 
clang::ento::mpi::MPIChecker::checkUnmatchedWaits(clang::ento::CallEvent 
const&, clang::ento::CheckerContext&) const 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp:88:7
  #4 0x8447dc8 in checkPreCall 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h:36:5
  #5 0x8447dc8 in void 
clang::ento::check::PreCall::_checkCall(void*, 
clang::ento::CallEvent const&, clang::ento::CheckerContext&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/Checker.h:168
  #6 0x86db2f2 in operator() 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:59:12
  #7 0x86db2f2 in runChecker 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:269
  #8 0x86db2f2 in expandGraphWithCheckers<(anonymous 
namespace)::CheckCallContext> 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:123
  #9 0x86db2f2 in clang::ento::CheckerManager::runCheckersForCallEvent(bool, 
clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&, 
clang::ento::CallEvent const&, clang::ento::ExprEngine&, bool) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:285
  #10 0x8782a84 in runCheckersForPreCall 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:252:5
  #11 0x8782a84 in 
clang::ento::ExprEngine::evalCall(clang::ento::ExplodedNodeSet&, 
clang::ento::ExplodedNode*, clang::ento::CallEvent const&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:509
  #12 0x878205b in clang::ento::ExprEngine::VisitCallExpr(clang::CallExpr 
const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:487:5
  #13 0x872a0d8 in clang::ento::ExprEngine::Visit(clang::Stmt const*, 
clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1104:7
  #14 0x87210bf in clang::ento::ExprEngine::ProcessStmt(clang::CFGStmt, 
clang::ento::ExplodedNode*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:448:5
  #15 0x87207ae in 
clang::ento::ExprEngine::processCFGElement(clang::CFGElement, 
clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:297:7
  #16 0x86fc7a6 in clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock 
const*, unsigned int, clang::ento::ExplodedNode*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:515:5
  #17 0x86fafed in 
clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, 
clang::ProgramPoint, clang::ento::WorkListUnit const&) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:274:7
  #18 0x86f9891 in 
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, 
unsigned int, llvm::IntrusiveRefCntPtr) 

r271981 - [analyzer] Speculative fix for r271907.

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jun  6 23:44:52 2016
New Revision: 271981

URL: http://llvm.org/viewvc/llvm-project?rev=271981=rev
Log:
[analyzer] Speculative fix for r271907.

Fix a compilation error on the bots involving brace initialization.

Differential Revision: http://reviews.llvm.org/D12761

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h?rev=271981=271980=271981=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h Mon Jun  
6 23:44:52 2016
@@ -28,7 +28,7 @@ class MPIBugReporter {
 public:
   MPIBugReporter(BugReporter , const CheckerBase ,
  const MPIFunctionClassifier )
-  : BReporter{BR} {
+  : BReporter(BR) {
 UnmatchedWaitBugType.reset(new BugType(, "Unmatched wait", MPIError));
 DoubleNonblockingBugType.reset(
 new BugType(, "Double nonblocking", MPIError));


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271978 - [OPENCL] Fix wrongly vla error for OpenCL array.

2016-06-06 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Mon Jun  6 23:34:00 2016
New Revision: 271978

URL: http://llvm.org/viewvc/llvm-project?rev=271978=rev
Log:
[OPENCL] Fix wrongly vla error for OpenCL array.

Summary:
OpenCL should support array with const value size length, those const
varibale in global and constant address space and variable in constant
address space.

Fixed test case error.

Reviewers: Anastasia, yaxunl, bader

Subscribers: bader, cfe-commits

Differential Revision: http://reviews.llvm.org/D20090

Added:
cfe/trunk/test/CodeGenOpenCL/vla.cl
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=271978=271977=271978=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun  6 23:34:00 2016
@@ -2745,7 +2745,10 @@ static CompleteObject findCompleteObject
   } else if (VD->isConstexpr()) {
 // OK, we can read this variable.
   } else if (BaseType->isIntegralOrEnumerationType()) {
-if (!BaseType.isConstQualified()) {
+// In OpenCL if a variable is in constant address space it is a const 
value.
+if (!(BaseType.isConstQualified() ||
+  (Info.getLangOpts().OpenCL &&
+   BaseType.getAddressSpace() == LangAS::opencl_constant))) {
   if (Info.getLangOpts().CPlusPlus) {
 Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
 Info.Note(VD->getLocation(), diag::note_declared_at);

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=271978=271977=271978=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Jun  6 23:34:00 2016
@@ -2063,7 +2063,8 @@ static bool isArraySizeVLA(Sema , Expr
   } Diagnoser;
 
   return S.VerifyIntegerConstantExpression(ArraySize, , Diagnoser,
-   S.LangOpts.GNUMode).isInvalid();
+   S.LangOpts.GNUMode ||
+   S.LangOpts.OpenCL).isInvalid();
 }
 
 /// \brief Build an array type.

Added: cfe/trunk/test/CodeGenOpenCL/vla.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vla.cl?rev=271978=auto
==
--- cfe/trunk/test/CodeGenOpenCL/vla.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/vla.cl Mon Jun  6 23:34:00 2016
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 
-o - %s | FileCheck %s
+
+constant int sz0 = 5;
+// CHECK: @sz0 = addrspace(2) constant i32 5
+const global int sz1 = 16;
+// CHECK: @sz1 = addrspace(1) constant i32 16
+const constant int sz2 = 8;
+// CHECK: @sz2 = addrspace(2) constant i32 8
+// CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef
+
+kernel void testvla()
+{
+  int vla0[sz0];
+// CHECK: %vla0 = alloca [5 x i32]
+  char vla1[sz1];
+// CHECK: %vla1 = alloca [16 x i8]
+  local short vla2[sz2];
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271977 - [analyzer] Reapply r271907 (2nd try).

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jun  6 23:23:08 2016
New Revision: 271977

URL: http://llvm.org/viewvc/llvm-project?rev=271977=rev
Log:
[analyzer] Reapply r271907 (2nd try).

Second try at reapplying
"[analyzer] Add checker for correct usage of MPI API in C and C++."

Special thanks to Dan Liew for helping test the fix for the template
specialization compiler error with gcc.

The original patch is by Alexander Droste!

Differential Revision: http://reviews.llvm.org/D12761

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
cfe/trunk/test/Analysis/MPIMock.h
cfe/trunk/test/Analysis/MemRegion.cpp
cfe/trunk/test/Analysis/mpichecker.cpp
cfe/trunk/test/Analysis/mpicheckernotes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=271977=271976=271977=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jun  6 
23:23:08 2016
@@ -72,6 +72,8 @@ def Containers : Package<"containers">,
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
+def MPI : Package<"mpi">, InPackage;
+
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -577,6 +579,12 @@ def PluralMisuseChecker : Checker<"Plura
   DescFile<"LocalizationChecker.cpp">;
 }
 
+let ParentPackage = MPI in {
+  def MPIChecker : Checker<"MPI-Checker">,
+  HelpText<"Checks MPI code">,
+  DescFile<"MPIChecker.cpp">;
+}
+
 
//===--===//
 // Checkers for LLVM development.
 
//===--===//

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=271977=271976=271977=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon 
Jun  6 23:23:08 2016
@@ -150,6 +150,28 @@ public:
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+
+  /// Get descriptive name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  //
+  /// \param UseQuotes Set if the name should be quoted.
+  ///
+  /// \returns variable name for memory region
+  std::string getDescriptiveName(bool UseQuotes = true) const;
+
+
+  /// Retrieve source range from memory region. The range retrieval
+  /// is based on the decl obtained from the memory region.
+  /// For a VarRegion the range of the base region is returned.
+  /// For a FieldRegion the range of the field is returned.
+  /// If no declaration is found, an empty source range is returned.
+  /// The client is responsible for checking if the returned range is valid.
+  ///
+  /// \returns source range for declaration retrieved from memory region
+  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=271977=271976=271977=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Jun  6 23:23:08 
2016
@@ -41,6 +41,9 @@ add_clang_library(clangStaticAnalyzerChe
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
+  MPI-Checker/MPIBugReporter.cpp
+  MPI-Checker/MPIChecker.cpp
+  MPI-Checker/MPIFunctionClassifier.cpp
   

Re: [PATCH] D20997: [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.
chapuni added a comment.

FYI :)

  --- a/clang/test/CoverageMapping/unused_function.cpp
  +++ b/clang/test/CoverageMapping/unused_function.cpp
  @@ -3,34 +3,34 @@
   #define START_SCOPE {
   #define END_SCOPE }
  
  -// CHECK: _Z2f0v:
  +// CHECK: {{_Z2f0v|\?f0@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
   inline void f0() {}
  
  -// CHECK: _Z2f1v:
  +// CHECK: {{_Z2f1v|\?f1@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
   inline void f1() START_SCOPE }
  
  -// CHECK: _Z2f2v:
  +// CHECK: {{_Z2f2v|\?f2@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:29 = 0
   inline void f2() { END_SCOPE
  
  -// CHECK: _Z2f3v:
  +// CHECK: {{_Z2f3v|\?f3@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:39 = 0
   inline void f3() START_SCOPE END_SCOPE
  
  -// CHECK: _Z2f4v:
  +// CHECK: {{_Z2f4v|\?f4@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:2 = 0
   inline void f4()
   #include "Inputs/starts_a_scope_only"
   }
  
  -// CHECK: _Z2f5v:
  +// CHECK: {{_Z2f5v|\?f5@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+2]]:36 = 0
   inline void f5() {
   #include "Inputs/ends_a_scope_only"
  
  -// CHECK: _Z2f6v:
  +// CHECK: {{_Z2f6v|\?f6@@YAXXZ}}:
   // CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:36 = 0
   inline void f6()
   #include "Inputs/starts_a_scope_only"


Repository:
  rL LLVM

http://reviews.llvm.org/D20997



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271976 - Revert [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Mon Jun  6 23:11:51 2016
New Revision: 271976

URL: http://llvm.org/viewvc/llvm-project?rev=271976=rev
Log:
Revert [Coverage] Fix an assertion failure if the definition of an unused 
function spans multiple files.

r271969 The test case fails on Windows.

Removed:
cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
cfe/trunk/test/CoverageMapping/unused_function.cpp
Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=271976=271975=271976=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Jun  6 23:11:51 2016
@@ -130,16 +130,6 @@ public:
 return strcmp(SM.getBufferName(SM.getSpellingLoc(Loc)), "") == 0;
   }
 
-  /// \brief Check whether \c Loc is included or expanded from \c Parent.
-  bool isNestedIn(SourceLocation Loc, FileID Parent) {
-do {
-  Loc = getIncludeOrExpansionLoc(Loc);
-  if (Loc.isInvalid())
-return false;
-} while (!SM.isInFileID(Loc, Parent));
-return true;
-  }
-
   /// \brief Get the start of \c S ignoring macro arguments and builtin macros.
   SourceLocation getStart(const Stmt *S) {
 SourceLocation Loc = S->getLocStart();
@@ -320,27 +310,7 @@ struct EmptyCoverageMappingBuilder : pub
 if (!D->hasBody())
   return;
 auto Body = D->getBody();
-SourceLocation Start = getStart(Body);
-SourceLocation End = getEnd(Body);
-if (!SM.isWrittenInSameFile(Start, End)) {
-  // Walk up to find the common ancestor.
-  // Correct the locations accordingly.
-  FileID StartFileID = SM.getFileID(Start);
-  FileID EndFileID = SM.getFileID(End);
-  while (StartFileID != EndFileID && !isNestedIn(End, StartFileID)) {
-Start = getIncludeOrExpansionLoc(Start);
-assert(Start.isValid() &&
-   "Declaration start location not nested within a known region");
-StartFileID = SM.getFileID(Start);
-  }
-  while (StartFileID != EndFileID) {
-End = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(End));
-assert(End.isValid() &&
-   "Declaration end location not nested within a known region");
-EndFileID = SM.getFileID(End);
-  }
-}
-SourceRegions.emplace_back(Counter(), Start, End);
+SourceRegions.emplace_back(Counter(), getStart(Body), getEnd(Body));
   }
 
   /// \brief Write the mapping data to the output stream
@@ -501,6 +471,16 @@ struct CounterCoverageMappingBuilder
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 
+  /// \brief Check whether \c Loc is included or expanded from \c Parent.
+  bool isNestedIn(SourceLocation Loc, FileID Parent) {
+do {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  if (Loc.isInvalid())
+return false;
+} while (!SM.isInFileID(Loc, Parent));
+return true;
+  }
+
   /// \brief Adjust regions and state when \c NewLoc exits a file.
   ///
   /// If moving from our most recently tracked location to \c NewLoc exits any

Removed: cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only?rev=271975=auto
==
--- cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only (original)
+++ cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only (removed)
@@ -1 +0,0 @@
-}

Removed: cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only?rev=271975=auto
==
--- cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only (original)
+++ cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only (removed)
@@ -1 +0,0 @@
-{

Removed: cfe/trunk/test/CoverageMapping/unused_function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/unused_function.cpp?rev=271975=auto
==
--- cfe/trunk/test/CoverageMapping/unused_function.cpp (original)
+++ cfe/trunk/test/CoverageMapping/unused_function.cpp (removed)
@@ -1,37 +0,0 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
-
-#define START_SCOPE {
-#define END_SCOPE }
-
-// CHECK: _Z2f0v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
-inline void f0() {}
-
-// CHECK: _Z2f1v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
-inline void f1() START_SCOPE }
-
-// CHECK: _Z2f2v:
-// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> 

r271975 - Revert "[OPENCL] Fix wrongly vla error for OpenCL array."

2016-06-06 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Mon Jun  6 22:41:07 2016
New Revision: 271975

URL: http://llvm.org/viewvc/llvm-project?rev=271975=rev
Log:
Revert "[OPENCL] Fix wrongly vla error for OpenCL array."

Test case break on system-z.

This reverts commit 9a7212e1e87f1396952d74f8c62314a775ccbb1c.

Removed:
cfe/trunk/test/CodeGenOpenCL/vla.cl
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=271975=271974=271975=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun  6 22:41:07 2016
@@ -2745,10 +2745,7 @@ static CompleteObject findCompleteObject
   } else if (VD->isConstexpr()) {
 // OK, we can read this variable.
   } else if (BaseType->isIntegralOrEnumerationType()) {
-// In OpenCL if a variable is in constant address space it is a const 
value.
-if (!(BaseType.isConstQualified() ||
-  (Info.getLangOpts().OpenCL &&
-   BaseType.getAddressSpace() == LangAS::opencl_constant))) {
+if (!BaseType.isConstQualified()) {
   if (Info.getLangOpts().CPlusPlus) {
 Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
 Info.Note(VD->getLocation(), diag::note_declared_at);

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=271975=271974=271975=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Jun  6 22:41:07 2016
@@ -2063,8 +2063,7 @@ static bool isArraySizeVLA(Sema , Expr
   } Diagnoser;
 
   return S.VerifyIntegerConstantExpression(ArraySize, , Diagnoser,
-   S.LangOpts.GNUMode ||
-   S.LangOpts.OpenCL).isInvalid();
+   S.LangOpts.GNUMode).isInvalid();
 }
 
 /// \brief Build an array type.

Removed: cfe/trunk/test/CodeGenOpenCL/vla.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vla.cl?rev=271974=auto
==
--- cfe/trunk/test/CodeGenOpenCL/vla.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/vla.cl (removed)
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
-
-constant int sz0 = 5;
-// CHECK: @sz0 = constant i32 5, align 4
-const global int sz1 = 16;
-// CHECK: @sz1 = constant i32 16, align 4
-const constant int sz2 = 8;
-// CHECK: @sz2 = constant i32 8, align 4
-// CHECK: @testvla.vla2 = internal global [8 x i16] undef, align 16
-
-kernel void testvla()
-{
-  int vla0[sz0];
-// CHECK: %vla0 = alloca [5 x i32], align 16
-  char vla1[sz1];
-// CHECK: %vla1 = alloca [16 x i8], align 16
-  local short vla2[sz2];
-}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20090: [OPENCL] Fix wrongly vla error for OpenCL array.

2016-06-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271971: [OPENCL] Fix wrongly vla error for OpenCL array. 
(authored by pxl).

Changed prior to commit:
  http://reviews.llvm.org/D20090?vs=58932=59823#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20090

Files:
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenOpenCL/vla.cl

Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -2745,7 +2745,10 @@
   } else if (VD->isConstexpr()) {
 // OK, we can read this variable.
   } else if (BaseType->isIntegralOrEnumerationType()) {
-if (!BaseType.isConstQualified()) {
+// In OpenCL if a variable is in constant address space it is a const 
value.
+if (!(BaseType.isConstQualified() ||
+  (Info.getLangOpts().OpenCL &&
+   BaseType.getAddressSpace() == LangAS::opencl_constant))) {
   if (Info.getLangOpts().CPlusPlus) {
 Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
 Info.Note(VD->getLocation(), diag::note_declared_at);
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2063,7 +2063,8 @@
   } Diagnoser;
 
   return S.VerifyIntegerConstantExpression(ArraySize, , Diagnoser,
-   S.LangOpts.GNUMode).isInvalid();
+   S.LangOpts.GNUMode ||
+   S.LangOpts.OpenCL).isInvalid();
 }
 
 /// \brief Build an array type.
Index: cfe/trunk/test/CodeGenOpenCL/vla.cl
===
--- cfe/trunk/test/CodeGenOpenCL/vla.cl
+++ cfe/trunk/test/CodeGenOpenCL/vla.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+constant int sz0 = 5;
+// CHECK: @sz0 = constant i32 5, align 4
+const global int sz1 = 16;
+// CHECK: @sz1 = constant i32 16, align 4
+const constant int sz2 = 8;
+// CHECK: @sz2 = constant i32 8, align 4
+// CHECK: @testvla.vla2 = internal global [8 x i16] undef, align 16
+
+kernel void testvla()
+{
+  int vla0[sz0];
+// CHECK: %vla0 = alloca [5 x i32], align 16
+  char vla1[sz1];
+// CHECK: %vla1 = alloca [16 x i8], align 16
+  local short vla2[sz2];
+}


Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -2745,7 +2745,10 @@
   } else if (VD->isConstexpr()) {
 // OK, we can read this variable.
   } else if (BaseType->isIntegralOrEnumerationType()) {
-if (!BaseType.isConstQualified()) {
+// In OpenCL if a variable is in constant address space it is a const value.
+if (!(BaseType.isConstQualified() ||
+  (Info.getLangOpts().OpenCL &&
+   BaseType.getAddressSpace() == LangAS::opencl_constant))) {
   if (Info.getLangOpts().CPlusPlus) {
 Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
 Info.Note(VD->getLocation(), diag::note_declared_at);
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2063,7 +2063,8 @@
   } Diagnoser;
 
   return S.VerifyIntegerConstantExpression(ArraySize, , Diagnoser,
-   S.LangOpts.GNUMode).isInvalid();
+   S.LangOpts.GNUMode ||
+   S.LangOpts.OpenCL).isInvalid();
 }
 
 /// \brief Build an array type.
Index: cfe/trunk/test/CodeGenOpenCL/vla.cl
===
--- cfe/trunk/test/CodeGenOpenCL/vla.cl
+++ cfe/trunk/test/CodeGenOpenCL/vla.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+constant int sz0 = 5;
+// CHECK: @sz0 = constant i32 5, align 4
+const global int sz1 = 16;
+// CHECK: @sz1 = constant i32 16, align 4
+const constant int sz2 = 8;
+// CHECK: @sz2 = constant i32 8, align 4
+// CHECK: @testvla.vla2 = internal global [8 x i16] undef, align 16
+
+kernel void testvla()
+{
+  int vla0[sz0];
+// CHECK: %vla0 = alloca [5 x i32], align 16
+  char vla1[sz1];
+// CHECK: %vla1 = alloca [16 x i8], align 16
+  local short vla2[sz2];
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271971 - [OPENCL] Fix wrongly vla error for OpenCL array.

2016-06-06 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Mon Jun  6 22:13:39 2016
New Revision: 271971

URL: http://llvm.org/viewvc/llvm-project?rev=271971=rev
Log:
[OPENCL] Fix wrongly vla error for OpenCL array.

Summary:
OpenCL should support array with const value size length, those const varibale 
in global and constant address space and variable in constant address space.

Reviewers: Anastasia, yaxunl, bader

Subscribers: bader, cfe-commits

Differential Revision: http://reviews.llvm.org/D20090

Added:
cfe/trunk/test/CodeGenOpenCL/vla.cl
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=271971=271970=271971=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun  6 22:13:39 2016
@@ -2745,7 +2745,10 @@ static CompleteObject findCompleteObject
   } else if (VD->isConstexpr()) {
 // OK, we can read this variable.
   } else if (BaseType->isIntegralOrEnumerationType()) {
-if (!BaseType.isConstQualified()) {
+// In OpenCL if a variable is in constant address space it is a const 
value.
+if (!(BaseType.isConstQualified() ||
+  (Info.getLangOpts().OpenCL &&
+   BaseType.getAddressSpace() == LangAS::opencl_constant))) {
   if (Info.getLangOpts().CPlusPlus) {
 Info.Diag(E, diag::note_constexpr_ltor_non_const_int, 1) << VD;
 Info.Note(VD->getLocation(), diag::note_declared_at);

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=271971=271970=271971=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Jun  6 22:13:39 2016
@@ -2063,7 +2063,8 @@ static bool isArraySizeVLA(Sema , Expr
   } Diagnoser;
 
   return S.VerifyIntegerConstantExpression(ArraySize, , Diagnoser,
-   S.LangOpts.GNUMode).isInvalid();
+   S.LangOpts.GNUMode ||
+   S.LangOpts.OpenCL).isInvalid();
 }
 
 /// \brief Build an array type.

Added: cfe/trunk/test/CodeGenOpenCL/vla.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/vla.cl?rev=271971=auto
==
--- cfe/trunk/test/CodeGenOpenCL/vla.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/vla.cl Mon Jun  6 22:13:39 2016
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+constant int sz0 = 5;
+// CHECK: @sz0 = constant i32 5, align 4
+const global int sz1 = 16;
+// CHECK: @sz1 = constant i32 16, align 4
+const constant int sz2 = 8;
+// CHECK: @sz2 = constant i32 8, align 4
+// CHECK: @testvla.vla2 = internal global [8 x i16] undef, align 16
+
+kernel void testvla()
+{
+  int vla0[sz0];
+// CHECK: %vla0 = alloca [5 x i32], align 16
+  char vla1[sz1];
+// CHECK: %vla1 = alloca [16 x i8], align 16
+  local short vla2[sz2];
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21054: CodeGen: Update Clang to use the new type metadata.

2016-06-06 Thread Peter Collingbourne via cfe-commits
pcc created this revision.
pcc added reviewers: mehdi_amini, kcc.
pcc added a subscriber: cfe-commits.
pcc added a dependency: D21053: IR: New representation for CFI and virtual call 
optimization pass metadata..
Herald added a subscriber: mehdi_amini.

Depends on D21053

http://reviews.llvm.org/D21054

Files:
  docs/ControlFlowIntegrityDesign.rst
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGen/cfi-check-fail.c
  test/CodeGen/cfi-check-fail2.c
  test/CodeGen/cfi-icall-cross-dso.c
  test/CodeGen/cfi-icall.c
  test/CodeGenCXX/bitset-inference.cpp
  test/CodeGenCXX/bitsets.cpp
  test/CodeGenCXX/cfi-blacklist.cpp
  test/CodeGenCXX/cfi-cast.cpp
  test/CodeGenCXX/cfi-cross-dso.cpp
  test/CodeGenCXX/cfi-icall.cpp
  test/CodeGenCXX/cfi-ms-rtti.cpp
  test/CodeGenCXX/cfi-nvcall.cpp
  test/CodeGenCXX/lto-visibility-inference.cpp
  test/CodeGenCXX/type-metadata.cpp

Index: test/CodeGenCXX/type-metadata.cpp
===
--- /dev/null
+++ test/CodeGenCXX/type-metadata.cpp
@@ -0,0 +1,226 @@
+// Tests for the cfi-vcall feature:
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=ITANIUM --check-prefix=ITANIUM-NDIAG --check-prefix=NDIAG %s
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-ABORT %s
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-vcall -fsanitize-recover=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=ITANIUM --check-prefix=ITANIUM-DIAG --check-prefix=DIAG --check-prefix=DIAG-RECOVER %s
+// RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck --check-prefix=CFI --check-prefix=MS --check-prefix=NDIAG %s
+
+// Tests for the whole-program-vtables feature:
+// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=ITANIUM %s
+// RUN: %clang_cc1 -flto -triple x86_64-pc-windows-msvc -fwhole-program-vtables -emit-llvm -o - %s | FileCheck --check-prefix=VTABLE-OPT --check-prefix=MS %s
+
+// ITANIUM: @_ZTV1A = {{[^!]*}}, !type [[A16:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL16:![0-9]+]]
+
+// ITANIUM: @_ZTV1B = {{[^!]*}}, !type [[A32:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL32:![0-9]+]]
+// ITANIUM-SAME: !type [[B32:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+
+// ITANIUM: @_ZTV1C = {{[^!]*}}, !type [[A32]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+// ITANIUM-SAME: !type [[C32:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+
+// DIAG: @[[SRC:.*]] = private unnamed_addr constant [{{.*}} x i8] c"{{.*}}type-metadata.cpp\00", align 1
+// DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'A'\00" }
+// DIAG: @[[BADTYPESTATIC:.*]] = private unnamed_addr global { i8, { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }* } { i8 0, { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 123, i32 3 }, { i16, i16, [4 x i8] }* @[[TYPE]] }
+
+// ITANIUM: @_ZTVN12_GLOBAL__N_11DE = {{[^!]*}}, !type [[A32]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+// ITANIUM-SAME: !type [[B32]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+// ITANIUM-SAME: !type [[C88:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL88:![0-9]+]]
+// ITANIUM-SAME: !type [[D32:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+
+// ITANIUM: @_ZTCN12_GLOBAL__N_11DE0_1B = {{[^!]*}}, !type [[A32]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+// ITANIUM-SAME: !type [[B32]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+
+// ITANIUM: @_ZTCN12_GLOBAL__N_11DE8_1C = {{[^!]*}}, !type [[A64:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL64:![0-9]+]]
+// ITANIUM-SAME: !type [[C32]]
+// ITANIUM-DIAG-SAME: !type [[ALL32]]
+
+// ITANIUM: @_ZTVZ3foovE2FA = {{[^!]*}}, !type [[A16]]
+// ITANIUM-DIAG-SAME: !type [[ALL16]]
+// ITANIUM-SAME: !type [[FA16:![0-9]+]]
+// ITANIUM-DIAG-SAME: !type [[ALL16]]
+
+// MS: comdat($"\01??_7A@@6B@"), !type [[A8:![0-9]+]]
+// MS: comdat($"\01??_7B@@6B0@@"), !type [[B8:![0-9]+]]
+// MS: comdat($"\01??_7B@@6BA@@@"), !type [[A8]]
+// MS: comdat($"\01??_7C@@6B@"), !type [[A8]]
+// MS: comdat($"\01??_7D@?A@@6BB@@@"), !type [[B8]], !type [[D8:![0-9]+]]
+// MS: comdat($"\01??_7D@?A@@6BA@@@"), !type [[A8]]
+// MS: comdat($"\01??_7FA@?1??foo@@YAXXZ@6B@"), !type [[A8]], !type [[FA8:![0-9]+]]
+
+struct A {
+  A();
+  virtual void f();
+};
+
+struct B : virtual A {
+  B();
+  virtual void g();
+  

Re: [PATCH] D20997: [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread Igor Kudrin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271969: [Coverage] Fix an assertion failure if the 
definition of an unused function… (authored by ikudrin).

Changed prior to commit:
  http://reviews.llvm.org/D20997?vs=59806=59818#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20997

Files:
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
  cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
  cfe/trunk/test/CoverageMapping/unused_function.cpp

Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -130,6 +130,16 @@
 return strcmp(SM.getBufferName(SM.getSpellingLoc(Loc)), "") == 0;
   }
 
+  /// \brief Check whether \c Loc is included or expanded from \c Parent.
+  bool isNestedIn(SourceLocation Loc, FileID Parent) {
+do {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  if (Loc.isInvalid())
+return false;
+} while (!SM.isInFileID(Loc, Parent));
+return true;
+  }
+
   /// \brief Get the start of \c S ignoring macro arguments and builtin macros.
   SourceLocation getStart(const Stmt *S) {
 SourceLocation Loc = S->getLocStart();
@@ -310,7 +320,27 @@
 if (!D->hasBody())
   return;
 auto Body = D->getBody();
-SourceRegions.emplace_back(Counter(), getStart(Body), getEnd(Body));
+SourceLocation Start = getStart(Body);
+SourceLocation End = getEnd(Body);
+if (!SM.isWrittenInSameFile(Start, End)) {
+  // Walk up to find the common ancestor.
+  // Correct the locations accordingly.
+  FileID StartFileID = SM.getFileID(Start);
+  FileID EndFileID = SM.getFileID(End);
+  while (StartFileID != EndFileID && !isNestedIn(End, StartFileID)) {
+Start = getIncludeOrExpansionLoc(Start);
+assert(Start.isValid() &&
+   "Declaration start location not nested within a known region");
+StartFileID = SM.getFileID(Start);
+  }
+  while (StartFileID != EndFileID) {
+End = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(End));
+assert(End.isValid() &&
+   "Declaration end location not nested within a known region");
+EndFileID = SM.getFileID(End);
+  }
+}
+SourceRegions.emplace_back(Counter(), Start, End);
   }
 
   /// \brief Write the mapping data to the output stream
@@ -471,16 +501,6 @@
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 
-  /// \brief Check whether \c Loc is included or expanded from \c Parent.
-  bool isNestedIn(SourceLocation Loc, FileID Parent) {
-do {
-  Loc = getIncludeOrExpansionLoc(Loc);
-  if (Loc.isInvalid())
-return false;
-} while (!SM.isInFileID(Loc, Parent));
-return true;
-  }
-
   /// \brief Adjust regions and state when \c NewLoc exits a file.
   ///
   /// If moving from our most recently tracked location to \c NewLoc exits any
Index: cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
===
--- cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
+++ cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
@@ -0,0 +1 @@
+}
Index: cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
===
--- cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
+++ cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
@@ -0,0 +1 @@
+{
Index: cfe/trunk/test/CoverageMapping/unused_function.cpp
===
--- cfe/trunk/test/CoverageMapping/unused_function.cpp
+++ cfe/trunk/test/CoverageMapping/unused_function.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+
+#define START_SCOPE {
+#define END_SCOPE }
+
+// CHECK: _Z2f0v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
+inline void f0() {}
+
+// CHECK: _Z2f1v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
+inline void f1() START_SCOPE }
+
+// CHECK: _Z2f2v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:29 = 0
+inline void f2() { END_SCOPE
+
+// CHECK: _Z2f3v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:39 = 0
+inline void f3() START_SCOPE END_SCOPE
+
+// CHECK: _Z2f4v:
+// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:2 = 0
+inline void f4()
+#include "Inputs/starts_a_scope_only"
+}
+
+// CHECK: _Z2f5v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+2]]:36 = 0
+inline void f5() {
+#include "Inputs/ends_a_scope_only"
+
+// CHECK: _Z2f6v:
+// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:36 = 0
+inline void f6()
+#include "Inputs/starts_a_scope_only"
+#include "Inputs/ends_a_scope_only"

r271969 - [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Mon Jun  6 21:17:03 2016
New Revision: 271969

URL: http://llvm.org/viewvc/llvm-project?rev=271969=rev
Log:
[Coverage] Fix an assertion failure if the definition of an unused function 
spans multiple files.

We have an assertion failure if, for example, the definition of an unused
inline function starts in one macro and ends in another. This patch fixes
the issue by finding the common ancestor of the start and end locations
of that function's body and changing the locations accordingly.

Differential Revision: http://reviews.llvm.org/D20997

Added:
cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
cfe/trunk/test/CoverageMapping/unused_function.cpp
Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=271969=271968=271969=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Jun  6 21:17:03 2016
@@ -130,6 +130,16 @@ public:
 return strcmp(SM.getBufferName(SM.getSpellingLoc(Loc)), "") == 0;
   }
 
+  /// \brief Check whether \c Loc is included or expanded from \c Parent.
+  bool isNestedIn(SourceLocation Loc, FileID Parent) {
+do {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  if (Loc.isInvalid())
+return false;
+} while (!SM.isInFileID(Loc, Parent));
+return true;
+  }
+
   /// \brief Get the start of \c S ignoring macro arguments and builtin macros.
   SourceLocation getStart(const Stmt *S) {
 SourceLocation Loc = S->getLocStart();
@@ -310,7 +320,27 @@ struct EmptyCoverageMappingBuilder : pub
 if (!D->hasBody())
   return;
 auto Body = D->getBody();
-SourceRegions.emplace_back(Counter(), getStart(Body), getEnd(Body));
+SourceLocation Start = getStart(Body);
+SourceLocation End = getEnd(Body);
+if (!SM.isWrittenInSameFile(Start, End)) {
+  // Walk up to find the common ancestor.
+  // Correct the locations accordingly.
+  FileID StartFileID = SM.getFileID(Start);
+  FileID EndFileID = SM.getFileID(End);
+  while (StartFileID != EndFileID && !isNestedIn(End, StartFileID)) {
+Start = getIncludeOrExpansionLoc(Start);
+assert(Start.isValid() &&
+   "Declaration start location not nested within a known region");
+StartFileID = SM.getFileID(Start);
+  }
+  while (StartFileID != EndFileID) {
+End = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(End));
+assert(End.isValid() &&
+   "Declaration end location not nested within a known region");
+EndFileID = SM.getFileID(End);
+  }
+}
+SourceRegions.emplace_back(Counter(), Start, End);
   }
 
   /// \brief Write the mapping data to the output stream
@@ -471,16 +501,6 @@ struct CounterCoverageMappingBuilder
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 
-  /// \brief Check whether \c Loc is included or expanded from \c Parent.
-  bool isNestedIn(SourceLocation Loc, FileID Parent) {
-do {
-  Loc = getIncludeOrExpansionLoc(Loc);
-  if (Loc.isInvalid())
-return false;
-} while (!SM.isInFileID(Loc, Parent));
-return true;
-  }
-
   /// \brief Adjust regions and state when \c NewLoc exits a file.
   ///
   /// If moving from our most recently tracked location to \c NewLoc exits any

Added: cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only?rev=271969=auto
==
--- cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only (added)
+++ cfe/trunk/test/CoverageMapping/Inputs/ends_a_scope_only Mon Jun  6 21:17:03 
2016
@@ -0,0 +1 @@
+}

Added: cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only?rev=271969=auto
==
--- cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only (added)
+++ cfe/trunk/test/CoverageMapping/Inputs/starts_a_scope_only Mon Jun  6 
21:17:03 2016
@@ -0,0 +1 @@
+{

Added: cfe/trunk/test/CoverageMapping/unused_function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/unused_function.cpp?rev=271969=auto
==
--- cfe/trunk/test/CoverageMapping/unused_function.cpp (added)
+++ cfe/trunk/test/CoverageMapping/unused_function.cpp Mon Jun  6 21:17:03 2016
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
+

Re: [PATCH] D21050: [clang-tidy] correct clang-tidy-diff.py help message

2016-06-06 Thread Igor Sugak via cfe-commits
sugak added inline comments.


Comment at: clang-tidy/tool/clang-tidy-diff.py:42
@@ -41,3 +41,3 @@
   help='path to clang-tidy binary')
   parser.add_argument('-p', metavar='NUM', default=0,
   help='strip the smallest prefix containing P slashes')

Eugene.Zelenko wrote:
> Shouldn't -p be used to specify compile database as in run-clang-tidy.py?
From the test plan it looks like this script doesn't support compilation 
database input:
```lang=bash
git diff -U0 HEAD^ | clang-tidy-diff.py -checks=-*,misc-use-override -p1 -- 
-std=gnu++14
```
It is similar to `patch`-like tools that process unified diff input -- uses 
`-p` to adjust file path. I can fix it in a separate diff, just need a better 
name for the current function of `-p`.


http://reviews.llvm.org/D21050



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21047: [clang] Documentation fixes for LibASTMatchersTutorial

2016-06-06 Thread Simon Whittaker via cfe-commits
simon.f.whittaker added a reviewer: klimek.
simon.f.whittaker added a comment.

Added Manuel Klimek at Sean's suggestion.


http://reviews.llvm.org/D21047



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21050: [clang-tidy] correct clang-tidy-diff.py help message

2016-06-06 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.


Comment at: clang-tidy/tool/clang-tidy-diff.py:42
@@ -41,3 +41,3 @@
   help='path to clang-tidy binary')
   parser.add_argument('-p', metavar='NUM', default=0,
   help='strip the smallest prefix containing P slashes')

Shouldn't -p be used to specify compile database as in run-clang-tidy.py?


http://reviews.llvm.org/D21050



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20878: [Coverage] Do not push a new region after a CXXTryStmt

2016-06-06 Thread Vedant Kumar via cfe-commits
vsk abandoned this revision.
vsk added a comment.

I see your point that it isn't expensive to do a best-effort job here. I 
updated docs/SourceBasedCodeCoverage.rst with a limitations section as per my 
earlier comment.


http://reviews.llvm.org/D20878



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21050: [clang-tidy] correct clang-tidy-diff.py help message

2016-06-06 Thread Igor Sugak via cfe-commits
sugak created this revision.
sugak added reviewers: klimek, alexfh.
sugak added a subscriber: cfe-commits.

Looks like the original code was copied from clang-format-diff.py.
Update help message to make it clang-tidy specific.

http://reviews.llvm.org/D21050

Files:
  clang-tidy/tool/clang-tidy-diff.py

Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -33,20 +33,20 @@
 
 def main():
   parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i 
'
-   'option just output the diff that would be '
-   'introduced.')
+   'Run clang-tidy against changed files, and '
+   'output diagnostics only for modified '
+   'lines.')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
   default='clang-tidy',
   help='path to clang-tidy binary')
   parser.add_argument('-p', metavar='NUM', default=0,
   help='strip the smallest prefix containing P slashes')
   parser.add_argument('-regex', metavar='PATTERN', default=None,
-  help='custom pattern selecting file paths to reformat '
+  help='custom pattern selecting file paths to check '
   '(case sensitive, overrides -iregex)')
   parser.add_argument('-iregex', metavar='PATTERN', default=
   r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc)',
-  help='custom pattern selecting file paths to reformat '
+  help='custom pattern selecting file paths to check '
   '(case insensitive, overridden by -regex)')
 
   parser.add_argument('-fix', action='store_true', default=False,


Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -33,20 +33,20 @@
 
 def main():
   parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i '
-   'option just output the diff that would be '
-   'introduced.')
+   'Run clang-tidy against changed files, and '
+   'output diagnostics only for modified '
+   'lines.')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
   default='clang-tidy',
   help='path to clang-tidy binary')
   parser.add_argument('-p', metavar='NUM', default=0,
   help='strip the smallest prefix containing P slashes')
   parser.add_argument('-regex', metavar='PATTERN', default=None,
-  help='custom pattern selecting file paths to reformat '
+  help='custom pattern selecting file paths to check '
   '(case sensitive, overrides -iregex)')
   parser.add_argument('-iregex', metavar='PATTERN', default=
   r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc)',
-  help='custom pattern selecting file paths to reformat '
+  help='custom pattern selecting file paths to check '
   '(case insensitive, overridden by -regex)')
 
   parser.add_argument('-fix', action='store_true', default=False,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20878: [Coverage] Do not push a new region after a CXXTryStmt

2016-06-06 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

I agree that it'd be expensive to put a new counter after each function call. 
Even if there is no `throw` statement within a TU, called functions still may 
raise exceptions.
Anyway, if we come across a `try` statement, we can guess that some exceptions 
are expected and do our best to support constructions like this:

  try {
...
  }
  catch (...) {
...
throw;
  }


http://reviews.llvm.org/D20878



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21047: [clang] Documentation fixes for LibASTMatchersTutorial

2016-06-06 Thread Sean Silva via cfe-commits
silvas accepted this revision.
silvas added a comment.
This revision is now accepted and ready to land.

Overall this LGTM, but let Manuel or one of the other libTooling folks sign off.



Comment at: docs/LibASTMatchersTutorial.rst:46
@@ -45,3 +45,3 @@
 
   cd ~/clang-llvm
   git clone git://cmake.org/stage/cmake.git

This part is a bit out of date. Ninja is pretty easy to obtain (e.g. from its 
releases page on github) and CMake has had Ninja support built-in for a while 
now.

I guess this change doesn't hurt, but (probably in a separate patch) you may 
want to revamp this whole section on ninja and cmake.


http://reviews.llvm.org/D21047



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271966 - Improve Visual Studio visualization of DeclaratorDecl

2016-06-06 Thread Mike Spertus via cfe-commits
Author: mps
Date: Mon Jun  6 19:27:37 2016
New Revision: 271966

URL: http://llvm.org/viewvc/llvm-project?rev=271966=rev
Log:
Improve Visual Studio visualization of DeclaratorDecl

With this change, you can now expand its name and type.

Modified:
cfe/trunk/utils/ClangVisualizers/clang.natvis

Modified: cfe/trunk/utils/ClangVisualizers/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis?rev=271966=271965=271966=diff
==
--- cfe/trunk/utils/ClangVisualizers/clang.natvis (original)
+++ cfe/trunk/utils/ClangVisualizers/clang.natvis Mon Jun  6 19:27:37 2016
@@ -403,6 +403,10 @@ For later versions of Visual Studio, no
   
   
 {DeclType,view(cpp)} {Name,view(cpp)}
+
+  Name
+  DeclType
+
   
   
 {*(DeclaratorDecl*)this,nd}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21047: [clang] Documentation fixes for LibASTMatchersTutorial

2016-06-06 Thread Simon Whittaker via cfe-commits
simon.f.whittaker created this revision.
simon.f.whittaker added reviewers: silvas, bogner.
simon.f.whittaker added a subscriber: cfe-commits.

This patch fixes Bug 25583 as well as cleaning up some other problems in the 
LibASTMatchersTutorial.

I've updated the tutorial to use:

'./configure.py —bootstrap' rather than 'bootstrap.py' in the ninja buildstep
'ninja check-llvm' and 'ninja check-clang' rather than 'ninja check' and 'ninja 
clang-test' respectively
Clarified that no output will be produced with the first iteration of the 
program (Step 1: Create a ClangTool)
Cleaned up some English usage in the section on hasCondition(binaryOperator
Fixed the problem in the original bug report:
'Context->getSourceManager().isFromMainFile(FS->getForLoc()' should be 
'Context->getSourceManager().isInMainFile(FS->getForLoc()'

The only change I'm unsure about is changing:

'ninja install' to 'sudo ninja install' in the installation step. If I follow 
the instructions step-by-step then no special install directory is set and the 
default is /usr/local on OS X which requires sudo. As we've used sudo in 
similar circumstances above this then it makes sense to me.

This is my first contribution of any kind to Clang / LLVM (or even open source) 
so hope I have everything correct.

Thanks,

Simon

http://reviews.llvm.org/D21047

Files:
  docs/LibASTMatchersTutorial.rst

Index: docs/LibASTMatchersTutorial.rst
===
--- docs/LibASTMatchersTutorial.rst
+++ docs/LibASTMatchersTutorial.rst
@@ -40,7 +40,7 @@
   git clone https://github.com/martine/ninja.git
   cd ninja
   git checkout release
-  ./bootstrap.py
+  ./configure.py —bootstrap
   sudo cp ninja /usr/bin/
 
   cd ~/clang-llvm
@@ -59,9 +59,9 @@
   mkdir build && cd build
   cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON  # Enable tests; default is 
off.
   ninja
-  ninja check   # Test LLVM only.
-  ninja clang-test  # Test Clang only.
-  ninja install
+  ninja check-llvm   # Test LLVM only.
+  ninja check-clang  # Test Clang only.
+  sudo ninja install
 
 And we're live.
 
@@ -176,6 +176,8 @@
 them from a compilation database - there just aren't any options needed
 right now.
 
+As there are no syntax errors in the example no output will be produced.
+
 Intermezzo: Learn AST matcher basics
 
 
@@ -404,10 +406,10 @@
 hasLHS(declRefExpr(to(varDecl(hasType(isInteger()),
 hasRHS(expr(hasType(isInteger())
 
-Why? Because it doesn't work. Of the three loops provided in
+However this doesn't work, of the three loops provided in
 ``test-files/simple.cpp``, zero of them have a matching condition. A
 quick look at the AST dump of the first for loop, produced by the
-previous iteration of loop-convert, shows us the answer:
+previous iteration of loop-convert, shows us why:
 
 ::
 
@@ -498,7 +500,7 @@
 ASTContext *Context = Result.Context;
 const ForStmt *FS = Result.Nodes.getStmtAs("forLoop");
 // We do not want to convert header files!
-if (!FS || 
!Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+if (!FS || !Context->getSourceManager().isInMainFile(FS->getForLoc()))
   return;
 const VarDecl *IncVar = Result.Nodes.getNodeAs("incVarName");
 const VarDecl *CondVar = 
Result.Nodes.getNodeAs("condVarName");


Index: docs/LibASTMatchersTutorial.rst
===
--- docs/LibASTMatchersTutorial.rst
+++ docs/LibASTMatchersTutorial.rst
@@ -40,7 +40,7 @@
   git clone https://github.com/martine/ninja.git
   cd ninja
   git checkout release
-  ./bootstrap.py
+  ./configure.py —bootstrap
   sudo cp ninja /usr/bin/
 
   cd ~/clang-llvm
@@ -59,9 +59,9 @@
   mkdir build && cd build
   cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON  # Enable tests; default is off.
   ninja
-  ninja check   # Test LLVM only.
-  ninja clang-test  # Test Clang only.
-  ninja install
+  ninja check-llvm   # Test LLVM only.
+  ninja check-clang  # Test Clang only.
+  sudo ninja install
 
 And we're live.
 
@@ -176,6 +176,8 @@
 them from a compilation database - there just aren't any options needed
 right now.
 
+As there are no syntax errors in the example no output will be produced.
+
 Intermezzo: Learn AST matcher basics
 
 
@@ -404,10 +406,10 @@
 hasLHS(declRefExpr(to(varDecl(hasType(isInteger()),
 hasRHS(expr(hasType(isInteger())
 
-Why? Because it doesn't work. Of the three loops provided in
+However this doesn't work, of the three loops provided in
 ``test-files/simple.cpp``, zero of them have a matching condition. A
 quick look at the AST dump of the first for loop, produced by the
-previous iteration of loop-convert, shows us the answer:
+previous iteration of 

Re: [PATCH] D20997: [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread Vedant Kumar via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D20997



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20997: [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread Igor Kudrin via cfe-commits
ikudrin updated the summary for this revision.
ikudrin removed rL LLVM as the repository for this revision.
ikudrin updated this revision to Diff 59806.
ikudrin added a comment.

- Use `StartFileID` and `EndFileID` variables to eliminate redundant calls to 
`SM.getFileID()`.
- Add comment strings to asserts.


http://reviews.llvm.org/D20997

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/Inputs/ends_a_scope_only
  test/CoverageMapping/Inputs/starts_a_scope_only
  test/CoverageMapping/unused_function.cpp

Index: test/CoverageMapping/unused_function.cpp
===
--- /dev/null
+++ test/CoverageMapping/unused_function.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | tee %t.out | FileCheck %s
+
+#define START_SCOPE {
+#define END_SCOPE }
+
+// CHECK: _Z2f0v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:20 = 0
+inline void f0() {}
+
+// CHECK: _Z2f1v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:31 = 0
+inline void f1() START_SCOPE }
+
+// CHECK: _Z2f2v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:29 = 0
+inline void f2() { END_SCOPE
+
+// CHECK: _Z2f3v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:39 = 0
+inline void f3() START_SCOPE END_SCOPE
+
+// CHECK: _Z2f4v:
+// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:2 = 0
+inline void f4()
+#include "Inputs/starts_a_scope_only"
+}
+
+// CHECK: _Z2f5v:
+// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+2]]:36 = 0
+inline void f5() {
+#include "Inputs/ends_a_scope_only"
+
+// CHECK: _Z2f6v:
+// CHECK-NEXT: File 0, [[@LINE+2]]:10 -> [[@LINE+3]]:36 = 0
+inline void f6()
+#include "Inputs/starts_a_scope_only"
+#include "Inputs/ends_a_scope_only"
Index: test/CoverageMapping/Inputs/starts_a_scope_only
===
--- /dev/null
+++ test/CoverageMapping/Inputs/starts_a_scope_only
@@ -0,0 +1 @@
+{
Index: test/CoverageMapping/Inputs/ends_a_scope_only
===
--- /dev/null
+++ test/CoverageMapping/Inputs/ends_a_scope_only
@@ -0,0 +1 @@
+}
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -130,6 +130,16 @@
 return strcmp(SM.getBufferName(SM.getSpellingLoc(Loc)), "") == 0;
   }
 
+  /// \brief Check whether \c Loc is included or expanded from \c Parent.
+  bool isNestedIn(SourceLocation Loc, FileID Parent) {
+do {
+  Loc = getIncludeOrExpansionLoc(Loc);
+  if (Loc.isInvalid())
+return false;
+} while (!SM.isInFileID(Loc, Parent));
+return true;
+  }
+
   /// \brief Get the start of \c S ignoring macro arguments and builtin macros.
   SourceLocation getStart(const Stmt *S) {
 SourceLocation Loc = S->getLocStart();
@@ -310,7 +320,27 @@
 if (!D->hasBody())
   return;
 auto Body = D->getBody();
-SourceRegions.emplace_back(Counter(), getStart(Body), getEnd(Body));
+SourceLocation Start = getStart(Body);
+SourceLocation End = getEnd(Body);
+if (!SM.isWrittenInSameFile(Start, End)) {
+  // Walk up to find the common ancestor.
+  // Correct the locations accordingly.
+  FileID StartFileID = SM.getFileID(Start);
+  FileID EndFileID = SM.getFileID(End);
+  while (StartFileID != EndFileID && !isNestedIn(End, StartFileID)) {
+Start = getIncludeOrExpansionLoc(Start);
+assert(Start.isValid() &&
+   "Declaration start location not nested within a known region");
+StartFileID = SM.getFileID(Start);
+  }
+  while (StartFileID != EndFileID) {
+End = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(End));
+assert(End.isValid() &&
+   "Declaration end location not nested within a known region");
+EndFileID = SM.getFileID(End);
+  }
+}
+SourceRegions.emplace_back(Counter(), Start, End);
   }
 
   /// \brief Write the mapping data to the output stream
@@ -471,16 +501,6 @@
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 
-  /// \brief Check whether \c Loc is included or expanded from \c Parent.
-  bool isNestedIn(SourceLocation Loc, FileID Parent) {
-do {
-  Loc = getIncludeOrExpansionLoc(Loc);
-  if (Loc.isInvalid())
-return false;
-} while (!SM.isInFileID(Loc, Parent));
-return true;
-  }
-
   /// \brief Adjust regions and state when \c NewLoc exits a file.
   ///
   /// If moving from our most recently tracked location to \c NewLoc exits any
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


LLVM buildmaster will be restarted tonight

2016-06-06 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

Galina
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Buildbot numbers for the last week of 5/29/2016 - 6/04/2016

2016-06-06 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 5/29/2016 - 6/04/2016.
I added new statistics with a longest time each builder was red during the
last week.

Thanks

Galina



buildername|  was_red
---+---
 lldb-amd64-ninja-freebsd11| 127:35:48
 lldb-x86-windows-msvc2015 | 59:50:06
 clang-cmake-aarch64-full  | 55:23:35
 clang-native-arm-lnt  | 51:46:54
 clang-cmake-aarch64-quick | 51:15:59
 clang-ppc64le-linux-lnt   | 51:09:46
 clang-ppc64be-linux-lnt   | 51:06:10
 lldb-x86_64-ubuntu-14.04-buildserver  | 44:38:46
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only | 29:25:21
 clang-x64-ninja-win7  | 29:21:27
 sanitizer-windows | 25:33:14
 clang-atom-d525-fedora-rel| 24:35:03
 perf-x86_64-penryn-O3 | 21:52:44
 clang-x86-win2008-selfhost| 21:43:03
 perf-x86_64-penryn-O3-polly   | 18:19:52
 perf-x86_64-penryn-O3-polly-unprofitable  | 17:18:59
 sanitizer-x86_64-linux| 15:54:00
 polly-amd64-linux | 15:17:59
 clang-cmake-mipsel| 14:17:09
 perf-x86_64-penryn-O3-polly-fast  | 11:54:11
 clang-cmake-mips  | 10:53:16
 clang-cmake-armv7-a15-selfhost-neon   | 10:52:14
 clang-cmake-thumbv7-a15-full-sh   | 10:29:41
 clang-ppc64be-linux-multistage| 10:13:14
 clang-ppc64be-linux   | 09:43:42
 clang-s390x-linux | 09:38:57
 llvm-mips-linux   | 09:32:24
 clang-ppc64le-linux-multistage| 08:14:25
 lldb-x86_64-ubuntu-14.04-android  | 07:59:04
 sanitizer-x86_64-linux-fast   | 07:35:17
 lldb-windows7-android | 07:34:49
 lldb-x86_64-ubuntu-14.04-cmake| 07:05:09
 sanitizer-x86_64-linux-bootstrap  | 06:49:43
 lldb-x86_64-darwin-13.4   | 06:45:12
 sanitizer-x86_64-linux-autoconf   | 06:30:49
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 05:47:43
 clang-cmake-armv7-a15-selfhost| 05:16:15
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 04:23:52
 sanitizer-ppc64le-linux   | 03:52:34
 clang-cmake-armv7-a15 | 03:28:39
 clang-cmake-armv7-a15-full| 02:50:25
 lldb-amd64-ninja-netbsd7  | 02:03:29
 sanitizer-x86_64-linux-fuzzer | 02:03:04
 clang-cmake-thumbv7-a15   | 01:33:30
 libcxx-libcxxabi-arm-linux| 01:25:26
 clang-ppc64le-linux   | 01:19:53
 sanitizer-ppc64be-linux   | 01:17:50
 clang-x86_64-linux-selfhost-modules   | 01:07:57
 llvm-sphinx-docs  | 01:07:31
 llvm-clang-lld-x86_64-debian-fast | 00:59:48
 clang-x86_64-debian-fast  | 00:59:21
 clang-hexagon-elf | 00:51:32
 llvm-hexagon-elf  | 00:48:00
 clang-sphinx-docs | 00:47:34
 clang-x86_64-linux-abi-test   | 00:40:39
 perf-x86_64-penryn-O3-polly-parallel-fast | 00:39:01
 clang-bpf-build   | 00:38:22
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 00:33:22
 lld-x86_64-darwin13   | 00:28:24
 lld-x86_64-win7   | 00:24:56
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 00:17:19
(61 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly

Re: [cfe-commitsatlists.llvm.org: r271801 - Add PIE magic for NetBSD. Add tests for the correct flags for]

2016-06-06 Thread Richard Smith via cfe-commits
LGTM for branch. Please also merge r271893 to fix a test failure from this
change.

On Sun, Jun 5, 2016 at 12:29 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Tom,
> I'd like to merge this change for getting rid of the stupid '-pie is
> nont used' warnings and to actual make it do the right thing :) This
> doesn't affect any other targets.
>
> Joerg
>
> - Forwarded message from Joerg Sonnenberger via cfe-commits <
> cfe-commitsatlists.llvm.org> -
>
> Author: joerg
> Date: Sat Jun  4 15:03:26 2016
> New Revision: 271801
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271801=rev
> Log:
> Add PIE magic for NetBSD. Add tests for the correct flags for
> non-shared, PIE and shared output mode.
>
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/netbsd.c
>
> - End forwarded message -
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20997: [Coverage] Fix an assertion failure if the definition of an unused function spans multiple files.

2016-06-06 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Thanks, this looks good overall. I just have a few minor comments.



Comment at: lib/CodeGen/CoverageMappingGen.cpp:329
@@ +328,3 @@
+  FileID ParentFile = SM.getFileID(Start);
+  while (ParentFile != SM.getFileID(End) && !isNestedIn(End, ParentFile)) {
+Start = getIncludeOrExpansionLoc(Start);

SM.getFileID() can be expensive if there's a miss in the SourceManager's cache. 
Seeing as `End` isn't updated in this loop, it might be profitable/cleaner to 
maintain dedicated `StartFileID` and `EndFileID` variables. Wdyt?


Comment at: lib/CodeGen/CoverageMappingGen.cpp:331
@@ +330,3 @@
+Start = getIncludeOrExpansionLoc(Start);
+assert(Start.isValid());
+ParentFile = SM.getFileID(Start);

Please add a string here, e.g "Declaration start loc not nested within a known 
region".


Comment at: lib/CodeGen/CoverageMappingGen.cpp:336
@@ +335,3 @@
+End = getPreciseTokenLocEnd(getIncludeOrExpansionLoc(End));
+assert(End.isValid());
+  }

^ ditto.


Repository:
  rL LLVM

http://reviews.llvm.org/D20997



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-06 Thread Richard Smith via cfe-commits
rsmith added a comment.

Yes, I definitely want us to implement this for GCC compatibility. And now that 
we have a specification for this feature, we can evaluate whether this is doing 
the right thing. On that basis:

I still want this refactored so that the normally-mangled part of a function 
name is only mangled once, rather than being mangled twice (once to find the 
implicit tag set and once to actually produce the mangled name). As suggested, 
you can achieve this by first computing the set of tags from the return type, 
then mangling the encoding to a separate buffer (collecting tags as you go) if 
the set is non-empty, and finally writing any remaining tags and the buffer 
contents.

Please factor out a function to mangle the source name and ABI tags for a 
`NamedDecl` rather than duplicating that pair of calls throughout the patch.

Current discussion on the ABI list suggests that it is not correct to mangle 
the return type / variable type to get the implicit tag set. The set of 
available attributes should be determined by a recursive walk of the original 
type (prior to any substitution), not by mangling it and seeing what it 
references. It's not yet clear whether that's the actual design intent or just 
the emergent behavior of the GCC implementation, however.


http://reviews.llvm.org/D18035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-06 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D18035#450211, @andreybokhanko wrote:

> In http://reviews.llvm.org/D18035#448057, @hfinkel wrote:
>
> > We just received the first draft of that specification yesterday.
>
>
> Is this specification confidential?


The link was posted here: 
http://sourcerytools.com/pipermail/cxx-abi-dev/2016-June/002919.html - which is 
the mailing list where the C++ ABI specification is discussed.

> If not, why it hasn't been made available in this code review?


It was, it was part of my comment.

> Most puzzlingly, why it hasn't been shared with Dmitry, who obviously 
> contributed the most towards making abi_tag supported in clang?


If he does not otherwise follow the cxx-abi-dev list, I assume he saw the link 
when I posted it.

> Yours,

> Andrey

>  =

>  Software Engineer

>  Intel Compiler Team



http://reviews.llvm.org/D18035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-06-06 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

In http://reviews.llvm.org/D18035#448057, @hfinkel wrote:

> We just received the first draft of that specification yesterday.


Is this specification confidential? If not, why it hasn't been made available 
in this code review? Most puzzlingly, why it hasn't been shared with Dmitry, 
who obviously contributed the most towards making abi_tag supported in clang?

> As far as I can tell, Richard also is very busy, like many of us, and it can 
> take time to get to things, even important things. I understand why this is 
> frustrating, but please don't become discouraged.


I understand that Richard is super-busy and apart of doing a lot of stuff 
himself also reviews *a ton* of other peoples' patches (I wonder how he finds 
time... probably saves on sleeping :-))

But what's wrong with letting us (Intel) carry on some burden and implement 
this particular piece? Seeing how this review is developing makes me... yeah, 
discouraged is the right word. :-(

Yours,

Andrey
==

Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D18035



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-06-06 Thread Jeroen Ketema via cfe-commits
Hi Sam,

Thanks baring with me, and thanks a lot for your explanation! I indeed now 
believe that this is correct; I got somewhat confused by all the macro magic 
that is going on, and had missed that the enabled extensions are actually 
stored in a class instance separate from the one with available options.

I still think it would be good if the extensions that only affect the host-side 
are removed, in particular cl_khr_icd and cl_khr_terminate_context. We have a 
runtime that indirectly includes both Clang’s OpenCLExtensions.def and the 
Khronos extension header, and we run into problems when we include the 
extension header before OpenCLExtensions.def, because the extension header 
defines macros named cl_khr_icd and cl_khr_terminate_context. I admit this is a 
somewhat special use-case though.

Thanks again,

 Jeroen

> On 02 Jun 2016, at 21:53, Liu, Yaxun (Sam)  wrote:
> 
> Sorry for the delay.
> 
> In ParsePragma.cpp:
> 
> void Parser::HandlePragmaOpenCLExtension() {
>  assert(Tok.is(tok::annot_pragma_opencl_extension));
>  OpenCLExtData data =
>  OpenCLExtData::getFromOpaqueValue(Tok.getAnnotationValue());
>  unsigned state = data.getInt();
>  IdentifierInfo *ename = data.getPointer();
>  SourceLocation NameLoc = Tok.getLocation();
>  ConsumeToken(); // The annotation token.
> 
>  OpenCLOptions  = Actions.getOpenCLOptions();
>  auto CLVer = getLangOpts().OpenCLVersion;
>  auto  = getTargetInfo().getSupportedOpenCLOpts();
>  // OpenCL 1.1 9.1: "The all variant sets the behavior for all extensions,
>  // overriding all previously issued extension directives, but only if the
>  // behavior is set to disable."
>  if (state == 0 && ename->isStr("all")) {
> #define OPENCLEXT(nm) \
>if (Supp.is_##nm##_supported_extension(CLVer)) \
>  f.nm = 0;
> #include "clang/Basic/OpenCLExtensions.def"
>  }
> #define OPENCLEXT(nm) else if (ename->isStr(#nm)) \
>   if (Supp.is_##nm##_supported_extension(CLVer)) \
> f.nm = state; \
>   else if (Supp.is_##nm##_supported_core(CLVer)) \
> PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << ename; \
>   else \
> PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << ename;
> #include "clang/Basic/OpenCLExtensions.def"
>  else {
>PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << ename;
>return;
>  }
> }
> 
> Whether an extension is supported is represented by 
> getTargetInfo().getSupportedOpenCLOpts(), which does not change with pragma.
> 
> Whether an extension is enabled is reprented by Actions.getOpenCLOptions(), 
> which changes with pragma.
> 
> test/SemaOpenCL/extensions.cl contains examples of unsupported extensions.
> 
> Sam
> 
> -Original Message-
> From: Jeroen Ketema [mailto:j.ket...@imperial.ac.uk] 
> Sent: Tuesday, May 31, 2016 6:07 PM
> To: Liu, Yaxun (Sam) 
> Cc: Anastasia Stulova ; Clang Commits 
> ; nd 
> Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> Hi Sam,
> 
>> This commit does not change the initial state of the extensions. An 
>> extension is supported is not the same as enabled. At the beginning all 
>> extensions are disabled.
> 
> I do not see this reflected in the code at all. Could you please:
> 
> a. Point me to the location where this distinction is made.
> 
> b. Convince me that I cannot enable an extension for a target if that target 
> does not support the extension?
> 
> Jeroen
> 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-06 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

> Specifically, I suspect that C (and maybe ObjC?) won't hit the analysis limit 
> often, but that C++ will hit the 

>  limit frequently because of the large number of inline functions.


It might be valuable to know this. Maybe we should changer the default for C++?

> (or a number derived from it) is that it scales to the expected worst-case 
> workload.


Sounds good.


http://reviews.llvm.org/D20933



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20867: [PCH] Fix timestamp check on windows hosts.

2016-06-06 Thread Richard Smith via cfe-commits
On Wed, Jun 1, 2016 at 8:33 AM, pierre gousseau via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> pgousseau created this revision.
> pgousseau added reviewers: rsmith, thakis.
> pgousseau added subscribers: cfe-commits, wristow, probinson, gbedwell,
> bruno, cameron314.
>
> On Linux, if the timestamp of a header file, included in the pch, is
> modified, then including the pch without regenerating it causes a fatal
> error, which is reasonable.
> On Windows the check is ifdefed out, allowing the compilation to continue
> in a broken state.
> The root of the broken state is that, if timestamps dont match, the
> preprocessor will reparse a header without discarding the pch data.
> This leads to "#pragma once" header to be included twice.
> The reason behind the ifdefing of the check lacks documentation, and was
> done 6 years ago.
>

It's documented in the comment you deleted:

   // In our regression testing, the Windows file system seems to
   // have inconsistent modification times that sometimes
   // erroneously trigger this error-handling path.

We should confirm whether this is in fact still the case. Maybe this is
caused by building on a networked file system, where a locally-changed file
might have a different mtime locally and remotely (the local mtime may be
precise where the remote one has been rounded to a multiple of 2 seconds by
an underlying FAT filesystem)? If it's something like that, we could
perhaps work around this by rounding the mtime to a multiple of 2 seconds
ourselves.


> This change tentatively removes the ifdefing and adds a cc1 option to
> disable the inclusion of timestamps in pch files, giving some flexibility
> to build systems such as distributed builds.
>
> This change is a follow up to the discussion started in
> http://reviews.llvm.org/D20243
>
> http://reviews.llvm.org/D20867
>
> Files:
>   include/clang/Driver/CC1Options.td
>   include/clang/Frontend/FrontendOptions.h
>   lib/Frontend/CompilerInvocation.cpp
>   lib/Frontend/FrontendActions.cpp
>   lib/Serialization/ASTReader.cpp
>   test/PCH/Inputs/include-timestamp-pch.h
>   test/PCH/Inputs/include-timestamp.h
>   test/PCH/include-timestamp.cpp
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-06 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 59778.
tra added a comment.

Replaced if() with assert() to catch unexpected PerformCopyInitialization() 
failures.


http://reviews.llvm.org/D20985

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCUDA/launch-bounds.cu
  test/SemaCUDA/pr27778.cu

Index: test/SemaCUDA/pr27778.cu
===
--- /dev/null
+++ test/SemaCUDA/pr27778.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+#include "Inputs/cuda.h"
+
+const int constint = 512;
+__launch_bounds__(constint) void TestConstInt(void) {}
Index: test/CodeGenCUDA/launch-bounds.cu
===
--- test/CodeGenCUDA/launch-bounds.cu
+++ test/CodeGenCUDA/launch-bounds.cu
@@ -79,3 +79,8 @@
 }
 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"maxntidx",
 // CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"minctasm",
+
+const char constchar = 12;
+__global__ void __launch_bounds__(constint, constchar) Kernel8() {}
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"maxntidx", i32 100
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"minctasm", i32 12
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -28,6 +28,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/DelayedDiagnostic.h"
+#include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/StringExtras.h"
@@ -4039,48 +4040,60 @@
   return false;
 }
 
-// Checks whether an argument of launch_bounds attribute is acceptable
-// May output an error.
-static bool checkLaunchBoundsArgument(Sema , Expr *E,
-  const CUDALaunchBoundsAttr ,
-  const unsigned Idx) {
+// Checks whether an argument of launch_bounds attribute is
+// acceptable, performs implicit conversion to Rvalue, and returns
+// non-nullptr Expr result on success. Otherwise, it returns nullptr
+// and may output an error.
+static Expr *makeLaunchBoundsArgExpr(Sema , Expr *E,
+ const CUDALaunchBoundsAttr ,
+ const unsigned Idx) {
   if (S.DiagnoseUnexpandedParameterPack(E))
-return false;
+return nullptr;
 
   // Accept template arguments for now as they depend on something else.
   // We'll get to check them when they eventually get instantiated.
   if (E->isValueDependent())
-return true;
+return E;
 
   llvm::APSInt I(64);
   if (!E->isIntegerConstantExpr(I, S.Context)) {
 S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
 <<  << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
-return false;
+return nullptr;
   }
   // Make sure we can fit it in 32 bits.
   if (!I.isIntN(32)) {
 S.Diag(E->getExprLoc(), diag::err_ice_too_large) << I.toString(10, false)
  << 32 << /* Unsigned */ 1;
-return false;
+return nullptr;
   }
   if (I < 0)
 S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative)
 <<  << Idx << E->getSourceRange();
 
-  return true;
+  // We may need to perform implicit conversion of the argument.
+  InitializedEntity Entity = InitializedEntity::InitializeParameter(
+  S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false);
+  ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E);
+  assert(!ValArg.isInvalid() &&
+ "Unexpected PerformCopyInitialization() failure.");
+
+  return ValArg.getAs();
 }
 
 void Sema::AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
Expr *MinBlocks, unsigned SpellingListIndex) {
   CUDALaunchBoundsAttr TmpAttr(AttrRange, Context, MaxThreads, MinBlocks,
SpellingListIndex);
-
-  if (!checkLaunchBoundsArgument(*this, MaxThreads, TmpAttr, 0))
+  MaxThreads = makeLaunchBoundsArgExpr(*this, MaxThreads, TmpAttr, 0);
+  if (MaxThreads == nullptr)
 return;
 
-  if (MinBlocks && !checkLaunchBoundsArgument(*this, MinBlocks, TmpAttr, 1))
-return;
+  if (MinBlocks) {
+MinBlocks = makeLaunchBoundsArgExpr(*this, MinBlocks, TmpAttr, 1);
+if (MinBlocks == nullptr)
+  return;
+  }
 
   D->addAttr(::new (Context) CUDALaunchBoundsAttr(
   AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271937 - [CMake] Fixing a typo in a CMake option

2016-06-06 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon Jun  6 15:18:38 2016
New Revision: 271937

URL: http://llvm.org/viewvc/llvm-project?rev=271937=rev
Log:
[CMake] Fixing a typo in a CMake option

CMake defines are set with -D, forgetting the D doesn’t work.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=271937=271936=271937=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Mon Jun  6 15:18:38 2016
@@ -82,7 +82,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E

-DCOMPILER_RT_INSTALL_PATH:STRING=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-   -LLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
-Dcmake_3_2_USES_TERMINAL=${cmake_3_2_USES_TERMINAL}
${COMPILER_RT_PASSTHROUGH_VARIABLES}
 INSTALL_COMMAND ""


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21036: Misplaced const-qualification with typedef types

2016-06-06 Thread Aaron Ballman via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Thank you for the quick turn-around!



Comment at: test/clang-tidy/misc-misplaced-const.c:20
@@ +19,3 @@
+  const volatile ip i4 = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i4' declared with a 
const-qualified typedef type; results in the type being 'int *const volatile' 
instead of 'const int *volatile'
+}

sbenza wrote:
> sbenza wrote:
> > If we are guessing that 'const' goes to the int, shouldn't we guess that 
> > volatile also goes to the int?
> Only keep the first instance with the full message.
> The rest can be collapsed with {{.*}} to try to fit in 80 cols.
Actually, that test was purposely showing that we do *not* treat all 
cv-qualifiers the same. `volatile` and `restrict` have sufficiently complex 
semantics that I would be wary about pointing out the type differences as being 
potentially problematic. Typically, if you are using those qualifiers, you 
probably know more about what you want the code to do and whether you want the 
*pointer* to have the qualifier instead of the pointee.


Comment at: test/clang-tidy/misc-misplaced-const.c:20
@@ +19,3 @@
+  const volatile ip i4 = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i4' declared with a 
const-qualified typedef type; results in the type being 'int *const volatile' 
instead of 'const int *volatile'
+}

aaron.ballman wrote:
> sbenza wrote:
> > sbenza wrote:
> > > If we are guessing that 'const' goes to the int, shouldn't we guess that 
> > > volatile also goes to the int?
> > Only keep the first instance with the full message.
> > The rest can be collapsed with {{.*}} to try to fit in 80 cols.
> Actually, that test was purposely showing that we do *not* treat all 
> cv-qualifiers the same. `volatile` and `restrict` have sufficiently complex 
> semantics that I would be wary about pointing out the type differences as 
> being potentially problematic. Typically, if you are using those qualifiers, 
> you probably know more about what you want the code to do and whether you 
> want the *pointer* to have the qualifier instead of the pointee.
I'll collapse the ones after the volatile test.


Comment at: test/clang-tidy/misc-misplaced-const.cpp:20
@@ +19,3 @@
+
+template 
+struct S {

sbenza wrote:
> I assume this check does not trigger for 'const X&' where X is a pointer.
> Please add a test for that.
Do you want:
```
template 
struct S {
  const Ty *i;
  const Ty 
};

template struct S;
template struct S; // ok
template struct S;
template struct S; // ok
```
Or something else?


http://reviews.llvm.org/D21036



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-06-06 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D17462



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21036: Misplaced const-qualification with typedef types

2016-06-06 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

I think this would be more interesting with macros.
Eg triggering in code like this:

  #define FOO(type, op) const type& X = op()
  FOO(int*, bar);



Comment at: clang-tidy/misc/MisplacedConstCheck.cpp:32
@@ +31,3 @@
+
+static QualType GuessAlternateQualification(ASTContext , QualType QT) {
+  // We're given a QualType from a typedef where the qualifiers apply to the

guessAlternateQualification (lower case)


Comment at: test/clang-tidy/misc-misplaced-const.c:20
@@ +19,3 @@
+  const volatile ip i4 = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i4' declared with a 
const-qualified typedef type; results in the type being 'int *const volatile' 
instead of 'const int *volatile'
+}

If we are guessing that 'const' goes to the int, shouldn't we guess that 
volatile also goes to the int?


Comment at: test/clang-tidy/misc-misplaced-const.c:20
@@ +19,3 @@
+  const volatile ip i4 = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i4' declared with a 
const-qualified typedef type; results in the type being 'int *const volatile' 
instead of 'const int *volatile'
+}

sbenza wrote:
> If we are guessing that 'const' goes to the int, shouldn't we guess that 
> volatile also goes to the int?
Only keep the first instance with the full message.
The rest can be collapsed with {{.*}} to try to fit in 80 cols.


Comment at: test/clang-tidy/misc-misplaced-const.cpp:20
@@ +19,3 @@
+
+template 
+struct S {

I assume this check does not trigger for 'const X&' where X is a pointer.
Please add a test for that.


http://reviews.llvm.org/D21036



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21012: clang-rename: implement renaming of classes inside static_cast

2016-06-06 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271933: clang-rename: implement renaming of classes inside 
static_cast (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D21012?vs=59695=59766#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21012

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp

Index: clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
+++ clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=X %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Base {
+};
+
+class Derived : public Base {
+public:
+  int getValue() const {
+return 0;
+  }
+};
+
+int main() {
+  Derived D;
+  const Base  = D;
+  const Base *Pointer = 
+
+  static_cast(Reference).getValue(); // CHECK: 
static_cast
+  static_cast(Pointer)->getValue();  // CHECK: 
static_cast
+}
+
+// Use grep -FUbo 'Derived'  to get the correct offset of foo when 
changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -123,6 +123,23 @@
 return true;
   }
 
+  bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) {
+clang::QualType Type = Expr->getType();
+// See if this a cast of a pointer.
+const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
+if (!Decl) {
+  // See if this is a cast of a reference.
+  Decl = Type->getAsCXXRecordDecl();
+}
+
+if (Decl && getUSRForDecl(Decl) == USR) {
+  SourceLocation Location = 
Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
+  LocationsFound.push_back(Location);
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping


Index: clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
+++ clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=X %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Base {
+};
+
+class Derived : public Base {
+public:
+  int getValue() const {
+return 0;
+  }
+};
+
+int main() {
+  Derived D;
+  const Base  = D;
+  const Base *Pointer = 
+
+  static_cast(Reference).getValue(); // CHECK: static_cast
+  static_cast(Pointer)->getValue();  // CHECK: static_cast
+}
+
+// Use grep -FUbo 'Derived'  to get the correct offset of foo when changing
+// this file.
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -123,6 +123,23 @@
 return true;
   }
 
+  bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) {
+clang::QualType Type = Expr->getType();
+// See if this a cast of a pointer.
+const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
+if (!Decl) {
+  // See if this is a cast of a reference.
+  Decl = Type->getAsCXXRecordDecl();
+}
+
+if (Decl && getUSRForDecl(Decl) == USR) {
+  SourceLocation Location = Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
+  LocationsFound.push_back(Location);
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r271933 - clang-rename: implement renaming of classes inside static_cast

2016-06-06 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Jun  6 14:40:12 2016
New Revision: 271933

URL: http://llvm.org/viewvc/llvm-project?rev=271933=rev
Log:
clang-rename: implement renaming of classes inside static_cast

"Derived" in static_cast(...) wasn't renamed, nor in its
pointer equivalent.

Reviewers: klimek

Differential Revision: http://reviews.llvm.org/D21012

Added:
clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=271933=271932=271933=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Mon Jun  6 14:40:12 
2016
@@ -123,6 +123,23 @@ public:
 return true;
   }
 
+  bool VisitCXXStaticCastExpr(clang::CXXStaticCastExpr *Expr) {
+clang::QualType Type = Expr->getType();
+// See if this a cast of a pointer.
+const RecordDecl* Decl = Type->getPointeeCXXRecordDecl();
+if (!Decl) {
+  // See if this is a cast of a reference.
+  Decl = Type->getAsCXXRecordDecl();
+}
+
+if (Decl && getUSRForDecl(Decl) == USR) {
+  SourceLocation Location = 
Expr->getTypeInfoAsWritten()->getTypeLoc().getBeginLoc();
+  LocationsFound.push_back(Location);
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping

Added: clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp?rev=271933=auto
==
--- clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp Mon Jun  6 
14:40:12 2016
@@ -0,0 +1,24 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=X %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Base {
+};
+
+class Derived : public Base {
+public:
+  int getValue() const {
+return 0;
+  }
+};
+
+int main() {
+  Derived D;
+  const Base  = D;
+  const Base *Pointer = 
+
+  static_cast(Reference).getValue(); // CHECK: 
static_cast
+  static_cast(Pointer)->getValue();  // CHECK: 
static_cast
+}
+
+// Use grep -FUbo 'Derived'  to get the correct offset of foo when 
changing
+// this file.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21036: Misplaced const-qualification with typedef types

2016-06-06 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza, hokein.
aaron.ballman added a subscriber: cfe-commits.

Sometimes it's easy for developers to not notice that the type they are working 
with is a typedef type to a pointer and add a const-qualifier that applies to 
the typedef type rather than the underlying pointer type. e.g.,

  typedef int *int_ptr;
  void func(const int_ptr ip);

This results in ip having the type int * const rather than const int *.

This patch adds a new clang-tidy check to diagnose such constructs to alert the 
developer of the difference in types. It does not diagnose if the underlying 
pointer type points to a const type or is a function type because the 
const-qualifier on the typedef is more likely to be intentional.

http://reviews.llvm.org/D21036

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tidy/misc/MisplacedConstCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-misplaced-const.rst
  test/clang-tidy/misc-misplaced-const.c
  test/clang-tidy/misc-misplaced-const.cpp

Index: test/clang-tidy/misc-misplaced-const.cpp
===
--- test/clang-tidy/misc-misplaced-const.cpp
+++ test/clang-tidy/misc-misplaced-const.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s misc-misplaced-const %t
+
+typedef int plain_i;
+typedef int *ip;
+typedef const int *cip;
+
+void func() {
+  if (const int *i = 0)
+;
+  if (const plain_i *i = 0)
+;
+  if (const cip i = 0)
+;
+
+  // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'i' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
+  if (const ip i = 0)
+;
+}
+
+template 
+struct S {
+  const Ty *i;
+};
+
+template struct S;
+template struct S; // ok
+template struct S;
Index: test/clang-tidy/misc-misplaced-const.c
===
--- test/clang-tidy/misc-misplaced-const.c
+++ test/clang-tidy/misc-misplaced-const.c
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s misc-misplaced-const %t
+
+typedef int plain_i;
+typedef int *ip;
+typedef const int *cip;
+
+typedef void (*func_ptr)(void);
+
+void func(void) {
+  // ok
+  const int *i0 = 0;
+  const plain_i *i1 = 0;
+  const cip i2 = 0; // const applies to both pointer and pointee.
+
+  // Not ok
+  const ip i3 = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
+
+  const volatile ip i4 = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i4' declared with a const-qualified typedef type; results in the type being 'int *const volatile' instead of 'const int *volatile'
+}
+
+void func2(const plain_i *i1,
+   const cip i2,
+   const ip i3,
+   // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i3' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
+   const int *i4) {
+}
+
+struct S {
+  const int *i0;
+  const plain_i *i1;
+  const cip i2;
+  const ip i3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
+};
+
+// Function pointers should not be diagnosed because a function
+// pointer type can never be const.
+void func3(const func_ptr fp) {
+  const func_ptr fp2 = fp;
+}
Index: docs/clang-tidy/checks/misc-misplaced-const.rst
===
--- docs/clang-tidy/checks/misc-misplaced-const.rst
+++ docs/clang-tidy/checks/misc-misplaced-const.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - misc-misplaced-const
+
+misc-misplaced-const
+
+
+This check diagnoses when a const qualifier is applied to a typedef to a pointer
+type rather than to the pointee, because such constructs are often misleading to
+developers because the const applies to the pointer rather than the pointee.
+
+For instance, in the following code, the resulting type is `int *` const rather
+than `const int *`:
+
+.. code:: c++
+
+  typedef int *int_ptr;
+  void f(const int_ptr ptr);
+
+The check does not diagnose when the underlying typedef type is a pointer to a
+const type or a function pointer type. This is because the const qualifier is
+less likely to be mistaken because it would be redundant (or disallowed) on the
+underlying pointee type.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,7 +4,6 @@
 =
 
 .. toctree::
-
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
cert-dcl50-cpp
@@ -63,6 +62,7 @@
misc-inefficient-algorithm
misc-macro-parentheses
  

Re: [PATCH] D20681: Add target-specific pre-linking passes to Clang

2016-06-06 Thread Yaxun Liu via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In http://reviews.llvm.org/D20681#448443, @Anastasia wrote:

> Do you think we could add any test for this change?


We have prelinking passes in amdgpu backend but it requires the llvm change to 
be committed first. We can add a test for this after that.



Comment at: lib/CodeGen/CodeGenAction.cpp:169
@@ +168,3 @@
+  std::function
+LinkCallBack = [=](llvm::Module *M)->bool {
+// Link LinkModule into this module if present, preserving its 
validity.

Anastasia wrote:
> Is there any reason for having this as a callback now?
> 
> Could we just add a call to prelink passes here above instead without 
> modifying much the original flow?
EmitBackendOutput does not set its own diagnostic handler. When linking error 
happens, the diagnostic handler of BackendConsumer is used, which requires the 
member variable CurLinkModule of BackendConsumer to be set to current module to 
be linked to emit correct error msg. Therefore the linking step of 
EmitBackendOutput needs to update a member of BackendConsumer, a lambda 
function can achieve that with minimal change to other parts of the code.

An alternative implementation can do without the lambda function, but needs to 

  # define a diagnostic handler for EmitBackendOutput 
  # at the begining of EmitBackendOutput, save the old diagnostic handler and 
set the new one
  # at the end of EmitBackendOutput, recover the old diagnostic handler
  # define a helper class for diagnostic handler for EmitBackendOutput to 
retain the states needed for emitting diagnostic msgs 
  # move or copy the diagnostic handling required by EmitBackendOutput from the 
diagnostic handler of BackendConsumer to the helper class of diagnostic handler 
for EmitBackendOutput

Do we want to take this approach?



http://reviews.llvm.org/D20681



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

2016-06-06 Thread Yaxun Liu via cfe-commits
yaxunl marked 4 inline comments as done.


Comment at: test/Headers/opencl-c-header.cl:50
@@ +49,3 @@
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck %s
+// RUN: diff %t/1_0.pcm %t/opencl_c.pcm
+// RUN: rm %t/opencl_c.pcm

Anastasia wrote:
> I see, but is diffing accurate here? Because if the file is regenerated but 
> with exactly the same content it won't be caught...
It cannot detect if the file was re-written with the same content.

There is one way we can do that:
get the modified time of the file
sleep 1 second
get the modified time of the file again and compare

but it will slow down the test by 1 second. do we really want to do that?


Comment at: test/Headers/opencl-c-header.cl:70
@@ +69,3 @@
+// RUN: %clang_cc1 -cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s

Anastasia wrote:
> So in this line it will be regenerated because the line above used different 
> triple?
No. It should use the cached module.


http://reviews.llvm.org/D20444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271927 - Adding an AST matcher to ignore parenthesis in *types* (rather than expressions). This is required for traversing certain types (like function pointer types).

2016-06-06 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Jun  6 13:52:17 2016
New Revision: 271927

URL: http://llvm.org/viewvc/llvm-project?rev=271927=rev
Log:
Adding an AST matcher to ignore parenthesis in *types* (rather than 
expressions). This is required for traversing certain types (like function 
pointer types).

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=271927=271926=271927=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Jun  6 13:52:17 2016
@@ -3521,6 +3521,10 @@ Example matches X, Y
 ChildT must be an AST base type.
 
 Usable as: Any Matcher
+Note that has is direct matcher, so it also matches things like implicit
+casts and paren casts. If you are matching with expr then you should
+probably consider using ignoringParenImpCasts like:
+has(ignoringParenImpCasts(expr())).
 
 
 
@@ -4897,6 +4901,17 @@ Usable as: Matcherhttp://cl
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypeignoringParensMatcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType
 InnerMatcher
+Matches types that 
match InnerMatcher after any parens are stripped.
+
+Given
+  void (*fp)(void);
+The matcher
+  varDecl(hasType(pointerType(pointee(ignoringParens(functionType())
+would match the declaration for fp.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypepointsToMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
 Overloaded to match the 
pointee type's declaration.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=271927=271926=271927=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Jun  6 13:52:17 2016
@@ -625,6 +625,22 @@ AST_MATCHER_P(Expr, ignoringParenImpCast
   return InnerMatcher.matches(*Node.IgnoreParenImpCasts(), Finder, Builder);
 }
 
+/// \brief Matches types that match InnerMatcher after any parens are stripped.
+///
+/// Given
+/// \code
+///   void (*fp)(void);
+/// \endcode
+/// The matcher
+/// \code
+///   varDecl(hasType(pointerType(pointee(ignoringParens(functionType())
+/// \endcode
+/// would match the declaration for fp.
+AST_MATCHER_P(QualType, ignoringParens,
+  internal::Matcher, InnerMatcher) {
+  return InnerMatcher.matches(Node.IgnoreParens(), Finder, Builder);
+}
+
 /// \brief Matches classTemplateSpecializations where the n'th TemplateArgument
 /// matches the given InnerMatcher.
 ///

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=271927=271926=271927=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Jun  6 13:52:17 2016
@@ -268,6 +268,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(ignoringImpCasts);
   REGISTER_MATCHER(ignoringParenCasts);
   REGISTER_MATCHER(ignoringParenImpCasts);
+  REGISTER_MATCHER(ignoringParens);
   REGISTER_MATCHER(implicitCastExpr);
   REGISTER_MATCHER(implicitValueInitExpr);
   REGISTER_MATCHER(incompleteArrayType);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=271927=271926=271927=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Mon Jun  6 13:52:17 
2016
@@ -1165,6 +1165,13 @@ TEST(TypeMatching, MatchesFunctionTypes)
   EXPECT_TRUE(matches("void f(int i) {}", functionType()));
 }
 
+TEST(TypeMatching, IgnoringParens) {
+  EXPECT_TRUE(
+  notMatches("void (*fp)(void);", pointerType(pointee(functionType();
+  EXPECT_TRUE(matches("void (*fp)(void);",
+  pointerType(pointee(ignoringParens(functionType());
+}
+
 TEST(TypeMatching, MatchesFunctionProtoTypes) {
   EXPECT_TRUE(matches("int (*f)(int);", functionProtoType()));
   EXPECT_TRUE(matches("void f(int i);", functionProtoType()));


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21020: [clang-tidy] readability-identifier-naming - Support for Macros

2016-06-06 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

It'll be good idea to mention improvement in  docs/ReleaseNotes.rst.

Please close PR23198 after commit.


http://reviews.llvm.org/D21020



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-06 Thread Ben Craig via cfe-commits
bcraig added a comment.

I'll try to get those stats.  My suspicion is that it is highly language / 
projects specific.  Specifically, I suspect that C (and maybe ObjC?) won't hit 
the analysis limit often, but that C++ will hit the limit frequently because of 
the large number of inline functions.

I will note that one of the reasons I like using the number of steps (or a 
number derived from it) is that it scales to the expected worst-case workload.  
Shallow analysis only get 75000 work items per top level function, so the 
exploded graph reservation scales down as appropriate.

I'll make sure the next diff (and future diffs) include more context.


http://reviews.llvm.org/D20933



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271920 - Revert "Reapply "[analyzer] Add checker for correct usage of MPI API in C and C++.""

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jun  6 13:29:43 2016
New Revision: 271920

URL: http://llvm.org/viewvc/llvm-project?rev=271920=rev
Log:
Revert "Reapply "[analyzer] Add checker for correct usage of MPI API in C and 
C++.""

This reverts commit r271914. It is still breaking bots.

Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
cfe/trunk/test/Analysis/MPIMock.h
cfe/trunk/test/Analysis/MemRegion.cpp
cfe/trunk/test/Analysis/mpichecker.cpp
cfe/trunk/test/Analysis/mpicheckernotes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=271920=271919=271920=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jun  6 
13:29:43 2016
@@ -72,8 +72,6 @@ def Containers : Package<"containers">,
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
-def MPI : Package<"mpi">, InPackage;
-
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -579,12 +577,6 @@ def PluralMisuseChecker : Checker<"Plura
   DescFile<"LocalizationChecker.cpp">;
 }
 
-let ParentPackage = MPI in {
-  def MPIChecker : Checker<"MPI-Checker">,
-  HelpText<"Checks MPI code">,
-  DescFile<"MPIChecker.cpp">;
-}
-
 
//===--===//
 // Checkers for LLVM development.
 
//===--===//

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=271920=271919=271920=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon 
Jun  6 13:29:43 2016
@@ -150,28 +150,6 @@ public:
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
-
-
-  /// Get descriptive name for memory region. The name is obtained from
-  /// the variable/field declaration retrieved from the memory region.
-  /// Regions that point to an element of an array are returned as: "arr[0]".
-  /// Regions that point to a struct are returned as: "st.var".
-  //
-  /// \param UseQuotes Set if the name should be quoted.
-  ///
-  /// \returns variable name for memory region
-  std::string getDescriptiveName(bool UseQuotes = true) const;
-
-
-  /// Retrieve source range from memory region. The range retrieval
-  /// is based on the decl obtained from the memory region.
-  /// For a VarRegion the range of the base region is returned.
-  /// For a FieldRegion the range of the field is returned.
-  /// If no declaration is found, an empty source range is returned.
-  /// The client is responsible for checking if the returned range is valid.
-  ///
-  /// \returns source range for declaration retrieved from memory region
-  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=271920=271919=271920=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Jun  6 13:29:43 
2016
@@ -41,9 +41,6 @@ add_clang_library(clangStaticAnalyzerChe
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
-  MPI-Checker/MPIBugReporter.cpp
-  MPI-Checker/MPIChecker.cpp
-  MPI-Checker/MPIFunctionClassifier.cpp
   NSAutoreleasePoolChecker.cpp
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp

Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
URL: 

Re: [PATCH] D20922: [libcxx] [test] Rename global "x" to "testcases" in complex.number/cases.h and make it const for safety.

2016-06-06 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Landed as revision 271919


http://reviews.llvm.org/D20922



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r271919 - Rename some test data (and make it const) to rid us of some shadowing warnings in the test suite. No functional change. Thanks to STL@microsoft for the report and patch.

2016-06-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jun  6 13:24:08 2016
New Revision: 271919

URL: http://llvm.org/viewvc/llvm-project?rev=271919=rev
Log:
Rename some test data (and make it const) to rid us of some shadowing warnings 
in the test suite. No functional change. Thanks to STL@microsoft for the report 
and patch.

Modified:
libcxx/trunk/test/std/numerics/complex.number/cases.h

libcxx/trunk/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acos.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asin.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/asinh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/atan.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/atanh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/cos.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/cosh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/exp.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/log.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/log10.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/sin.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/sinh.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/tan.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
libcxx/trunk/test/std/numerics/complex.number/complex.value.ops/abs.pass.cpp
libcxx/trunk/test/std/numerics/complex.number/complex.value.ops/arg.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.value.ops/norm.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.value.ops/polar.pass.cpp

libcxx/trunk/test/std/numerics/complex.number/complex.value.ops/proj.pass.cpp

Modified: libcxx/trunk/test/std/numerics/complex.number/cases.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/complex.number/cases.h?rev=271919=271918=271919=diff
==
--- libcxx/trunk/test/std/numerics/complex.number/cases.h (original)
+++ libcxx/trunk/test/std/numerics/complex.number/cases.h Mon Jun  6 13:24:08 
2016
@@ -17,7 +17,7 @@
 #include 
 #include 
 
-std::complex x[] =
+const std::complex testcases[] =
 {
 std::complex( 1.e-6,  1.e-6),
 std::complex(-1.e-6,  1.e-6),

Modified: 
libcxx/trunk/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp?rev=271919=271918=271919=diff
==
--- 
libcxx/trunk/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
 Mon Jun  6 13:24:08 2016
@@ -37,16 +37,16 @@ test()
 
 void test_edges()
 {
-const unsigned N = sizeof(x) / sizeof(x[0]);
+const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
 for (unsigned i = 0; i < N; ++i)
 {
 for (unsigned j = 0; j < N; ++j)
 {
-std::complex r = x[i] / x[j];
-switch (classify(x[i]))
+std::complex r = testcases[i] / testcases[j];
+switch (classify(testcases[i]))
 {
 case zero:
-switch (classify(x[j]))
+switch (classify(testcases[j]))
 {
 case zero:
 assert(classify(r) == NaN);
@@ -66,7 +66,7 @@ void test_edges()
 }
 break;
 case non_zero:
-switch (classify(x[j]))
+switch (classify(testcases[j]))
 {
 case zero:
 assert(classify(r) == inf);
@@ -86,7 +86,7 @@ void test_edges()
 }
 break;
 case inf:
-switch (classify(x[j]))
+

r271918 - Add a release note about the --build-id change.

2016-06-06 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon Jun  6 13:23:11 2016
New Revision: 271918

URL: http://llvm.org/viewvc/llvm-project?rev=271918=rev
Log:
Add a release note about the --build-id change.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271918=271917=271918=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jun  6 13:23:11 2016
@@ -47,7 +47,10 @@ sections with improvements to Clang's su
 Major New Features
 --
 
-- Feature1...
+- Clang will no longer passes --build-id by default to the linker. In modern
+  linkers that is a relatively expensive option. It can be passed explicitly
+  with -Wl,--build-id. To have clang always pass it, build it with
+  -DENABLE_LINKER_BUILD_ID.
 
 Improvements to Clang's diagnostics
 ^^^


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271914 - Reapply "[analyzer] Add checker for correct usage of MPI API in C and C++."

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jun  6 13:08:35 2016
New Revision: 271914

URL: http://llvm.org/viewvc/llvm-project?rev=271914=rev
Log:
Reapply "[analyzer] Add checker for correct usage of MPI API in C and C++."

Reapply r271907 with a fix for the compiler error with gcc about specializing
clang::ento::ProgramStateTrait in a different namespace.

Differential Revision: http://reviews.llvm.org/D12761

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
cfe/trunk/test/Analysis/MPIMock.h
cfe/trunk/test/Analysis/MemRegion.cpp
cfe/trunk/test/Analysis/mpichecker.cpp
cfe/trunk/test/Analysis/mpicheckernotes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=271914=271913=271914=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jun  6 
13:08:35 2016
@@ -72,6 +72,8 @@ def Containers : Package<"containers">,
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
+def MPI : Package<"mpi">, InPackage;
+
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -577,6 +579,12 @@ def PluralMisuseChecker : Checker<"Plura
   DescFile<"LocalizationChecker.cpp">;
 }
 
+let ParentPackage = MPI in {
+  def MPIChecker : Checker<"MPI-Checker">,
+  HelpText<"Checks MPI code">,
+  DescFile<"MPIChecker.cpp">;
+}
+
 
//===--===//
 // Checkers for LLVM development.
 
//===--===//

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=271914=271913=271914=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon 
Jun  6 13:08:35 2016
@@ -150,6 +150,28 @@ public:
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+
+  /// Get descriptive name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  //
+  /// \param UseQuotes Set if the name should be quoted.
+  ///
+  /// \returns variable name for memory region
+  std::string getDescriptiveName(bool UseQuotes = true) const;
+
+
+  /// Retrieve source range from memory region. The range retrieval
+  /// is based on the decl obtained from the memory region.
+  /// For a VarRegion the range of the base region is returned.
+  /// For a FieldRegion the range of the field is returned.
+  /// If no declaration is found, an empty source range is returned.
+  /// The client is responsible for checking if the returned range is valid.
+  ///
+  /// \returns source range for declaration retrieved from memory region
+  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=271914=271913=271914=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Jun  6 13:08:35 
2016
@@ -41,6 +41,9 @@ add_clang_library(clangStaticAnalyzerChe
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
+  MPI-Checker/MPIBugReporter.cpp
+  MPI-Checker/MPIChecker.cpp
+  MPI-Checker/MPIFunctionClassifier.cpp
   NSAutoreleasePoolChecker.cpp
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp

Added: 

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-06-06 Thread Tim Shen via cfe-commits
timshen added a comment.

I'm looking at some internal test failures caused by this patch.


http://reviews.llvm.org/D20499



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-06-06 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

This doesn't compile under gcc so it broke the bots. The fix is to move the 
specialization of clang::ento::ProgramStateTrait for RequestMapImpl out of the 
global namespace and into clang::ento. I will apply and recommit.


Repository:
  rL LLVM

http://reviews.llvm.org/D12761



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271911 - Fix typo in last submission to visualize proper template argument

2016-06-06 Thread Mike Spertus via cfe-commits
Author: mps
Date: Mon Jun  6 12:23:37 2016
New Revision: 271911

URL: http://llvm.org/viewvc/llvm-project?rev=271911=rev
Log:
Fix typo in last submission to visualize proper template argument

Modified:
cfe/trunk/utils/ClangVisualizers/clang.natvis

Modified: cfe/trunk/utils/ClangVisualizers/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis?rev=271911=271910=271911=diff
==
--- cfe/trunk/utils/ClangVisualizers/clang.natvis (original)
+++ cfe/trunk/utils/ClangVisualizers/clang.natvis Mon Jun  6 12:23:37 2016
@@ -265,7 +265,7 @@ For later versions of Visual Studio, no
 
 , 
{Arguments[1],view(cpp)}{*this,view(arg2)}
 
-, {Arguments[1],view(cpp)}, 
...
+, {Arguments[2],view(cpp)}, 
...
 {*this,view(arg0)}
 
   NumArguments


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver

2016-06-06 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added a reviewer: Anastasia.
ashi1 added subscribers: yaxunl, cfe-commits, pxli168, bader, rsmith, nhaustov.

Allow -cl-std and other standard -cl- options from cc1 to driver.

Added a test for the options moved.

http://reviews.llvm.org/D21031

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- /dev/null
+++ test/Driver/opencl.cl
@@ -0,0 +1,33 @@
+// RUN: %clang -S -### %s
+// RUN: %clang -S -### -cl-std=CL %s | FileCheck --check-prefix=CHECK-CL %s
+// RUN: %clang -S -### -cl-std=CL1.1 %s | FileCheck --check-prefix=CHECK-CL11 %s
+// RUN: %clang -S -### -cl-std=CL1.2 %s | FileCheck --check-prefix=CHECK-CL12 %s
+// RUN: %clang -S -### -cl-std=CL2.0 %s | FileCheck --check-prefix=CHECK-CL20 %s
+// RUN: %clang -S -### -cl-opt-disable %s | FileCheck --check-prefix=CHECK-OPT-DISABLE %s
+// RUN: %clang -S -### -cl-strict-aliasing %s | FileCheck --check-prefix=CHECK-STRICT-ALIASING %s
+// RUN: %clang -S -### -cl-single-precision-constant %s | FileCheck --check-prefix=CHECK-SINGLE-PRECISION-CONST %s
+// RUN: %clang -S -### -cl-finite-math-only %s | FileCheck --check-prefix=CHECK-FINITE-MATH-ONLY %s
+// RUN: %clang -S -### -cl-kernel-arg-info %s | FileCheck --check-prefix=CHECK-KERNEL-ARG-INFO %s
+// RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
+// RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
+// RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
+// RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
+// RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
+// CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
+// CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
+// CHECK-CL: .*clang.* "-cc1" .* "-cl-std=CL"
+// CHECK-CL11: .*clang.* "-cc1" .* "-cl-std=CL1.1"
+// CHECK-CL12: .*clang.* "-cc1" .* "-cl-std=CL1.2"
+// CHECK-CL20: .*clang.* "-cc1" .* "-cl-std=CL2.0"
+// CHECK-OPT-DISABLE: .*clang.* "-cc1" .* "-cl-opt-disable"
+// CHECK-STRICT-ALIASING: .*clang.* "-cc1" .* "-cl-strict-aliasing"
+// CHECK-SINGLE-PRECISION-CONST: .*clang.* "-cc1" .* "-cl-single-precision-constant"
+// CHECK-FINITE-MATH-ONLY: .*clang.* "-cc1" .* "-cl-finite-math-only"
+// CHECK-KERNEL-ARG-INFO: .*clang.* "-cc1" .* "-cl-kernel-arg-info"
+// CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
+// CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
+// CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
+// CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
+
+kernel void func(void);
\ No newline at end of file
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5065,6 +5065,40 @@
 CmdArgs.push_back("-arm-restrict-it");
   }
 
+  // Forward -cl options to -cc1
+  if (Arg *A = Args.getLastArg(options::OPT_cl_opt_disable)) {
+CmdArgs.push_back("-cl-opt-disable");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_strict_aliasing)) {
+CmdArgs.push_back("-cl-strict-aliasing");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_single_precision_constant)) {
+CmdArgs.push_back("-cl-single-precision-constant");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_finite_math_only)) {
+CmdArgs.push_back("-cl-finite-math-only");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_kernel_arg_info)) {
+CmdArgs.push_back("-cl-kernel-arg-info");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_unsafe_math_optimizations)) {
+CmdArgs.push_back("-cl-unsafe-math-optimizations");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_fast_relaxed_math)) {
+CmdArgs.push_back("-cl-fast-relaxed-math");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_mad_enable)) {
+CmdArgs.push_back("-cl-mad-enable");
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_std_EQ)) {
+std::string CLStdStr = "-cl-std=";
+CLStdStr += A->getValue();
+CmdArgs.push_back(Args.MakeArgString(CLStdStr));
+  }
+  if (Arg *A = Args.getLastArg(options::OPT_cl_denorms_are_zero)) {
+CmdArgs.push_back("-cl-denorms-are-zero");
+  }
+
   // Forward -f options with positive and negative forms; we translate
   // these by hand.
   if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -78,6 +78,7 @@
 def i_Group  

Re: [PATCH] D20687: [ASTMatchers] Make isNoThrow and hasDynamicExceptionSpec polymorphic for use with both functionDecl and functionProtoType

2016-06-06 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 59747.
hintonda added a comment.

Use FunctionProtoType instead of auto for clarity.


http://reviews.llvm.org/D20687

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -845,6 +845,13 @@
 notMatches("void f() noexcept(false);", functionDecl(isNoThrow(;
   EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow(;
   EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow(;
+
+  EXPECT_TRUE(notMatches("void f();", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(notMatches("void f() throw(int);", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(
+notMatches("void f() noexcept(false);", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(matches("void f() throw();", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(matches("void f() noexcept;", functionProtoType(isNoThrow(;
 }
 
 TEST(isConstexpr, MatchesConstexprDeclarations) {
@@ -1396,6 +1403,20 @@
   matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec(;
   EXPECT_TRUE(
   matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec(;
+
+  EXPECT_TRUE(notMatches("void f();", functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void g() noexcept;",
+ functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void h() noexcept(true);",
+ functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void i() noexcept(false);",
+ functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void j() throw();", functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void k() throw(int);", functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void l() throw(...);", functionProtoType(hasDynamicExceptionSpec(;
 }
 
 TEST(HasObjectExpression, DoesNotMatchMember) {
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -106,6 +106,17 @@
   return Node.getUnderlyingType();
 }
 
+/// \brief Unifies obtaining the FunctionProtoType pointer from both
+/// FunctionProtoType and FunctionDecl nodes..
+inline const FunctionProtoType *
+getFunctionProtoType(const FunctionProtoType ) {
+  return 
+}
+
+inline const FunctionProtoType *getFunctionProtoType(const FunctionDecl ) {
+  return Node.getType()->getAs();
+}
+
 /// \brief Internal version of BoundNodes. Holds all the bound nodes.
 class BoundNodesMap {
 public:
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3245,10 +3245,13 @@
 ///   void k() throw(int);
 ///   void l() throw(...);
 /// \endcode
-/// functionDecl(hasDynamicExceptionSpec())
-///   matches the declarations of j, k, and l, but not f, g, h, or i.
-AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) {
-  if (const auto *FnTy = Node.getType()->getAs())
+/// functionDecl(hasDynamicExceptionSpec()) and
+///   functionProtoType(hasDynamicExceptionSpec())
+///   match the declarations of j, k, and l, but not f, g, h, or i.
+AST_POLYMORPHIC_MATCHER(hasDynamicExceptionSpec,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+FunctionProtoType)) {
+  if (const FunctionProtoType *FnTy = internal::getFunctionProtoType(Node))
 return FnTy->hasDynamicExceptionSpec();
   return false;
 }
@@ -3263,10 +3266,12 @@
 ///   void i() throw(int);
 ///   void j() noexcept(false);
 /// \endcode
-/// functionDecl(isNoThrow())
-///   matches the declarations of g, and h, but not f, i or j.
-AST_MATCHER(FunctionDecl, isNoThrow) {
-  const auto *FnTy = Node.getType()->getAs();
+/// functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
+///   match the declarations of g, and h, but not f, i or j.
+AST_POLYMORPHIC_MATCHER(isNoThrow,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+FunctionProtoType)) {
+  const FunctionProtoType *FnTy = internal::getFunctionProtoType(Node);
 
   // If the function does not have a prototype, then it is assumed to be a
   // throwing function (as it would if the function did not have any exception
@@ -3278,7 +3283,7 @@
   if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
 

r271910 - Better Visual Studio visualization of TemplateArgument and TemplateArgumentList

2016-06-06 Thread Mike Spertus via cfe-commits
Author: mps
Date: Mon Jun  6 12:08:32 2016
New Revision: 271910

URL: http://llvm.org/viewvc/llvm-project?rev=271910=rev
Log:
Better Visual Studio visualization of TemplateArgument and TemplateArgumentList

For pack TemplateArguments, visualize all of the items in the pack
Visualize a TemplateArgumentList as a template argument list. E.g., 

Modified:
cfe/trunk/utils/ClangVisualizers/clang.natvis

Modified: cfe/trunk/utils/ClangVisualizers/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangVisualizers/clang.natvis?rev=271910=271909=271910=diff
==
--- cfe/trunk/utils/ClangVisualizers/clang.natvis (original)
+++ cfe/trunk/utils/ClangVisualizers/clang.natvis Mon Jun  6 12:08:32 2016
@@ -233,8 +233,22 @@ For later versions of Visual Studio, no
 
   
   
-{*(clang::QualType 
*)TypeOrValue.V,view(cpp)}
-{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en}
 template parameter: {*(clang::QualType *)TypeOrValue.V}
+{*(clang::QualType 
*)TypeOrValue.V,view(cpp)}
+{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en}
 template argument: {*(clang::QualType *)TypeOrValue.V}
+
+{Args.Args[0]}{*this,view(arg1)}
+
+, 
{Args.Args[1]}{*this,view(arg2)}
+
+, {Args.Args[2]}, ...
+
+{Args.Args[0],view(cpp)}{*this,view(arg1cpp)}
+
+, 
{Args.Args[1],view(cpp)}{*this,view(arg2cpp)}
+
+, {Args.Args[2],view(cpp)}, 
...
+{*this,view(arg0cpp)}
+{*this,view(arg0)}
 
{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en}
 
   *(clang::QualType 
*)TypeOrValue.V
@@ -245,6 +259,22 @@ For later versions of Visual Studio, no
   
 
   
+  
+
+{Arguments[0],view(cpp)}{*this,view(arg1)}
+
+, 
{Arguments[1],view(cpp)}{*this,view(arg2)}
+
+, {Arguments[1],view(cpp)}, 
...
+{*this,view(arg0)}
+
+  NumArguments
+  
+NumArguments
+Arguments
+  
+
+  
   
   
 void


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271909 - Revert "[analyzer] Add checker for correct usage of MPI API in C and C++."

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jun  6 12:01:08 2016
New Revision: 271909

URL: http://llvm.org/viewvc/llvm-project?rev=271909=rev
Log:
Revert "[analyzer] Add checker for correct usage of MPI API in C and C++."

This reverts commit r271907. It broke a bunch of bots with compile errors
about specializations in different namespaces.

Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
cfe/trunk/test/Analysis/MPIMock.h
cfe/trunk/test/Analysis/MemRegion.cpp
cfe/trunk/test/Analysis/mpichecker.cpp
cfe/trunk/test/Analysis/mpicheckernotes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=271909=271908=271909=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jun  6 
12:01:08 2016
@@ -72,8 +72,6 @@ def Containers : Package<"containers">,
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
-def MPI : Package<"mpi">, InPackage;
-
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -579,12 +577,6 @@ def PluralMisuseChecker : Checker<"Plura
   DescFile<"LocalizationChecker.cpp">;
 }
 
-let ParentPackage = MPI in {
-  def MPIChecker : Checker<"MPI-Checker">,
-  HelpText<"Checks MPI code">,
-  DescFile<"MPIChecker.cpp">;
-}
-
 
//===--===//
 // Checkers for LLVM development.
 
//===--===//

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=271909=271908=271909=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon 
Jun  6 12:01:08 2016
@@ -150,28 +150,6 @@ public:
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
-
-
-  /// Get descriptive name for memory region. The name is obtained from
-  /// the variable/field declaration retrieved from the memory region.
-  /// Regions that point to an element of an array are returned as: "arr[0]".
-  /// Regions that point to a struct are returned as: "st.var".
-  //
-  /// \param UseQuotes Set if the name should be quoted.
-  ///
-  /// \returns variable name for memory region
-  std::string getDescriptiveName(bool UseQuotes = true) const;
-
-
-  /// Retrieve source range from memory region. The range retrieval
-  /// is based on the decl obtained from the memory region.
-  /// For a VarRegion the range of the base region is returned.
-  /// For a FieldRegion the range of the field is returned.
-  /// If no declaration is found, an empty source range is returned.
-  /// The client is responsible for checking if the returned range is valid.
-  ///
-  /// \returns source range for declaration retrieved from memory region
-  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=271909=271908=271909=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Jun  6 12:01:08 
2016
@@ -41,9 +41,6 @@ add_clang_library(clangStaticAnalyzerChe
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
-  MPI-Checker/MPIBugReporter.cpp
-  MPI-Checker/MPIChecker.cpp
-  MPI-Checker/MPIFunctionClassifier.cpp
   NSAutoreleasePoolChecker.cpp
   NSErrorChecker.cpp
   NoReturnFunctionChecker.cpp

Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
URL: 

Re: [PATCH] D20499: [Temporary, Lifetime] Add lifetime marks for temporaries

2016-06-06 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Is anything blocking us on this review?


http://reviews.llvm.org/D20499



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-06-06 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271907: [analyzer] Add checker for correct usage of MPI API 
in C and C++. (authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D12761?vs=54001=59742#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12761

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
  cfe/trunk/test/Analysis/MPIMock.h
  cfe/trunk/test/Analysis/MemRegion.cpp
  cfe/trunk/test/Analysis/mpichecker.cpp
  cfe/trunk/test/Analysis/mpicheckernotes.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,28 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+
+  /// Get descriptive name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  //
+  /// \param UseQuotes Set if the name should be quoted.
+  ///
+  /// \returns variable name for memory region
+  std::string getDescriptiveName(bool UseQuotes = true) const;
+
+
+  /// Retrieve source range from memory region. The range retrieval
+  /// is based on the decl obtained from the memory region.
+  /// For a VarRegion the range of the base region is returned.
+  /// For a FieldRegion the range of the field is returned.
+  /// If no declaration is found, an empty source range is returned.
+  /// The client is responsible for checking if the returned range is valid.
+  ///
+  /// \returns source range for declaration retrieved from memory region
+  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -72,6 +72,8 @@
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
+def MPI : Package<"mpi">, InPackage;
+
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -577,6 +579,12 @@
   DescFile<"LocalizationChecker.cpp">;
 }
 
+let ParentPackage = MPI in {
+  def MPIChecker : Checker<"MPI-Checker">,
+  HelpText<"Checks MPI code">,
+  DescFile<"MPIChecker.cpp">;
+}
+
 //===--===//
 // Checkers for LLVM development.
 //===--===//
Index: cfe/trunk/test/Analysis/mpicheckernotes.cpp
===
--- cfe/trunk/test/Analysis/mpicheckernotes.cpp
+++ cfe/trunk/test/Analysis/mpicheckernotes.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.mpi.MPI-Checker -analyzer-output=text -verify %s
+
+// MPI-Checker test file to test note diagnostics.
+
+#include "MPIMock.h"
+
+void doubleNonblocking() {
+  double buf = 0;
+  MPI_Request sendReq;
+  MPI_Isend(, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, ); // expected-note{{Request is previously used by nonblocking call here.}}
+  MPI_Irecv(, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, ); // expected-warning{{Double nonblocking on request 'sendReq'.}} expected-note{{Double nonblocking on request 'sendReq'.}}
+  MPI_Wait(, MPI_STATUS_IGNORE);
+}
+
+void missingWait() {
+  double buf = 0;
+  MPI_Request sendReq;
+  MPI_Ireduce(MPI_IN_PLACE, , 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, ); // expected-note{{Request is previously used by nonblocking call here.}}
+} // expected-warning{{Request 'sendReq' has no matching wait.}} expected-note{{Request 'sendReq' has no matching wait.}}
+
+// If more than 2 nonblocking calls are using a request in a sequence, they all
+// point to the first call as the 'previous' call. This is because the
+// BugReporterVisitor only 

r271907 - [analyzer] Add checker for correct usage of MPI API in C and C++.

2016-06-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Jun  6 11:47:16 2016
New Revision: 271907

URL: http://llvm.org/viewvc/llvm-project?rev=271907=rev
Log:
[analyzer] Add checker for correct usage of MPI API in C and C++.

This commit adds a static analysis checker to check for the correct usage of the
MPI API in C and C++.

3 path-sensitive checks are included:

- Double nonblocking: Double request usage by nonblocking calls
  without intermediate wait.
- Missing wait: Nonblocking call without matching wait.
- Unmatched wait: Waiting for a request that was never used by a
  nonblocking call.

Examples of how to use the checker can be found
at https://github.com/0ax1/MPI-Checker

Reviewers: zaks.anna

A patch by Alexander Droste!

Differential Revision: http://reviews.llvm.org/D12761

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
cfe/trunk/test/Analysis/MPIMock.h
cfe/trunk/test/Analysis/MemRegion.cpp
cfe/trunk/test/Analysis/mpichecker.cpp
cfe/trunk/test/Analysis/mpicheckernotes.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=271907=271906=271907=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jun  6 
11:47:16 2016
@@ -72,6 +72,8 @@ def Containers : Package<"containers">,
 def LocalizabilityAlpha : Package<"localizability">, InPackage;
 def LocalizabilityOptIn : Package<"localizability">, InPackage;
 
+def MPI : Package<"mpi">, InPackage;
+
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -577,6 +579,12 @@ def PluralMisuseChecker : Checker<"Plura
   DescFile<"LocalizationChecker.cpp">;
 }
 
+let ParentPackage = MPI in {
+  def MPIChecker : Checker<"MPI-Checker">,
+  HelpText<"Checks MPI code">,
+  DescFile<"MPIChecker.cpp">;
+}
+
 
//===--===//
 // Checkers for LLVM development.
 
//===--===//

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=271907=271906=271907=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Mon 
Jun  6 11:47:16 2016
@@ -150,6 +150,28 @@ public:
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+
+  /// Get descriptive name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  //
+  /// \param UseQuotes Set if the name should be quoted.
+  ///
+  /// \returns variable name for memory region
+  std::string getDescriptiveName(bool UseQuotes = true) const;
+
+
+  /// Retrieve source range from memory region. The range retrieval
+  /// is based on the decl obtained from the memory region.
+  /// For a VarRegion the range of the base region is returned.
+  /// For a FieldRegion the range of the field is returned.
+  /// If no declaration is found, an empty source range is returned.
+  /// The client is responsible for checking if the returned range is valid.
+  ///
+  /// \returns source range for declaration retrieved from memory region
+  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=271907=271906=271907=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ 

[PATCH] D21030: [Sema] Fix rejects-valid where parameter pack was not expanded in type alias

2016-06-06 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
erik.pilkington added a subscriber: cfe-commits.

Clang rejects the following valid code:

```
template  struct Foo {};
template  using FooAlias = Foo;
template  int bar(FooAlias);
int main() { bar(FooAlias<>()); }
```

The problem is that in the substitution of `FooAlias` during the parsing 
of bar, the pack expansion in `Foo` is transformed into a 
parameter with the unexpanded flag set, as opposed to another pack expansion. 
This leads to deduction failing in `main`, which is incorrect. The fix is to 
expand the parameter pack when needed.

Fixes PR25250 & PR26017.

Incidentally, there was an incorrect comment in a very similar function that 
said that a path wasn't reachable. This isn't the case, although no existing 
test case exercised it, so I added one that did. Please let me know if it would 
be cleaner to commit that separately!

Thanks!

http://reviews.llvm.org/D21030

Files:
  lib/Sema/TreeTransform.h
  test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Index: test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -437,3 +437,32 @@
   template void g<>();
   template void g<1, 2, 3>();
 }
+
+template 
+int var_expr(Ts... ts);
+
+template 
+auto a_function(Ts... ts) -> decltype(var_expr(ts...));
+
+template 
+using partial = decltype(a_function);
+
+int use_partial() { partial n; }
+
+namespace PR26017 {
+template 
+struct Foo {};
+template 
+using FooAlias = Foo;
+
+template 
+void bar(const FooAlias &) {}
+
+int fn() {
+  FooAlias<> a;
+  bar(a);
+
+  FooAlias b;
+  bar(b);
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3311,8 +3311,6 @@
 if (Out.isInvalid())
   return true;
 
-// FIXME: Can this happen? We should not try to expand the pack
-// in this case.
 if (Out.get()->containsUnexpandedParameterPack()) {
   Out = getDerived().RebuildPackExpansion(
   Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
@@ -4781,6 +4779,13 @@
   if (NewType.isNull())
 return true;
 
+  if (NewType->containsUnexpandedParameterPack()) {
+NewType = getDerived().RebuildPackExpansionType(
+NewType, SourceRange(), Loc, NumExpansions);
+if (NewType.isNull())
+  return true;
+  }
+
   if (ParamInfos)
 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
   OutParamTypes.push_back(NewType);


Index: test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -437,3 +437,32 @@
   template void g<>();
   template void g<1, 2, 3>();
 }
+
+template 
+int var_expr(Ts... ts);
+
+template 
+auto a_function(Ts... ts) -> decltype(var_expr(ts...));
+
+template 
+using partial = decltype(a_function);
+
+int use_partial() { partial n; }
+
+namespace PR26017 {
+template 
+struct Foo {};
+template 
+using FooAlias = Foo;
+
+template 
+void bar(const FooAlias &) {}
+
+int fn() {
+  FooAlias<> a;
+  bar(a);
+
+  FooAlias b;
+  bar(b);
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3311,8 +3311,6 @@
 if (Out.isInvalid())
   return true;
 
-// FIXME: Can this happen? We should not try to expand the pack
-// in this case.
 if (Out.get()->containsUnexpandedParameterPack()) {
   Out = getDerived().RebuildPackExpansion(
   Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
@@ -4781,6 +4779,13 @@
   if (NewType.isNull())
 return true;
 
+  if (NewType->containsUnexpandedParameterPack()) {
+NewType = getDerived().RebuildPackExpansionType(
+NewType, SourceRange(), Loc, NumExpansions);
+if (NewType.isNull())
+  return true;
+  }
+
   if (ParamInfos)
 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
   OutParamTypes.push_back(NewType);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

2016-06-06 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Headers/opencl-c-header.cl:50
@@ +49,3 @@
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck %s
+// RUN: diff %t/1_0.pcm %t/opencl_c.pcm
+// RUN: rm %t/opencl_c.pcm

I see, but is diffing accurate here? Because if the file is regenerated but 
with exactly the same content it won't be caught...


Comment at: test/Headers/opencl-c-header.cl:53-54
@@ +52,4 @@
+
+// ===
+// Compile for OpenCL 2.0 for the first time. The module should change.
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck 
--check-prefix=CHECK20 %s

Sounds cool. Thanks!


Comment at: test/Headers/opencl-c-header.cl:70
@@ +69,3 @@
+// RUN: %clang_cc1 -cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s

So in this line it will be regenerated because the line above used different 
triple?


http://reviews.llvm.org/D20444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20948: [OpenCL] Fix access qualifiers handling for typedefs

2016-06-06 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7882
@@ -7881,1 +7881,3 @@
   "multiple access qualifiers">;
+def warn_default_access_qualifier : Warning<
+  "missing access qualifier: assuming read_only">,

I am not sure why to give a warning about deduced access qualifier? It seems 
perfectly ok according to the spec to default to read_only if not specified.


Comment at: lib/Sema/SemaType.cpp:6480
@@ -6474,2 +6479,3 @@
Sema ) {
   // OpenCL v2.0 s6.6 - Access qualifier can used only for image and pipe type.
+  if (!(CurType->isImageType() || CurType->isPipeType()) ||

Not related to your change but could you fix this typo please:
 can used -> can be used


Comment at: test/SemaOpenCL/images-typedef.cl:7
@@ +6,3 @@
+typedef read_only image1d_t img1d_ro;
+typedef read_write image1d_t img1d_rw;
+

Should this only be allowed for OpenCL2.0?


Comment at: test/SemaOpenCL/images-typedef.cl:14
@@ +13,3 @@
+void myWrite(write_only image1d_t); // expected-note {{passing argument to 
parameter here}} expected-note {{passing argument to parameter here}}
+void myRead (read_only image1d_t); // expected-note {{passing argument to 
parameter here}}
+

myRead ( -> myRead(


Comment at: test/SemaOpenCL/images-typedef.cl:39
@@ +38,3 @@
+
+kernel void k7 (write_only img1d_ro_default img) { // expected-error {{access 
qualifier can only be used for pipe and image type}}
+}

I feel this error might be a bit confusing, because the typedef is to an image 
at the end.

Did we have an error here before?


Comment at: test/SemaOpenCL/images-typedef.cl:42
@@ +41,3 @@
+
+kernel void k8 (read_only int img) { // expected-error {{access qualifier can 
only be used for pipe and image type}}
+}

I think this is already being tested in invalid-access-qualifier.cl.

Also could we combine with that test file into one?


http://reviews.llvm.org/D20948



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20687: [ASTMatchers] Make isNoThrow and hasDynamicExceptionSpec polymorphic for use with both functionDecl and functionProtoType

2016-06-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

This is looking good, aside from a few small nits. The only question I have 
remaining is whether this should be on FunctionProtoType or FunctionType? I 
think being on FunctionProtoType (how you have it) is preferable. @sbenza or 
@klimek, do you agree?



Comment at: include/clang/ASTMatchers/ASTMatchers.h:3254
@@ -3252,1 +3253,3 @@
+FunctionProtoType)) {
+  if (const auto *FnTy = internal::getFunctionProtoType(Node))
 return FnTy->hasDynamicExceptionSpec();

Since the type isn't explicitly spelled out in the initialization, probably 
should use `const FunctionProtoType *` instead of `const auto *`.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:3274
@@ -3270,1 +3273,3 @@
+FunctionProtoType)) {
+  const auto *FnTy = internal::getFunctionProtoType(Node);
 

Same here.


http://reviews.llvm.org/D20687



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21026: [clang-format] append newline after code when inserting new headers at the end of the code which does not end with newline.

2016-06-06 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

append newline after code when inserting new headers at the end of the
code which does not end with newline.

http://reviews.llvm.org/D21026

Files:
  lib/Format/Format.cpp
  unittests/Format/CleanupTest.cpp

Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -679,12 +679,12 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
-  std::string Code = "#include ";
-  std::string Expected = "#include #include \n";
-  tooling::Replacements Replaces = {createInsertion("#include ")};
+  std::string Code = "#include \"fix.h\"";
+  std::string Expected =
+  "#include \"fix.h\"\n#include \n#include \"x.h\"\n";
+  tooling::Replacements Replaces = {createInsertion("#include "),
+createInsertion("#include \"x.h\"")};
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1476,9 +1476,6 @@
   return AfterComments;
 }
 
-// FIXME: we also need to insert a '\n' at the end of the code if we have an
-// insertion with offset Code.size(), and there is no '\n' at the end of the
-// code.
 // FIXME: do not insert headers into conditional #include blocks, e.g. 
#includes
 // surrounded by compile condition "#if...".
 // FIXME: do not insert existing headers.
@@ -1560,6 +1557,7 @@
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  bool NeedNewLineAtEnd = !Code.empty() && Code.back() != '\n';
   for (const auto  : HeaderInsertions) {
 auto IncludeDirective = R.getReplacementText();
 bool Matched = IncludeRegex.match(IncludeDirective, );
@@ -1570,6 +1568,19 @@
 int Category =
 Categories.getIncludePriority(IncludeName, /*CheckMainHeader=*/true);
 Offset = CategoryEndOffsets[Category];
+// When inserting headers at end of the code, also insert a '\n' at the end
+// of the code if it does not ends with '\n'.
+// The way of inserting '\n' is a bit of hack since we have no control over
+// wether header insertions with the same offset (i.e. `Code.size()`) are
+// inserted after the new line insertion ('\n' would actually be inserted
+// after other insertions with the same offset). To walk around this,
+// instead of inserting a '\n' at the end, we replace the last character of
+// the code with the character itself plus a '\n' character.
+if (NeedNewLineAtEnd && Offset == Code.size()) {
+  auto End = (Code.substr(Code.size()-1, Code.size()) + "\n").str();
+  Result.insert(tooling::Replacement(FileName, Offset-1, 1, End));
+  NeedNewLineAtEnd = false;
+}
 std::string NewInclude = !IncludeDirective.endswith("\n")
  ? (IncludeDirective + "\n").str()
  : IncludeDirective.str();


Index: unittests/Format/CleanupTest.cpp
===
--- unittests/Format/CleanupTest.cpp
+++ unittests/Format/CleanupTest.cpp
@@ -679,12 +679,12 @@
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
-// FIXME: although this case does not crash, the insertion is wrong. A '\n'
-// should be inserted between the two #includes.
 TEST_F(CleanUpReplacementsTest, NoNewLineAtTheEndOfCode) {
-  std::string Code = "#include ";
-  std::string Expected = "#include #include \n";
-  tooling::Replacements Replaces = {createInsertion("#include ")};
+  std::string Code = "#include \"fix.h\"";
+  std::string Expected =
+  "#include \"fix.h\"\n#include \n#include \"x.h\"\n";
+  tooling::Replacements Replaces = {createInsertion("#include "),
+createInsertion("#include \"x.h\"")};
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1476,9 +1476,6 @@
   return AfterComments;
 }
 
-// FIXME: we also need to insert a '\n' at the end of the code if we have an
-// insertion with offset Code.size(), and there is no '\n' at the end of the
-// code.
 // FIXME: do not insert headers into conditional #include blocks, e.g. #includes
 // surrounded by compile condition "#if...".
 // FIXME: do not insert existing headers.
@@ -1560,6 +1557,7 @@
 if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())
   CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(I)];
 
+  

r271902 - [docs] Clarify limitations section of SourceBasedCodeCoverage.rst

2016-06-06 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Jun  6 10:44:40 2016
New Revision: 271902

URL: http://llvm.org/viewvc/llvm-project?rev=271902=rev
Log:
[docs] Clarify limitations section of SourceBasedCodeCoverage.rst

Mention that the code coverage tool becomes less precise whenever
unpredictable changes in control flow occur.

Thanks to Sean Silva for pointing this out!

Modified:
cfe/trunk/docs/SourceBasedCodeCoverage.rst

Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SourceBasedCodeCoverage.rst?rev=271902=271901=271902=diff
==
--- cfe/trunk/docs/SourceBasedCodeCoverage.rst (original)
+++ cfe/trunk/docs/SourceBasedCodeCoverage.rst Mon Jun  6 10:44:40 2016
@@ -188,8 +188,9 @@ Format compatibility guarantees
 Drawbacks and limitations
 =
 
-* Code coverage does not handle stack unwinding in the presence of uncaught
-  exceptions precisely. Consider the following function:
+* Code coverage does not handle unpredictable changes in control flow or stack
+  unwinding in the presence of exceptions precisely. Consider the following
+  function:
 
   .. code-block:: cpp
 
@@ -198,6 +199,6 @@ Drawbacks and limitations
 return 0;
   }
 
-  If the function ``may_throw()`` propagates an exception into ``f``, the code
+  If the call to ``may_throw()`` propagates an exception into ``f``, the code
   coverage tool may mark the ``return`` statement as executed even though it is
-  not.
+  not. A call to ``longjmp()`` can have similar effects.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r271544 - [docs] Add a limitations section to SourceBasedCodeCoverage.rst

2016-06-06 Thread Vedant Kumar via cfe-commits

> On Jun 4, 2016, at 6:28 PM, Sean Silva  wrote:
> 
> 
> 
> On Thu, Jun 2, 2016 at 10:19 AM, Vedant Kumar via cfe-commits 
>  wrote:
> Author: vedantk
> Date: Thu Jun  2 12:19:45 2016
> New Revision: 271544
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=271544=rev
> Log:
> [docs] Add a limitations section to SourceBasedCodeCoverage.rst
> 
> Modified:
> cfe/trunk/docs/SourceBasedCodeCoverage.rst
> 
> Modified: cfe/trunk/docs/SourceBasedCodeCoverage.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SourceBasedCodeCoverage.rst?rev=271544=271543=271544=diff
> ==
> --- cfe/trunk/docs/SourceBasedCodeCoverage.rst (original)
> +++ cfe/trunk/docs/SourceBasedCodeCoverage.rst Thu Jun  2 12:19:45 2016
> @@ -165,9 +165,9 @@ A few final notes:
>indexed profiles. To combine profiling data from multiple runs of a 
> program,
>try e.g:
> 
> -.. code-block:: console
> +  .. code-block:: console
> 
> -% llvm-profdata merge -sparse foo1.profraw foo2.profdata -o foo3.profdata
> +  % llvm-profdata merge -sparse foo1.profraw foo2.profdata -o 
> foo3.profdata
> 
>  Format compatibility guarantees
>  ===
> @@ -184,3 +184,20 @@ Format compatibility guarantees
>  * There is a third format in play: the format of the coverage mappings 
> emitted
>into instrumented binaries. Tools must retain **backwards** compatibility
>with these formats. These formats are not forwards-compatible.
> +
> +Drawbacks and limitations
> +=
> +
> +* Code coverage does not handle stack unwinding in the presence of uncaught
> +  exceptions precisely.
> 
> I think it's more accurate to say "thrown exceptions" (or just "exceptions") 
> instead of "uncaught exceptions". The latter could be interpreted as meaning 
> that if the exception is caught later (in a caller of f), then the result 
> might still be precise.

Fair point, I've dropped the "uncaught" modifier.


> Also setjmp/longjmp can affect things too, no?

Yes, I mentioned this in r271902. Feel free to change up the wording!

thanks
vedant


> 
> -- Sean Silva
>  
> Consider the following function:
> +
> +  .. code-block:: cpp
> +
> +  int f() {
> +may_throw();
> +return 0;
> +  }
> +
> +  If the function ``may_throw()`` propagates an exception into ``f``, the 
> code
> +  coverage tool may mark the ``return`` statement as executed even though it 
> is
> +  not.
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21022: [ARM] Fix linker emulation for arm 32 big endian

2016-06-06 Thread Peter Smith via cfe-commits
peter.smith added a comment.

That looks correct to me. Certainly armebelf_linux_eabi is not recognised on a 
recent ld.



Comment at: lib/Driver/Tools.cpp:9098
@@ -9097,3 +9097,3 @@
   case llvm::Triple::thumbeb:
-return "armebelf_linux_eabi"; /* TODO: check which NAME.  */
+return "armelfb_linux_eabi"; /* TODO: check which NAME.  */
   case llvm::Triple::ppc:

armelfb_linux_eabi matches the emulation name of my installation of gnu ld and 
the name in ld/configure.tgt. I think it is at least as authoratitive as 
armelf_linux_eabi so I suggest removing the /* TODO */ comment.


http://reviews.llvm.org/D21022



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-06-06 Thread Yaxun Liu via cfe-commits
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Ping

Xiuli, could you please take a look? Thanks.


http://reviews.llvm.org/D20133



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

2016-06-06 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 59733.
yaxunl marked 8 inline comments as done.
yaxunl added a comment.

Update the diagnositic msg for fblocks.


http://reviews.llvm.org/D20444

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CompilerInvocation.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Headers/module.modulemap
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/Frontend/opencl-blocks.cl
  test/Headers/opencl-c-header.cl

Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -1,33 +1,84 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
 // RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s -cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem ../../lib/Headers -include 

Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

2016-06-06 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: test/Headers/opencl-c-header.cl:50
@@ +49,3 @@
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck %s
+// RUN: diff %t/1_0.pcm %t/opencl_c.pcm
+// RUN: rm %t/opencl_c.pcm

Anastasia wrote:
> Sam, what was the aim of this test?
> 
> I was just wondering if we should instead check that the file is exactly the 
> same i.e. hasn't been overwritten with exactly the same content?
This checks whether the content has changed, which is the same approach used by 
test/Modules/fmodules-validate-once-per-build-session.c to make sure a module 
is not re-compiled.

It seems there is no good way otherwise. stat -c %Y filename can get the 
modification time but it is in seconds, which is not accurate enough.


Comment at: test/Headers/opencl-c-header.cl:53-54
@@ +52,4 @@
+
+// ===
+// Compile for OpenCL 2.0 for the first time. The module should change.
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck 
--check-prefix=CHECK20 %s

Anastasia wrote:
> Indeed PCH size is an issue. I don't quite get why it expands from the 
> original source code size by a factor or 2. Something to look at!
I can take a look why the PCH size is much larger than the header file itself.


Comment at: test/Headers/opencl-c-header.cl:70
@@ +69,3 @@
+// RUN: %clang_cc1 -cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s

Anastasia wrote:
> This line seems exactly the same as line 67.
Right. The first compilation generates the module and the second compilation 
uses the cached module. The module is compiled for different OpenCL version and 
triple to make sure the cached module still works.


http://reviews.llvm.org/D20444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-06-06 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


http://reviews.llvm.org/D20133



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20467: [include-fixer] Mention more details in the document.

2016-06-06 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Two more nits, looks good otherwise :)



Comment at: docs/include-fixer.rst:73
@@ +72,3 @@
+
+You can custonmize the number of headers being showed by setting
+``let g:clang_include_fixer_maximum_suggested_headers=5``

typo custo**n**mize, headers being **shown**


http://reviews.llvm.org/D20467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20467: [include-fixer] Mention more details in the document.

2016-06-06 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59725.
hokein marked 3 inline comments as done.
hokein added a comment.

Add comments.


http://reviews.llvm.org/D20467

Files:
  docs/ReleaseNotes.rst
  docs/include-fixer.rst

Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -41,14 +41,16 @@
 .. code-block:: console
 
   $ cd path/to/llvm-build
+  $ ninja find-all-symbols // build find-all-symbols tool.
+  $ ninja clang-include-fixer // build clang-include-fixer tool.
   $ ls compile_commands.json # Make sure compile_commands.json exists.
 compile_commands.json
   $ 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 ... wait as clang indexes the code base ...
   $ ln -s $PWD/find_all_symbols_db.yaml path/to/llvm/source/ # Link database 
into the source tree.
   $ ln -s $PWD/compile_commands.json path/to/llvm/source/ # Also link 
compilation database if it's not there already.
   $ cd path/to/llvm/source
-  $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
+  $ /path/to/clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
 Integrate with Vim
@@ -63,6 +65,14 @@
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` 
to
 another binding if you need clang-include-fixer on a different key.
 
+Make sure vim can find :program:`clang-include-fixer`:
+
+- Add the path to :program:`clang-include-fixer` to the PATH environment 
variable.
+- Or set ``g:clang_include_fixer_path`` in vimrc: ``let 
g:clang_include_fixer_path=path/to/clang-include-fixer``
+
+You can custonmize the number of headers being showed by setting
+``let g:clang_include_fixer_maximum_suggested_headers=5``
+
 See ``clang-include-fixer.py`` for more details.
 
 How it Works
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -44,7 +44,8 @@
 Major New Features
 --
 
-- Feature1...
+- :program:`clang-include-fixer`, a tool that provides an automated way of
+  adding ``#include`` directives for missing symbols in one translation unit.
 
 Improvements to clang-query
 ---


Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -41,14 +41,16 @@
 .. code-block:: console
 
   $ cd path/to/llvm-build
+  $ ninja find-all-symbols // build find-all-symbols tool.
+  $ ninja clang-include-fixer // build clang-include-fixer tool.
   $ ls compile_commands.json # Make sure compile_commands.json exists.
 compile_commands.json
   $ path/to/llvm/source/tools/clang/tools/extra/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 ... wait as clang indexes the code base ...
   $ ln -s $PWD/find_all_symbols_db.yaml path/to/llvm/source/ # Link database into the source tree.
   $ ln -s $PWD/compile_commands.json path/to/llvm/source/ # Also link compilation database if it's not there already.
   $ cd path/to/llvm/source
-  $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
+  $ /path/to/clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
 Integrate with Vim
@@ -63,6 +65,14 @@
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` to
 another binding if you need clang-include-fixer on a different key.
 
+Make sure vim can find :program:`clang-include-fixer`:
+
+- Add the path to :program:`clang-include-fixer` to the PATH environment variable.
+- Or set ``g:clang_include_fixer_path`` in vimrc: ``let g:clang_include_fixer_path=path/to/clang-include-fixer``
+
+You can custonmize the number of headers being showed by setting
+``let g:clang_include_fixer_maximum_suggested_headers=5``
+
 See ``clang-include-fixer.py`` for more details.
 
 How it Works
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -44,7 +44,8 @@
 Major New Features
 --
 
-- Feature1...
+- :program:`clang-include-fixer`, a tool that provides an automated way of
+  adding ``#include`` directives for missing symbols in one translation unit.
 
 Improvements to clang-query
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20687: [ASTMatchers] Make isNoThrow and hasDynamicExceptionSpec polymorphic for use with both functionDecl and functionProtoType

2016-06-06 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 59726.
hintonda added a comment.

Update narrowing matchers, isNoThrow and hasDynamicExceptionSpec, to
work with both functionDecl and functionProtoType matchers.  Update
tests and regenerate documentation.

Since FunctionDecl and FunctionProtoType are not polymorphically
related, an overloaded helper function, getFunctionProtoType(), was
added that takes either a FunctionDecl node or FunctionProtoType node
and returns a FunctionProtoType pointer.  This is based on the
getUnderlyingType() implementation.


http://reviews.llvm.org/D20687

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -845,6 +845,13 @@
 notMatches("void f() noexcept(false);", functionDecl(isNoThrow(;
   EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow(;
   EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow(;
+
+  EXPECT_TRUE(notMatches("void f();", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(notMatches("void f() throw(int);", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(
+notMatches("void f() noexcept(false);", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(matches("void f() throw();", functionProtoType(isNoThrow(;
+  EXPECT_TRUE(matches("void f() noexcept;", functionProtoType(isNoThrow(;
 }
 
 TEST(isConstexpr, MatchesConstexprDeclarations) {
@@ -1396,6 +1403,20 @@
   matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec(;
   EXPECT_TRUE(
   matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec(;
+
+  EXPECT_TRUE(notMatches("void f();", functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void g() noexcept;",
+ functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void h() noexcept(true);",
+ functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(notMatches("void i() noexcept(false);",
+ functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void j() throw();", functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void k() throw(int);", functionProtoType(hasDynamicExceptionSpec(;
+  EXPECT_TRUE(
+  matches("void l() throw(...);", functionProtoType(hasDynamicExceptionSpec(;
 }
 
 TEST(HasObjectExpression, DoesNotMatchMember) {
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -106,6 +106,17 @@
   return Node.getUnderlyingType();
 }
 
+/// \brief Unifies obtaining the FunctionProtoType pointer from both
+/// FunctionProtoType and FunctionDecl nodes..
+inline const FunctionProtoType *
+getFunctionProtoType(const FunctionProtoType ) {
+  return 
+}
+
+inline const FunctionProtoType *getFunctionProtoType(const FunctionDecl ) {
+  return Node.getType()->getAs();
+}
+
 /// \brief Internal version of BoundNodes. Holds all the bound nodes.
 class BoundNodesMap {
 public:
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3245,10 +3245,13 @@
 ///   void k() throw(int);
 ///   void l() throw(...);
 /// \endcode
-/// functionDecl(hasDynamicExceptionSpec())
-///   matches the declarations of j, k, and l, but not f, g, h, or i.
-AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) {
-  if (const auto *FnTy = Node.getType()->getAs())
+/// functionDecl(hasDynamicExceptionSpec()) and
+///   functionProtoType(hasDynamicExceptionSpec())
+///   match the declarations of j, k, and l, but not f, g, h, or i.
+AST_POLYMORPHIC_MATCHER(hasDynamicExceptionSpec,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
+FunctionProtoType)) {
+  if (const auto *FnTy = internal::getFunctionProtoType(Node))
 return FnTy->hasDynamicExceptionSpec();
   return false;
 }
@@ -3263,10 +3266,12 @@
 ///   void i() throw(int);
 ///   void j() noexcept(false);
 /// \endcode
-/// functionDecl(isNoThrow())
-///   matches the declarations of g, and h, but not f, i or j.
-AST_MATCHER(FunctionDecl, isNoThrow) {
-  const auto *FnTy = Node.getType()->getAs();
+/// functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
+///   match the declarations of g, and h, but not f, i or j.
+AST_POLYMORPHIC_MATCHER(isNoThrow,
+

Re: [PATCH] D20467: [include-fixer] Mention more details in the document.

2016-06-06 Thread Benjamin Kramer via cfe-commits
bkramer added inline comments.


Comment at: docs/ReleaseNotes.rst:47
@@ -46,2 +46,3 @@
 
-- Feature1...
+- :program:`clang-include-fixer`, a tool provides an automated way of adding
+  ``#include`` directives for missing symbols in one translation unit.

a tool **that** provides


Comment at: docs/include-fixer.rst:70
@@ +69,3 @@
+
+- Add :program:`clang-include-fixer` path in the environment PATH variable.
+- Or set ``g:clang_include_fixer_path`` in vim configuration path: ``let 
g:clang_include_fixer_path=path/to/clang-include-fixer``

add the path to clang-include-fixer to the PATH environment variable


Comment at: docs/include-fixer.rst:71
@@ +70,3 @@
+- Add :program:`clang-include-fixer` path in the environment PATH variable.
+- Or set ``g:clang_include_fixer_path`` in vim configuration path: ``let 
g:clang_include_fixer_path=path/to/clang-include-fixer``
+

in vimrc


http://reviews.llvm.org/D20467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21023: [mips] Defer validity check for CPU/ABI pairs and improve error message for invalid cases.

2016-06-06 Thread Daniel Sanders via cfe-commits
dsanders created this revision.
dsanders added a reviewer: atanasyan.
dsanders added a subscriber: cfe-commits.
Herald added a subscriber: sdardis.

The validity of ABI/CPU pairs is no longer checked on the fly but is
instead checked after initialization. As a result, invalid CPU/ABI pairs
can be reported as being known but invalid instead of being unknown. For
example, we now emit:
  error: ABI 'n32' is not supported on CPU 'mips32r2'
instead of:
  error: unknown target ABI 'n64'

http://reviews.llvm.org/D21023

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets.cpp
  test/Driver/mips-abi.c

Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -1,16 +1,27 @@
 // Check passing Mips ABI options to the backend.
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS-DEF %s
-// MIPS-DEF: "-target-cpu" "mips32r2"
-// MIPS-DEF: "-target-abi" "o32"
+// RUN:   | FileCheck -check-prefix=MIPS32R2-O32 %s
+// RUN: %clang -target mips64-linux-gnu -mips32r2 -mabi=32 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS32R2-O32 %s
+// MIPS32R2-O32: "-target-cpu" "mips32r2"
+// MIPS32R2-O32: "-target-abi" "o32"
+//
+// FIXME: This is a valid combination of options but we reject it at the moment
+//because the backend can't handle it.
+// RUN: not %clang -target mips-linux-gnu -c %s \
+// RUN:-march=mips64r2 -mabi=32 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
+// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
 //
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-mti-linux-gnu -mips64r2 -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-linux-gnu -mips64r2 -mabi=64 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // MIPS64R2-N64: "-target-cpu" "mips64r2"
 // MIPS64R2-N64: "-target-abi" "n64"
 //
@@ -114,7 +125,7 @@
 // RUN: not %clang -target mips-linux-gnu -c %s \
 // RUN:-march=p5600 -mabi=64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-N64 %s
-// MIPS-ARCH-P5600-N64: error: unknown target ABI 'n64'
+// MIPS-ARCH-P5600-N64: error: ABI 'n64' is not supported on CPU 'p5600'
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-march=mips64 2>&1 \
@@ -143,7 +154,7 @@
 // RUN: not %clang -target mips64-linux-gnu -c %s \
 // RUN:-march=mips32 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-6432 %s
-// MIPS-ARCH-6432: error: unknown target CPU 'mips32'
+// MIPS-ARCH-6432: error: ABI 'n64' is not supported on CPU 'mips32'
 //
 // RUN: not %clang -target mips-linux-gnu -c %s \
 // RUN:-march=unknown 2>&1 \
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7074,34 +7074,38 @@
 return IsNan2008;
   }
 
+  bool processorSupportsGPR64() const {
+return llvm::StringSwitch(CPU)
+.Case("mips3", true)
+.Case("mips4", true)
+.Case("mips5", true)
+.Case("mips64", true)
+.Case("mips64r2", true)
+.Case("mips64r3", true)
+.Case("mips64r5", true)
+.Case("mips64r6", true)
+.Case("octeon", true)
+.Default(false);
+return false;
+  }
+
   StringRef getABI() const override { return ABI; }
   bool setABI(const std::string ) override {
-// FIXME: The Arch component on the triple actually has no bearing on
-//whether the ABI is valid or not. It's features of the CPU that
-//matters and the size of the GPR's in particular.
-//However, we can't allow O32 on 64-bit processors just yet because
-//the backend still checks the Arch component instead of the ABI in
-//a few places.
-if (getTriple().getArch() == llvm::Triple::mips ||
-getTriple().getArch() == llvm::Triple::mipsel) {
-  if (Name == "o32") {
-setO32ABITypes();
-ABI = Name;
-return true;
-  }
+if (Name == "o32") {
+  setO32ABITypes();
+  ABI = Name;
+  return true;
 }
-if (getTriple().getArch() == llvm::Triple::mips64 ||
-getTriple().getArch() == llvm::Triple::mips64el) {
-  if (Name == "n32") {
-setN32ABITypes();
-ABI = Name;
-return true;
-  }
-  if (Name == "n64") {
-setN64ABITypes();
-ABI = Name;
-return true;
-  }
+
+if (Name == "n32") {
+  setN32ABITypes();
+  ABI = Name;
+  return true;
+}
+if (Name == "n64") {
+  setN64ABITypes();
+  ABI = Name;
+  return 

Re: [PATCH] D21019: [include-fixer] try to make vim header selection more friendly.

2016-06-06 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 59722.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressed reviewer's comments.


http://reviews.llvm.org/D21019

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -35,12 +35,31 @@
   vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
 
-def ShowDialog(message, choices, default_choice_index=0):
-  to_eval = "confirm('{0}', '{1}', '{2}')".format(message,
-  choices.strip(),
-  default_choice_index)
-  return int(vim.eval(to_eval));
-
+def GetUserSelection(message, headers, maximum_suggested_headers):
+  eval_message = message + '\n'
+  for idx, header in enumerate(headers[0:maximum_suggested_headers]):
+eval_message += "({0}). {1}\n".format(idx+1, header)
+  eval_message += "Enter (q) to quit;"
+  if maximum_suggested_headers < len(headers):
+eval_message += " (a) to show all candidates.";
+  eval_message += "\nSelect (default 1): "
+  to_eval = "input('{0}')".format(eval_message)
+  res = vim.eval(to_eval)
+  if res == '':
+# choose the top ranked header by default
+idx = 1
+  elif res == 'q':
+raise Exception('   Insertion cancelled...')
+  elif res == 'a' and maximum_suggested_headers < len(headers):
+return GetUserSelection(message, headers, len(headers))
+  else:
+try:
+  idx = int(res)
+  if idx <= 0 or idx >= len(headers):
+raise Exception()
+except Exception:
+raise Exception("   ERROR: Invalid option {0}...Abort!".format(res))
+  return headers[idx-1]
 
 def execute(command, text):
   p = subprocess.Popen(command,
@@ -88,7 +107,7 @@
 
   if not symbol:
 print "The file is fine, no need to add a header.\n"
-return;
+return
 
   if not headers:
 print "Couldn't find a header for {0}.\n".format(symbol)
@@ -102,19 +121,16 @@
 print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
-  choices_message = ""
-  index = 1;
-  for header in headers[0:maximum_suggested_headers]:
-choices_message += "&{0} {1}\n".format(index, header)
-index += 1
-
-  select = ShowDialog("choose a header file for {0}.".format(symbol),
-  choices_message)
-  # Insert a selected header.
-  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
-   "Headers":[headers[select-1]]}, text)
-  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
-  return;
+  try:
+selected = GetUserSelection("choose a header file for {0}.".format(symbol),
+headers, maximum_suggested_headers)
+# Insert a selected header.
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[selected]}, text)
+print "Added #include {0} for {1}.\n".format(selected, symbol)
+  except Exception as error:
+print >> sys.stderr, error.message
+  return
 
 
 if __name__ == '__main__':


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -35,12 +35,31 @@
   vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
 
-def ShowDialog(message, choices, default_choice_index=0):
-  to_eval = "confirm('{0}', '{1}', '{2}')".format(message,
-  choices.strip(),
-  default_choice_index)
-  return int(vim.eval(to_eval));
-
+def GetUserSelection(message, headers, maximum_suggested_headers):
+  eval_message = message + '\n'
+  for idx, header in enumerate(headers[0:maximum_suggested_headers]):
+eval_message += "({0}). {1}\n".format(idx+1, header)
+  eval_message += "Enter (q) to quit;"
+  if maximum_suggested_headers < len(headers):
+eval_message += " (a) to show all candidates.";
+  eval_message += "\nSelect (default 1): "
+  to_eval = "input('{0}')".format(eval_message)
+  res = vim.eval(to_eval)
+  if res == '':
+# choose the top ranked header by default
+idx = 1
+  elif res == 'q':
+raise Exception('   Insertion cancelled...')
+  elif res == 'a' and maximum_suggested_headers < len(headers):
+return GetUserSelection(message, headers, len(headers))
+  else:
+try:
+  idx = int(res)
+  if idx <= 0 or idx >= len(headers):
+raise Exception()
+except Exception:
+raise Exception("   ERROR: Invalid option {0}...Abort!".format(res))
+  return headers[idx-1]
 
 def execute(command, text):
   p = subprocess.Popen(command,
@@ -88,7 +107,7 @@
 
   if not symbol:
 print "The file is fine, no need to add a header.\n"
-return;
+return
 
 

Re: [PATCH] D20467: [include-fixer] Mention more details in the document.

2016-06-06 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D20467#435685, @Eugene.Zelenko wrote:

> Could you please mention include-fixer in  docs/ReleaseNotes.rst? This is 
> definitely major new feature in upcoming release.


Done.


http://reviews.llvm.org/D20467



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20467: [include-fixer] Mention more details in the document.

2016-06-06 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 59721.
hokein marked an inline comment as done.
hokein added a comment.

Address review comments.


http://reviews.llvm.org/D20467

Files:
  docs/ReleaseNotes.rst
  docs/include-fixer.rst

Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -41,14 +41,16 @@
 .. code-block:: console
 
   $ cd path/to/llvm-build
+  $ ninja find-all-symbols // build find-all-symbols tool.
+  $ ninja clang-include-fixer // build clang-include-fixer tool.
   $ ls compile_commands.json # Make sure compile_commands.json exists.
 compile_commands.json
   $ 
path/to/llvm/source/tools/clang/tools/extra/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 ... wait as clang indexes the code base ...
   $ ln -s $PWD/find_all_symbols_db.yaml path/to/llvm/source/ # Link database 
into the source tree.
   $ ln -s $PWD/compile_commands.json path/to/llvm/source/ # Also link 
compilation database if it's not there already.
   $ cd path/to/llvm/source
-  $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
+  $ /path/to/clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
 Integrate with Vim
@@ -63,6 +65,14 @@
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` 
to
 another binding if you need clang-include-fixer on a different key.
 
+Make sure vim can find :program:`clang-include-fixer`:
+
+- Add :program:`clang-include-fixer` path in the environment PATH variable.
+- Or set ``g:clang_include_fixer_path`` in vim configuration path: ``let 
g:clang_include_fixer_path=path/to/clang-include-fixer``
+
+You can custonmize the number of headers being showed by setting
+``let g:clang_include_fixer_maximum_suggested_headers=5``
+
 See ``clang-include-fixer.py`` for more details.
 
 How it Works
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -44,7 +44,8 @@
 Major New Features
 --
 
-- Feature1...
+- :program:`clang-include-fixer`, a tool provides an automated way of adding
+  ``#include`` directives for missing symbols in one translation unit.
 
 Improvements to clang-query
 ---


Index: docs/include-fixer.rst
===
--- docs/include-fixer.rst
+++ docs/include-fixer.rst
@@ -41,14 +41,16 @@
 .. code-block:: console
 
   $ cd path/to/llvm-build
+  $ ninja find-all-symbols // build find-all-symbols tool.
+  $ ninja clang-include-fixer // build clang-include-fixer tool.
   $ ls compile_commands.json # Make sure compile_commands.json exists.
 compile_commands.json
   $ path/to/llvm/source/tools/clang/tools/extra/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
 ... wait as clang indexes the code base ...
   $ ln -s $PWD/find_all_symbols_db.yaml path/to/llvm/source/ # Link database into the source tree.
   $ ln -s $PWD/compile_commands.json path/to/llvm/source/ # Also link compilation database if it's not there already.
   $ cd path/to/llvm/source
-  $ clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
+  $ /path/to/clang-include-fixer -db=yaml path/to/file/with/missing/include.cpp
 Added #include "foo.h"
 
 Integrate with Vim
@@ -63,6 +65,14 @@
 This enables `clang-include-fixer` for NORMAL and VISUAL mode. Change ``,cf`` to
 another binding if you need clang-include-fixer on a different key.
 
+Make sure vim can find :program:`clang-include-fixer`:
+
+- Add :program:`clang-include-fixer` path in the environment PATH variable.
+- Or set ``g:clang_include_fixer_path`` in vim configuration path: ``let g:clang_include_fixer_path=path/to/clang-include-fixer``
+
+You can custonmize the number of headers being showed by setting
+``let g:clang_include_fixer_maximum_suggested_headers=5``
+
 See ``clang-include-fixer.py`` for more details.
 
 How it Works
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -44,7 +44,8 @@
 Major New Features
 --
 
-- Feature1...
+- :program:`clang-include-fixer`, a tool provides an automated way of adding
+  ``#include`` directives for missing symbols in one translation unit.
 
 Improvements to clang-query
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21022: [ARM] Fix linker emulation for arm 32 big endian

2016-06-06 Thread Strahinja Petrovic via cfe-commits
spetrovic created this revision.
spetrovic added reviewers: rafael, petarj.
spetrovic added subscribers: rankov, ivanbaev, cfe-commits.
Herald added subscribers: rengolin, aemerson.

This patch fixes target linker emulation for arm 32 big endian. As I saw in gcc 
only supported linker emulation is armelfb_linux_eabi.

http://reviews.llvm.org/D21022

Files:
  lib/Driver/Tools.cpp
  test/Driver/linux-ld.c

Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1561,13 +1561,13 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ARMEB %s
 // CHECK-ARMEB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARMEB-NOT: "--be8"
-// CHECK-ARMEB: "-m" "armebelf_linux_eabi"
+// CHECK-ARMEB: "-m" "armelfb_linux_eabi"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=armebv7-unknown-linux \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ARMV7EB %s
 // CHECK-ARMV7EB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARMV7EB: "--be8"
-// CHECK-ARMV7EB: "-m" "armebelf_linux_eabi"
+// CHECK-ARMV7EB: "-m" "armelfb_linux_eabi"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9095,7 +9095,7 @@
 return "armelf_linux_eabi";
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
-return "armebelf_linux_eabi"; /* TODO: check which NAME.  */
+return "armelfb_linux_eabi"; /* TODO: check which NAME.  */
   case llvm::Triple::ppc:
 return "elf32ppclinux";
   case llvm::Triple::ppc64:


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1561,13 +1561,13 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ARMEB %s
 // CHECK-ARMEB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARMEB-NOT: "--be8"
-// CHECK-ARMEB: "-m" "armebelf_linux_eabi"
+// CHECK-ARMEB: "-m" "armelfb_linux_eabi"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=armebv7-unknown-linux \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ARMV7EB %s
 // CHECK-ARMV7EB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-ARMV7EB: "--be8"
-// CHECK-ARMV7EB: "-m" "armebelf_linux_eabi"
+// CHECK-ARMV7EB: "-m" "armelfb_linux_eabi"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9095,7 +9095,7 @@
 return "armelf_linux_eabi";
   case llvm::Triple::armeb:
   case llvm::Triple::thumbeb:
-return "armebelf_linux_eabi"; /* TODO: check which NAME.  */
+return "armelfb_linux_eabi"; /* TODO: check which NAME.  */
   case llvm::Triple::ppc:
 return "elf32ppclinux";
   case llvm::Triple::ppc64:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r271896 - [clang-tidy] Do not try to suggest a fix if the parameter is partially in a macro.

2016-06-06 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Mon Jun  6 09:21:11 2016
New Revision: 271896

URL: http://llvm.org/viewvc/llvm-project?rev=271896=rev
Log:
[clang-tidy] Do not try to suggest a fix if the parameter is partially in a 
macro.

It is not easy to tell where to do the suggestion and whether the
suggestion will be correct.

Modified:
clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp?rev=271896=271895=271896=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp 
Mon Jun  6 09:21:11 2016
@@ -88,6 +88,12 @@ void AvoidConstParamsInDecls::check(cons
 Diag << Param;
   }
 
+  if (Param->getLocStart().isMacroID() != Param->getLocEnd().isMacroID()) {
+// Do not offer a suggestion if the part of the variable declaration comes
+// from a macro.
+return;
+  }
+
   CharSourceRange FileRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(getTypeRange(*Param)),
   *Result.SourceManager, Result.Context->getLangOpts());


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r271897 - Remove arithmetic +/-127 on chars; results in UB when dealing with signed chars. Thanks to STL@microsoft for the report.

2016-06-06 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jun  6 09:35:22 2016
New Revision: 271897

URL: http://llvm.org/viewvc/llvm-project?rev=271897=rev
Log:
Remove arithmetic +/-127 on chars; results in UB when dealing with signed 
chars. Thanks to STL@microsoft for the report.

Modified:

libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp?rev=271897=271896=271897=diff
==
--- 
libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
 Mon Jun  6 09:35:22 2016
@@ -1,6 +1,6 @@
 
//===--===//
 //
-// The LLVM Compiler Infrastructure
+//The LLVM Compiler Infrastructure
 //
 // This file is dual licensed under the MIT and the University of Illinois Open
 // Source Licenses. See LICENSE.TXT for details.
@@ -18,11 +18,16 @@
 
 int main()
 {
-char c = '\0';
-assert(!std::char_traits::lt('a', 'a'));
-assert( std::char_traits::lt('A', 'a'));
-assert(!std::char_traits::lt('A' + 127, 'a'));
-assert(!std::char_traits::lt('A' - 127, 'a'));
-assert( std::char_traits::lt('A', 'a' + 127));
-assert( std::char_traits::lt('A', 'a' - 127));
+   assert( std::char_traits::lt('\0', 'A'));
+   assert(!std::char_traits::lt('A', '\0'));
+
+   assert(!std::char_traits::lt('a', 'a'));
+   assert( std::char_traits::lt('A', 'a'));
+   assert(!std::char_traits::lt('a', 'A'));
+   
+   assert( std::char_traits::lt('a', 'z'));
+   assert( std::char_traits::lt('A', 'Z'));
+
+   assert( std::char_traits::lt(' ', 'A'));
+   assert( std::char_traits::lt('A', '~'));
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21019: [include-fixer] try to make vim header selection more friendly.

2016-06-06 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/tool/clang-include-fixer.py:53
@@ +52,3 @@
+  except Exception:
+if res == '':
+  # choose the top ranked header by default

We can handle the ` ` , `a`, `q` cases after `res=vim.eval(to_eval)` instead of 
handling them in exception block. They don't look like errors in my opinion.


Comment at: include-fixer/tool/clang-include-fixer.py:132
@@ +131,3 @@
+  except Exception as error:
+print error.message
+  return

For error message, it might be better to print to stderr `print >> sys.stderr, 
error.message`?


http://reviews.llvm.org/D21019



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21021: [Clang][AVX512][BuiltIn]Adding intrinsics move_{sd|ss} to clang

2016-06-06 Thread michael zuckerman via cfe-commits
m_zuckerman created this revision.
m_zuckerman added reviewers: AsafBadouh, igorb, delena.
m_zuckerman added a subscriber: cfe-commits.

http://reviews.llvm.org/D21021

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -7433,4 +7433,32 @@
   // CHECK-LABEL: @test_mm512_setzero_pd
   // CHECK: zeroinitializer
   return _mm512_setzero_pd();
-}
\ No newline at end of file
+}
+
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d 
__B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -9118,6 +9118,40 @@
(__mmask16) __U);
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf) __W,
+   (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
+   (__v4sf)
+   _mm_setzero_si128(),
+   (__mmask8) __U);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_move_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
+   (__v2df) __W,
+   (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
+   (__v2di)
+   _mm_setzero_pd (),
+   (__mmask8) __U);
+}
+
 #define _mm512_shuffle_epi32(A, I) __extension__ ({ \
   (__m512i)__builtin_ia32_pshufd512_mask((__v16si)(__m512i)(A), (int)(I), \
  (__v16si)_mm512_undefined_epi32(), \
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -2232,6 +2232,8 @@
 TARGET_BUILTIN(__builtin_ia32_movapd256_mask, "V4dV4dV4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movaps128_mask, "V4fV4fV4fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movaps256_mask, "V8fV8fV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_movss_mask, "V4fV4fV4fV4fUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_movsd_mask, "V2dV2dV2dV2dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, 
"vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, 
"vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, 
"vV16f*V16fUs","","avx512f")


Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -7433,4 +7433,32 @@
   // CHECK-LABEL: @test_mm512_setzero_pd
   // CHECK: zeroinitializer
   return _mm512_setzero_pd();
-}
\ No newline at end of file
+}
+
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: @llvm.x86.avx512.mask.move.ss
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: @llvm.x86.avx512.mask.move.sd
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: 

[PATCH] D21020: [clang-tidy] readability-identifier-naming - Support for Macros

2016-06-06 Thread James Reynolds via cfe-commits
JamesReynolds created this revision.
JamesReynolds added a reviewer: alexfh.
JamesReynolds added a subscriber: cfe-commits.

Added support for macro definitions.
--

1. Added a pre-processor callback to catch macro definitions
2. Changed the type of the failure map so that macros and declarations can 
share the same map
3. Added extra tests to ensure fix-ups work using the new map
4. Added fix-ups for type aliases in variable and function declarations as part 
of adding the new tests

http://reviews.llvm.org/D21020

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tidy/readability/IdentifierNamingCheck.h
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -61,6 +61,7 @@
 // RUN: {key: readability-identifier-naming.VariableCase, value: lower_case}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.VirtualMethodPrefix, value: 'v_'}, \
+// RUN: {key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE}, \
 // RUN: {key: readability-identifier-naming.IgnoreFailedSplit, value: 0} \
 // RUN:   ]}' -- -std=c++11 -fno-delayed-template-parsing \
 // RUN:   -I%S/Inputs/readability-identifier-naming \
@@ -305,6 +306,12 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for typedef 'struct_type'
 // CHECK-FIXES: {{^}}typedef this_structure struct_type_t;{{$}}
 
+struct_type GlobalTypedefTestFunction(struct_type a_argument1) {
+// CHECK-FIXES: {{^}}struct_type_t GlobalTypedefTestFunction(struct_type_t a_argument1) {
+struct_type typedef_test_1;
+// CHECK-FIXES: {{^}}struct_type_t typedef_test_1;
+}
+
 static void static_Function() {
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for function 'static_Function'
 // CHECK-FIXES: {{^}}static void staticFunction() {{{$}}
@@ -318,5 +325,9 @@
 // CHECK-FIXES: {{^}}  using ::foo_ns::inline_namespace::ce_function;{{$}}
 }
 
+#define MY_TEST_Macro(X) X()
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for macro definition 'MY_TEST_Macro'
+// CHECK-FIXES: {{^}}#define MY_TEST_MACRO(X) X()
+
 }
 }
Index: clang-tidy/readability/IdentifierNamingCheck.h
===
--- clang-tidy/readability/IdentifierNamingCheck.h
+++ clang-tidy/readability/IdentifierNamingCheck.h
@@ -36,6 +36,7 @@
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+  void registerPPCallbacks(CompilerInstance ) override;
   void onEndOfTranslationUnit() override;
 
   enum CaseType {
@@ -64,7 +65,7 @@
 
   /// \brief Holds an identifier name check failure, tracking the kind of the
   /// identifer, its possible fixup and the starting locations of all the
-  /// idenfiier usages.
+  /// identifier usages.
   struct NamingCheckFailure {
 std::string KindName;
 std::string Fixup;
@@ -81,9 +82,17 @@
 
 NamingCheckFailure() : ShouldFix(true) {}
   };
-  typedef llvm::DenseMap
+
+  struct NamingCheckId : std::pair {
+typedef std::pair Parent;
+using Parent::Parent;
+  };
+
+  typedef llvm::DenseMap
   NamingCheckFailureMap;
 
+  void checkMacro(SourceManager , const Token );
+
 private:
   std::vector NamingStyles;
   bool IgnoreFailedSplit;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -12,11 +12,53 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/DenseMapInfo.h"
 
 #define DEBUG_TYPE "clang-tidy"
 
 using namespace clang::ast_matchers;
 
+namespace llvm {
+/// Specialisation of DenseMapInfo to allow NamingCheckId objects in DenseMaps
+template <>
+struct DenseMapInfo<
+clang::tidy::readability::IdentifierNamingCheck::NamingCheckId> {
+  using NamingCheckId =
+  clang::tidy::readability::IdentifierNamingCheck::NamingCheckId;
+
+  static inline NamingCheckId getEmptyKey() {
+return NamingCheckId(
+clang::SourceLocation::getFromRawEncoding(static_cast(-1)),
+"EMPTY");
+  }
+
+  static inline NamingCheckId getTombstoneKey() {
+return NamingCheckId(
+clang::SourceLocation::getFromRawEncoding(static_cast(-2)),
+"TOMBSTONE");
+  }
+
+  static 

r271893 - Give FileCheck a hint on which ld to match. Under Windows, the preferred

2016-06-06 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Mon Jun  6 08:13:12 2016
New Revision: 271893

URL: http://llvm.org/viewvc/llvm-project?rev=271893=rev
Log:
Give FileCheck a hint on which ld to match. Under Windows, the preferred
match was the ld.elf_so that should be matched in a second step. Add one
of the ever-present-but-irrelevant-for-this-test arguments to the
pattern to force matching the right argument.

Modified:
cfe/trunk/test/Driver/netbsd.c

Modified: cfe/trunk/test/Driver/netbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/netbsd.c?rev=271893=271892=271893=diff
==
--- cfe/trunk/test/Driver/netbsd.c (original)
+++ cfe/trunk/test/Driver/netbsd.c Mon Jun  6 08:13:12 2016
@@ -115,7 +115,7 @@
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-POWERPC64 %s
 
-// STATIC: ld{{.*}}"
+// STATIC: ld{{.*}}" "--eh-frame-hdr"
 // STATIC-NOT: "-pie"
 // STATIC-NOT: "-Bshareable"
 // STATIC: "-dynamic-linker" "/libexec/ld.elf_so"
@@ -125,14 +125,14 @@
 // STATIC: "{{.*}}/usr/lib{{/|}}crti.o" 
"{{.*}}/usr/lib{{/|}}crtbegin.o"
 // STATIC: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
-// SHARED: ld{{.*}}"
+// SHARED: ld{{.*}}" "--eh-frame-hdr"
 // SHARED-NOT: "-pie"
 // SHARED-NOT: "-dynamic-linker"
 // SHARED-NOT: "{{.*}}/usr/lib{{/|}}crt0.o"
 // SHARED: "{{.*}}/usr/lib{{/|}}crti.o" 
"{{.*}}/usr/lib{{/|}}crtbeginS.o"
 // SHARED: "{{.*}}/usr/lib{{/|}}crtendS.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
-// PIE: ld{{.*}}"
+// PIE: ld{{.*}}" "--eh-frame-hdr"
 // PIE-NOT: "-Bshareable"
 // PIE "-pie" "-dynamic-linker" "/libexec/ld.elf_so"
 // PIE-NOT: "-Bshareable"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20863: [analyzer] Fix for the strdup family in unix.malloc checker

2016-06-06 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

This patch is doing a very good thing - modeling contents of the copied string 
as a lazy compound value of the original string. For that, i guess it's worth 
adding some tests (ExprInspection-based(?)) that show that, say, first few 
characters of the copied string are same as the original. It might also be a 
good idea to move this modeling to CStringChecker completely, because right now 
it's easier to assume a range on SymbolExtent of the strdupped region, than 
transfer correct string length into MallocChecker. But then you'd need to 
enable CStringChecker in your builds so that they could work together to model 
strdup().

The effect you observe, however - finding leaks on overwriting variables that 
hold leaked symbols - is in fact not because you modeled the copy better, but 
because you managed to accidentally work around the "zombie symbols" bug, 
described in http://lists.llvm.org/pipermail/cfe-dev/2016-March/047922.html and 
http://reviews.llvm.org/D18860 (there's still no certainty as of how exactly to 
fix it). Because you model contents of the copied string by binding a value to 
it, the Store is eager to reap the symbol as soon as possible, and hence detect 
a leak. Before, only the checker knew about the symbol of the copied string, 
and it wasn't eager to reap that symbol after it disappeared from the rest of 
the program state through overwriting. The problem could as well be fixed with 
code as simple and unobvious as:

  void MallocChecker::checkLiveSymbols(ProgramStateRef State,
   SymbolReaper ) const {
for (const auto : State->get())
  SR.maybeDead(Item.first);
  }



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2134
@@ +2133,3 @@
+  auto sizeTy = svalBuilder.getContext().getSizeType();
+  auto strLength = svalBuilder.getMetadataSymbolVal(MallocChecker::getTag(), 
MR,
+Ex, sizeTy, 
C.blockCount());

I'm not sure if this is truly worth it. In CStringChecker, a lot of work is 
done in order to model the length of the string; however, currently 
MallocChecker does not have any access to that info, and a lot more code 
copy-paste'ing would be necessary to re-model all the stuff. And even if you do 
so, the symbol you create in that statement wouldn't be the same as the symbol 
used in CStringChecker, so you may never compare them to each other and see 
that they're equal - say, strlen() of a duplicated string, strlen() for the 
original string, and the value you produce on that statement, would still be 
three different symbols.

Ideally, we can leave this out for later, and wait until we allow checkers 
interact with each other and share such information. So that we could ask 
CStringChecker directly here, and obtain string length as CStringChecker sees 
it.


http://reviews.llvm.org/D20863



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: Missing definition of a template virtual function

2016-06-06 Thread Srivastava, Sunil via cfe-commits
Hi Richard,

Thanks for you analysis. I have some follow up questions though:

First, either of these two suggestions below should fix the bug, though it may 
be better to do both. Right ?

Then, approach (2) has a cost. It will prevent devirtualizations of calls which 
could get defined elsewhere.

While my example of https://llvm.org/bugs/show_bug.cgi?id=27895#c4   is good 
for demonstrating the bug, it is an unusual case. The usual case is that the 
template will be defined somewhere. So by suppressing devirtualization in this 
case we will be penalizing the usual cases to fix a bug in unusual cases.

The approach (1) is doable of course. It involves passing some kind of 
isFullObject flag few levels down in SemaOverload.cpp, and then prevent reset 
of OdrUse flag if isFullObject is true.

However I want to understand better what is going on here. Specifically, why 
virtual operators are treated different from virtual functions. In my example, 
if you replace the operator[] with a plain function doing the same thing, the 
function definition gets generated.

In your bugzilla comment 5, you perhaps alluded to this point:


> we model operator[] as weak_odr unnamed_addr, which would allow us to

> discard the symbol in the other translation unit if we can merge the

> function with something else, even though its address is exposed in

> the vtable

But what can the compiler do with user written operator[] that it can not do 
with a plain function ?

Beside, this bug is not just with operator[]. It is with every member operator.

Thanks
Sunil Srivastava
Sony Interactive Entertainment

Yes, this is a bug. We emit a direct call to TmplWithArray::operator[] 
so we're required to also emit a definition of it. I think the code that 
r227073 removed was really masking this bug rather than fixing it. It seems 
like there are two issues here:

 1) Sema should mark a virtual function as used if it sees an 
obviously-devirtualizable call to the function (where the base object has a 
known dynamic type)

 2) Clang CodeGen's devirtualization of obviously-devirtualizable calls should 
not devirtualize calls to linkonce_odr functions that it can't emit



--
template < typename T, int N = 0 > class TmplWithArray {
public:
  virtual T& operator [] (int idx);
  T ar[N+1];
};
template  T& TmplWithArray::operator[](int idx) {
  return ar[idx];
}
class Wrapper {
  TmplWithArray data;
  bool indexIt(int a);
};
bool Wrapper::indexIt(int a)
{
   return data[a];
}
int main(){}
--

Starting from  r227073 it does not link (at any optimization level). The code
has a direct call to the operator[] function, but that function definition is
not generated.

Versions prior to r227073,
-  at –O0 or –O1, generate the operator[] function and the direct call, and
-  at –O2 do not generate the function, but inline it
Either way they link fine.

In this example the key-function for the generation of the vtable is the
operator[] function itself.

So the compiler can either generate both the vtable and the operator[]
function, or not generate either; they are both consistent states.

The call in data[a] is to a virtual function, and if the compiler left it as a
virtual call, it will link. There will be no ctor, no vtable, and no operator[]
function. Wrapper::indexIt will be dead code, but it will link.

But the compiler does devirtualization of the call and generates a direct call,
yet, beginning with r227073, it does not generate the operator[] function.
Hence the link failure.

Another interesting tidbit is that if the operator[] is replaced by a plain
function doing the same thing, along with the corresponding change in the
usage, something like:
virtual T& getElt(int idx);
then the behavior is the same as pre r227073. Either getElt is defined or it
gets inlined.

BTW, this is not just an idle curiosity. This example was trimmed down from
a user bug report having a link failure.

Sunil Srivastava
Sony Interactive Entertainment

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21019: [include-fixer] try to make vim header selection more friendly.

2016-06-06 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: bkramer, hokein.
ioeric added a subscriber: cfe-commits.

use 'input()' to get user's input so that we can support more options.

http://reviews.llvm.org/D21019

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -35,12 +35,31 @@
   vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
 
-def ShowDialog(message, choices, default_choice_index=0):
-  to_eval = "confirm('{0}', '{1}', '{2}')".format(message,
-  choices.strip(),
-  default_choice_index)
-  return int(vim.eval(to_eval));
-
+def GetUserSelection(message, headers, maximum_suggested_headers):
+  eval_message = message + '\n'
+  for idx, header in enumerate(headers[0:maximum_suggested_headers]):
+eval_message += "({0}). {1}\n".format(idx+1, header)
+  eval_message += "Enter (q) to quit;"
+  if maximum_suggested_headers < len(headers):
+eval_message += " (a) to show all candidates.";
+  eval_message += "\nSelect (default 1): "
+  to_eval = "input('{0}')".format(eval_message)
+  res = vim.eval(to_eval)
+  try:
+idx = int(res)
+if idx <= 0 or idx >= len(headers):
+  raise Exception()
+  except Exception:
+if res == '':
+  # choose the top ranked header by default
+  idx = 1
+elif res == 'q':
+  raise Exception('   Insertion cancelled...')
+elif res == 'a' and maximum_suggested_headers < len(headers):
+  return GetUserSelection(message, headers, len(headers))
+else:
+  raise Exception("   ERROR: Invalid option {0}...Abort!".format(res))
+  return headers[idx-1]
 
 def execute(command, text):
   p = subprocess.Popen(command,
@@ -88,7 +107,7 @@
 
   if not symbol:
 print "The file is fine, no need to add a header.\n"
-return;
+return
 
   if not headers:
 print "Couldn't find a header for {0}.\n".format(symbol)
@@ -102,19 +121,16 @@
 print "Added #include {0} for {1}.\n".format(headers[0], symbol)
 return
 
-  choices_message = ""
-  index = 1;
-  for header in headers[0:maximum_suggested_headers]:
-choices_message += "&{0} {1}\n".format(index, header)
-index += 1
-
-  select = ShowDialog("choose a header file for {0}.".format(symbol),
-  choices_message)
-  # Insert a selected header.
-  InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
-   "Headers":[headers[select-1]]}, text)
-  print "Added #include {0} for {1}.\n".format(headers[select-1], symbol)
-  return;
+  try:
+selected = GetUserSelection("choose a header file for {0}.".format(symbol),
+headers, maximum_suggested_headers)
+# Insert a selected header.
+InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
+ "Headers":[selected]}, text)
+print "Added #include {0} for {1}.\n".format(selected, symbol)
+  except Exception as error:
+print error.message
+  return
 
 
 if __name__ == '__main__':


Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -35,12 +35,31 @@
   vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
 
-def ShowDialog(message, choices, default_choice_index=0):
-  to_eval = "confirm('{0}', '{1}', '{2}')".format(message,
-  choices.strip(),
-  default_choice_index)
-  return int(vim.eval(to_eval));
-
+def GetUserSelection(message, headers, maximum_suggested_headers):
+  eval_message = message + '\n'
+  for idx, header in enumerate(headers[0:maximum_suggested_headers]):
+eval_message += "({0}). {1}\n".format(idx+1, header)
+  eval_message += "Enter (q) to quit;"
+  if maximum_suggested_headers < len(headers):
+eval_message += " (a) to show all candidates.";
+  eval_message += "\nSelect (default 1): "
+  to_eval = "input('{0}')".format(eval_message)
+  res = vim.eval(to_eval)
+  try:
+idx = int(res)
+if idx <= 0 or idx >= len(headers):
+  raise Exception()
+  except Exception:
+if res == '':
+  # choose the top ranked header by default
+  idx = 1
+elif res == 'q':
+  raise Exception('   Insertion cancelled...')
+elif res == 'a' and maximum_suggested_headers < len(headers):
+  return GetUserSelection(message, headers, len(headers))
+else:
+  raise Exception("   ERROR: Invalid option {0}...Abort!".format(res))
+  return headers[idx-1]
 
 def execute(command, text):
   p = subprocess.Popen(command,
@@ -88,7 +107,7 @@
 
   if not symbol:
 print "The file is fine, no need to add a 

r271884 - [mips] The default ABI depends on the CPU not the Arch on MTI and IMG vendor triples.

2016-06-06 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Mon Jun  6 07:02:21 2016
New Revision: 271884

URL: http://llvm.org/viewvc/llvm-project?rev=271884=rev
Log:
[mips] The default ABI depends on the CPU not the Arch on MTI and IMG vendor 
triples.

Summary:
32-bit CPU's default to O32. 64-bit CPU's default to N64. The default CPU
(mips32r2/mips64r2) still depends on the arch so there's no functional
change when the CPU isn't specified but commands like:
  clang -target mips-mti-linux-gnu -mips64r2
will now default to a 64-bit ABI like our gcc toolchains do* instead of
asserting in the backend**.

Other vendors (including Triple::UnknownVendor) still derive the default
ABI from the arch.

* Although not the same one as our gcc toolchains, clang has historically
  defaulted to N64 where gcc defaults to N32.
** Mixing O32 and a 64-bit CPU causing assertions is a long-standing bug.

Reviewers: atanasyan

Subscribers: sdardis, cfe-commits

Differential Revision: http://reviews.llvm.org/D21016

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-abi.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=271884=271883=271884=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jun  6 07:02:21 2016
@@ -1221,6 +1221,30 @@ void mips::getMipsCPUAndABI(const ArgLis
 }
   }
 
+  if (ABIName.empty() &&
+  (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
+   Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {
+ABIName = llvm::StringSwitch(CPUName)
+  .Case("mips1", "o32")
+  .Case("mips2", "o32")
+  .Case("mips3", "n64")
+  .Case("mips4", "n64")
+  .Case("mips5", "n64")
+  .Case("mips32", "o32")
+  .Case("mips32r2", "o32")
+  .Case("mips32r3", "o32")
+  .Case("mips32r5", "o32")
+  .Case("mips32r6", "o32")
+  .Case("mips64", "n64")
+  .Case("mips64r2", "n64")
+  .Case("mips64r3", "n64")
+  .Case("mips64r5", "n64")
+  .Case("mips64r6", "n64")
+  .Case("octeon", "n64")
+  .Case("p5600", "o32")
+  .Default("");
+  }
+
   if (ABIName.empty()) {
 // Deduce ABI name from the target triple.
 if (Triple.getArch() == llvm::Triple::mips ||

Modified: cfe/trunk/test/Driver/mips-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=271884=271883=271884=diff
==
--- cfe/trunk/test/Driver/mips-abi.c (original)
+++ cfe/trunk/test/Driver/mips-abi.c Mon Jun  6 07:02:21 2016
@@ -6,9 +6,22 @@
 // MIPS-DEF: "-target-abi" "o32"
 //
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64-DEF %s
-// MIPS64-DEF: "-target-cpu" "mips64r2"
-// MIPS64-DEF: "-target-abi" "n64"
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-mti-linux-gnu -mips64r2 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// MIPS64R2-N64: "-target-cpu" "mips64r2"
+// MIPS64R2-N64: "-target-abi" "n64"
+//
+// RUN: %clang -target mips64-linux-gnu -### -mips64r3 -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// RUN: %clang -target mips-img-linux-gnu -mips64r3 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// RUN: %clang -target mips-mti-linux-gnu -mips64r3 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// MIPS64R3-N64: "-target-cpu" "mips64r3"
+// MIPS64R3-N64: "-target-abi" "n64"
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-mabi=32 2>&1 \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21016: [mips] The default ABI depends on the CPU not the Arch on MTI and IMG vendor triples.

2016-06-06 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D21016



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r271801 - Add PIE magic for NetBSD. Add tests for the correct flags for

2016-06-06 Thread Joerg Sonnenberger via cfe-commits
On Mon, Jun 06, 2016 at 02:21:37PM +0300, Ismail Donmez wrote:
> This seems to fail for me on Windows:
> $ "C:/cygwin64/home/ismail/src/llvm/dist/./bin/clang.EXE"
> "-no-canonical-prefixes" "-target" "x86_64--netbsd"
> "--sysroot=C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver/Inputs/basic_netbsd_tree"
> "C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c"
> "-###"
> $ "C:/cygwin64/home/ismail/src/llvm/dist/./bin\FileCheck.EXE"
> "-check-prefix=STATIC"
> "C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c"
> # command stderr:
> C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c:121:12:
> error: expected string not found in input
> // STATIC: "-dynamic-linker" "/libexec/ld.elf_so"
>^
> :7:1: note: scanning from here
> 
> ^

I don't understand this error. The test is structured just like the
existing checks and the patterns it is looking for are in the input as
well.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r271801 - Add PIE magic for NetBSD. Add tests for the correct flags for

2016-06-06 Thread Ismail Donmez via cfe-commits
Hi,

On Sat, Jun 4, 2016 at 11:03 PM, Joerg Sonnenberger via cfe-commits
 wrote:
> Author: joerg
> Date: Sat Jun  4 15:03:26 2016
> New Revision: 271801
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271801=rev
> Log:
> Add PIE magic for NetBSD. Add tests for the correct flags for
> non-shared, PIE and shared output mode.
>
> Modified:
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/test/Driver/netbsd.c

This seems to fail for me on Windows:
$ "C:/cygwin64/home/ismail/src/llvm/dist/./bin/clang.EXE"
"-no-canonical-prefixes" "-target" "x86_64--netbsd"
"--sysroot=C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver/Inputs/basic_netbsd_tree"
"C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c"
"-###"
$ "C:/cygwin64/home/ismail/src/llvm/dist/./bin\FileCheck.EXE"
"-check-prefix=STATIC"
"C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c"
# command stderr:
C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c:121:12:
error: expected string not found in input
// STATIC: "-dynamic-linker" "/libexec/ld.elf_so"
   ^
:7:1: note: scanning from here

^

error: command failed with exit status: 1

--



Here is the output passed to FileCheck:

win7-vbox ~ > "C:/cygwin64/home/ismail/src/llvm/dist/./bin/clang.EXE"
"-no-canonical-prefixes" "-target" "x86_64--netbsd"
"--sysroot=C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver/Inputs/basic_netbsd_tree"
"C:\cygwin64\home\ismail\src\llvm\tools\clang\test\Driver\netbsd.c"
"-###"
clang version 3.9.0 (http://llvm.org/git/clang
4076bbb87bd1f3b606192c84d4de201e9b9217fb) (http://llvm.org/git/llvm
6dbfac925fe759193c6a16089e2be36f586729d6)
Target: x86_64--netbsd
Thread model: posix
InstalledDir: C:\cygwin64\home\ismail\src\llvm\dist\bin
 "C:\\cygwin64\\home\\ismail\\src\\llvm\\dist\\bin\\clang.EXE" "-cc1"
"-triple" "x86_64--netbsd" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name"
"netbsd.c" "-mrelocation-model" "static" "-mthread-model" "posix"
"-mdisable-fp-elim" "-masm-verbose" "-mconstructor-aliases"
"-munwind-tables" "-target-cpu" "x86-64" "-dwarf-column-info"
"-debugger-tuning=gdb" "-resource-dir"
"C:\\cygwin64\\home\\ismail\\src\\llvm\\dist\\bin\\..\\lib\\clang\\3.9.0"
"-isysroot" 
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree"
"-fdebug-compilation-dir" "C:\\cygwin64\\home\\ismail" "-ferror-limit"
"19" "-fmessage-length" "0" "-fobjc-runtime=gnustep"
"-fdiagnostics-show-option" "-o" "C:\\cygwin64\\tmp\\netbsd-7165c6.o"
"-x" "c" 
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver\\netbsd.c"
 "C:\\cygwin64\\bin\\ld.exe"
"--sysroot=C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree"
"--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" "-o" "a.out"
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree/usr/lib\\crt0.o"
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree/usr/lib\\crti.o"
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree/usr/lib\\crtbegin.o"
"C:\\cygwin64\\tmp\\netbsd-7165c6.o" "-lc"
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree/usr/lib\\crtend.o"
"C:\\cygwin64\\home\\ismail\\src\\llvm\\tools\\clang\\test\\Driver/Inputs/basic_netbsd_tree/usr/lib\\crtn.o"

Let me know if you can stop any error.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20959: [clang-format] make header guard identification stricter (with Lexer).

2016-06-06 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271883: [clang-format] make header guard identification 
stricter (with Lexer). (authored by ioeric).

Changed prior to commit:
  http://reviews.llvm.org/D20959?vs=59700=59703#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20959

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp

Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1436,6 +1436,49 @@
  llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText());
 }
 
+void skipComments(Lexer , Token ) {
+  while (Tok.is(tok::comment))
+if (Lex.LexFromRawLexer(Tok))
+  return;
+}
+
+// Check if a sequence of tokens is like "# ". If it is,
+// \p Tok will be the token after this directive; otherwise, it can be any token
+// after the given \p Tok (including \p Tok).
+bool checkAndConsumeDirectiveWithName(Lexer , StringRef Name, Token ) {
+  bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier) &&
+ Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier);
+  if (Matched)
+Lex.LexFromRawLexer(Tok);
+  return Matched;
+}
+
+unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName,
+   StringRef Code,
+   FormatStyle Style) {
+  std::unique_ptr Env =
+  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
+  const SourceManager  = Env->getSourceManager();
+  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
+getFormattingLangOpts(Style));
+  Token Tok;
+  // Get the first token.
+  Lex.LexFromRawLexer(Tok);
+  skipComments(Lex, Tok);
+  unsigned AfterComments = SourceMgr.getFileOffset(Tok.getLocation());
+  if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) {
+skipComments(Lex, Tok);
+if (checkAndConsumeDirectiveWithName(Lex, "define", Tok))
+  return SourceMgr.getFileOffset(Tok.getLocation());
+  }
+  return AfterComments;
+}
+
+// FIXME: we also need to insert a '\n' at the end of the code if we have an
+// insertion with offset Code.size(), and there is no '\n' at the end of the
+// code.
 // FIXME: do not insert headers into conditional #include blocks, e.g. #includes
 // surrounded by compile condition "#if...".
 // FIXME: do not insert existing headers.
@@ -1469,48 +1512,33 @@
   StringRef FileName = Replaces.begin()->getFilePath();
   IncludeCategoryManager Categories(Style, FileName);
 
-  std::unique_ptr Env =
-  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
-  const SourceManager  = Env->getSourceManager();
-  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
-getFormattingLangOpts(Style));
-  Token Tok;
-  // All new headers should be inserted after this offset.
-  int MinInsertOffset = Code.size();
-  while (!Lex.LexFromRawLexer(Tok)) {
-if (Tok.isNot(tok::comment)) {
-  MinInsertOffset = SourceMgr.getFileOffset(Tok.getLocation());
-  break;
-}
-  }
   // Record the offset of the end of the last include in each category.
   std::map CategoryEndOffsets;
   // All possible priorities.
   // Add 0 for main header and INT_MAX for headers that are not in any category.
   std::set Priorities = {0, INT_MAX};
   for (const auto  : Style.IncludeCategories)
 Priorities.insert(Category.Priority);
   int FirstIncludeOffset = -1;
-  bool HeaderGuardFound = false;
+  // All new headers should be inserted after this offset.
+  unsigned MinInsertOffset =
+  getOffsetAfterHeaderGuardsAndComments(FileName, Code, Style);
   StringRef TrimmedCode = Code.drop_front(MinInsertOffset);
   SmallVector Lines;
   TrimmedCode.split(Lines, '\n');
-  int Offset = MinInsertOffset;
+  unsigned Offset = MinInsertOffset;
+  unsigned NextLineOffset;
   for (auto Line : Lines) {
+NextLineOffset = std::min(Code.size(), Offset + Line.size() + 1);
 if (IncludeRegex.match(Line, )) {
   StringRef IncludeName = Matches[2];
   int Category = Categories.getIncludePriority(
   IncludeName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
-  CategoryEndOffsets[Category] = Offset + Line.size() + 1;
+  CategoryEndOffsets[Category] = NextLineOffset;
   if (FirstIncludeOffset < 0)
 FirstIncludeOffset = Offset;
 }
-Offset += Line.size() + 1;
-// FIXME: make header guard matching stricter, e.g. consider #ifndef.
-if (!HeaderGuardFound && DefineRegex.match(Line)) {
-  HeaderGuardFound = true;
-  MinInsertOffset = Offset;
-}
+Offset = NextLineOffset;
   }
 
   // Populate CategoryEndOfssets:
Index: 

r271883 - [clang-format] make header guard identification stricter (with Lexer).

2016-06-06 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Jun  6 06:00:13 2016
New Revision: 271883

URL: http://llvm.org/viewvc/llvm-project?rev=271883=rev
Log:
[clang-format] make header guard identification stricter (with Lexer).

Summary: make header guard identification stricter with Lexer.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D20959

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=271883=271882=271883=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jun  6 06:00:13 2016
@@ -1436,6 +1436,49 @@ inline bool isHeaderInsertion(const tool
  llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText());
 }
 
+void skipComments(Lexer , Token ) {
+  while (Tok.is(tok::comment))
+if (Lex.LexFromRawLexer(Tok))
+  return;
+}
+
+// Check if a sequence of tokens is like "# ". If it is,
+// \p Tok will be the token after this directive; otherwise, it can be any 
token
+// after the given \p Tok (including \p Tok).
+bool checkAndConsumeDirectiveWithName(Lexer , StringRef Name, Token ) {
+  bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier) &&
+ Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&
+ Tok.is(tok::raw_identifier);
+  if (Matched)
+Lex.LexFromRawLexer(Tok);
+  return Matched;
+}
+
+unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName,
+   StringRef Code,
+   FormatStyle Style) {
+  std::unique_ptr Env =
+  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
+  const SourceManager  = Env->getSourceManager();
+  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
+getFormattingLangOpts(Style));
+  Token Tok;
+  // Get the first token.
+  Lex.LexFromRawLexer(Tok);
+  skipComments(Lex, Tok);
+  unsigned AfterComments = SourceMgr.getFileOffset(Tok.getLocation());
+  if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) {
+skipComments(Lex, Tok);
+if (checkAndConsumeDirectiveWithName(Lex, "define", Tok))
+  return SourceMgr.getFileOffset(Tok.getLocation());
+  }
+  return AfterComments;
+}
+
+// FIXME: we also need to insert a '\n' at the end of the code if we have an
+// insertion with offset Code.size(), and there is no '\n' at the end of the
+// code.
 // FIXME: do not insert headers into conditional #include blocks, e.g. 
#includes
 // surrounded by compile condition "#if...".
 // FIXME: do not insert existing headers.
@@ -1469,20 +1512,6 @@ fixCppIncludeInsertions(StringRef Code,
   StringRef FileName = Replaces.begin()->getFilePath();
   IncludeCategoryManager Categories(Style, FileName);
 
-  std::unique_ptr Env =
-  Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{});
-  const SourceManager  = Env->getSourceManager();
-  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr,
-getFormattingLangOpts(Style));
-  Token Tok;
-  // All new headers should be inserted after this offset.
-  int MinInsertOffset = Code.size();
-  while (!Lex.LexFromRawLexer(Tok)) {
-if (Tok.isNot(tok::comment)) {
-  MinInsertOffset = SourceMgr.getFileOffset(Tok.getLocation());
-  break;
-}
-  }
   // Record the offset of the end of the last include in each category.
   std::map CategoryEndOffsets;
   // All possible priorities.
@@ -1491,26 +1520,25 @@ fixCppIncludeInsertions(StringRef Code,
   for (const auto  : Style.IncludeCategories)
 Priorities.insert(Category.Priority);
   int FirstIncludeOffset = -1;
-  bool HeaderGuardFound = false;
+  // All new headers should be inserted after this offset.
+  unsigned MinInsertOffset =
+  getOffsetAfterHeaderGuardsAndComments(FileName, Code, Style);
   StringRef TrimmedCode = Code.drop_front(MinInsertOffset);
   SmallVector Lines;
   TrimmedCode.split(Lines, '\n');
-  int Offset = MinInsertOffset;
+  unsigned Offset = MinInsertOffset;
+  unsigned NextLineOffset;
   for (auto Line : Lines) {
+NextLineOffset = std::min(Code.size(), Offset + Line.size() + 1);
 if (IncludeRegex.match(Line, )) {
   StringRef IncludeName = Matches[2];
   int Category = Categories.getIncludePriority(
   IncludeName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
-  CategoryEndOffsets[Category] = Offset + Line.size() + 1;
+  CategoryEndOffsets[Category] = NextLineOffset;
   if (FirstIncludeOffset < 0)
 FirstIncludeOffset = Offset;
 }
-Offset += Line.size() + 1;
-// FIXME: make header guard matching stricter, e.g. consider #ifndef.
-if 

Re: [PATCH] D20959: [clang-format] make header guard identification stricter (with Lexer).

2016-06-06 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Nice :-)


http://reviews.llvm.org/D20959



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21016: [mips] The default ABI depends on the CPU not the Arch on MTI and IMG vendor triples.

2016-06-06 Thread Daniel Sanders via cfe-commits
dsanders created this revision.
dsanders added a reviewer: atanasyan.
dsanders added a subscriber: cfe-commits.
Herald added a subscriber: sdardis.

32-bit CPU's default to O32. 64-bit CPU's default to N64. The default CPU
(mips32r2/mips64r2) still depends on the arch so there's no functional
change when the CPU isn't specified but commands like:
  clang -target mips-mti-linux-gnu -mips64r2
will now default to a 64-bit ABI like our gcc toolchains do* instead of
asserting in the backend**.

Other vendors (including Triple::UnknownVendor) still derive the default
ABI from the arch.

* Although not the same one as our gcc toolchains, clang has historically
  defaulted to N64 where gcc defaults to N32.
** Mixing O32 and a 64-bit CPU causing assertions is a long-standing bug.

http://reviews.llvm.org/D21016

Files:
  lib/Driver/Tools.cpp
  test/Driver/mips-abi.c

Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -6,9 +6,22 @@
 // MIPS-DEF: "-target-abi" "o32"
 //
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64-DEF %s
-// MIPS64-DEF: "-target-cpu" "mips64r2"
-// MIPS64-DEF: "-target-abi" "n64"
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-mti-linux-gnu -mips64r2 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// MIPS64R2-N64: "-target-cpu" "mips64r2"
+// MIPS64R2-N64: "-target-abi" "n64"
+//
+// RUN: %clang -target mips64-linux-gnu -### -mips64r3 -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// RUN: %clang -target mips-img-linux-gnu -mips64r3 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// RUN: %clang -target mips-mti-linux-gnu -mips64r3 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// MIPS64R3-N64: "-target-cpu" "mips64r3"
+// MIPS64R3-N64: "-target-abi" "n64"
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-mabi=32 2>&1 \
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1221,6 +1221,30 @@
 }
   }
 
+  if (ABIName.empty() &&
+  (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
+   Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {
+ABIName = llvm::StringSwitch(CPUName)
+  .Case("mips1", "o32")
+  .Case("mips2", "o32")
+  .Case("mips3", "n64")
+  .Case("mips4", "n64")
+  .Case("mips5", "n64")
+  .Case("mips32", "o32")
+  .Case("mips32r2", "o32")
+  .Case("mips32r3", "o32")
+  .Case("mips32r5", "o32")
+  .Case("mips32r6", "o32")
+  .Case("mips64", "n64")
+  .Case("mips64r2", "n64")
+  .Case("mips64r3", "n64")
+  .Case("mips64r5", "n64")
+  .Case("mips64r6", "n64")
+  .Case("octeon", "n64")
+  .Case("p5600", "o32")
+  .Default("");
+  }
+
   if (ABIName.empty()) {
 // Deduce ABI name from the target triple.
 if (Triple.getArch() == llvm::Triple::mips ||


Index: test/Driver/mips-abi.c
===
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -6,9 +6,22 @@
 // MIPS-DEF: "-target-abi" "o32"
 //
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64-DEF %s
-// MIPS64-DEF: "-target-cpu" "mips64r2"
-// MIPS64-DEF: "-target-abi" "n64"
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// RUN: %clang -target mips-mti-linux-gnu -mips64r2 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
+// MIPS64R2-N64: "-target-cpu" "mips64r2"
+// MIPS64R2-N64: "-target-abi" "n64"
+//
+// RUN: %clang -target mips64-linux-gnu -### -mips64r3 -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// RUN: %clang -target mips-img-linux-gnu -mips64r3 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// RUN: %clang -target mips-mti-linux-gnu -mips64r3 -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
+// MIPS64R3-N64: "-target-cpu" "mips64r3"
+// MIPS64R3-N64: "-target-abi" "n64"
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-mabi=32 2>&1 \
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1221,6 +1221,30 @@
 }
   }
 
+  if (ABIName.empty() &&
+ 

  1   2   >