[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26418#590383, @nkakuev wrote:

> The warning is caused by a third-party code, but header filter won't help you 
> to suppress it since it now relates to your sources.


The header filter suppresses the warning location, but the note locations are 
in the main file so they unsuppress the warning.

It sounds like you want note locations to be ignored.


https://reviews.llvm.org/D26418



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


[PATCH] D24235: [OpenCL] Improve double literal handling

2016-11-09 Thread Neil Hickey via cfe-commits
neil.hickey updated this revision to Diff 77321.
neil.hickey added a comment.

Moving location of no-diagnostics statement to beginning of file


https://reviews.llvm.org/D24235

Files:
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/fpmath.cl
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -1,13 +1,20 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
 // RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
 
+#ifdef FP64
+// expected-no-diagnostics
+#endif
+
+#if __OPENCL_C_VERSION__ < 120
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
 }
+#endif
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #ifdef NOFP64
@@ -21,16 +28,19 @@
 #endif
 
   (void) 1.0;
+
 #ifdef NOFP64
-// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}}
+// expected-warning@-6{{double precision constant requires cl_khr_fp64, casting to single precision}}
 #endif
 }
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : disable
 #ifdef NOFP64
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#if __OPENCL_C_VERSION__ < 120
 void f3(void) {
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
 }
+#endif
Index: test/CodeGenOpenCL/fpmath.cl
===
--- test/CodeGenOpenCL/fpmath.cl
+++ test/CodeGenOpenCL/fpmath.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck --check-prefix=CHECK --check-prefix=NODIVOPT %s
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-fp32-correctly-rounded-divide-sqrt | FileCheck --check-prefix=CHECK --check-prefix=DIVOPT %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -DNOFP64 -cl-std=CL1.1 -triple r600-unknown-unknown -target-cpu r600 -pedantic | FileCheck --check-prefix=CHECK-DBL %s
 
 typedef __attribute__(( ext_vector_type(4) )) float float4;
 
@@ -21,14 +22,26 @@
   return a / b;
 }
 
+void printf(constant char* fmt, ...);
+
+#ifndef NOFP64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+void testdbllit(long *val) {
+  // CHECK-DBL: float 2.00e+01
+  // CHECK: double 2.00e+01
+  printf("%f", 20.0);
+}
 
+#ifndef NOFP64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
   // CHECK: #[[ATTR]]
   // CHECK-NOT: !fpmath
   return a / b;
 }
+#endif
 
 // CHECK: attributes #[[ATTR]] = {
 // NODIVOPT: "correctly-rounded-divide-sqrt-fp-math"="false"
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1401,8 +1401,7 @@
   Result = Context.DoubleTy;
 
 if (S.getLangOpts().OpenCL &&
-!((S.getLangOpts().OpenCLVersion >= 120) ||
-  S.getOpenCLOptions().cl_khr_fp64)) {
+!(S.getOpenCLOptions().cl_khr_fp64)) {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
   << Result << "cl_khr_fp64";
   declarator.setInvalidType(true);
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -705,9 +705,13 @@
   if (getLangOpts().ObjCAutoRefCount &&
   E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
 Cleanup.setExprNeedsCleanups(true);
+  
+  ExprResult Res = E;
 
-  ExprResult Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
-nullptr, VK_RValue);
+  if ( T != E->getType()) {
+Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
+   nullptr, VK_RValue);
+  }
 
   // C11 6.3.2.1p2:
   //   ... if the lvalue has atomic type, the value has the non-atomic version 
@@ -817,8 +821,16 @@
   // double.
   const BuiltinType *BTy = Ty->getAs();
   if (BTy && (BTy->getKind() == BuiltinType::Half ||
-  BTy->getKind() == BuiltinType::Float))
-E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
+  BTy->getKind() == BuiltinType::Float)) {
+if (getLangOpts().OpenCL &&
+!(getOpenCLOptions().cl_khr_fp64)) {
+if (BTy->getKind() == BuiltinType::Half) {
+E = ImpCastExprToType(E, Context.

[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: include/clang/Sema/DeclSpec.h:1314
   for (unsigned I = 0; I < NumParams; ++I) {
-delete Params[I].DefaultArgTokens;
-Params[I].DefaultArgTokens = nullptr;
+Params[I].DefaultArgTokens.release();
   }

Did you mean `reset()`?



Comment at: lib/Parse/ParseDecl.cpp:6064
   if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
-delete DefArgToks;
-DefArgToks = nullptr;
+DefArgToks.release();
 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);

Did you mean `reset()`?


https://reviews.llvm.org/D26435



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


[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-09 Thread Alex Lorenz via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Sema/DeclSpec.h:1313
 void freeParams() {
   for (unsigned I = 0; I < NumParams; ++I) {
+Params[I].DefaultArgTokens.release();

You can elide the curly braces here now that the loop has just one statement.


https://reviews.llvm.org/D26435



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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-09 Thread Alex Lorenz via cfe-commits
arphaman accepted this revision.
arphaman added a reviewer: arphaman.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D26406



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-11-09 Thread Nikita Kakuev via cfe-commits
nkakuev added a comment.

In https://reviews.llvm.org/D26418#590417, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D26418#590383, @nkakuev wrote:
>
> > The warning is caused by a third-party code, but header filter won't help 
> > you to suppress it since it now relates to your sources.
>
>
> The header filter suppresses the warning location, but the note locations are 
> in the main file so they unsuppress the warning.
>
> It sounds like you want note locations to be ignored.


I want a convenient instrument to suppress unwanted diagnostics. Even if I 
change clang-tidy to ignore note locations, it would still be impractical to 
use '-header-filter' to //exclude// diagnostics from certain headers. Header 
filter was designed to //include// headers, not to //exclude// them. Trying to 
exclude "these m directories and that n files" is close to impossible using a 
single regular expression. Plus, even if I manage to do this, I'll be ignoring 
all diagnostics and not only the faulty ones.

Suppress-check-filter is specifically designed to //exclude// headers and 
doesn't require abusing regular expressions to do this. Plus, it allows a user 
to specify what diagnostics he doesn't want, instead of ignoring everything.


https://reviews.llvm.org/D26418



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


r286354 - [Sema] Avoid -Wshadow warnings for shadowed variables that aren't captured

2016-11-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov  9 04:38:57 2016
New Revision: 286354

URL: http://llvm.org/viewvc/llvm-project?rev=286354&view=rev
Log:
[Sema] Avoid -Wshadow warnings for shadowed variables that aren't captured
by lambdas with an explicit capture list

This commit avoids the -Wshadow warning for variables which shadow variables
that aren't captured by lambdas with an explicit capture list. It provides an
additional note that points to location of the explicit capture.

The old behaviour is preserved with -Wshadow-all or -Wshadow-uncaptured-local.

rdar://17135966

Differential Revision: https://reviews.llvm.org/D26278

Added:
cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=286354&r1=286353&r2=286354&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Nov  9 04:38:57 2016
@@ -348,12 +348,14 @@ def ShadowFieldInConstructorModified : D
 def ShadowFieldInConstructor : DiagGroup<"shadow-field-in-constructor",
  [ShadowFieldInConstructorModified]>;
 def ShadowIvar : DiagGroup<"shadow-ivar">;
+def ShadowUncapturedLocal : DiagGroup<"shadow-uncaptured-local">;
 
 // -Wshadow-all is a catch-all for all shadowing. -Wshadow is just the
 // shadowing that we think is unsafe.
 def Shadow : DiagGroup<"shadow", [ShadowFieldInConstructorModified,
   ShadowIvar]>;
-def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor]>;
+def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor,
+ ShadowUncapturedLocal]>;
 
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=286354&r1=286353&r2=286354&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov  9 04:38:57 
2016
@@ -357,6 +357,9 @@ def warn_decl_shadow :
   "static data member of %2|"
   "field of %2}1">,
   InGroup, DefaultIgnore;
+def warn_decl_shadow_uncaptured_local :
+  Warning,
+  InGroup, DefaultIgnore;
 def warn_ctor_parm_shadows_field:
   Warning<"constructor parameter %0 shadows the field %1 of %2">,
   InGroup, DefaultIgnore;
@@ -6230,6 +6233,8 @@ let CategoryName = "Lambda Issue" in {
   def note_lambda_to_block_conv : Note<
 "implicit capture of lambda object due to conversion to block pointer "
 "here">;
+  def note_var_explicitly_captured_here : Note<"variable %0 is explicitly "
+"captured here">;
 
   // C++14 lambda init-captures.
   def warn_cxx11_compat_init_capture : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=286354&r1=286353&r2=286354&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov  9 04:38:57 2016
@@ -6582,6 +6582,17 @@ static ShadowedDeclKind computeShadowedD
   return OldDC->isFileContext() ? SDK_Global : SDK_Local;
 }
 
+/// Return the location of the capture if the given lambda captures the given
+/// variable \p VD, or an invalid source location otherwise.
+static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI,
+ const VarDecl *VD) {
+  for (const LambdaScopeInfo::Capture &Capture : LSI->Captures) {
+if (Capture.isVariableCapture() && Capture.getVariable() == VD)
+  return Capture.getLocation();
+  }
+  return SourceLocation();
+}
+
 /// \brief Diagnose variable or built-in function shadowing.  Implements
 /// -Wshadow.
 ///
@@ -6640,6 +6651,22 @@ void Sema::CheckShadow(Scope *S, VarDecl
 
   DeclContext *OldDC = ShadowedDecl->getDeclContext();
 
+  unsigned WarningDiag = diag::warn_decl_shadow;
+  SourceLocation CaptureLoc;
+  if (isa(ShadowedDecl) && NewDC && isa(NewDC)) {
+if (const auto *RD = dyn_cast(NewDC->getParent())) {
+  // Try to avoid warnings for lambdas with an explicit capture list.
+  if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent()) &&
+  RD->getLambdaCaptureDefault() == LCD_None) {
+const auto *LSI = cast(getCurFunction());
+// Warn only when the lambda captures the shadowed decl explicitly.
+CaptureLoc

[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

2016-11-09 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286354: [Sema] Avoid -Wshadow warnings for shadowed 
variables that aren't captured (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26278?vs=77205&id=77328#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26278

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -348,12 +348,14 @@
 def ShadowFieldInConstructor : DiagGroup<"shadow-field-in-constructor",
  [ShadowFieldInConstructorModified]>;
 def ShadowIvar : DiagGroup<"shadow-ivar">;
+def ShadowUncapturedLocal : DiagGroup<"shadow-uncaptured-local">;
 
 // -Wshadow-all is a catch-all for all shadowing. -Wshadow is just the
 // shadowing that we think is unsafe.
 def Shadow : DiagGroup<"shadow", [ShadowFieldInConstructorModified,
   ShadowIvar]>;
-def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor]>;
+def ShadowAll : DiagGroup<"shadow-all", [Shadow, ShadowFieldInConstructor,
+ ShadowUncapturedLocal]>;
 
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
 def : DiagGroup<"sign-promo">;
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -357,6 +357,9 @@
   "static data member of %2|"
   "field of %2}1">,
   InGroup, DefaultIgnore;
+def warn_decl_shadow_uncaptured_local :
+  Warning,
+  InGroup, DefaultIgnore;
 def warn_ctor_parm_shadows_field:
   Warning<"constructor parameter %0 shadows the field %1 of %2">,
   InGroup, DefaultIgnore;
@@ -6230,6 +6233,8 @@
   def note_lambda_to_block_conv : Note<
 "implicit capture of lambda object due to conversion to block pointer "
 "here">;
+  def note_var_explicitly_captured_here : Note<"variable %0 is explicitly "
+"captured here">;
 
   // C++14 lambda init-captures.
   def warn_cxx11_compat_init_capture : Warning<
Index: cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow -D AVOID %s
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow -Wshadow-uncaptured-local %s
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow-all %s
+
+void foo(int param) { // expected-note 1+ {{previous declaration is here}}
+  int var = 0; // expected-note 1+ {{previous declaration is here}}
+
+  // Warn for lambdas with a default capture specifier.
+  {
+auto f1 = [=] { int var = 1; };  // expected-warning {{declaration shadows a local variable}}
+auto f2 = [&] { int var = 2; };  // expected-warning {{declaration shadows a local variable}}
+auto f3 = [=] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [&] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn normally inside of lambdas.
+  auto l1 = [] { // expected-note {{previous declaration is here}}
+  int x = 1; // expected-note {{previous declaration is here}}
+  { int x = 2; } // expected-warning {{declaration shadows a local variable}}
+  };
+  auto l2 = [] (int x) { // expected-note {{previous declaration is here}}
+{ int x = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Avoid warnings for variables that aren't explicitly captured.
+  {
+#ifdef AVOID
+auto f1 = [] { int var = 1; }; // no warning
+auto f2 = [] (int param) { ; }; // no warning
+auto f3 = [param] () { int var = 1; }; // no warning
+auto f4 = [var] (int param) { ; }; // no warning
+#else
+auto f1 = [] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f2 = [] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f3 = [param] () { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [var] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  };
+
+  // Warn for variables that are explicitly captured.
+  {
+auto f1 = [var] () { // expected-note {{variable 'var' is explicitly captured here}}
+  int var = 1; // expected-warning {{declaration shadows a local variable}}
+};
+au

[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-11-09 Thread Nikita Kakuev via cfe-commits
nkakuev added a comment.

In https://reviews.llvm.org/D26418#590417, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D26418#590383, @nkakuev wrote:
>
> > The warning is caused by a third-party code, but header filter won't help 
> > you to suppress it since it now relates to your sources.
>
>
> The header filter suppresses the warning location, but the note locations are 
> in the main file so they unsuppress the warning.
>
> It sounds like you want note locations to be ignored.


On a second thought, ignoring note locations might be a good enough solution 
for me.
How should I do this? Add a new option (e.g. '-ignore-note-locations')?


https://reviews.llvm.org/D26418



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons resigned from this revision.
malcolm.parsons removed a reviewer: malcolm.parsons.
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26418#590476, @nkakuev wrote:

> On a second thought, ignoring note locations might be a good enough solution 
> for me.
>  How should I do this? Add a new option (e.g. '-ignore-note-locations')?


I'll let @alexfh decide.


https://reviews.llvm.org/D26418



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


[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-11-09 Thread Pavel Labath via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286356: [VFS] Replace TimeValue usage with std::chrono 
(authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D25948?vs=75723&id=77330#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25948

Files:
  cfe/trunk/include/clang/Basic/VirtualFileSystem.h
  cfe/trunk/lib/Basic/FileSystemStatCache.cpp
  cfe/trunk/lib/Basic/VirtualFileSystem.cpp
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/lib/Serialization/ModuleManager.cpp
  cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -16,10 +16,10 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -34,7 +34,7 @@
 class Status {
   std::string Name;
   llvm::sys::fs::UniqueID UID;
-  llvm::sys::TimeValue MTime;
+  llvm::sys::TimePoint<> MTime;
   uint32_t User;
   uint32_t Group;
   uint64_t Size;
@@ -48,7 +48,7 @@
   Status() : Type(llvm::sys::fs::file_type::status_error) {}
   Status(const llvm::sys::fs::file_status &Status);
   Status(StringRef Name, llvm::sys::fs::UniqueID UID,
- llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group,
+ llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group,
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
@@ -64,7 +64,7 @@
   /// @{
   llvm::sys::fs::file_type getType() const { return Type; }
   llvm::sys::fs::perms getPermissions() const { return Perms; }
-  llvm::sys::TimeValue getLastModificationTime() const { return MTime; }
+  llvm::sys::TimePoint<> getLastModificationTime() const { return MTime; }
   llvm::sys::fs::UniqueID getUniqueID() const { return UID; }
   uint32_t getUser() const { return User; }
   uint32_t getGroup() const { return Group; }
Index: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
===
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp
@@ -23,7 +23,7 @@
  FileData &Data) {
   Data.Name = Status.getName();
   Data.Size = Status.getSize();
-  Data.ModTime = Status.getLastModificationTime().toEpochTime();
+  Data.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
   Data.UniqueID = Status.getUniqueID();
   Data.IsDirectory = Status.isDirectory();
   Data.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;
Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -47,7 +47,7 @@
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::TimeValue(ModificationTime, 0), 0, 0,
+llvm::sys::toTimePoint(ModificationTime), 0, 0,
 Buffer->getBufferSize(),
 llvm::sys::fs::file_type::regular_file,
 llvm::sys::fs::all_all);
@@ -545,9 +545,9 @@
   // FIXME: expose the status details in the interface.
   Status Stat(
   StringRef(Path.str().begin(), Name.end() - Path.str().begin()),
-  getNextVirtualUniqueID(), llvm::sys::TimeValue(ModificationTime, 0),
-  0, 0, Buffer->getBufferSize(),
-  llvm::sys::fs::file_type::directory_

r286356 - [VFS] Replace TimeValue usage with std::chrono

2016-11-09 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Nov  9 04:52:22 2016
New Revision: 286356

URL: http://llvm.org/viewvc/llvm-project?rev=286356&view=rev
Log:
[VFS] Replace TimeValue usage with std::chrono

Summary: NFCI

Reviewers: benlangmuir, zturner

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25948

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/FileSystemStatCache.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=286356&r1=286355&r2=286356&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Wed Nov  9 04:52:22 2016
@@ -16,10 +16,10 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -34,7 +34,7 @@ namespace vfs {
 class Status {
   std::string Name;
   llvm::sys::fs::UniqueID UID;
-  llvm::sys::TimeValue MTime;
+  llvm::sys::TimePoint<> MTime;
   uint32_t User;
   uint32_t Group;
   uint64_t Size;
@@ -48,7 +48,7 @@ public:
   Status() : Type(llvm::sys::fs::file_type::status_error) {}
   Status(const llvm::sys::fs::file_status &Status);
   Status(StringRef Name, llvm::sys::fs::UniqueID UID,
- llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group,
+ llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group,
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
@@ -64,7 +64,7 @@ public:
   /// @{
   llvm::sys::fs::file_type getType() const { return Type; }
   llvm::sys::fs::perms getPermissions() const { return Perms; }
-  llvm::sys::TimeValue getLastModificationTime() const { return MTime; }
+  llvm::sys::TimePoint<> getLastModificationTime() const { return MTime; }
   llvm::sys::fs::UniqueID getUniqueID() const { return UID; }
   uint32_t getUser() const { return User; }
   uint32_t getGroup() const { return Group; }

Modified: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=286356&r1=286355&r2=286356&view=diff
==
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp (original)
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp Wed Nov  9 04:52:22 2016
@@ -23,7 +23,7 @@ static void copyStatusToFileData(const v
  FileData &Data) {
   Data.Name = Status.getName();
   Data.Size = Status.getSize();
-  Data.ModTime = Status.getLastModificationTime().toEpochTime();
+  Data.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
   Data.UniqueID = Status.getUniqueID();
   Data.IsDirectory = Status.isDirectory();
   Data.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=286356&r1=286355&r2=286356&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Nov  9 04:52:22 2016
@@ -47,7 +47,7 @@ Status::Status(const file_status &Status
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@ public:
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@ bool InMemoryFileSystem::addFile(const T
 // End of the path, create a new file.
 // FIXME: expose the status de

[PATCH] D26335: [ms] Reinstate https://reviews.llvm.org/D14748 after https://reviews.llvm.org/D20291

2016-11-09 Thread Andrea Di Biagio via cfe-commits
andreadb added inline comments.



Comment at: lib/Headers/x86intrin.h:49
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__tzcnt_u32(unsigned int __X) { return __X ? __builtin_ctz(__X) : 32; }
+#ifdef __x86_64__

hans wrote:
> probinson wrote:
> > hans wrote:
> > > I'm worried about the conditional here. IIRC, ffmpeg uses TZCNT just as a 
> > > faster encoding for BSF, but now we're putting a conditional in the way, 
> > > so this will be slower actually. On the other hand, the alternative is 
> > > weird too :-/
> > I thought there was a peephole to notice a guard like this and do the right 
> > thing? In which case having the guard is fine.
> But for non-BMI targets it won't be able to remove the guard (unless it can 
> prove the argument is zero).
> 
> MSVC will just emit the raw 'tzcnt' instruction here, and that's what ffmpeg 
> wants.
I understand your point. However, the semantic of tzcnt_u32 (at least for BMI) 
is well defined on zero input. Changing that semantic for non-BMI targets 
sounds a bit odd/confusing to me.

I guess ffmpeg is reliant on the fact that other compilers would either 
preserve the intrinsic call until instruction selection, or fold it to a 
meaningful value (i.e. 32 in this case) when the input is known to be zero. If 
we remove the zero check from tzcnt_u32 (for non BMI targets), we let the 
optimizer enable rules to aggressively fold calls to tzcnt_u32 to undef when 
the input is zero.

As a side note: I noticed that gcc provides intrinsic `__bsfd` in ia32intrin.h. 
Maybe we should do something similar?


https://reviews.llvm.org/D26335



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


r286357 - Replace TimeValue with TimePoint in BuildSystem.cpp. NFC.

2016-11-09 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Nov  9 05:19:39 2016
New Revision: 286357

URL: http://llvm.org/viewvc/llvm-project?rev=286357&view=rev
Log:
Replace TimeValue with TimePoint in BuildSystem.cpp. NFC.

Modified:
cfe/trunk/tools/libclang/BuildSystem.cpp

Modified: cfe/trunk/tools/libclang/BuildSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/BuildSystem.cpp?rev=286357&r1=286356&r2=286357&view=diff
==
--- cfe/trunk/tools/libclang/BuildSystem.cpp (original)
+++ cfe/trunk/tools/libclang/BuildSystem.cpp Wed Nov  9 05:19:39 2016
@@ -16,15 +16,15 @@
 #include "clang/Basic/VirtualFileSystem.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace llvm::sys;
 
 unsigned long long clang_getBuildSessionTimestamp(void) {
-  return llvm::sys::TimeValue::now().toEpochTime();
+  return llvm::sys::toTimeT(std::chrono::system_clock::now());
 }
 
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(clang::vfs::YAMLVFSWriter,


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


[PATCH] D24933: Enable configuration files in clang

2016-11-09 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

> For Chromium, our build system provides a specific Clang version close to 
> ToT, and obviously what flags to use when invoking it. (Developers can of 
> course override the flags when configuring if they want.) Now maybe a 
> developer has a ~/clang.cfg because they want certain flags on by default 
> when they build *other* projects, those flags would now be applied to all 
> clangs, including the one we provide, and potentially wreak havoc.

Default config file is searched for only in the directory where clang 
executable resides. It allows SDK suppliers to customize compiler, for instance 
by turning off unneeded warnings, by providing their own `clang.cfg`. On the 
other hand developers cannot by accident override default setting because 
`clang.cfg` is placed in system directory.

> As for compiler bugs getting harder to reproduce, we already get a lot of bug 
> reports where only the driver invocation is provided, e.g. "clang -O2 foo.c".

If `foo.c` includes other files, it can be a challenge now. `clang -v` can help 
but anyway, this task indeed becomes a bit more complex.

> Do we want to get the same config file for "clang", "clang++" and "clang-cl"? 
> They accept different flags.

The driver is still the same, so I think we can use the same config file in 
these cases. Using --driver-mode as a second dimension would make the scheme 
awkward, IMHO.

> Maybe it'd be better to take a step back and attempt to create a regular, 
> .ini/.conf-style configuration file. One particular advantage of that is that 
> we can precisely decide which options to support and how to support them. I 
> think this could be better both for opponents of 'free configuration' (since 
> it will be less powerful and more controlled), and for proponents of nice 
> configuration files (such as me).

Advanced config file format is a nice idea, but it already got objections in 
mail list:

> because then we will have to document and maintain the semantics of things 
> like multiple configuration files, in what order they override each other, 
> and how they interact with flags. Our command line flag logic is already too 
> complicated. We have one public interface, and it's flags, and I'm hesitant 
> to add a new one.

I think many things can be simpler if we had enough powerful description 
language, as gcc spec. As for particular concern of making config files less 
powerful, maybe we could do simple validation of options contained there? For 
instance, only options started from `-W`, `-I`, etc are allowed, other would 
cause warning. This however complicates the driver and requires documenting 
intended behavior.


https://reviews.llvm.org/D24933



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


[PATCH] D26448: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with a default capture specifier

2016-11-09 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: rnk, rsmith.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This is a follow-up patch to r286354. This patch avoids the -Wshadow warning 
for variables which shadow variables that aren't captured by lambdas with a 
default capture specifier. It provides an additional note that points to 
location of the capture.

The old behaviour is preserved with -Wshadow-all.

This fixes PR 21426 fully.


Repository:
  rL LLVM

https://reviews.llvm.org/D26448

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp

Index: test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -5,12 +5,48 @@
 void foo(int param) { // expected-note 1+ {{previous declaration is here}}
   int var = 0; // expected-note 1+ {{previous declaration is here}}
 
-  // Warn for lambdas with a default capture specifier.
+  // Avoid warnings for variables that aren't implicitly captured.
   {
+#ifdef AVOID
+auto f1 = [=] { int var = 1; };  // no warning
+auto f2 = [&] { int var = 2; };  // no warning
+auto f3 = [=] (int param) { ; }; // no warning
+auto f4 = [&] (int param) { ; }; // no warning
+#else
 auto f1 = [=] { int var = 1; };  // expected-warning {{declaration shadows a local variable}}
 auto f2 = [&] { int var = 2; };  // expected-warning {{declaration shadows a local variable}}
 auto f3 = [=] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
 auto f4 = [&] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  }
+
+  // Warn for variables that are implicitly captured.
+  {
+auto f1 = [=] () {
+  {
+int var = 1; // expected-warning {{declaration shadows a local variable}}
+  }
+  int x = var; // expected-note {{variable 'var' is captured here}}
+};
+auto f2 = [&]
+#ifdef AVOID
+  (int param) {
+#else
+  (int param) { // expected-warning {{declaration shadows a local variable}}
+#endif
+  int x = var; // expected-note {{variable 'var' is captured here}}
+  int var = param; // expected-warning {{declaration shadows a local variable}}
+};
+  }
+
+  // Warn for variables that are explicitly captured when a lambda has a default
+  // capture specifier.
+  {
+auto f1 = [=, &var] () { // expected-note {{variable 'var' is captured here}}
+  int x = param; // expected-note {{variable 'param' is captured here}}
+  int var = 0; // expected-warning {{declaration shadows a local variable}}
+  int param = 0; // expected-warning {{declaration shadows a local variable}}
+};
   }
 
   // Warn normally inside of lambdas.
@@ -72,20 +108,32 @@
 };
 #ifdef AVOID
 auto f1 = [] { int var = 1; }; // no warning
+auto f2 = [=] { int var = 1; }; // no warning
 #else
 auto f1 = [] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
-#endif
 auto f2 = [=] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+#endif
 auto f3 = [var] // expected-note {{variable 'var' is explicitly captured here}}
   { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [&] {
+  int x = var; // expected-note {{variable 'var' is captured here}}
+  int var = 2; // expected-warning {{declaration shadows a local variable}}
+};
+  };
+  auto l6 = [&] {
+auto f1 = [param] { // expected-note {{variable 'param' is explicitly captured here}}
+  int param = 0; // expected-warning {{declaration shadows a local variable}}
+};
   };
 
   // Generic lambda arguments should work.
 #ifdef AVOID
   auto g1 = [](auto param) { ; }; // no warning
+  auto g2 = [=](auto param) { ; }; // no warning
 #else
   auto g1 = [](auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto g2 = [=](auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
 #endif
-  auto g2 = [param] // expected-note {{variable 'param' is explicitly captured here}}
+  auto g3 = [param] // expected-note {{variable 'param' is explicitly captured here}}
(auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
 }
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1620,6 +1620,9 @@
 CheckConstexprFunctionBody(CallOperator, CallOperator->getBody()));
   }
 
+  // Emit delayed shadowing warnings now that the full capture list is known.
+  DiagnoseShadowingLambdaDecls(LSI);
+
   if (!CurContext->isDependentContext()) {
 switch (ExprEvalContexts.

[PATCH] D26071: [CodeCompletion] Show block invocation result for block property setters

2016-11-09 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286363: [CodeCompletion] Show block invocation results for 
block property setters (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26071?vs=76178&id=77337#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26071

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/Index/complete-block-properties.m
  cfe/trunk/test/Index/complete-block-property-assignment.m

Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -3612,6 +3612,44 @@
   return Container;
 }
 
+/// \brief Adds a block invocation code completion result for the given block
+/// declaration \p BD.
+static void AddObjCBlockCall(ASTContext &Context, const PrintingPolicy &Policy,
+ CodeCompletionBuilder &Builder,
+ const NamedDecl *BD,
+ const FunctionTypeLoc &BlockLoc,
+ const FunctionProtoTypeLoc &BlockProtoLoc) {
+  Builder.AddResultTypeChunk(
+  GetCompletionTypeString(BlockLoc.getReturnLoc().getType(), Context,
+  Policy, Builder.getAllocator()));
+
+  AddTypedNameChunk(Context, Policy, BD, Builder);
+  Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+
+  if (BlockProtoLoc && BlockProtoLoc.getTypePtr()->isVariadic()) {
+Builder.AddPlaceholderChunk("...");
+  } else {
+for (unsigned I = 0, N = BlockLoc.getNumParams(); I != N; ++I) {
+  if (I)
+Builder.AddChunk(CodeCompletionString::CK_Comma);
+
+  // Format the placeholder string.
+  std::string PlaceholderStr =
+  FormatFunctionParameter(Policy, BlockLoc.getParam(I));
+
+  if (I == N - 1 && BlockProtoLoc &&
+  BlockProtoLoc.getTypePtr()->isVariadic())
+PlaceholderStr += ", ...";
+
+  // Add the placeholder string.
+  Builder.AddPlaceholderChunk(
+  Builder.getAllocator().CopyString(PlaceholderStr));
+}
+  }
+
+  Builder.AddChunk(CodeCompletionString::CK_RightParen);
+}
+
 static void AddObjCProperties(const CodeCompletionContext &CCContext,
   ObjCContainerDecl *Container,
   bool AllowCategories, bool AllowNullaryMethods,
@@ -3629,42 +3667,61 @@
 if (!AddedProperties.insert(P->getIdentifier()).second)
   continue;
 
-Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
-   CurContext);
+// FIXME: Provide block invocation completion for non-statement
+// expressions.
+if (!P->getType().getTypePtr()->isBlockPointerType() ||
+!IsBaseExprStatement) {
+  Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
+ CurContext);
+  continue;
+}
+
+// Block setter and invocation completion is provided only when we are able
+// to find the FunctionProtoTypeLoc with parameter names for the block.
+FunctionTypeLoc BlockLoc;
+FunctionProtoTypeLoc BlockProtoLoc;
+findTypeLocationForBlockDecl(P->getTypeSourceInfo(), BlockLoc,
+ BlockProtoLoc);
+if (!BlockLoc) {
+  Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
+ CurContext);
+  continue;
+}
+
+// The default completion result for block properties should be the block
+// invocation completion when the base expression is a statement.
+CodeCompletionBuilder Builder(Results.getAllocator(),
+  Results.getCodeCompletionTUInfo());
+AddObjCBlockCall(Container->getASTContext(),
+ getCompletionPrintingPolicy(Results.getSema()), Builder, P,
+ BlockLoc, BlockProtoLoc);
+Results.MaybeAddResult(
+Result(Builder.TakeString(), P, Results.getBasePriority(P)),
+CurContext);
 
 // Provide additional block setter completion iff the base expression is a
-// statement.
-if (!P->isReadOnly() && IsBaseExprStatement &&
-P->getType().getTypePtr()->isBlockPointerType()) {
-  FunctionTypeLoc BlockLoc;
-  FunctionProtoTypeLoc BlockProtoLoc;
-  findTypeLocationForBlockDecl(P->getTypeSourceInfo(), BlockLoc,
-   BlockProtoLoc);
-
-  // Provide block setter completion only when we are able to find
-  // the FunctionProtoTypeLoc with parameter names for the block.
-  if (BlockLoc) {
-CodeCompletionBuilder Builder(Results.getAllocator(),
-  Results.getCodeCompletionTUInfo());
-AddResultTypeChunk(Container->getASTContext(),
-   getCompletionPrintingPolicy(Results.getSema()), P,
-   CCContext.getBaseType(), Buil

r286363 - [CodeCompletion] Show block invocation results for block property setters

2016-11-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov  9 07:43:18 2016
New Revision: 286363

URL: http://llvm.org/viewvc/llvm-project?rev=286363&view=rev
Log:
[CodeCompletion] Show block invocation results for block property setters

This commit changes the code completion results for block property setters:
The default block property result is now a block invocation rather than a simple
property reference.

rdar://28846196

Differential Revision: https://reviews.llvm.org/D26071

Added:
cfe/trunk/test/Index/complete-block-properties.m
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-block-property-assignment.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=286363&r1=286362&r2=286363&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Nov  9 07:43:18 2016
@@ -3612,6 +3612,44 @@ static ObjCContainerDecl *getContainerDe
   return Container;
 }
 
+/// \brief Adds a block invocation code completion result for the given block
+/// declaration \p BD.
+static void AddObjCBlockCall(ASTContext &Context, const PrintingPolicy &Policy,
+ CodeCompletionBuilder &Builder,
+ const NamedDecl *BD,
+ const FunctionTypeLoc &BlockLoc,
+ const FunctionProtoTypeLoc &BlockProtoLoc) {
+  Builder.AddResultTypeChunk(
+  GetCompletionTypeString(BlockLoc.getReturnLoc().getType(), Context,
+  Policy, Builder.getAllocator()));
+
+  AddTypedNameChunk(Context, Policy, BD, Builder);
+  Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+
+  if (BlockProtoLoc && BlockProtoLoc.getTypePtr()->isVariadic()) {
+Builder.AddPlaceholderChunk("...");
+  } else {
+for (unsigned I = 0, N = BlockLoc.getNumParams(); I != N; ++I) {
+  if (I)
+Builder.AddChunk(CodeCompletionString::CK_Comma);
+
+  // Format the placeholder string.
+  std::string PlaceholderStr =
+  FormatFunctionParameter(Policy, BlockLoc.getParam(I));
+
+  if (I == N - 1 && BlockProtoLoc &&
+  BlockProtoLoc.getTypePtr()->isVariadic())
+PlaceholderStr += ", ...";
+
+  // Add the placeholder string.
+  Builder.AddPlaceholderChunk(
+  Builder.getAllocator().CopyString(PlaceholderStr));
+}
+  }
+
+  Builder.AddChunk(CodeCompletionString::CK_RightParen);
+}
+
 static void AddObjCProperties(const CodeCompletionContext &CCContext,
   ObjCContainerDecl *Container,
   bool AllowCategories, bool AllowNullaryMethods,
@@ -3629,42 +3667,61 @@ static void AddObjCProperties(const Code
 if (!AddedProperties.insert(P->getIdentifier()).second)
   continue;
 
-Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
-   CurContext);
+// FIXME: Provide block invocation completion for non-statement
+// expressions.
+if (!P->getType().getTypePtr()->isBlockPointerType() ||
+!IsBaseExprStatement) {
+  Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
+ CurContext);
+  continue;
+}
+
+// Block setter and invocation completion is provided only when we are able
+// to find the FunctionProtoTypeLoc with parameter names for the block.
+FunctionTypeLoc BlockLoc;
+FunctionProtoTypeLoc BlockProtoLoc;
+findTypeLocationForBlockDecl(P->getTypeSourceInfo(), BlockLoc,
+ BlockProtoLoc);
+if (!BlockLoc) {
+  Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
+ CurContext);
+  continue;
+}
+
+// The default completion result for block properties should be the block
+// invocation completion when the base expression is a statement.
+CodeCompletionBuilder Builder(Results.getAllocator(),
+  Results.getCodeCompletionTUInfo());
+AddObjCBlockCall(Container->getASTContext(),
+ getCompletionPrintingPolicy(Results.getSema()), Builder, 
P,
+ BlockLoc, BlockProtoLoc);
+Results.MaybeAddResult(
+Result(Builder.TakeString(), P, Results.getBasePriority(P)),
+CurContext);
 
 // Provide additional block setter completion iff the base expression is a
-// statement.
-if (!P->isReadOnly() && IsBaseExprStatement &&
-P->getType().getTypePtr()->isBlockPointerType()) {
-  FunctionTypeLoc BlockLoc;
-  FunctionProtoTypeLoc BlockProtoLoc;
-  findTypeLocationForBlockDecl(P->getTypeSourceInfo(), BlockLoc,
-   BlockProtoLoc);
-
-  // Provide block setter completion only when we are able to find
-  // the FunctionProtoTy

[PATCH] D25764: Add end location of loop to loop metadata.

2016-11-09 Thread Florian Hahn via cfe-commits
fhahn updated this revision to Diff 77317.

https://reviews.llvm.org/D25764

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/debug-info-line-if.cpp
  test/CodeGenCXX/debug-info-loops.cpp

Index: test/CodeGenCXX/debug-info-loops.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-loops.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang -g -gcolumn-info -std=c++11 -S -emit-llvm %s -o - | FileCheck %s
+extern int v[2];
+int a = 0, b = 0;
+int main() {
+#line 100
+  for (int x : v) {
+if (x)
+  ++b;
+else
+  ++a;
+  }
+
+  // CHECK: br label {{.*}}, !dbg [[DBG1:![0-9]*]], !llvm.loop [[L1:![0-9]*]]
+
+#line 200
+  while (a)
+if (b)
+  ++b;
+else
+  ++a;
+  // CHECK: br label {{.*}}, !dbg [[DBG2:![0-9]*]], !llvm.loop [[L2:![0-9]*]]
+
+#line 300
+  for (unsigned i = 0; i < 100; i++) {
+a++;
+for (int y : v)
+  ++b;
+  }
+
+  // CHECK: br label {{.*}}, !dbg [[DBG3:![0-9]*]], !llvm.loop [[L3:![0-9]*]]
+  // CHECK: br label {{.*}}, !dbg [[DBG3:![0-9]*]], !llvm.loop [[L4:![0-9]*]]
+
+
+  // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[SLDBG1:![0-9]*]], [[ELDBG1:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG1]] = !DILocation(line: 100, column: 3, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG1]] = !DILocation(line: 105, column: 3, scope: !{{.*}})
+
+  // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[SLDBG2:![0-9]*]], [[ELDBG2:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG2]] = !DILocation(line: 200, column: 3, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG2]] = !DILocation(line: 204, column: 9, scope: !{{.*}})
+
+  // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[SLDBG3:![0-9]*]], [[ELDBG3:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG3]] = !DILocation(line: 302, column: 5, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG3]] = !DILocation(line: 303, column: 9, scope: !{{.*}})
+  //
+  // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[SLDBG4:![0-9]*]], [[ELDBG4:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG4]] = !DILocation(line: 300, column: 3, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG4]] = !DILocation(line: 304, column: 3, scope: !{{.*}})
+}
Index: test/CodeGenCXX/debug-info-line-if.cpp
===
--- test/CodeGenCXX/debug-info-line-if.cpp
+++ test/CodeGenCXX/debug-info-line-if.cpp
@@ -53,15 +53,19 @@
   // CHECK-DAG: [[DBG3]] = !DILocation(line: 300, scope: !{{.*}})
   // CHECK-DAG: [[DBG4]] = !DILocation(line: 401, scope: !{{.*}})
 
-  // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[LDBG1:![0-9]*]]}
-  // CHECK-DAG: [[LDBG1]] = !DILocation(line: 100, scope: !{{.*}})
+  // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[SLDBG1:![0-9]*]], [[ELDBG1:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG1]] = !DILocation(line: 100, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG1]] = !DILocation(line: 104, scope: !{{.*}})
 
-  // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[LDBG2:![0-9]*]]}
-  // CHECK-DAG: [[LDBG2]] = !DILocation(line: 200, scope: !{{.*}})
+  // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[SLDBG2:![0-9]*]], [[ELDBG2:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG2]] = !DILocation(line: 200, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG2]] = !DILocation(line: 204, scope: !{{.*}})
 
-  // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[LDBG3:![0-9]*]]}
-  // CHECK-DAG: [[LDBG3]] = !DILocation(line: 300, scope: !{{.*}})
+  // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[SLDBG3:![0-9]*]], [[ELDBG3:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG3]] = !DILocation(line: 300, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG3]] = !DILocation(line: 304, scope: !{{.*}})
 
-  // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[LDBG4:![0-9]*]]}
-  // CHECK-DAG: [[LDBG4]] = !DILocation(line: 401, scope: !{{.*}})
+  // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[SLDBG4:![0-9]*]], [[ELDBG4:![0-9]*]]}
+  // CHECK-DAG: [[SLDBG4]] = !DILocation(line: 401, scope: !{{.*}})
+  // CHECK-DAG: [[ELDBG4]] = !DILocation(line: 405, scope: !{{.*}})
 }
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2113,6 +2113,10 @@
   OffsetValue);
   }
 
+  /// Converts Location to a DebugLoc, if debug information is enabled.
+  llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location);
+
+
   //======//
   //Declaration Emission
   //======//
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -2080,3 +2080,10 @@
   IRB.SetCurrentDebugLocation(Builder.getCurrentDebugLocation());
   CGM.getSanStats().create(IRB, SSK);
 

[PATCH] D25764: Add end location of loop to loop metadata.

2016-11-09 Thread Florian Hahn via cfe-commits
fhahn added a comment.

@rjmccall thanks for the feedback. I initially kept the arguments optional 
because the single Location argument used to be optional as well.

But I think we can pass proper locations for all loops constructed by clang and 
I updated my patch to make the Start and End locations non-optional, which in 
turn required passing them through when constructing loops in 
lib/CodeGen/CGStmtOpenMP.cpp .


https://reviews.llvm.org/D25764



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


[PATCH] D26442: [analyzer] Fix crash on getSVal: handle case of CompoundVal

2016-11-09 Thread Ilya Palachev via cfe-commits
ilya-palachev created this revision.
ilya-palachev added reviewers: dcoughlin, zaks.anna, NoQ.
ilya-palachev added subscribers: cfe-commits, a.sidorin.
ilya-palachev set the repository for this revision to rL LLVM.

If the pointer to the uninitialized union is casted to the structure of another 
type, this may lead to the crash in the RegionStore. This patch tries to handle 
this bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D26442

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/uninit-vals-union.c


Index: test/Analysis/uninit-vals-union.c
===
--- /dev/null
+++ test/Analysis/uninit-vals-union.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin 
-analyzer-store=region -verify -Wno-unused %s
+
+typedef union {
+  int y;
+} U;
+
+typedef struct { int x; } A;
+
+void foo() {
+  U u = {};
+  A *a = &u; // expected-warning{{incompatible pointer types}}
+  a->x;  // no-crash
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1674,7 +1674,8 @@
 
 // Lazy bindings are usually handled through getExistingLazyBinding().
 // We should unify these two code paths at some point.
-if (val.getAs())
+if (val.getAs() ||
+val.getAs())
   return val;
 
 llvm_unreachable("Unknown default value");


Index: test/Analysis/uninit-vals-union.c
===
--- /dev/null
+++ test/Analysis/uninit-vals-union.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin -analyzer-store=region -verify -Wno-unused %s
+
+typedef union {
+  int y;
+} U;
+
+typedef struct { int x; } A;
+
+void foo() {
+  U u = {};
+  A *a = &u; // expected-warning{{incompatible pointer types}}
+  a->x;  // no-crash
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1674,7 +1674,8 @@
 
 // Lazy bindings are usually handled through getExistingLazyBinding().
 // We should unify these two code paths at some point.
-if (val.getAs())
+if (val.getAs() ||
+val.getAs())
   return val;
 
 llvm_unreachable("Unknown default value");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286365 - [AST] Dump dependent scope member expression with its member name

2016-11-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Nov  9 08:02:18 2016
New Revision: 286365

URL: http://llvm.org/viewvc/llvm-project?rev=286365&view=rev
Log:
[AST] Dump dependent scope member expression with its member name

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/Misc/ast-dump-stmt.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=286365&r1=286364&r2=286365&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Wed Nov  9 08:02:18 2016
@@ -545,6 +545,8 @@ namespace  {
   dumpDecl(Node->getLambdaClass());
 }
 void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
+void
+VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node);
 
 // ObjC
 void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
@@ -2194,6 +2196,11 @@ void ASTDumper::VisitSizeOfPackExpr(cons
   dumpTemplateArgument(A);
 }
 
+void ASTDumper::VisitCXXDependentScopeMemberExpr(
+const CXXDependentScopeMemberExpr *Node) {
+  VisitExpr(Node);
+  OS << " " << (Node->isArrow() ? "->" : ".") << Node->getMember();
+}
 
 
//===--===//
 // Obj-C Expressions

Modified: cfe/trunk/test/Misc/ast-dump-stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-stmt.cpp?rev=286365&r1=286364&r2=286365&view=diff
==
--- cfe/trunk/test/Misc/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-stmt.cpp Wed Nov  9 08:02:18 2016
@@ -65,3 +65,19 @@ void TestDependentAllocationExpr() {
 // CHECK: FunctionTemplateDecl {{.*}} TestDependentAllocationExpr
 // CHECK: CXXNewExpr {{.*'T \*'$}}
 // CHECK: CXXDeleteExpr {{.*'void'$}}
+
+template 
+class DependentScopeMemberExprWrapper {
+  T member;
+};
+
+template 
+void TestDependentScopeMemberExpr() {
+  DependentScopeMemberExprWrapper obj;
+  obj.member = T();
+  (&obj)->member = T();
+}
+
+// CHECK: FunctionTemplateDecl {{.*}} TestDependentScopeMemberExpr
+// CHECK: CXXDependentScopeMemberExpr {{.*}} lvalue .member
+// CHECK: CXXDependentScopeMemberExpr {{.*}} lvalue ->member


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


r286367 - clang-format: [TypeScript] Fix bug in handling of non-null operator.

2016-11-09 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Nov  9 08:12:55 2016
New Revision: 286367

URL: http://llvm.org/viewvc/llvm-project?rev=286367&view=rev
Log:
clang-format: [TypeScript] Fix bug in handling of non-null operator.

Before:
  var i = x!-1;

After:
  var i = x! - 1;

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=286367&r1=286366&r2=286367&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Nov  9 08:12:55 2016
@@ -1311,7 +1311,13 @@ private:
 
   TokenType determinePlusMinusCaretUsage(const FormatToken &Tok) {
 const FormatToken *PrevToken = Tok.getPreviousNonComment();
-if (!PrevToken || PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator))
+if (!PrevToken)
+  return TT_UnaryOperator;
+
+if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator) &&
+!PrevToken->is(tok::exclaim))
+  // There aren't any trailing unary operators except for TypeScript's
+  // non-null operator (!). Thus, this must be squence of leading 
operators.
   return TT_UnaryOperator;
 
 // Use heuristics to recognize unary operators.

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=286367&r1=286366&r2=286367&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Nov  9 08:12:55 2016
@@ -1462,6 +1462,7 @@ TEST_F(FormatTestJS, NonNullAssertionOpe
   verifyFormat("let x = !foo;\n");
   verifyFormat("let x = foo[0]!;\n");
   verifyFormat("let x = (foo)!;\n");
+  verifyFormat("let x = foo! - 1;\n");
   verifyFormat("let x = {foo: 1}!;\n");
 }
 


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


[PATCH] D26203: [ClangTidy - performance-unnecessary-value-param]: Do not issue fix for functions that are referenced outside of callExpr

2016-11-09 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 77343.

https://reviews.llvm.org/D26203

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -259,4 +259,21 @@
 void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
   // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
   // CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& 
A) {
+
+void PositiveOnlyMessageAsReferencedInCompilationUnit(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:75: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void 
PositiveOnlyMessageAsReferencedInCompilationUnit(ExpensiveToCopyType A) {
+}
+
+void ReferenceFunctionOutsideOfCallExpr() {
+  void (*ptr)(ExpensiveToCopyType) = 
&PositiveOnlyMessageAsReferencedInCompilationUnit;
+}
+
+void PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveMessageAndFixAsFunctionIsCalled(const 
ExpensiveToCopyType& A) {
+}
+
+void ReferenceFunctionByCallingIt() {
+  PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType());
 }
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -39,6 +39,14 @@
   return true;
 }
 
+bool isReferencedOutsideOfCallExpr(const FunctionDecl &Function,
+   ASTContext &Context) {
+  auto Matches = match(declRefExpr(to(functionDecl(equalsNode(&Function))),
+   unless(hasAncestor(callExpr(,
+   Context);
+  return !Matches.empty();
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -118,10 +126,14 @@
   "invocation but only used as a const reference; "
   "consider making it a const reference")
   << paramNameOrIndex(Param->getName(), Index);
-  // Do not propose fixes in macros since we cannot place them correctly, or if
-  // function is virtual as it might break overrides.
+  // Do not propose fixes when:
+  // 1. the ParmVarDecl is in a macro, since we cannot place them correctly
+  // 2. the function is virtual as it might break overrides
+  // 3. the function is referenced outside of a call expression within the
+  //compilation unit as the signature change could introduce build errors.
   const auto *Method = llvm::dyn_cast(Function);
-  if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()))
+  if (Param->getLocStart().isMacroID() || (Method && Method->isVirtual()) ||
+  isReferencedOutsideOfCallExpr(*Function, *Result.Context))
 return;
   for (const auto *FunctionDecl = Function; FunctionDecl != nullptr;
FunctionDecl = FunctionDecl->getPreviousDecl()) {


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -259,4 +259,21 @@
 void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
   // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
   // CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A) {
+
+void PositiveOnlyMessageAsReferencedInCompilationUnit(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:75: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveOnlyMessageAsReferencedInCompilationUnit(ExpensiveToCopyType A) {
+}
+
+void ReferenceFunctionOutsideOfCallExpr() {
+  void (*ptr)(ExpensiveToCopyType) = &PositiveOnlyMessageAsReferencedInCompilationUnit;
+}
+
+void PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:66: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveMessageAndFixAsFunctionIsCalled(const ExpensiveToCopyType& A) {
+}
+
+void ReferenceFunctionByCallingIt() {
+  PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType());
 }
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -39,6 +39,14 @@
   return true;
 }
 
+bool isReferencedOutsideOfCallExpr(const FunctionDecl &Function,
+   ASTContext &Context) {
+  auto Matche

[PATCH] D26203: [ClangTidy - performance-unnecessary-value-param]: Do not issue fix for functions that are referenced outside of callExpr

2016-11-09 Thread Felix Berger via cfe-commits
flx marked an inline comment as done.
flx added a comment.

Thanks for the review!


https://reviews.llvm.org/D26203



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


[PATCH] D16533: Bug 20796 - GCC's -Wstrict-prototypes warning not implemented in Clang

2016-11-09 Thread Alex Lorenz via cfe-commits
arphaman added reviewers: rsmith, bruno.
arphaman set the repository for this revision to rL LLVM.
arphaman updated this revision to Diff 77351.
arphaman added a comment.

I rebased the patch, adjusted the test and added a test case for Objective-C 
blocks.


Repository:
  rL LLVM

https://reviews.llvm.org/D16533

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/Sema/warn-strict-prototypes.c
  test/Sema/warn-strict-prototypes.m

Index: test/Sema/warn-strict-prototypes.m
===
--- /dev/null
+++ test/Sema/warn-strict-prototypes.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -verify -fblocks %s
+
+@interface Foo
+
+@property (nonatomic, copy) void (^noProtoBlock)(); // expected-warning {{this function declaration is not a prototype}}
+@property (nonatomic, copy) void (^block)(void); // no warning
+
+- doStuff:(void (^)()) completionHandler; // expected-warning {{this function declaration is not a prototype}}
+- doOtherStuff:(void (^)(void)) completionHandler; // no warning
+
+@end
+
+void foo() {
+  void (^block)() = // expected-warning {{this function declaration is not a prototype}}
+^void(int arg) { // no warning
+  };
+  void (^block2)(void) = // no warning
+ ^void() { // expected-warning {{this function declaration is not a prototype}}
+  };
+}
Index: test/Sema/warn-strict-prototypes.c
===
--- /dev/null
+++ test/Sema/warn-strict-prototypes.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// function declaration with unspecified params
+void foo1(); // expected-warning {{this function declaration is not a prototype}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:11}:"void"
+// function declaration with 0 params
+void foo2(void);
+
+// function definition with 0 params(for both cases),
+// valid according to 6.7.5.3/14
+void foo1() {}
+void foo2(void) {}
+
+// function type typedef unspecified params
+typedef void foo3(); // expected-warning {{this function declaration is not a prototype}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:19}:"void"
+
+// global fp unspecified params
+void (*foo4)(); // expected-warning {{this function declaration is not a prototype}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"void"
+
+// struct member fp unspecified params
+struct { void (*foo5)(); } s; // expected-warning {{this function declaration is not a prototype}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:23-[[@LINE-1]]:23}:"void"
+
+// param fp unspecified params
+void bar2(void (*foo6)()) { // expected-warning {{this function declaration is not a prototype}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:24-[[@LINE-1]]:24}:"void"
+  // local fp unspecified params
+  void (*foo7)() = 0; // expected-warning {{this function declaration is not a prototype}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"void"
+  // array fp unspecified params
+  void (*foo8[2])() = {0}; // expected-warning {{this function declaration is not a prototype}}
+   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:19}:"void"
+}
+
+// function type cast using using an anonymous function declaration
+void bar3(void) {
+  // casting function w/out prototype to unspecified params function type
+  (void)(void(*)()) foo1; // expected-warning {{this function declaration is not a prototype}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:18}:"void"
+  // .. specified params
+  (void)(void(*)(void)) foo1;
+}
+
+// K&R function definition not preceded by full prototype
+int foo9(a, b) // expected-warning {{old-style function definition is not preceded by a prototype}}
+  int a, b;
+{
+  return a + b;
+}
+
+// Function declaration with no types
+void foo10(); // expected-warning {{this function declaration is not a prototype}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:12-[[@LINE-1]]:12}:"void"
+// K&R function definition with incomplete param list declared
+void foo10(p, p2) void *p; {} // expected-warning {{old-style function definition is not preceded by a prototype}}
+
+// K&R function definition with previous prototype declared is not diagnosed.
+void foo11(int p, int p2);
+void foo11(p, p2) int p; int p2; {}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4177,6 +4177,20 @@
   if (FTI.isAmbiguous)
 warnAboutAmbiguousFunction(S, D, DeclType, T);
 
+  // GNU warning -Wstrict-prototypes
+  //   Warn 

[PATCH] D26286: [Sparc]: correct the ATOMIC_LLONG_LOCK_FREE macro

2016-11-09 Thread Douglas Katzman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286376: [Sparc] LLONG is not lock-free atomic on v8 
(authored by dougk).

Changed prior to commit:
  https://reviews.llvm.org/D26286?vs=76879&id=77353#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26286

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/atomics-inlining.c
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/CodeGen/atomics-inlining.c
===
--- cfe/trunk/test/CodeGen/atomics-inlining.c
+++ cfe/trunk/test/CodeGen/atomics-inlining.c
@@ -3,7 +3,8 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck 
%s -check-prefix=PPC64
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s 
-check-prefix=MIPS32
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck 
%s -check-prefix=MIPS64
-// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARCV8 -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARCV9 -check-prefix=SPARC
 
 unsigned char c1, c2;
 unsigned short s1, s2;
@@ -99,8 +100,10 @@
 // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst
 // SPARC: = load atomic i32, i32* @i1 seq_cst
 // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst
-// SPARC: = load atomic i64, i64* @ll1 seq_cst
-// SPARC: store atomic i64 {{.*}}, i64* @ll1 seq_cst
-// SPARC: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
-// SPARC: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
+// SPARCV8: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
+// SPARCV8: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
+// SPARCV9: load atomic i64, i64* @ll1 seq_cst, align 8
+// SPARCV9: store atomic i64 %7, i64* @ll1 seq_cst, align 8
+// SPARCV8: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
+// SPARCV8: call void @__atomic_store(i32 100, i8* getelementptr inbounds 
([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a2, i32 0, i32 0)
 }
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -6913,6 +6913,7 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
 // SPARC:#define __INT16_C_SUFFIX__
 // SPARC:#define __INT16_FMTd__ "hd"
 // SPARC:#define __INT16_FMTi__ "hi"
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -6803,7 +6803,10 @@
   PtrDiffType = SignedLong;
   break;
 }
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+// Up to 32 bits are lock-free atomic, but we're willing to do atomic ops
+// on up to 64 bits.
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   void getTargetDefines(const LangOptions &Opts,


Index: cfe/trunk/test/CodeGen/atomics-inlining.c
===
--- cfe/trunk/test/CodeGen/atomics-inlining.c
+++ cfe/trunk/test/CodeGen/atomics-inlining.c
@@ -3,7 +3,8 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC64
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64
-// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV8 -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV9 -check-prefix=SPARC
 
 unsigned char c1, c2;
 unsigned short s1, s2;
@@ -99,8 +100,10 @@
 // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst
 // SPARC: = load atomic i32, i32* @i1 seq_cst
 // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst
-// SPARC: = load atomic i64, i64* @ll1 seq_cst
-// SPARC: store atomic i64 {{.*}}, i64* @ll1 seq_cst
-// SPARC: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x i8], [100 x

r286376 - [Sparc] LLONG is not lock-free atomic on v8

2016-11-09 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Wed Nov  9 09:43:51 2016
New Revision: 286376

URL: http://llvm.org/viewvc/llvm-project?rev=286376&view=rev
Log:
[Sparc] LLONG is not lock-free atomic on v8

Differential Revision: https://reviews.llvm.org/D26286

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/CodeGen/atomics-inlining.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286376&r1=286375&r2=286376&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Nov  9 09:43:51 2016
@@ -6803,7 +6803,10 @@ public:
   PtrDiffType = SignedLong;
   break;
 }
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+// Up to 32 bits are lock-free atomic, but we're willing to do atomic ops
+// on up to 64 bits.
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   void getTargetDefines(const LangOptions &Opts,

Modified: cfe/trunk/test/CodeGen/atomics-inlining.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomics-inlining.c?rev=286376&r1=286375&r2=286376&view=diff
==
--- cfe/trunk/test/CodeGen/atomics-inlining.c (original)
+++ cfe/trunk/test/CodeGen/atomics-inlining.c Wed Nov  9 09:43:51 2016
@@ -3,7 +3,8 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck 
%s -check-prefix=PPC64
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s 
-check-prefix=MIPS32
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck 
%s -check-prefix=MIPS64
-// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARCV8 -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARCV9 -check-prefix=SPARC
 
 unsigned char c1, c2;
 unsigned short s1, s2;
@@ -99,8 +100,10 @@ void test1(void) {
 // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst
 // SPARC: = load atomic i32, i32* @i1 seq_cst
 // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst
-// SPARC: = load atomic i64, i64* @ll1 seq_cst
-// SPARC: store atomic i64 {{.*}}, i64* @ll1 seq_cst
-// SPARC: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
-// SPARC: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
+// SPARCV8: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
+// SPARCV8: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
+// SPARCV9: load atomic i64, i64* @ll1 seq_cst, align 8
+// SPARCV9: store atomic i64 %7, i64* @ll1 seq_cst, align 8
+// SPARCV8: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
+// SPARCV8: call void @__atomic_store(i32 100, i8* getelementptr inbounds 
([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a2, i32 0, i32 0)
 }

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=286376&r1=286375&r2=286376&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Nov  9 09:43:51 2016
@@ -6913,6 +6913,7 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
 // SPARC:#define __INT16_C_SUFFIX__
 // SPARC:#define __INT16_FMTd__ "hd"
 // SPARC:#define __INT16_FMTi__ "hi"


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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-09 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:423
+
+void IteratorPastEndChecker::handleComparison(CheckerContext &C,
+  const SVal &LVal,

baloghadamsoftware wrote:
> NoQ wrote:
> > a.sidorin wrote:
> > > What will happen if we write something like this:
> > > ```
> > > bool Eq1 = it1 == it2;
> > > bool Eq2 = it3 == it4;
> > > if (Eq1) {...}?
> > > ```
> > > 
> > > As I understand, we'll assume the second condition instead of first.
> > Had a look. So the problem is, we obtain the result of the comparison as a 
> > symbol, from which it is too hard to recover the operands in order to move 
> > iterator position data from one value to another.
> > 
> > Normally we obtain a simple SymbolConjured for the return value of the 
> > `operator==()` call (or, similarly, `operator!=()`). For plain-value 
> > iterators (eg. `typedef T *iterator`) we might be obtaining an actual 
> > binary symbolic expression, but even then it's not quite clear how to 
> > obtain operands (the structure of the expression might have changed due to 
> > algebraic simplifications). Additionally, LHS and RHS aren't necessarily 
> > symbols (they might be semi-concrete), so composing symbolic expressions 
> > from them in general is problematic with our symbol hierarchy, which is 
> > rarely a problem for numbers but for structural symbols it'd be a mess.
> > 
> > For now i suggest, instead of storing only the last LHS and RHS, to save a 
> > map from symbols (which are results of comparisons) to (LHS value, RHS 
> > value) pairs. This map should, apart from the obvious, be cleaned up 
> > whenever one of the iterators in the pair gets mutated (incremented or 
> > decremented). This should take care of the problem Alexey points out, and 
> > should work with semi-concrete stuff.
> > 
> > For the future i suggest to let users construct their own symbols and 
> > symbolic expressions more easily. In fact, if only we had all iterators as 
> > regions, we should have probably used SymbolMetadata for this purpose: it's 
> > easy to both recover the parent region from it and use it in symbolic 
> > expressions. We could also deprecate the confusing structural symbols 
> > (provide default-bound lazy compound values for conjured structures 
> > instead), and then it'd be possible to transition to SymbolMetadata 
> > entirely.
> Thank you for the suggestion. I am not sure if I fully understand you. If I 
> create a map where the key is the resulting symbol of the comparison, it will 
> not work because evalAssume is called for the innermost comparison. So if the 
> body of operator== (or operator!=) is inlined, then I get a binary symbolic 
> expression in evalAssume, not the SymbolConjured. This binary Symbolic 
> expression is a comparison of the internals of the iterators, e.g. the 
> internal pointer. So the key will not match any LHS and RHS value pair in the 
> map. I also thought on such solution earlier but I dismissed it because of 
> this.
Maybe if I evaluate the operator==() call for iterators using evalCall()?


https://reviews.llvm.org/D25660



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


Re: r284272 - Implement no_sanitize_address for global vars

2016-11-09 Thread Douglas Katzman via cfe-commits
will do.  I'll initiate a review for the original change and a new one for
the suggestions.

The ExpectedFunctionGlobalVarMethodOrProperty diagnostic was essentially a
copy-and-paste from here:

def Alias : Attr {
  let Spellings = [GCC<"alias">];
  let Args = [StringArgument<"Aliasee">];
  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
 "ExpectedFunctionGlobalVarMethodOrProperty">;
  let Documentation = [Undocumented];
}

I guess that one's wrong?  That'll teach me to look at existing code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26452: Make output of -ast-print a valid C++ code.

2016-11-09 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: ABataev, gribozavr, rtrieu.
sepavloff added a subscriber: cfe-commits.

Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.

Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.

The change affects many test files but the changes are mostly
mechanical. Two main reasons why the test files require update are:

- change in form of template specialization output,
- template now is printed before its specializations.


https://reviews.llvm.org/D26452

Files:
  lib/AST/DeclPrinter.cpp
  test/Analysis/cfg.cpp
  test/Coverage/ast-print-func.cpp
  test/Coverage/ast-print-temp-class.cpp
  test/Coverage/ast-print-temp-func.cpp
  test/Coverage/ast-printing.cpp
  test/Index/comment-cplus-decls.cpp
  test/Index/comment-to-html-xml-conversion.cpp
  test/Misc/ast-dump-templates.cpp
  test/OpenMP/atomic_ast_print.cpp
  test/OpenMP/barrier_ast_print.cpp
  test/OpenMP/critical_ast_print.cpp
  test/OpenMP/declare_reduction_ast_print.cpp
  test/OpenMP/declare_simd_ast_print.cpp
  test/OpenMP/declare_target_ast_print.cpp
  test/OpenMP/distribute_ast_print.cpp
  test/OpenMP/distribute_dist_schedule_ast_print.cpp
  test/OpenMP/distribute_parallel_for_ast_print.cpp
  test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
  test/OpenMP/distribute_simd_ast_print.cpp
  test/OpenMP/flush_ast_print.cpp
  test/OpenMP/for_ast_print.cpp
  test/OpenMP/for_simd_ast_print.cpp
  test/OpenMP/ordered_ast_print.cpp
  test/OpenMP/parallel_ast_print.cpp
  test/OpenMP/parallel_for_ast_print.cpp
  test/OpenMP/parallel_for_simd_ast_print.cpp
  test/OpenMP/parallel_sections_ast_print.cpp
  test/OpenMP/sections_ast_print.cpp
  test/OpenMP/simd_ast_print.cpp
  test/OpenMP/single_ast_print.cpp
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_data_ast_print.cpp
  test/OpenMP/target_data_use_device_ptr_ast_print.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_is_device_ptr_ast_print.cpp
  test/OpenMP/target_parallel_ast_print.cpp
  test/OpenMP/target_parallel_for_ast_print.cpp
  test/OpenMP/target_parallel_for_simd_ast_print.cpp
  test/OpenMP/target_simd_ast_print.cpp
  test/OpenMP/target_update_ast_print.cpp
  test/OpenMP/task_ast_print.cpp
  test/OpenMP/taskloop_ast_print.cpp
  test/OpenMP/taskloop_simd_ast_print.cpp
  test/OpenMP/taskwait_ast_print.cpp
  test/OpenMP/taskyield_ast_print.cpp
  test/OpenMP/teams_ast_print.cpp
  test/OpenMP/teams_distribute_ast_print.cpp
  test/OpenMP/teams_distribute_simd_ast_print.cpp
  test/OpenMP/threadprivate_ast_print.cpp
  test/SemaTemplate/temp_arg_enum_printing.cpp
  unittests/AST/ASTTypeTraitsTest.cpp
  unittests/AST/DeclPrinterTest.cpp

Index: unittests/AST/DeclPrinterTest.cpp
===
--- unittests/AST/DeclPrinterTest.cpp
+++ unittests/AST/DeclPrinterTest.cpp
@@ -254,178 +254,157 @@
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "class A { int a; };",
 "A",
-"class A {\n}"));
-// Should be: with semicolon, with { ... }
+"class A {}"));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl2) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "struct A { int a; };",
 "A",
-"struct A {\n}"));
-// Should be: with semicolon, with { ... }
+"struct A {}"));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl3) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "union A { int a; };",
 "A",
-"union A {\n}"));
-// Should be: with semicolon, with { ... }
+"union A {}"));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl4) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "class Z { int a; };"
 "class A : Z { int b; };",
 "A",
-"class A : Z {\n}"));
-// Should be: with semicolon, with { ... }
+"class A : Z {}"));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl5) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "struct Z { int a; };"
 "struct A : Z { int b; };",
 "A",
-"struct A : Z {\n}"));
-// Should be: with semicolon, with { ... }
+"struct A : Z {}"));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl6) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "class Z { int a; };"
 "class A : public Z { int b; };",
 "A",
-"class A : public Z {\n}"));
-// Should be: with semicolon, with { ... }
+"class A : public Z {}"));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl7) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
 "class Z { int a; };"
 "class A : protected Z { int b; };",
 "A",
-"class A : protected Z {\n}"))

Re: r285543 - Make output of ast-print closer to C++ code

2016-11-09 Thread Serge Pavlov via cfe-commits
The patch https://reviews.llvm.org/D26452 implements testing for output
made with -ast-print, it fixes problems which this commit addressed
(file declare_simd_ast_print.cpp) and tests them.

Thanks,
--Serge

2016-11-02 23:39 GMT+07:00 Richard Smith :

> Test?
>
> On 30 Oct 2016 10:20 pm, "Serge Pavlov via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sepavloff
>> Date: Mon Oct 31 00:11:12 2016
>> New Revision: 285543
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=285543&view=rev
>> Log:
>> Make output of ast-print closer to C++ code
>>
>> Put semicolon after non-defining method declaration and a class
>> specialization body.
>>
>> Modified:
>> cfe/trunk/lib/AST/DeclPrinter.cpp
>>
>> Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPr
>> inter.cpp?rev=285543&r1=285542&r2=285543&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Oct 31 00:11:12 2016
>> @@ -337,10 +337,9 @@ void DeclPrinter::VisitDeclContext(DeclC
>>  const char *Terminator = nullptr;
>>  if (isa(*D) || isa(*
>> D))
>>Terminator = nullptr;
>> -else if (isa(*D) &&
>> - cast(*D)->isThisDeclarationADefinition())
>> +else if (isa(*D) && cast(*D)->hasBody())
>>Terminator = nullptr;
>> -else if (isa(*D) && cast(*D)->getB
>> ody())
>> +else if (isa(*D) && cast(*D)->hasB
>> ody())
>>Terminator = nullptr;
>>  else if (isa(*D) || isa(*D) ||
>>   isa(*D) ||
>> @@ -984,7 +983,7 @@ void DeclPrinter::VisitClassTemplateDecl
>>  for (auto *I : D->specializations()) {
>>PrintTemplateParameters(Params, &I->getTemplateArgs());
>>Visit(I);
>> -  Out << '\n';
>> +  Out << ";\n";
>>  }
>>}
>>
>>
>>
>> ___
>> 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] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh, flx.
malcolm.parsons added a subscriber: cfe-commits.

An addition to the move-constructor-init check was duplicating the
modernize-pass-by-value check.
Remove the additional check and UseCERTSemantics option.
Run the move-constructor-init test with both checks enabled.
Fix modernize-pass-by-value false-positive when initializing a base
class.


https://reviews.llvm.org/D26453

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- -- -std=c++11 -isystem %S/Inputs/Headers
 
 #include 
 
@@ -96,7 +96,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: pass by value and use std::move [modernize-pass-by-value]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
@@ -121,7 +121,6 @@
 };
 
 struct NegativeNotPassedByValue {
-  NegativeNotPassedByValue(const Movable &M) : M_(M) {}
   NegativeNotPassedByValue(const Movable M) : M_(M) {}
   NegativeNotPassedByValue(Movable &M) : M_(M) {}
   NegativeNotPassedByValue(Movable *M) : M_(*M) {}
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -9,20 +9,10 @@
 initializing a member or base class through a copy constructor instead of a
 move constructor.
 
-It also flags constructor arguments that are passed by value, have a non-deleted
-move-constructor and are assigned to a class field by copy construction.
-
 Options
 ---
 
 .. option:: IncludeStyle
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
-
-.. option:: UseCERTSemantics
-
-   When non-zero, the check conforms to the behavior expected by the CERT secure
-   coding recommendation
-   `OOP11-CPP `_.
-   Default is `0` for misc-move-constructor-init and `1` for cert-oop11-cpp.
Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -136,7 +136,8 @@
   cxxConstructorDecl(
   forEachConstructorInitializer(
   cxxCtorInitializer(
-  // Clang builds a CXXConstructExpr only whin it knows which
+  unless(isBaseInitializer()),
+  // Clang builds a CXXConstructExpr only when it knows which
   // constructor will be called. In dependent contexts a
   // ParenListExpr is generated instead of a CXXConstructExpr,
   // filtering out templates automatically for us.
Index: clang-tidy/misc/MoveConstructorInitCheck.h
===
--- clang-tidy/misc/MoveConstructorInitCheck.h
+++ clang-tidy/misc/MoveConstructorInitCheck.h
@@ -33,14 +33,8 @@
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
 
 private:
-  void
-  handleMoveConstructor(const ast_matchers::MatchFinder::MatchResult &Result);
-  void
-  handleParamNotMoved(const ast_matchers::MatchFinder::MatchResult &Result);
-
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
-  const bool UseCERTSemantics;
 };
 
 } // namespace misc
Index: clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -21,30 +21,11 @@
 namespace tidy {
 namespace misc {
 
-namespace {
-
-unsigned int
-parmVarDeclRefExprOccurences(const ParmVarDecl &MovableParam,
- const CXXConstructorDecl &ConstructorDecl,
- ASTContext &Context) {
-  unsigned int Occurrences = 0;
-  auto AllDeclRefs =
-  findAll(declRefExpr(to(parmVarDecl(equalsNode(&MovableParam);
-  Occurrences += match(AllDecl

[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-09 Thread Felix Berger via cfe-commits
flx added a comment.

Is the modernize-pass-by-value check configurable in a way to only trigger when 
copied constructor arguments are not moved?

I think our use case has been to have move-constructor-init check enabled to 
catch cases that can be optimized but not trigger on every constructor that 
uses const& instead of value + move, i.e. modernizing is not prescribed, but 
catching cases where the argument is already passed by value and making them 
faster is desirable.


https://reviews.llvm.org/D26453



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


[PATCH] D26454: Implement no_sanitize_address for global vars

2016-11-09 Thread Douglas Katzman via cfe-commits
dougk created this revision.
dougk added a reviewer: aaron.ballman.
dougk added a subscriber: cfe-commits.

This was already submitted as r284272.

Regarding the use of Attr as a local variable name, I would prefer to remain 
consistent with the existing code in CodeGenFunction.cpp which was not touched 
by this patch.

line 720:  for (auto Attr : D->specific_attrs())

but I'm certainly not opposed to changing both places.


https://reviews.llvm.org/D26454

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/CodeGen/SanitizerMetadata.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/asan-globals.cpp
  test/SemaCXX/attr-no-sanitize-address.cpp
  test/SemaCXX/attr-no-sanitize.cpp

Index: test/SemaCXX/attr-no-sanitize.cpp
===
--- test/SemaCXX/attr-no-sanitize.cpp
+++ test/SemaCXX/attr-no-sanitize.cpp
@@ -2,8 +2,6 @@
 // RUN: not %clang_cc1 -std=c++11 -ast-dump %s | FileCheck --check-prefix=DUMP %s
 // RUN: not %clang_cc1 -std=c++11 -ast-print %s | FileCheck --check-prefix=PRINT %s
 
-int v1 __attribute__((no_sanitize("address"))); // expected-error{{'no_sanitize' attribute only applies to functions and methods}}
-
 int f1() __attribute__((no_sanitize)); // expected-error{{'no_sanitize' attribute takes at least 1 argument}}
 
 int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' attribute requires a string}}
Index: test/SemaCXX/attr-no-sanitize-address.cpp
===
--- test/SemaCXX/attr-no-sanitize-address.cpp
+++ test/SemaCXX/attr-no-sanitize-address.cpp
@@ -21,9 +21,6 @@
   return x;
 }
 
-int noanal_test_var NO_SANITIZE_ADDRESS; // \
-  // expected-error {{'no_sanitize_address' attribute only applies to functions}}
-
 class NoanalFoo {
  private:
   int test_field NO_SANITIZE_ADDRESS; // \
Index: test/CodeGen/asan-globals.cpp
===
--- test/CodeGen/asan-globals.cpp
+++ test/CodeGen/asan-globals.cpp
@@ -7,6 +7,7 @@
 
 int global;
 int dyn_init_global = global;
+int __attribute__((no_sanitize("address"))) attributed_global;
 int blacklisted_global;
 
 void func() {
@@ -14,24 +15,26 @@
   const char *literal = "Hello, world!";
 }
 
-// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, i1 false}
 // CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 8, i32 5}
 // CHECK: ![[DYN_INIT_GLOBAL]] = !{{{.*}} ![[DYN_INIT_LOC:[0-9]+]], !"dyn_init_global", i1 true, i1 false}
 // CHECK: ![[DYN_INIT_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 9, i32 5}
+// CHECK: ![[ATTR_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
 // CHECK: ![[BLACKLISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
 // CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 false, i1 false}
-// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 13, i32 14}
+// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 14, i32 14}
 // CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"", i1 false, i1 false}
-// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 14, i32 25}
+// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}asan-globals.cpp", i32 15, i32 25}
 
-// BLACKLIST-SRC: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// BLACKLIST-SRC: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[ATTR_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
 // BLACKLIST-SRC: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], !"extra_global", i1 false, i1 false}
 // BLACKLIST-SRC: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // BLACKLIST-SRC: ![[GLOBAL]] = !{{{.*}} null, null, i1 false, i1 true}
 // BLACKLIST-SRC: ![[DYN_INIT_GLOBAL]] = !{{{.*}} null, null, i1 true, i1 true}
+// BLACKLIST-SRC: ![[ATTR_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
 // BLACKLIST-SRC: ![[BLACKLISTED_GLOBAL]] = !{{{.*}}, null, null, i1 false, i1 true}
 // BLACKLIST-SRC: ![[STATIC_VAR]] = !{{{.*}} null, null, i1 false, i1 true}
 // BLACKLIST-SRC: ![[LITERAL]] = !{{{.*}} null, null, i1 false, i1 true}
Index: lib/Sema/Se

[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26453#590636, @flx wrote:

> Is the modernize-pass-by-value check configurable in a way to only trigger 
> when copied constructor arguments are not moved?


No; good idea.


https://reviews.llvm.org/D26453



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


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 77358.
malcolm.parsons added a comment.

Update comment in performance-unnecessary-value-param check.


https://reviews.llvm.org/D26453

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- -- -std=c++11 -isystem %S/Inputs/Headers
 
 #include 
 
@@ -96,7 +96,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: pass by value and use std::move [modernize-pass-by-value]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
@@ -121,7 +121,6 @@
 };
 
 struct NegativeNotPassedByValue {
-  NegativeNotPassedByValue(const Movable &M) : M_(M) {}
   NegativeNotPassedByValue(const Movable M) : M_(M) {}
   NegativeNotPassedByValue(Movable &M) : M_(M) {}
   NegativeNotPassedByValue(Movable *M) : M_(*M) {}
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -9,20 +9,10 @@
 initializing a member or base class through a copy constructor instead of a
 move constructor.
 
-It also flags constructor arguments that are passed by value, have a non-deleted
-move-constructor and are assigned to a class field by copy construction.
-
 Options
 ---
 
 .. option:: IncludeStyle
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
-
-.. option:: UseCERTSemantics
-
-   When non-zero, the check conforms to the behavior expected by the CERT secure
-   coding recommendation
-   `OOP11-CPP `_.
-   Default is `0` for misc-move-constructor-init and `1` for cert-oop11-cpp.
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -75,7 +75,7 @@
 
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
-  //misc-move-constructor-init which will suggest to move the argument.
+  //modernize-pass-by-value which will suggest to move the argument.
   if (!IsConstQualified && (llvm::isa(Function) ||
 !Function->doesThisDeclarationHaveABody()))
 return;
Index: clang-tidy/modernize/PassByValueCheck.cpp
===
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -136,7 +136,8 @@
   cxxConstructorDecl(
   forEachConstructorInitializer(
   cxxCtorInitializer(
-  // Clang builds a CXXConstructExpr only whin it knows which
+  unless(isBaseInitializer()),
+  // Clang builds a CXXConstructExpr only when it knows which
   // constructor will be called. In dependent contexts a
   // ParenListExpr is generated instead of a CXXConstructExpr,
   // filtering out templates automatically for us.
Index: clang-tidy/misc/MoveConstructorInitCheck.h
===
--- clang-tidy/misc/MoveConstructorInitCheck.h
+++ clang-tidy/misc/MoveConstructorInitCheck.h
@@ -33,14 +33,8 @@
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
 
 private:
-  void
-  handleMoveConstructor(const ast_matchers::MatchFinder::MatchResult &Result);
-  void
-  handleParamNotMoved(const ast_matchers::MatchFinder::MatchResult &Result);
-
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
-  const bool UseCERTSemantics;
 };
 
 } // namespace misc
Index: clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tidy/misc/MoveConstructo

Re: r286243 - [clang-format] Remove (SourceManager, FileID) variants

2016-11-09 Thread Galina Kistanova via cfe-commits
Thank you!

On Tue, Nov 8, 2016 at 11:57 AM, Daniel Jasper  wrote:

> Fixed in r286279.
>
> On Tue, Nov 8, 2016 at 10:45 AM, Galina Kistanova 
> wrote:
>
>> Hello Daniel,
>>
>> This commit broke at least one of our builders:
>> http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/234
>>
>> Please have a look at this?
>>
>> Thanks
>>
>> Galina
>>
>> On Tue, Nov 8, 2016 at 8:11 AM, Daniel Jasper via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: djasper
>>> Date: Tue Nov  8 10:11:33 2016
>>> New Revision: 286243
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=286243&view=rev
>>> Log:
>>> [clang-format] Remove (SourceManager, FileID) variants
>>>
>>> In Format, remove the reformat() and clean() functions taking a
>>> SourceManager
>>> and a FileID. Keep the versions taking StringRef Code.
>>>
>>> - there was duplicated functionality
>>> - the FileID versions were harder to use
>>> - the clean() version is dead code anyways
>>>
>>> Patch by Krasimir Georgiev. Thank you.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Format/Format.h
>>> cfe/trunk/lib/Format/Format.cpp
>>> cfe/trunk/lib/Index/CommentToXML.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Format/Format.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Format/Format.h?rev=286243&r1=286242&r2=286243&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Format/Format.h (original)
>>> +++ cfe/trunk/include/clang/Format/Format.h Tue Nov  8 10:11:33 2016
>>> @@ -794,7 +794,7 @@ llvm::Expected
>>>  cleanupAroundReplacements(StringRef Code, const tooling::Replacements
>>> &Replaces,
>>>const FormatStyle &Style);
>>>
>>> -/// \brief Reformats the given \p Ranges in the file \p ID.
>>> +/// \brief Reformats the given \p Ranges in \p Code.
>>>  ///
>>>  /// Each range is extended on either end to its next bigger logic unit,
>>> i.e.
>>>  /// everything that might influence its formatting or might be
>>> influenced by its
>>> @@ -806,31 +806,15 @@ cleanupAroundReplacements(StringRef Code
>>>  /// If ``IncompleteFormat`` is non-null, its value will be set to true
>>> if any
>>>  /// of the affected ranges were not formatted due to a non-recoverable
>>> syntax
>>>  /// error.
>>> -tooling::Replacements reformat(const FormatStyle &Style,
>>> -   SourceManager &SourceMgr, FileID ID,
>>> -   ArrayRef Ranges,
>>> -   bool *IncompleteFormat = nullptr);
>>> -
>>> -/// \brief Reformats the given \p Ranges in \p Code.
>>> -///
>>> -/// Otherwise identical to the reformat() function using a file ID.
>>>  tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
>>> ArrayRef Ranges,
>>> StringRef FileName = "",
>>> bool *IncompleteFormat = nullptr);
>>>
>>> -/// \brief Clean up any erroneous/redundant code in the given \p Ranges
>>> in the
>>> -/// file \p ID.
>>> -///
>>> -/// Returns the ``Replacements`` that clean up all \p Ranges in the
>>> file \p ID.
>>> -tooling::Replacements cleanup(const FormatStyle &Style,
>>> -  SourceManager &SourceMgr, FileID ID,
>>> -  ArrayRef Ranges);
>>> -
>>>  /// \brief Clean up any erroneous/redundant code in the given \p Ranges
>>> in \p
>>>  /// Code.
>>>  ///
>>> -/// Otherwise identical to the cleanup() function using a file ID.
>>> +/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
>>>  tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
>>>ArrayRef Ranges,
>>>StringRef FileName = "");
>>>
>>> Modified: cfe/trunk/lib/Format/Format.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/For
>>> mat.cpp?rev=286243&r1=286242&r2=286243&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Format/Format.cpp (original)
>>> +++ cfe/trunk/lib/Format/Format.cpp Tue Nov  8 10:11:33 2016
>>> @@ -1719,18 +1719,6 @@ cleanupAroundReplacements(StringRef Code
>>>return processReplacements(Cleanup, Code, NewReplaces, Style);
>>>  }
>>>
>>> -tooling::Replacements reformat(const FormatStyle &Style, SourceManager
>>> &SM,
>>> -   FileID ID, ArrayRef
>>> Ranges,
>>> -   bool *IncompleteFormat) {
>>> -  FormatStyle Expanded = expandPresets(Style);
>>> -  if (Expanded.DisableFormat)
>>> -return tooling::Replacements();
>>> -
>>> -  Environment Env(SM, ID, Ranges);
>>> -  Formatter Format(Env, Expanded, IncompleteFormat);
>>> -  return Format.process();
>>> -}
>>> -
>>>  tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
>>> ArrayRef

r286380 - [Sparc] Unbreak test

2016-11-09 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Wed Nov  9 11:02:07 2016
New Revision: 286380

URL: http://llvm.org/viewvc/llvm-project?rev=286380&view=rev
Log:
[Sparc] Unbreak test

Modified:
cfe/trunk/test/CodeGen/atomics-inlining.c

Modified: cfe/trunk/test/CodeGen/atomics-inlining.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomics-inlining.c?rev=286380&r1=286379&r2=286380&view=diff
==
--- cfe/trunk/test/CodeGen/atomics-inlining.c (original)
+++ cfe/trunk/test/CodeGen/atomics-inlining.c Wed Nov  9 11:02:07 2016
@@ -103,7 +103,7 @@ void test1(void) {
 // SPARCV8: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
 // SPARCV8: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
 // SPARCV9: load atomic i64, i64* @ll1 seq_cst, align 8
-// SPARCV9: store atomic i64 %7, i64* @ll1 seq_cst, align 8
+// SPARCV9: store atomic i64 {{.*}}, i64* @ll1 seq_cst, align 8
 // SPARCV8: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
 // SPARCV8: call void @__atomic_store(i32 100, i8* getelementptr inbounds 
([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a2, i32 0, i32 0)
 }


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


[PATCH] D24933: Enable configuration files in clang

2016-11-09 Thread Hans Wennborg via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D24933#590493, @sepavloff wrote:

> > For Chromium, our build system provides a specific Clang version close to 
> > ToT, and obviously what flags to use when invoking it. (Developers can of 
> > course override the flags when configuring if they want.) Now maybe a 
> > developer has a ~/clang.cfg because they want certain flags on by default 
> > when they build *other* projects, those flags would now be applied to all 
> > clangs, including the one we provide, and potentially wreak havoc.
>
> Default config file is searched for only in the directory where clang 
> executable resides. It allows SDK suppliers to customize compiler, for 
> instance by turning off unneeded warnings, by providing their own 
> `clang.cfg`. On the other hand developers cannot by accident override default 
> setting because `clang.cfg` is placed in system directory.


I thought one of the stated goals for this patch would be to allow users to set 
default flags without touching the project's build system.

What about this line?

  static const ArrayRef SearchDirs({ "~/.llvm", "/etc/llvm" });

That sounds like you'll be searching the home directory for a default config 
file.

And even if we ignore that, the CLANGCFG environment variable presents the same 
problem.

Let's say a developer uses that to point to a config file with their favourite 
compiler flags for compiling on their x86_64 machine.

But then they want to build something using the Android NDK, whose Clang will 
now pull in that config file and start passing flags which doesn't apply to the 
target, e.g. ARM. The user might not even be invoking the NDK directly; it 
might be through Android Studio which certainly doesn't expect other flags to 
be used than the ones it passes.


https://reviews.llvm.org/D24933



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


[PATCH] D26457: Protect smart-pointer tests under no exceptions

2016-11-09 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, rmaprath, mclow.lists.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception be thrown under no-exceptions.


https://reviews.llvm.org/D26457

Files:
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp


Index: 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
===
--- 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@
 }
 }
 assert(A::count == 0);
+#endif
 }
Index: 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===
--- 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));


Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@
 }
 }
 assert(A::count == 0);
+#endif
 }
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26456: Handle adding new nested namespace in old namespace.

2016-11-09 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: hokein.
ioeric added a subscriber: cfe-commits.

https://reviews.llvm.org/D26456

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -97,6 +97,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
   NewNamespace = "na::nc";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -57,16 +57,19 @@
 }
 
 // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`.
-// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is
-// returned.
+// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName`
+// is empty, nullptr is returned.
 // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then
 // the NamespaceDecl of namespace "a" will be returned.
 const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs,
llvm::StringRef PartialNsName) {
+  if (!InnerNs || PartialNsName.empty())
+return nullptr;
   const auto *CurrentContext = llvm::cast(InnerNs);
   const auto *CurrentNs = InnerNs;
   llvm::SmallVector PartialNsNameSplitted;
-  PartialNsName.split(PartialNsNameSplitted, "::");
+  PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1,
+  /*KeepEmpty=*/false);
   while (!PartialNsNameSplitted.empty()) {
 // Get the inner-most namespace in CurrentContext.
 while (CurrentContext && !llvm::isa(CurrentContext))
@@ -468,16 +471,22 @@
   // "x::y" will be inserted inside the existing namespace "a" and after 
"a::b".
   // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b"
   // in the above example.
-  // FIXME: consider the case where DiffOldNamespace is empty.
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc;
+  if (OuterNs) {
+SourceLocation LocAfterNs =
+getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
+   Result.Context->getLangOpts());
+assert(LocAfterNs.isValid() &&
+   "Failed to get location after DiffOldNamespace");
+InsertionLoc = LocAfterNs;
+  } else {
+InsertionLoc = Start;
+  }
   MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(LocAfterNs));
-
+  Result.SourceManager->getSpellingLoc(InsertionLoc));
   MoveNs.FID = Result.SourceManager->getFileID(Start);
   MoveNs.SourceMgr = Result.SourceManager;
   MoveNamespaces[R.getFilePath()].push_back(MoveNs);


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -97,6 +97,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A 

[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-09 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception be thrown.


https://reviews.llvm.org/D26458

Files:
  test/std/language.support/support.exception/except.nested/assign.pass.cpp
  test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
  
test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp

Index: test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
===
--- test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
+++ test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -32,6 +33,7 @@
 std::nested_exception e;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -53,4 +55,5 @@
 }
 }
 }
+#endif
 }
Index: test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
===
--- test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
+++ test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -33,6 +34,7 @@
 std::nested_exception e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -55,4 +57,5 @@
 }
 }
 }
+#endif
 }
Index: test/std/language.support/support.exception/except.nested/assign.pass.cpp
===
--- test/std/language.support/support.exception/except.nested/assign.pass.cpp
+++ test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -34,6 +35,7 @@
 e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -57,4 +59,5 @@
 }
 }
 }
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26459: Fix mismatched enum value name and diagnostic text.

2016-11-09 Thread Douglas Katzman via cfe-commits
dougk created this revision.
dougk added a reviewer: aaron.ballman.
dougk added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

ExpectedFunctionGlobalVarMethodOrProperty would previously say "functions and 
global variables" instead of "functions, methods, properties, and global 
variables"

The newly added ExpectedFunctionOrGlobalVariable says "functions and global 
variables"


https://reviews.llvm.org/D26459

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h


Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -885,6 +885,7 @@
   ExpectedFunction,
   ExpectedUnion,
   ExpectedVariableOrFunction,
+  ExpectedFunctionOrGlobalVar,
   ExpectedFunctionVariableOrObjCInterface,
   ExpectedFunctionOrMethod,
   ExpectedParameter,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2597,6 +2597,7 @@
   "functions"
   "|unions"
   "|variables and functions"
+  "|functions and global variables"
   "|functions, variables, and Objective-C interfaces"
   "|functions and methods"
   "|parameters"
@@ -2627,7 +2628,7 @@
   "|functions, variables, classes, and Objective-C interfaces"
   "|Objective-C protocols"
   "|variables with static or thread storage duration"
-  "|functions and global variables"
+  "|functions, methods, properties, and global variables"
   "|structs, unions, and typedefs"
   "|structs and typedefs"
   "|interface or protocol declarations"
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -382,7 +382,7 @@
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
- "ExpectedFunctionGlobalVarMethodOrProperty">;
+ "ExpectedFunctionOrGlobalVar">;
   let Documentation = [Undocumented];
 }
 
@@ -1746,7 +1746,7 @@
GCC<"no_sanitize_thread">,
GNU<"no_sanitize_memory">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
-"ExpectedFunctionGlobalVarMethodOrProperty">;
+"ExpectedFunctionOrGlobalVar">;
   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
NoSanitizeMemoryDocs];
   let ASTNode = 0;


Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -885,6 +885,7 @@
   ExpectedFunction,
   ExpectedUnion,
   ExpectedVariableOrFunction,
+  ExpectedFunctionOrGlobalVar,
   ExpectedFunctionVariableOrObjCInterface,
   ExpectedFunctionOrMethod,
   ExpectedParameter,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2597,6 +2597,7 @@
   "functions"
   "|unions"
   "|variables and functions"
+  "|functions and global variables"
   "|functions, variables, and Objective-C interfaces"
   "|functions and methods"
   "|parameters"
@@ -2627,7 +2628,7 @@
   "|functions, variables, classes, and Objective-C interfaces"
   "|Objective-C protocols"
   "|variables with static or thread storage duration"
-  "|functions and global variables"
+  "|functions, methods, properties, and global variables"
   "|structs, unions, and typedefs"
   "|structs and typedefs"
   "|interface or protocol declarations"
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -382,7 +382,7 @@
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
- "ExpectedFunctionGlobalVarMethodOrProperty">;
+ "ExpectedFunctionOrGlobalVar">;
   let Documentation = [Undocumented];
 }
 
@@ -1746,7 +1746,7 @@
GCC<"no_sanitize_thread">,
GNU<"no_sanitize_memory">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
-"ExpectedFunctionGlobalVarMethodOrProperty">;
+"ExpectedFunctionOrGlobalVar">;
   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
NoSanitizeMemoryDocs];
   let ASTNode = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26459: Fix mismatched enum value name and diagnostic text.

2016-11-09 Thread Douglas Katzman via cfe-commits
dougk updated this revision to Diff 77367.
dougk added a comment.

inadvertent omission of attr-section.c test


https://reviews.llvm.org/D26459

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  test/Sema/attr-section.c


Index: test/Sema/attr-section.c
===
--- test/Sema/attr-section.c
+++ test/Sema/attr-section.c
@@ -10,7 +10,7 @@
 
 // PR6007
 void test() {
-  __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' 
attribute only applies to functions and global variables}}
+  __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' 
attribute only applies to functions, methods, properties, and global variables}}
   __attribute__((section("NEAR,x"))) static int n2; // ok.
 }
 
@@ -18,4 +18,4 @@
 void __attribute__((section("foo,zed"))) test2(void); // expected-note 
{{previous attribute is here}}
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning 
{{section does not match previous declaration}}
 
-enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions and global variables}}
+enum __attribute__((section("NEAR,x"))) e { one }; // expected-error 
{{'section' attribute only applies to functions, methods, properties, and 
global variables}}
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -885,6 +885,7 @@
   ExpectedFunction,
   ExpectedUnion,
   ExpectedVariableOrFunction,
+  ExpectedFunctionOrGlobalVar,
   ExpectedFunctionVariableOrObjCInterface,
   ExpectedFunctionOrMethod,
   ExpectedParameter,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2597,6 +2597,7 @@
   "functions"
   "|unions"
   "|variables and functions"
+  "|functions and global variables"
   "|functions, variables, and Objective-C interfaces"
   "|functions and methods"
   "|parameters"
@@ -2627,7 +2628,7 @@
   "|functions, variables, classes, and Objective-C interfaces"
   "|Objective-C protocols"
   "|variables with static or thread storage duration"
-  "|functions and global variables"
+  "|functions, methods, properties, and global variables"
   "|structs, unions, and typedefs"
   "|structs and typedefs"
   "|interface or protocol declarations"
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -382,7 +382,7 @@
   let Spellings = [GCC<"alias">];
   let Args = [StringArgument<"Aliasee">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
- "ExpectedFunctionGlobalVarMethodOrProperty">;
+ "ExpectedFunctionOrGlobalVar">;
   let Documentation = [Undocumented];
 }
 
@@ -1746,7 +1746,7 @@
GCC<"no_sanitize_thread">,
GNU<"no_sanitize_memory">];
   let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
-"ExpectedFunctionGlobalVarMethodOrProperty">;
+"ExpectedFunctionOrGlobalVar">;
   let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
NoSanitizeMemoryDocs];
   let ASTNode = 0;


Index: test/Sema/attr-section.c
===
--- test/Sema/attr-section.c
+++ test/Sema/attr-section.c
@@ -10,7 +10,7 @@
 
 // PR6007
 void test() {
-  __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions and global variables}}
+  __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions, methods, properties, and global variables}}
   __attribute__((section("NEAR,x"))) static int n2; // ok.
 }
 
@@ -18,4 +18,4 @@
 void __attribute__((section("foo,zed"))) test2(void); // expected-note {{previous attribute is here}}
 void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}
 
-enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions and global variables}}
+enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions, methods, properties, and global variables}}
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -885,6 +885,7 @@
   ExpectedFunction,
   ExpectedUnion,
   ExpectedVariableOrFunction,
+  ExpectedFunctionOrGlobalVar,
   ExpectedFunctionVariableOrObjC

[clang-tools-extra] r286381 - Fix grammar

2016-11-09 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Wed Nov  9 11:47:56 2016
New Revision: 286381

URL: http://llvm.org/viewvc/llvm-project?rev=286381&view=rev
Log:
Fix grammar

"allow" requires a direct object in this case.

Modified:
clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=286381&r1=286380&r2=286381&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Wed Nov  
9 11:47:56 2016
@@ -5,8 +5,8 @@
 
 ;;; Commentary:
 
-;; This package allows to invoke the 'clang-include-fixer' within Emacs.
-;; 'clang-include-fixer' provides an automated way of adding #include
+;; This package allows Emacs users to invoke the 'clang-include-fixer' within
+;; Emacs.  'clang-include-fixer' provides an automated way of adding #include
 ;; directives for missing symbols in one translation unit, see
 ;; .
 


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


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 77371.
malcolm.parsons updated the summary for this revision.
malcolm.parsons added a comment.

Add ValuesOnly option to modernize-pass-by-value.


https://reviews.llvm.org/D26453

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/modernize-pass-by-value.rst
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -1,4 +1,7 @@
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: modernize-pass-by-value.ValuesOnly, value: 1}]}' \
+// RUN: -- -std=c++11 -isystem %S/Inputs/Headers
 
 #include 
 
@@ -28,8 +31,8 @@
   D() : B() {}
   D(const D &RHS) : B(RHS) {}
   // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init]
-  // CHECK-MESSAGES: 23:3: note: copy constructor being called
-  // CHECK-MESSAGES: 24:3: note: candidate move constructor here
+  // CHECK-MESSAGES: 26:3: note: copy constructor being called
+  // CHECK-MESSAGES: 27:3: note: candidate move constructor here
   D(D &&RHS) : B(RHS) {}
 };
 
@@ -96,7 +99,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: pass by value and use std::move [modernize-pass-by-value]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
@@ -121,6 +124,7 @@
 };
 
 struct NegativeNotPassedByValue {
+  // This const ref constructor isn't warned about because the ValuesOnly option is set.
   NegativeNotPassedByValue(const Movable &M) : M_(M) {}
   NegativeNotPassedByValue(const Movable M) : M_(M) {}
   NegativeNotPassedByValue(Movable &M) : M_(M) {}
Index: docs/clang-tidy/checks/modernize-pass-by-value.rst
===
--- docs/clang-tidy/checks/modernize-pass-by-value.rst
+++ docs/clang-tidy/checks/modernize-pass-by-value.rst
@@ -159,3 +159,8 @@
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: ValuesOnly
+
+   When non-zero, the check only warns about copied parameters that are already
+   passed by value. Default is `0`.
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -9,20 +9,10 @@
 initializing a member or base class through a copy constructor instead of a
 move constructor.
 
-It also flags constructor arguments that are passed by value, have a non-deleted
-move-constructor and are assigned to a class field by copy construction.
-
 Options
 ---
 
 .. option:: IncludeStyle
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
-
-.. option:: UseCERTSemantics
-
-   When non-zero, the check conforms to the behavior expected by the CERT secure
-   coding recommendation
-   `OOP11-CPP `_.
-   Default is `0` for misc-move-constructor-init and `1` for cert-oop11-cpp.
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -75,7 +75,7 @@
 
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
-  //misc-move-constructor-init which will suggest to move the argument.
+  //modernize-pass-by-value which will suggest to move the argument.
   if (!IsConstQualified && (llvm::isa(Function) ||
 !Function->doesThisDeclarationHaveABody()))
 return;
Index: clang-tidy/modernize/PassByValueCheck.h
===
--- clang-tidy/modernize/PassByValueCheck.h
+++ clang-tidy/modernize/PassByValueCheck.h
@@ -30,6 +30,7 @@
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeSt

[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-09 Thread David Tarditi via cfe-commits
dtarditi updated this revision to Diff 77373.
dtarditi added a comment.

Thanks for the code review feedback - I've addressed it.  Yes, we should use 
reset() instead of release().   I also deleted the unnecessary brackets.  I 
don't have commit access, so if this looks good, could someone commit this on 
my behalf?


https://reviews.llvm.org/D26435

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDeclCXX.cpp

Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -395,17 +395,15 @@
++argIdx) {
 ParmVarDecl *Param = cast(chunk.Fun.Params[argIdx].Param);
 if (Param->hasUnparsedDefaultArg()) {
-  CachedTokens *Toks = chunk.Fun.Params[argIdx].DefaultArgTokens;
+  std::unique_ptr Toks = std::move(chunk.Fun.Params[argIdx].DefaultArgTokens);
   SourceRange SR;
   if (Toks->size() > 1)
 SR = SourceRange((*Toks)[1].getLocation(),
  Toks->back().getLocation());
   else
 SR = UnparsedDefaultArgLocs[Param];
   Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
 << SR;
-  delete Toks;
-  chunk.Fun.Params[argIdx].DefaultArgTokens = nullptr;
 } else if (Param->getDefaultArg()) {
   Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
 << Param->getDefaultArg()->getSourceRange();
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -229,7 +229,8 @@
   I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
   I.Fun.DeleteParams = true;
 }
-memcpy(I.Fun.Params, Params, sizeof(Params[0]) * NumParams);
+for (unsigned i = 0; i < NumParams; i++)
+  I.Fun.Params[i] = std::move(Params[i]);
   }
 
   // Check what exception specification information we should actually store.
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2039,7 +2039,7 @@
 LateMethod->DefaultArgs.reserve(FTI.NumParams);
 for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
   LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
-FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens));
+FTI.Params[ParamIdx].Param, std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
   }
 }
 
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -6021,7 +6021,7 @@
 
 // DefArgToks is used when the parsing of default arguments needs
 // to be delayed.
-CachedTokens *DefArgToks = nullptr;
+std::unique_ptr DefArgToks;
 
 // If no parameter was specified, verify that *something* was specified,
 // otherwise we have a missing type and identifier.
@@ -6057,13 +6057,11 @@
   // If we're inside a class definition, cache the tokens
   // corresponding to the default argument. We'll actually parse
   // them when we see the end of the class definition.
-  // FIXME: Can we use a smart pointer for Toks?
-  DefArgToks = new CachedTokens;
+  DefArgToks.reset(new CachedTokens);
 
   SourceLocation ArgStartLoc = NextToken().getLocation();
   if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
-delete DefArgToks;
-DefArgToks = nullptr;
+DefArgToks.reset();
 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
   } else {
 Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
@@ -6099,7 +6097,7 @@
 
   ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII,
   ParmDeclarator.getIdentifierLoc(), 
-  Param, DefArgToks));
+  Param, std::move(DefArgToks)));
 }
 
 if (TryConsumeToken(tok::ellipsis, EllipsisLoc)) {
Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -319,7 +319,8 @@
 // Introduce the parameter into scope.
 bool HasUnparsed = Param->hasUnparsedDefaultArg();
 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param);
-if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
+std::unique_ptr Toks = std::move(LM.DefaultArgs[I].Toks);
+if (Toks) {
   // Mark the end of the default argument so that we know when to stop when
   // we parse it later

[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-09 Thread Dave Lee via cfe-commits
kastiglione added a comment.

Thanks @arphaman, are you able to commit this?


https://reviews.llvm.org/D26406



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


[PATCH] D26464: [ARM] Fix sema check of ARM special register names

2016-11-09 Thread Oleg Ranevskyy via cfe-commits
iid_iunknown created this revision.
iid_iunknown added a reviewer: LukeCheeseman.
iid_iunknown added a subscriber: cfe-commits.
iid_iunknown set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.

This is a simple sema check patch for arguments of `__builtin_arm_rsr` and the 
related builtins, which currently do not allow special registers with indexes 
>7.

Some of the possible register name formats these builtins accept are:

  {c}p::c:c:

  o0:op1:CRn:CRm:op2

where `op1` / `op2` are integers in the range [0, 7] and `CRn` / `CRm` are 
integers in the range [0, 15].

The current sema check does not allow `CRn` > 7 and accepts `op2` up to 15.


Repository:
  rL LLVM

https://reviews.llvm.org/D26464

Files:
  lib/Sema/SemaChecking.cpp


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -4191,7 +4191,7 @@
 
 SmallVector Ranges;
 if (FiveFields)
-  Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 7, 15, 15});
+  Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
 else
   Ranges.append({15, 7, 15});
 


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -4191,7 +4191,7 @@
 
 SmallVector Ranges;
 if (FiveFields)
-  Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 7, 15, 15});
+  Ranges.append({IsAArch64Builtin ? 1 : 15, 7, 15, 15, 7});
 else
   Ranges.append({15, 7, 15});
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26465: [Diag] Optimize DiagnosticIDs::getDiagnosticSeverity

2016-11-09 Thread Olivier Goffart via cfe-commits
ogoffart created this revision.
ogoffart added reviewers: cfe-commits, rsmith.
Herald added a subscriber: sanjoy.

DiagnosticIDs::getDiagnosticSeverity function turns out to take a lot of time 
in getDecomposedLoc. It is called quite often from different places. (For 
example from Sema::CheckTemplateArgument which attempt to emit 
warn_cxx98_compat_* diagnostics.)
In most cases, the diagnostics are not overridden by pragmas and the mapping 
from the command line is good enough. This commit adds a bit in the the first 
mapping which specify if we should look up the real mapping.

This saves more than 5% of the parsing time according to perf.


https://reviews.llvm.org/D26465

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/Diagnostic.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/Serialization/ASTReader.cpp

Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5299,6 +5299,10 @@
 diag::Severity Map = (diag::Severity)F.PragmaDiagMappings[Idx++];
 DiagnosticMapping Mapping = Diag.makeUserMapping(Map, Loc);
 Diag.GetCurDiagState()->setMapping(DiagID, Mapping);
+
+// We are overriding a default behavior
+Diag.DiagStates.front().getOrAddMapping(DiagID).setMightBeOverriden(
+true);
   }
 }
   }
Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -406,25 +406,29 @@
 DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
  const DiagnosticsEngine &Diag) const {
   assert(getBuiltinDiagClass(DiagID) != CLASS_NOTE);
-
   // Specific non-error diagnostics may be mapped to various levels from ignored
   // to error.  Errors can only be mapped to fatal.
   diag::Severity Result = diag::Severity::Fatal;
 
-  DiagnosticsEngine::DiagStatePointsTy::iterator
-Pos = Diag.GetDiagStatePointForLoc(Loc);
-  DiagnosticsEngine::DiagState *State = Pos->State;
-
-  // Get the mapping information, or compute it lazily.
-  DiagnosticMapping &Mapping = State->getOrAddMapping((diag::kind)DiagID);
+  // Calling GetDiagStatePointForLoc might be costly as it needs to create
+  // FullSourceLoc and compare them to the ones in the states. So first query
+  // the base state and check if it might be overridden.
+  DiagnosticsEngine::DiagState &BaseState = Diag.DiagStates.front();
+  assert(&BaseState == Diag.DiagStatePoints.front().State);
+  DiagnosticMapping *Mapping = &BaseState.getOrAddMapping((diag::kind)DiagID);
+  if (Mapping->mightBeOverriden()) {
+DiagnosticsEngine::DiagStatePointsTy::iterator Pos =
+Diag.GetDiagStatePointForLoc(Loc);
+Mapping = &Pos->State->getOrAddMapping((diag::kind)DiagID);
+  }
 
   // TODO: Can a null severity really get here?
-  if (Mapping.getSeverity() != diag::Severity())
-Result = Mapping.getSeverity();
+  if (Mapping->getSeverity() != diag::Severity())
+Result = Mapping->getSeverity();
 
   // Upgrade ignored diagnostics if -Weverything is enabled.
   if (Diag.EnableAllWarnings && Result == diag::Severity::Ignored &&
-  !Mapping.isUser() && getBuiltinDiagClass(DiagID) != CLASS_REMARK)
+  !Mapping->isUser() && getBuiltinDiagClass(DiagID) != CLASS_REMARK)
 Result = diag::Severity::Warning;
 
   // Ignore -pedantic diagnostics inside __extension__ blocks.
@@ -437,7 +441,7 @@
 
   // For extension diagnostics that haven't been explicitly mapped, check if we
   // should upgrade the diagnostic.
-  if (IsExtensionDiag && !Mapping.isUser())
+  if (IsExtensionDiag && !Mapping->isUser())
 Result = std::max(Result, Diag.ExtBehavior);
 
   // At this point, ignored errors can no longer be upgraded.
@@ -451,14 +455,14 @@
 
   // If -Werror is enabled, map warnings to errors unless explicitly disabled.
   if (Result == diag::Severity::Warning) {
-if (Diag.WarningsAsErrors && !Mapping.hasNoWarningAsError())
+if (Diag.WarningsAsErrors && !Mapping->hasNoWarningAsError())
   Result = diag::Severity::Error;
   }
 
   // If -Wfatal-errors is enabled, map errors to fatal unless explicity
   // disabled.
   if (Result == diag::Severity::Error) {
-if (Diag.ErrorsAsFatal && !Mapping.hasNoErrorAsFatal())
+if (Diag.ErrorsAsFatal && !Mapping->hasNoErrorAsFatal())
   Result = diag::Severity::Fatal;
   }
 
Index: lib/Basic/Diagnostic.cpp
===
--- lib/Basic/Diagnostic.cpp
+++ lib/Basic/Diagnostic.cpp
@@ -201,6 +201,11 @@
   }
   DiagnosticMapping Mapping = makeUserMapping(Map, L);
 
+  if (Loc.isValid()) {
+// We are potentially overriding a default behavior
+DiagStates.front().getOrAddMapping(Diag).setMightBeOverriden(true);
+  }
+
   // Common case; setting all the diagnostics of a group in one place.
  

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

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

Sorry for inactivity, been thinking quite a bit about this checker. The checker 
is very cool because it is an excellent showcase of our API problems in the 
realm of C++ checkers. Once the checker is committed, we could try various 
things to make it easier to develop other checkers like this in the future. 
Also the check is very useful, and improving C++ support in the analyzer is 
very desired, so again thank you for your work.

Right now the course of action, i think, is to

- Agree on the `evalAssume()` implementation (i'm still not quite understanding 
what the problem is here, see the new inline comments);
- Add some more comments into the code (especially comment up all the 
object-copy handling, when iterator state moves from one symbol/region to 
another symbol/region upon various events).

Then, i think, we should land the commit, assuming that you have a desire to 
address more issues in subsequent commits to eventually enable it by default.

For enabling by default, the following should most likely be addressed:

- We should probably not warn by default on unchecked std::find (see comments 
following the `push_back(2016)` example), unless some strong arguments against 
such code patterns are provided;
- A BugReporterVisitor should be added to report iterator state changes to the 
user across the diagnostic path;
- Our code owners often have strong opinions regarding warning message wording.

Then there are a few ideas on finding more bugs, which you shouldn't 
necessarily implement, that came up during the review, eg.:

- Alexey suspects that iterators implemented as plain pointers (commonly used 
in LLVM itself) might be unsupported;
- Alexey points out that ++/-- may be handled in a less conservative manner;
- More checks could be implemented in this checker, eg. passing `end()` as 
first argument of `std::find()` is an instant bug (somebody accidentally 
swapped begin and end?).

A list of ideas on improving core experience, mostly for myself because i seem 
to be the only one with strong opinions on this:

- Provide a checker callback for structure copies, which would unify the 
multitude of similar callbacks in this checker;
- Consider removing the conjured structure symbol hack.

Did i forget anything?




Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:423
+
+void IteratorPastEndChecker::handleComparison(CheckerContext &C,
+  const SVal &LVal,

baloghadamsoftware wrote:
> NoQ wrote:
> > a.sidorin wrote:
> > > What will happen if we write something like this:
> > > ```
> > > bool Eq1 = it1 == it2;
> > > bool Eq2 = it3 == it4;
> > > if (Eq1) {...}?
> > > ```
> > > 
> > > As I understand, we'll assume the second condition instead of first.
> > Had a look. So the problem is, we obtain the result of the comparison as a 
> > symbol, from which it is too hard to recover the operands in order to move 
> > iterator position data from one value to another.
> > 
> > Normally we obtain a simple SymbolConjured for the return value of the 
> > `operator==()` call (or, similarly, `operator!=()`). For plain-value 
> > iterators (eg. `typedef T *iterator`) we might be obtaining an actual 
> > binary symbolic expression, but even then it's not quite clear how to 
> > obtain operands (the structure of the expression might have changed due to 
> > algebraic simplifications). Additionally, LHS and RHS aren't necessarily 
> > symbols (they might be semi-concrete), so composing symbolic expressions 
> > from them in general is problematic with our symbol hierarchy, which is 
> > rarely a problem for numbers but for structural symbols it'd be a mess.
> > 
> > For now i suggest, instead of storing only the last LHS and RHS, to save a 
> > map from symbols (which are results of comparisons) to (LHS value, RHS 
> > value) pairs. This map should, apart from the obvious, be cleaned up 
> > whenever one of the iterators in the pair gets mutated (incremented or 
> > decremented). This should take care of the problem Alexey points out, and 
> > should work with semi-concrete stuff.
> > 
> > For the future i suggest to let users construct their own symbols and 
> > symbolic expressions more easily. In fact, if only we had all iterators as 
> > regions, we should have probably used SymbolMetadata for this purpose: it's 
> > easy to both recover the parent region from it and use it in symbolic 
> > expressions. We could also deprecate the confusing structural symbols 
> > (provide default-bound lazy compound values for conjured structures 
> > instead), and then it'd be possible to transition to SymbolMetadata 
> > entirely.
> Thank you for the suggestion. I am not sure if I fully understand you. If I 
> create a map where the key is the resulting symbol of the comparison, it will 
> not work because evalAssume is called for the innermost comparison. So if the 
> body of operator== (or operator!=) is inli

Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-09 Thread Devin Coughlin via cfe-commits

> On Nov 8, 2016, at 9:44 AM, Malcolm Parsons  wrote:
> 
> On 8 November 2016 at 16:59, Alexander Kornienko  wrote:
>> On Nov 8, 2016 2:11 AM, "Malcolm Parsons"  wrote:
>>> Oh, I was using clang-analyzer-alpha.cplusplus.VirtualCall.
>>> 
>>> Should clang-tidy have an option to enable experimental checks?
>> 
>> I'd instead ask Static Analyzer folks if they can graduate this check. 

We agree that this is a valuable checker and are committed to getting it out of 
alpha. This check is in alpha because:

a) The diagnostic experience is not very good. It reports a call path directly 
in the diagnostic message (for example “Call path: foo <— bar” for a call to 
foo() in bar()) rather than as a path diagnostic.

b) The lack of path-sensitive reasoning may result in false positives when a 
called function uses a member variable flag to track whether initialization is 
complete and does not call the virtual member function during initialization.

c) The check issues a warning for both calls to pure virtual functions (which 
is always an error) and non-pure virtual functions (which is more of a code 
smell and may be a false positive).

From our perspective, the diagnostic experience is the primary blocker to 
moving this checker out of alpha and thus turning it on by default.

Here is our plan to graduate the checker:

Step 1) Modify the existing AST-based checker to only report on virtual calls 
in the constructor/destructor itself. This will result in false negatives but 
avoid the poor diagnostic experience in a). We’ll move the checker out of 
alpha, which will turn it on by default for all users, and add an 
-analyzer-config flag to to recover the old behavior.

Step 2) Rewrite the checker to be path-sensitive. This will improve the 
diagnostic experience so that we can turn the inter-procedural case back on and 
also limit false positives from b).

I’ll commit to doing Step 1) in the immediate future and Step 2) eventually. 
Once the checker is on by default we’ll need to assess whether the false 
positive rate from c) is too high — if so, we’ll need to turn the 
non-pure-virtual case off by default.

Devin

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


Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-09 Thread Devin Coughlin via cfe-commits
+ Anna, Alexander, and Artem.

> On Nov 9, 2016, at 10:50 AM, Devin Coughlin via cfe-commits 
>  wrote:
> 
> 
>> On Nov 8, 2016, at 9:44 AM, Malcolm Parsons  
>> wrote:
>> 
>> On 8 November 2016 at 16:59, Alexander Kornienko  wrote:
>>> On Nov 8, 2016 2:11 AM, "Malcolm Parsons"  wrote:
 Oh, I was using clang-analyzer-alpha.cplusplus.VirtualCall.
 
 Should clang-tidy have an option to enable experimental checks?
>>> 
>>> I'd instead ask Static Analyzer folks if they can graduate this check. 
> 
> We agree that this is a valuable checker and are committed to getting it out 
> of alpha. This check is in alpha because:
> 
> a) The diagnostic experience is not very good. It reports a call path 
> directly in the diagnostic message (for example “Call path: foo <— bar” for a 
> call to foo() in bar()) rather than as a path diagnostic.
> 
> b) The lack of path-sensitive reasoning may result in false positives when a 
> called function uses a member variable flag to track whether initialization 
> is complete and does not call the virtual member function during 
> initialization.
> 
> c) The check issues a warning for both calls to pure virtual functions (which 
> is always an error) and non-pure virtual functions (which is more of a code 
> smell and may be a false positive).
> 
> From our perspective, the diagnostic experience is the primary blocker to 
> moving this checker out of alpha and thus turning it on by default.
> 
> Here is our plan to graduate the checker:
> 
> Step 1) Modify the existing AST-based checker to only report on virtual calls 
> in the constructor/destructor itself. This will result in false negatives but 
> avoid the poor diagnostic experience in a). We’ll move the checker out of 
> alpha, which will turn it on by default for all users, and add an 
> -analyzer-config flag to to recover the old behavior.
> 
> Step 2) Rewrite the checker to be path-sensitive. This will improve the 
> diagnostic experience so that we can turn the inter-procedural case back on 
> and also limit false positives from b).
> 
> I’ll commit to doing Step 1) in the immediate future and Step 2) eventually. 
> Once the checker is on by default we’ll need to assess whether the false 
> positive rate from c) is too high — if so, we’ll need to turn the 
> non-pure-virtual case off by default.
> 
> Devin
> 
> ___
> 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] D26466: [clang-tidy] Fix NOLINT test

2016-11-09 Thread Nikita Kakuev via cfe-commits
nkakuev created this revision.
nkakuev added a reviewer: alexfh.
nkakuev added a subscriber: cfe-commits.

Test cases I've added in review https://reviews.llvm.org/D26218 were too 
brittle and weren't working properly.
This patch fixes this.


https://reviews.llvm.org/D26466

Files:
  test/clang-tidy/nolint.cpp


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,5 +1,12 @@
 // RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult
 %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
 
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-MESSAGES-NOT: trigger_warning.h:{{.*}} warning
+// CHECK-MESSAGES-NOT: :[[@LINE-4]]:{{.*}} note
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
@@ -28,12 +35,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-#include "trigger_warning.h"
-void I(int& Out) {
-  int In;
-  A1(In, Out);
-}
-// CHECK-NOT: trigger_warning.h:{{.*}} warning: The left operand of '>' is a 
garbage value
-// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
-
 // CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)


Index: test/clang-tidy/nolint.cpp
===
--- test/clang-tidy/nolint.cpp
+++ test/clang-tidy/nolint.cpp
@@ -1,5 +1,12 @@
 // RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
 
+#include "trigger_warning.h"
+void I(int& Out) {
+  int In;
+  A1(In, Out);
+}
+// CHECK-MESSAGES-NOT: trigger_warning.h:{{.*}} warning
+// CHECK-MESSAGES-NOT: :[[@LINE-4]]:{{.*}} note
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
@@ -28,12 +35,4 @@
 #define DOUBLE_MACRO MACRO(H) // NOLINT
 DOUBLE_MACRO
 
-#include "trigger_warning.h"
-void I(int& Out) {
-  int In;
-  A1(In, Out);
-}
-// CHECK-NOT: trigger_warning.h:{{.*}} warning: The left operand of '>' is a garbage value
-// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
-
 // CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-09 Thread Nikita Kakuev via cfe-commits
nkakuev marked an inline comment as done.
nkakuev added inline comments.



Comment at: test/clang-tidy/nolint.cpp:36
+}
+// CHECK-NOT: trigger_warning.h:{{.*}} warning: The left operand of '>' is a 
garbage value
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note

alexfh wrote:
> The test is too brittle: if the functionality breaks after the text of the 
> message changes, it will still pass.
> 
> Two ways to deal with it:
> 1. add a positive test to ensure this pattern actually triggers a warning
> 2. make the CHECK-NOT pattern broader: `// CHECK-NOT: warning:`.
Fixed in review D26466.


https://reviews.llvm.org/D26218



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


[PATCH] D26456: Handle adding new nested namespace in old namespace.

2016-11-09 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 77380.
ioeric added a comment.

- Added a test case with type references.


https://reviews.llvm.org/D26456

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -97,6 +97,48 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, NewNsNestedInOldNsWithRefs) {
+  NewNamespace = "na::nb::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "namespace nc {\n"
+ "class B {};\n"
+ "class C {};\n"
+ "void f() { A a; B b; }\n"
+ "} // namespace nc\n"
+ "\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
   NewNamespace = "na::nc";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -57,16 +57,19 @@
 }
 
 // Returns the containing namespace of `InnerNs` by skipping `PartialNsName`.
-// If the `InnerNs` does not have `PartialNsName` as suffix, nullptr is
-// returned.
+// If the `InnerNs` does not have `PartialNsName` as suffix, or `PartialNsName`
+// is empty, nullptr is returned.
 // For example, if `InnerNs` is "a::b::c" and `PartialNsName` is "b::c", then
 // the NamespaceDecl of namespace "a" will be returned.
 const NamespaceDecl *getOuterNamespace(const NamespaceDecl *InnerNs,
llvm::StringRef PartialNsName) {
+  if (!InnerNs || PartialNsName.empty())
+return nullptr;
   const auto *CurrentContext = llvm::cast(InnerNs);
   const auto *CurrentNs = InnerNs;
   llvm::SmallVector PartialNsNameSplitted;
-  PartialNsName.split(PartialNsNameSplitted, "::");
+  PartialNsName.split(PartialNsNameSplitted, "::", /*MaxSplit=*/-1,
+  /*KeepEmpty=*/false);
   while (!PartialNsNameSplitted.empty()) {
 // Get the inner-most namespace in CurrentContext.
 while (CurrentContext && !llvm::isa(CurrentContext))
@@ -468,16 +471,22 @@
   // "x::y" will be inserted inside the existing namespace "a" and after "a::b".
   // `OuterNs` is the first namespace in `DiffOldNamespace`, e.g. "namespace b"
   // in the above example.
-  // FIXME: consider the case where DiffOldNamespace is empty.
+  // If there is no outer namespace (i.e. DiffOldNamespace is empty), the new
+  // namespace will be a nested namespace in the old namespace
   const NamespaceDecl *OuterNs = getOuterNamespace(NsDecl, DiffOldNamespace);
-  SourceLocation LocAfterNs =
-  getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
- Result.Context->getLangOpts());
-  assert(LocAfterNs.isValid() &&
- "Failed to get location after DiffOldNamespace");
+  SourceLocation InsertionLoc;
+  if (OuterNs) {
+SourceLocation LocAfterNs =
+getStartOfNextLine(OuterNs->getRBraceLoc(), *Result.SourceManager,
+   Result.Context->getLangOpts());
+assert(LocAfterNs.isValid() &&
+   "Failed to get location after DiffOldNamespace");
+InsertionLoc = LocAfterNs;
+  } else {
+InsertionLoc = Start;
+  }
   MoveNs.InsertionOffset = Result.SourceManager->getFileOffset(
-  Result.SourceManager->getSpellingLoc(LocAfterNs));
-
+  Result.

[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Aleksey Shlyapnikov via cfe-commits
alekseyshl created this revision.
alekseyshl added a reviewer: eugenis.
alekseyshl added a subscriber: cfe-commits.

New clang flags, all default to true:
-f[no-]sanitize-thread-data-races
-f[no-]sanitize-thread-stack-traces
-f[no-]sanitize-thread-atomics


https://reviews.llvm.org/D26461

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -729,6 +729,18 @@
   Opts.SanitizeCoverageTracePC = Args.hasArg(OPT_fsanitize_coverage_trace_pc);
   Opts.SanitizeCoverageTracePCGuard =
   Args.hasArg(OPT_fsanitize_coverage_trace_pc_guard);
+  Opts.SanitizeThreadDataRaces =
+  Args.hasFlag(OPT_fsanitize_thread_data_races,
+   OPT_fno_sanitize_thread_data_races,
+   Opts.SanitizeThreadDataRaces);
+  Opts.SanitizeThreadStackTraces =
+  Args.hasFlag(OPT_fsanitize_thread_stack_traces,
+   OPT_fno_sanitize_thread_stack_traces,
+   Opts.SanitizeThreadStackTraces);
+  Opts.SanitizeThreadAtomics =
+  Args.hasFlag(OPT_fsanitize_thread_atomics,
+   OPT_fno_sanitize_thread_atomics,
+   Opts.SanitizeThreadAtomics);
   Opts.SanitizeMemoryTrackOrigins =
   getLastArgIntValue(Args, OPT_fsanitize_memory_track_origins_EQ, 0, Diags);
   Opts.SanitizeMemoryUseAfterDtor =
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -437,6 +437,18 @@
  TC.getTriple().getArch() == llvm::Triple::x86_64);
   }
 
+  if (AllAddedKinds & Thread) {
+TsanDataRaces = Args.hasFlag(options::OPT_fsanitize_thread_data_races,
+ options::OPT_fno_sanitize_thread_data_races,
+ TsanDataRaces);
+TsanStackTraces = Args.hasFlag(options::OPT_fsanitize_thread_stack_traces,
+   options::OPT_fno_sanitize_thread_stack_traces,
+   TsanStackTraces);
+TsanAtomics = Args.hasFlag(options::OPT_fsanitize_thread_atomics,
+   options::OPT_fno_sanitize_thread_atomics,
+   TsanAtomics);
+  }
+
   if (AllAddedKinds & CFI) {
 CfiCrossDso = Args.hasFlag(options::OPT_fsanitize_cfi_cross_dso,
options::OPT_fno_sanitize_cfi_cross_dso, false);
@@ -685,6 +697,13 @@
   if (MsanUseAfterDtor)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-use-after-dtor"));
 
+  if (!TsanDataRaces)
+CmdArgs.push_back(Args.MakeArgString("-fno-sanitize-thread-data-races"));
+  if (!TsanStackTraces)
+CmdArgs.push_back(Args.MakeArgString("-fno-sanitize-thread-stack-traces"));
+  if (!TsanAtomics)
+CmdArgs.push_back(Args.MakeArgString("-fno-sanitize-thread-atomics"));
+
   if (CfiCrossDso)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-cfi-cross-dso"));
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -219,7 +219,12 @@
 
 static void addThreadSanitizerPass(const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) {
-  PM.add(createThreadSanitizerPass());
+  const PassManagerBuilderWrapper &BuilderWrapper =
+  static_cast(Builder);
+  const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
+  PM.add(createThreadSanitizerPass(CGOpts.SanitizeThreadDataRaces,
+   CGOpts.SanitizeThreadStackTraces,
+   CGOpts.SanitizeThreadAtomics));
 }
 
 static void addDataFlowSanitizerPass(const PassManagerBuilder &Builder,
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -163,6 +163,13 @@
   ///< in sanitizer coverage.
 CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with guard
///< in sanitizer coverage.
+CODEGENOPT(SanitizeThreadDataRaces, 1, 1) ///< Enable data race detection in
+  ///< ThreadSanitizer
+CODEGENOPT(SanitizeThreadStackTraces, 1, 1) ///< Enable stack trace recording in
+///< ThreadSanitizer
+CODEGENOPT(SanitizeThreadAtomics, 1, 1) ///< Enable analysis of the
+///< synchronization via atomic
+

[PATCH] D26423: [clang-move] Support template class.

2016-11-09 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with a few nits.




Comment at: clang-move/ClangMove.cpp:417
+  if (const auto *FTD = CMD->getDescribedFunctionTemplate())
+UnremovedDeclsInOldHeader.erase(FTD);
+  else

`erase(FTD ? FTD : CMD)`



Comment at: clang-move/ClangMove.cpp:430
+// class template.
+if (const auto * TC = CD->getDescribedClassTemplate())
+  MovedDecls.emplace_back(TC, &Result.Context->getSourceManager());

`emplace_back(TC ? TC : CD, ...)`



Comment at: clang-move/ClangMove.cpp:440
 if (RemovedDecls.empty()) {
-  if (const auto *DCT = FWD->getDescribedClassTemplate()) {
+  if (const auto *DCT = FWD->getDescribedClassTemplate())
 MovedDecls.emplace_back(DCT, &Result.Context->getSourceManager());

Similarly.


https://reviews.llvm.org/D26423



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


[PATCH] D26448: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with a default capture specifier

2016-11-09 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D26448



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


[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:735
+   OPT_fno_sanitize_thread_data_races,
+   Opts.SanitizeThreadDataRaces);
+  Opts.SanitizeThreadStackTraces =

It seems common to hardcode the default option value here.
The same in SanitizerArgs.cpp.


https://reviews.llvm.org/D26461



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


[PATCH] D26457: Protect smart-pointer tests under no exceptions

2016-11-09 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

LGTM.


https://reviews.llvm.org/D26457



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


[PATCH] D25850: Accept nullability annotations (_Nullable) on array parameters

2016-11-09 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

This is looking great, Jordan.


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-09 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Not sure if either of these tests add much value to the no-exceptions variant, 
using `std::nested_exception` with such a library seem pointless to me. Perhaps 
marking these as `UNSUPPORTED` is a better fix?


https://reviews.llvm.org/D26458



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


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-09 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D26458#590865, @rmaprath wrote:

> Not sure if either of these tests add much value to the no-exceptions 
> variant, using `std::nested_exception` with such a library seem pointless to 
> me. Perhaps marking these as `UNSUPPORTED` is a better fix?


Also, it seems like we are saving the same assert in all the three tests. If we 
want to save it that badly, perhaps creating a new test case with a `REQUIRES: 
libcpp-no-exceptions` is a better  fix.


https://reviews.llvm.org/D26458



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


[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

Oh, and this needs a test. See test/Driver/fsanitize.c (search for 
-fsanitize-address-use-after-scope as an example).


https://reviews.llvm.org/D26461



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


[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Aleksey Shlyapnikov via cfe-commits
alekseyshl added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:735
+   OPT_fno_sanitize_thread_data_races,
+   Opts.SanitizeThreadDataRaces);
+  Opts.SanitizeThreadStackTraces =

eugenis wrote:
> It seems common to hardcode the default option value here.
> The same in SanitizerArgs.cpp.
True, but the default value for these flags is already mentioned in more than 
one place, why not to try to reduce the complexity?


https://reviews.llvm.org/D26461



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


[PATCH] D26423: [clang-move] Support template class.

2016-11-09 Thread Haojian Wu via cfe-commits
hokein marked 3 inline comments as done.
hokein added inline comments.



Comment at: clang-move/ClangMove.cpp:417
+  if (const auto *FTD = CMD->getDescribedFunctionTemplate())
+UnremovedDeclsInOldHeader.erase(FTD);
+  else

ioeric wrote:
> `erase(FTD ? FTD : CMD)`
We can't write the code like this way since the ternary operator (`condition ? 
E1:E2`) requires E1 and E2 has same type or they can convert to each other. In 
our case, the pointer types of `FTD` and `CMD` are different, and they can't 
convert to each other. 

We could pass the compilation by writing the code like following way, but I'd 
keep the current way.

```
erase(FTD ? static_cast(FTD) : static_castCMD);
```  


https://reviews.llvm.org/D26423



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


[PATCH] D26454: Implement no_sanitize_address for global vars

2016-11-09 Thread Douglas Katzman via cfe-commits
dougk added a comment.

Also note: In this change, the diagnostic messages are correct; it's the enum 
name that's bad. The diagnostic message is wrong for the 'section' attribute, 
which is fixed by https://reviews.llvm.org/D26459


https://reviews.llvm.org/D26454



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


[PATCH] D26423: [clang-move] Support template class.

2016-11-09 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: clang-move/ClangMove.cpp:417
+  if (const auto *FTD = CMD->getDescribedFunctionTemplate())
+UnremovedDeclsInOldHeader.erase(FTD);
+  else

hokein wrote:
> ioeric wrote:
> > `erase(FTD ? FTD : CMD)`
> We can't write the code like this way since the ternary operator (`condition 
> ? E1:E2`) requires E1 and E2 has same type or they can convert to each other. 
> In our case, the pointer types of `FTD` and `CMD` are different, and they 
> can't convert to each other. 
> 
> We could pass the compilation by writing the code like following way, but I'd 
> keep the current way.
> 
> ```
> erase(FTD ? static_cast(FTD) : static_castCMD);
> ```  
nvm. you can keep it as it is.


https://reviews.llvm.org/D26423



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


[clang-tools-extra] r286390 - [clang-tidy docs] Recommend using add_new_check.py more

2016-11-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Nov  9 14:03:30 2016
New Revision: 286390

URL: http://llvm.org/viewvc/llvm-project?rev=286390&view=rev
Log:
[clang-tidy docs] Recommend using add_new_check.py more

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=286390&r1=286389&r2=286390&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed Nov  9 14:03:30 2016
@@ -352,43 +352,58 @@ readability, etc.), certain coding style
 or a widely used API (e.g. MPI). Their names are same as user-facing check
 groups names described :ref:`above `.
 
-After choosing the module, you need to create a class for your check:
+After choosing the module and the name for the check, run the
+``clang-tidy/add_new_check.py`` script to create the skeleton of the check and
+plug it to clang-tidy. It's the recommended way of adding new checks.
+
+If we want to create a `readability-awesome-function-names`, we would run:
+
+.. code-block:: console
+
+  $ clang-tidy/add_new_check.py readability awesome-function-names
+
+
+The ``add_new_check.py`` script will:
+  * create the class for your check inside the specified module's directory and
+register it in the module and in the build system;
+  * create a lit test file in the ``test/clang-tidy/`` directory;
+  * create a documentation file and include it into the
+``docs/clang-tidy/checks/list.rst``.
+
+Let's see in more detail at the check class definition:
 
 .. code-block:: c++
 
+  ...
+
   #include "../ClangTidy.h"
 
   namespace clang {
   namespace tidy {
-  namespace some_module {
+  namespace readability {
 
-  class MyCheck : public ClangTidyCheck {
+  ...
+  class AwesomeFunctionNamesCheck : public ClangTidyCheck {
   public:
-MyCheck(StringRef Name, ClangTidyContext *Context)
+AwesomeFunctionNamesCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context) {}
+void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   };
 
-  } // namespace some_module
+  } // namespace readability
   } // namespace tidy
   } // namespace clang
 
+  ...
+
 Constructor of the check receives the ``Name`` and ``Context`` parameters, and
 must forward them to the ``ClangTidyCheck`` constructor.
 
-Next, you need to decide whether it should operate on the preprocessor level or
-on the AST level. Let's imagine that we need to work with the AST in our check.
-In this case we need to override two methods:
-
-.. code-block:: c++
-
-  ...
-  class ExplicitConstructorCheck : public ClangTidyCheck {
-  public:
-ExplicitConstructorCheck(StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
-void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-void check(ast_matchers::MatchFinder::MatchResult &Result) override;
-  };
+In our case the check needs to operate on the AST level and it overrides the
+``registerMatchers`` and ``check`` methods. If we wanted to analyze code on the
+preprocessor level, we'd need instead to override the ``registerPPCallbacks``
+method.
 
 In the ``registerMatchers`` method we create an AST Matcher (see `AST 
Matchers`_
 for more information) that will find the pattern in the AST that we want to
@@ -399,24 +414,20 @@ can further inspect them and report diag
 
   using namespace ast_matchers;
 
-  void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) {
-Finder->addMatcher(constructorDecl().bind("ctor"), this);
+  void AwesomeFunctionNamesCheck::registerMatchers(MatchFinder *Finder) {
+Finder->addMatcher(functionDecl().bind("x"), this);
   }
 
-  void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) 
{
-const auto *Ctor = Result.Nodes.getNodeAs("ctor");
-// Do not be confused: isExplicit means 'explicit' keyword is present,
-// isImplicit means that it's a compiler-generated constructor.
-if (Ctor->isOutOfLine() || Ctor->isExplicit() || Ctor->isImplicit())
+  void AwesomeFunctionNamesCheck::check(const MatchFinder::MatchResult 
&Result) {
+const auto *MatchedDecl = Result.Nodes.getNodeAs("x");
+if (MatchedDecl->getName().startswith("awesome_"))
   return;
-if (Ctor->getNumParams() == 0 || Ctor->getMinRequiredArguments() > 1)
-  return;
-SourceLocation Loc = Ctor->getLocation();
-diag(Loc, "single-argument constructors must be explicit")
-<< FixItHint::CreateInsertion(Loc, "explicit ");
+diag(MatchedDecl->getLocation(), "function %0 is insufficiently awesome")
+<< MatchedDecl
+<< FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
   }
 
-(The full code fo

[PATCH] D26342: [analyzer] Add MutexChecker for the Magenta kernel

2016-11-09 Thread Kareem Khazem via cfe-commits
khazem added a comment.

Thanks for the detailed review Artem!

I think that it's sensible to try merging this with PthreadLockChecker. In 
fact, I could also try merging the SpinLockChecker [1] that I've posted for 
review with PthreadLockChecker also, since they all implement similar 
functionality. This would be in line with what we discussed at the developer 
meeting, where there was a consensus that there could be too many 
domain-specific checkers that were only different in what function names they 
look for.

Here is my proposal: I could try refactoring the PthreadLockChecker into a 
LockChecker class, which would be instantiated as various subclasses (for 
Pthread, XNU, Magenta, and others in the future). The common functionality 
would be implemented in LockChecker, but the user would ask for a specific 
checker using command-line flags. Using subclasses would hopefully prevent the 
class from becoming a mess of if/switch statements, while allowing future 
LockCheckers to be implemented for other lock APIs. Does this seem reasonable?

I could then have a go at the other improvements that you mentioned, and they 
would hopefully apply to all LockCheckers and not just our Magenta one.

[1] https://reviews.llvm.org/D26340


https://reviews.llvm.org/D26342



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


[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel

2016-11-09 Thread Kareem Khazem via cfe-commits
khazem marked 4 inline comments as done.
khazem added a comment.

Devin, based on Artem's review of the other checker that I have posted [1] I am 
wondering about merging both this SpinLockChecker and the MutexChecker into 
PthreadLockChecker. Do you think it is still worth landing this 
SpinLockChecker, or do you suppose that abandoning this patch and working on 
merging all the checkers would be a good idea? I've noted how the checkers 
might be merged in my reply to Artem: [2].

[1] https://reviews.llvm.org/D26342
[2] https://reviews.llvm.org/D26342#590881


https://reviews.llvm.org/D26340



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


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2016-11-09 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

Looks good! I appreciate the refactoring of recordNullabilitySeen


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS

2016-11-09 Thread Shoaib Meenai via cfe-commits
smeenai abandoned this revision.
smeenai added a comment.

Abandoning this then. In case the new incarnation of the test needs to 
overwrite any memory allocation methods, this diff has the most reliable way to 
do it on OS X :)


https://reviews.llvm.org/D26150



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


[PATCH] D26109: Warn when 'assume_nonnull' infers nullability within an array.

2016-11-09 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rL LLVM

https://reviews.llvm.org/D26109



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


[PATCH] D26227: Don't require nullability on 'va_list'.

2016-11-09 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

I don't see a better way to do this. Nice meta programming hack.


Repository:
  rL LLVM

https://reviews.llvm.org/D26227



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


Re: r272668 - clang-format: [JS] Fix failing format with TypeScript casts.

2016-11-09 Thread Nico Weber via cfe-commits
This apparently caused https://llvm.org/bugs/show_bug.cgi?id=30527

On Tue, Jun 14, 2016 at 9:54 AM, Daniel Jasper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: djasper
> Date: Tue Jun 14 08:54:38 2016
> New Revision: 272668
>
> URL: http://llvm.org/viewvc/llvm-project?rev=272668&view=rev
> Log:
> clang-format: [JS] Fix failing format with TypeScript casts.
>
> Before, this could be formatted at all (with BracketAlignmentStyle
> AlwaysBreak):
>
>   foo = [
> 1, /* */
> 2
>   ];
>
> Modified:
> cfe/trunk/lib/Format/TokenAnnotator.cpp
> cfe/trunk/unittests/Format/FormatTestJS.cpp
>
> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/
> TokenAnnotator.cpp?rev=272668&r1=272667&r2=272668&view=diff
> 
> ==
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jun 14 08:54:38 2016
> @@ -319,9 +319,9 @@ private:
>  Left->Type = TT_JsComputedPropertyName;
>} else if (Style.Language == FormatStyle::LK_Proto ||
>   (Parent &&
> -  Parent->isOneOf(TT_BinaryOperator, tok::at, tok::comma,
> -  tok::l_paren, tok::l_square,
> tok::question,
> -  tok::colon, tok::kw_return,
> +  Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser,
> tok::at,
> +  tok::comma, tok::l_paren, tok::l_square,
> +  tok::question, tok::colon,
> tok::kw_return,
>// Should only be relevant to
> JavaScript:
>tok::kw_default))) {
>  Left->Type = TT_ArrayInitializerLSquare;
>
> Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/
> Format/FormatTestJS.cpp?rev=272668&r1=272667&r2=272668&view=diff
> 
> ==
> --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun 14 08:54:38 2016
> @@ -1205,6 +1205,10 @@ TEST_F(FormatTestJS, TemplateStrings) {
>  TEST_F(FormatTestJS, CastSyntax) {
>verifyFormat("var x = foo;");
>verifyFormat("var x = foo as type;");
> +  verifyFormat("foo = [\n"
> +   "  1,  //\n"
> +   "  2\n"
> +   "];");
>  }
>
>  TEST_F(FormatTestJS, TypeArguments) {
>
>
> ___
> 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: r272668 - clang-format: [JS] Fix failing format with TypeScript casts.

2016-11-09 Thread Nico Weber via cfe-commits
Oh, looks like someone already sent a fix: https://reviews.llvm.org/D26163

On Wed, Nov 9, 2016 at 4:41 PM, Nico Weber  wrote:

> This apparently caused https://llvm.org/bugs/show_bug.cgi?id=30527
>
> On Tue, Jun 14, 2016 at 9:54 AM, Daniel Jasper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: djasper
>> Date: Tue Jun 14 08:54:38 2016
>> New Revision: 272668
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=272668&view=rev
>> Log:
>> clang-format: [JS] Fix failing format with TypeScript casts.
>>
>> Before, this could be formatted at all (with BracketAlignmentStyle
>> AlwaysBreak):
>>
>>   foo = [
>> 1, /* */
>> 2
>>   ];
>>
>> Modified:
>> cfe/trunk/lib/Format/TokenAnnotator.cpp
>> cfe/trunk/unittests/Format/FormatTestJS.cpp
>>
>> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Tok
>> enAnnotator.cpp?rev=272668&r1=272667&r2=272668&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
>> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jun 14 08:54:38 2016
>> @@ -319,9 +319,9 @@ private:
>>  Left->Type = TT_JsComputedPropertyName;
>>} else if (Style.Language == FormatStyle::LK_Proto ||
>>   (Parent &&
>> -  Parent->isOneOf(TT_BinaryOperator, tok::at,
>> tok::comma,
>> -  tok::l_paren, tok::l_square,
>> tok::question,
>> -  tok::colon, tok::kw_return,
>> +  Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser,
>> tok::at,
>> +  tok::comma, tok::l_paren,
>> tok::l_square,
>> +  tok::question, tok::colon,
>> tok::kw_return,
>>// Should only be relevant to
>> JavaScript:
>>tok::kw_default))) {
>>  Left->Type = TT_ArrayInitializerLSquare;
>>
>> Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Form
>> at/FormatTestJS.cpp?rev=272668&r1=272667&r2=272668&view=diff
>> 
>> ==
>> --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
>> +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun 14 08:54:38 2016
>> @@ -1205,6 +1205,10 @@ TEST_F(FormatTestJS, TemplateStrings) {
>>  TEST_F(FormatTestJS, CastSyntax) {
>>verifyFormat("var x = foo;");
>>verifyFormat("var x = foo as type;");
>> +  verifyFormat("foo = [\n"
>> +   "  1,  //\n"
>> +   "  2\n"
>> +   "];");
>>  }
>>
>>  TEST_F(FormatTestJS, TypeArguments) {
>>
>>
>> ___
>> 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] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:735
+   OPT_fno_sanitize_thread_data_races,
+   Opts.SanitizeThreadDataRaces);
+  Opts.SanitizeThreadStackTraces =

alekseyshl wrote:
> eugenis wrote:
> > It seems common to hardcode the default option value here.
> > The same in SanitizerArgs.cpp.
> True, but the default value for these flags is already mentioned in more than 
> one place, why not to try to reduce the complexity?
I guess I don't mind either way.


https://reviews.llvm.org/D26461



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


r286400 - Use an artificial debug location for non-virtual thunks.

2016-11-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Nov  9 15:43:51 2016
New Revision: 286400

URL: http://llvm.org/viewvc/llvm-project?rev=286400&view=rev
Log:
Use an artificial debug location for non-virtual thunks.
Thunks are artificial and have no corresponding source location except for the
line number on the DISubprogram, which is marked as artificial.



Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp
cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=286400&r1=286399&r2=286400&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov  9 15:43:51 2016
@@ -3032,9 +3032,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
 
   if (!HasDecl || D->isImplicit()) {
 Flags |= llvm::DINode::FlagArtificial;
-// Artificial functions without a location should not silently reuse 
CurLoc.
-if (Loc.isInvalid())
-  CurLoc = SourceLocation();
+// Artificial functions should not silently reuse CurLoc.
+CurLoc = SourceLocation();
   }
   unsigned LineNo = getLineNumber(Loc);
   unsigned ScopeLine = getLineNumber(ScopeLoc);

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=286400&r1=286399&r2=286400&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Nov  9 15:43:51 2016
@@ -229,8 +229,11 @@ void CodeGenFunction::StartThunk(llvm::F
 CGM.getCXXABI().addImplicitStructorParams(*this, ResultType, FunctionArgs);
 
   // Start defining the function.
+  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(GlobalDecl(), ResultType, Fn, FnInfo, FunctionArgs,
-MD->getLocation(), MD->getLocation());
+MD->getLocation());
+  // Create a scope with an artificial location for the body of this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Since we didn't pass a GlobalDecl to StartFunction, do this ourselves.
   CGM.getCXXABI().EmitInstanceFunctionProlog(*this);
@@ -282,7 +285,7 @@ void CodeGenFunction::EmitCallAndReturnF
 
   // Add the rest of the arguments.
   for (const ParmVarDecl *PD : MD->parameters())
-EmitDelegateCallArg(CallArgs, PD, PD->getLocStart());
+EmitDelegateCallArg(CallArgs, PD, SourceLocation());
 
   const FunctionProtoType *FPT = MD->getType()->getAs();
 
@@ -396,6 +399,8 @@ void CodeGenFunction::generateThunk(llvm
 const CGFunctionInfo &FnInfo,
 GlobalDecl GD, const ThunkInfo &Thunk) {
   StartThunk(Fn, GD, FnInfo);
+  // Create a scope with an artificial location for the body of this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Get our callee.
   llvm::Type *Ty =

Modified: cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=286400&r1=286399&r2=286400&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp Wed Nov  9 15:43:51 2016
@@ -13,8 +13,17 @@ struct C : A, B {
 };
 
 void C::f() { }
-
-// CHECK: !DISubprogram(linkageName: "_ZThn{{[48]}}_N1C1fEv"
+// CHECK: define void @_ZThn{{[48]}}_N1C1fEv
+// CHECK-SAME: !dbg ![[SP:[0-9]+]]
+// CHECK-NOT: {{ret }}
+// CHECK: = load{{.*}} !dbg ![[DBG:[0-9]+]]
+// CHECK-NOT: {{ret }}
+// CHECK: ret void, !dbg ![[DBG]]
+//
+// CHECK: ![[SP]] = distinct !DISubprogram(linkageName: "_ZThn{{[48]}}_N1C1fEv"
 // CHECK-SAME:  line: 15
 // CHECK-SAME:  isDefinition: true
+// CHECK-SAME:  DIFlagArtificial
 // CHECK-SAME:  ){{$}}
+//
+// CHECK: ![[DBG]] = !DILocation(line: 0

Modified: cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp?rev=286400&r1=286399&r2=286400&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp Wed Nov  9 15:43:51 
2016
@@ -19,4 +19,4 @@ template struct AB;
 // CHECK: define
 
 // CHECK: [[THUNK_VEC_DEL_DTOR]] = distinct !DISubprogram
-// CHECK: [[THUNK_LOC]] = !DILocation(line: 15, scope: [[THUNK_VEC_DEL_DTOR]])
+// CHECK: [[THUNK_LOC]] = !DILocation(line: 0, scope: [[THUNK_VEC_DEL_DTOR]])


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
htt

[PATCH] D26471: [Sema] Use MS ABI behavior for dllexport in Itanium

2016-11-09 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added a reviewer: compnerd.
smeenai added a subscriber: cfe-commits.

Similar to r284288, make the Itanium ABI follow MS ABI dllexport
semantics in the case of an explicit instantiation declaration followed
by a dllexport explicit instantiation definition.


https://reviews.llvm.org/D26471

Files:
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCXX/windows-itanium-dllexport.cpp


Index: test/CodeGenCXX/windows-itanium-dllexport.cpp
===
--- test/CodeGenCXX/windows-itanium-dllexport.cpp
+++ test/CodeGenCXX/windows-itanium-dllexport.cpp
@@ -7,3 +7,19 @@
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1saSERKS_
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1s1fEv
 
+template 
+class c {
+  void f() {}
+};
+
+template class __declspec(dllexport) c;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
+
+extern template class c;
+template class __declspec(dllexport) c;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
+
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7674,7 +7674,8 @@
   Def->setTemplateSpecializationKind(TSK);
 
   if (!getDLLAttr(Def) && getDLLAttr(Specialization) &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) 
{
 // In the MS ABI, an explicit instantiation definition can add a dll
 // attribute to a template with a previous instantiation declaration.
 // MinGW doesn't allow this.


Index: test/CodeGenCXX/windows-itanium-dllexport.cpp
===
--- test/CodeGenCXX/windows-itanium-dllexport.cpp
+++ test/CodeGenCXX/windows-itanium-dllexport.cpp
@@ -7,3 +7,19 @@
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1saSERKS_
 // CHECK: define {{.*}} dllexport {{.*}} @_ZN1s1fEv
 
+template 
+class c {
+  void f() {}
+};
+
+template class __declspec(dllexport) c;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
+
+extern template class c;
+template class __declspec(dllexport) c;
+
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
+// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
+
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7674,7 +7674,8 @@
   Def->setTemplateSpecializationKind(TSK);
 
   if (!getDLLAttr(Def) && getDLLAttr(Specialization) &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+   Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
 // In the MS ABI, an explicit instantiation definition can add a dll
 // attribute to a template with a previous instantiation declaration.
 // MinGW doesn't allow this.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-09 Thread Serge Rogatch via cfe-commits
rSerge added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

dberris wrote:
> I'm wondering whether it's worth turning this into a `switch` statement now 
> that we have more than two supported architectures?
I think that would lead to more awkward code: there wouldn't be a single 
decision outcome point (like the current `else` block), so to avoid duplicating 
the code which currently prints the message, a `bool` variable would be needed. 
I think it's more neat to just enumerate all the OS&CPU combinations in the 
`if` condition for now.
This place is not performance-critical and the compiler should convert 
appropriate `if`s into `switch`es anyway.


https://reviews.llvm.org/D26415



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


Re: r286376 - [Sparc] LLONG is not lock-free atomic on v8

2016-11-09 Thread Joerg Sonnenberger via cfe-commits
On Wed, Nov 09, 2016 at 03:43:52PM -, Douglas Katzman via cfe-commits wrote:
> Author: dougk
> Date: Wed Nov  9 09:43:51 2016
> New Revision: 286376
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=286376&view=rev
> Log:
> [Sparc] LLONG is not lock-free atomic on v8

Technically, even 32bit is lying for true V8.

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


[clang-tools-extra] r286404 - [clang-tidy docs] Minor formatting changes.

2016-11-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Nov  9 16:31:07 2016
New Revision: 286404

URL: http://llvm.org/viewvc/llvm-project?rev=286404&view=rev
Log:
[clang-tidy docs] Minor formatting changes.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=286404&r1=286403&r2=286404&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed Nov  9 16:31:07 2016
@@ -71,7 +71,7 @@ Name prefixDescription
 == 
=
 
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
-diagnostics are displayed by clang-tidy and can be filtered out using
+diagnostics are displayed by :program:`clang-tidy` and can be filtered out 
using
 ``-checks=`` option. However, the ``-checks=`` option does not affect
 compilation arguments, so it can not turn on Clang warnings which are not
 already turned on in build configuration. The ``-warnings-as-errors=`` option
@@ -237,16 +237,16 @@ Getting Involved
 checks, but its power is in the ability to easily write custom checks.
 
 Checks are organized in modules, which can be linked into :program:`clang-tidy`
-with minimal or no code changes in clang-tidy.
+with minimal or no code changes in :program:`clang-tidy`.
 
 Checks can plug into the analysis on the preprocessor level using 
`PPCallbacks`_
 or on the AST level using `AST Matchers`_. When an error is found, checks can
 report them in a way similar to how Clang diagnostics work. A fix-it hint can 
be
 attached to a diagnostic message.
 
-The interface provided by clang-tidy makes it easy to write useful and precise
-checks in just a few lines of code. If you have an idea for a good check, the
-rest of this document explains how to do this.
+The interface provided by :program:`clang-tidy` makes it easy to write useful
+and precise checks in just a few lines of code. If you have an idea for a good
+check, the rest of this document explains how to do this.
 
 There are a few tools particularly useful when developing clang-tidy checks:
   * ``add_new_check.py`` is a script to automate the process of adding a new
@@ -354,7 +354,7 @@ groups names described :ref:`above `` variable:
 
@@ -472,8 +472,9 @@ Add this near the ``ClangTidyModuleRegis
   // and thus register the MyModule.
   volatile int MyModuleAnchorSource = 0;
 
-And this to the main translation unit of the clang-tidy binary (or the binary
-you link the ``clang-tidy`` library in) ``clang-tidy/tool/ClangTidyMain.cpp``:
+And this to the main translation unit of the :program:`clang-tidy` binary (or
+the binary you link the ``clang-tidy`` library in)
+``clang-tidy/tool/ClangTidyMain.cpp``:
 
 .. code-block:: c++
 
@@ -573,9 +574,9 @@ most frequent pitfalls are macros and te
 2. multiple macro expansions/template instantiations may result in the same 
code
being inspected by the check multiple times (possibly, with different
meanings, see 1), and the same warning (or a slightly different one) may be
-   issued by the check multiple times; clang-tidy will deduplicate _identical_
-   warnings, but if the warnings are slightly different, all of them will be
-   shown to the user (and used for applying fixes, if any);
+   issued by the check multiple times; :program:`clang-tidy` will deduplicate
+   _identical_ warnings, but if the warnings are slightly different, all of 
them
+   will be shown to the user (and used for applying fixes, if any);
 3. making replacements to a macro body/template definition may be fine for some
macro expansions/template instantiations, but easily break some other
expansions/instantiations.


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


[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Aleksey Shlyapnikov via cfe-commits
alekseyshl updated this revision to Diff 77398.
alekseyshl added a comment.

- Added ust test for the new command line args.


https://reviews.llvm.org/D26461

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -278,6 +278,33 @@
 // RUN: %clang -target i386-apple-tvossimulator -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-I386-TVOSSIMULATOR
 // CHECK-TSAN-I386-TVOSSIMULATOR: unsupported option '-fsanitize=thread' for target 'i386-apple-tvossimulator'
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-data-races %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-DATA-RACES
+// CHECK-TSAN-DATA-RACES-NOT: -cc1{{.*}}thread-data-races
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fno-sanitize-thread-data-races %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-DATA-RACES-OFF
+// CHECK-TSAN-DATA-RACES-OFF: -cc1{{.*}}-fno-sanitize-thread-data-races
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fno-sanitize-thread-data-races -fsanitize-thread-data-races %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-DATA-RACES-BOTH
+// CHECK-TSAN-DATA-RACES-BOTH-NOT: -cc1{{.*}}thread-data-races
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-data-races -fno-sanitize-thread-data-races %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-DATA-RACES-OFF
+// CHECK-TSAN-DATA-RACES-BOTH-OFF: -cc1{{.*}}-fno-sanitize-thread-data-races
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-stack-traces %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-STACK-TRACES
+// CHECK-TSAN-STACK-TRACES-NOT: -cc1{{.*}}thread-stack-traces
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fno-sanitize-thread-stack-traces %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-STACK-TRACES-OFF
+// CHECK-TSAN-STACK-TRACES-OFF: -cc1{{.*}}-fno-sanitize-thread-stack-traces
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fno-sanitize-thread-stack-traces -fsanitize-thread-stack-traces %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-STACK-TRACES-BOTH
+// CHECK-TSAN-STACK-TRACES-BOTH-NOT: -cc1{{.*}}thread-stack-traces
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-stack-traces -fno-sanitize-thread-stack-traces %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-STACK-TRACES-OFF
+// CHECK-TSAN-STACK-TRACES-BOTH-OFF: -cc1{{.*}}-fno-sanitize-thread-stack-traces
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-atomics %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-ATOMICS
+// CHECK-TSAN-ATOMICS-NOT: -cc1{{.*}}thread-atomics
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fno-sanitize-thread-atomics %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-ATOMICS-OFF
+// CHECK-TSAN-ATOMICS-OFF: -cc1{{.*}}-fno-sanitize-thread-atomics
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fno-sanitize-thread-atomics -fsanitize-thread-atomics %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-STACK-TRACES-BOTH
+// CHECK-TSAN-ATOMICS-BOTH-NOT: -cc1{{.*}}thread-atomics
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-thread-atomics -fno-sanitize-thread-atomics %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-ATOMICS-OFF
+// CHECK-TSAN-ATOMICS-BOTH-OFF: -cc1{{.*}}-fno-sanitize-thread-atomics
+
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=function %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FSAN-DARWIN
 // CHECK-FSAN-DARWIN: unsupported option '-fsanitize=function' for target 'x86_64-apple-darwin10'
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -729,6 +729,18 @@
   Opts.SanitizeCoverageTracePC = Args.hasArg(OPT_fsanitize_coverage_trace_pc);
   Opts.SanitizeCoverageTracePCGuard =
   Args.hasArg(OPT_fsanitize_coverage_trace_pc_guard);
+  Opts.SanitizeThreadDataRaces =
+  Args.hasFlag(OPT_fsanitize_thread_data_races,
+   OPT_fno_sanitize_thread_data_races,
+   Opts.SanitizeThreadDataRaces);
+  Opts.SanitizeThreadStackTraces =
+  Args.hasFlag(OPT_fsanitize_thread_stack_traces,
+   OPT_fno_sanitize_thread_stack_traces,
+   Opts.SanitizeThreadStackTraces);
+  Opts.SanitizeThreadAtomics =
+  Args.hasFlag(OPT_fsanitize_thread_atomics,
+   OPT_fno_sanitize_thread_atomics,
+   Opts.SanitizeThreadAtomics);
   Opts.SanitizeMemoryTrackOrigins =
   getLastArgIntValue(Args, O

[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.



Comment at: test/Driver/fsanitize.c:288
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread 
-fsanitize-thread-data-races -fno-sanitize-thread-data-races %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-TSAN-DATA-RACES-OFF
+// CHECK-TSAN-DATA-RACES-BOTH-OFF: -cc1{{.*}}-fno-sanitize-thread-data-races
+

did you mean CHECK-TSAN-DATA-RACES-BOTH-NOT?



https://reviews.llvm.org/D26461



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


r286409 - [Sema][NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-11-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Nov  9 16:52:23 2016
New Revision: 286409

URL: http://llvm.org/viewvc/llvm-project?rev=286409&view=rev
Log:
[Sema][NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

Differential revision: https://reviews.llvm.org/D22770

Modified:
cfe/trunk/lib/Sema/ScopeInfo.cpp

Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=286409&r1=286408&r2=286409&view=diff
==
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Wed Nov  9 16:52:23 2016
@@ -29,6 +29,7 @@ void FunctionScopeInfo::Clear() {
   HasIndirectGoto = false;
   HasDroppedStmt = false;
   HasOMPDeclareReductionCombiner = false;
+  HasFallthroughStmt = false;
   HasPotentialAvailabilityViolations = false;
   ObjCShouldCallSuper = false;
   ObjCIsDesignatedInit = false;


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


[PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-11-09 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286409: [Sema][NFC] Reset HasFallthroughStmt when clearing 
FunctionScopeInfo (authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D22770?vs=65380&id=77399#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22770

Files:
  cfe/trunk/lib/Sema/ScopeInfo.cpp


Index: cfe/trunk/lib/Sema/ScopeInfo.cpp
===
--- cfe/trunk/lib/Sema/ScopeInfo.cpp
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp
@@ -29,6 +29,7 @@
   HasIndirectGoto = false;
   HasDroppedStmt = false;
   HasOMPDeclareReductionCombiner = false;
+  HasFallthroughStmt = false;
   HasPotentialAvailabilityViolations = false;
   ObjCShouldCallSuper = false;
   ObjCIsDesignatedInit = false;


Index: cfe/trunk/lib/Sema/ScopeInfo.cpp
===
--- cfe/trunk/lib/Sema/ScopeInfo.cpp
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp
@@ -29,6 +29,7 @@
   HasIndirectGoto = false;
   HasDroppedStmt = false;
   HasOMPDeclareReductionCombiner = false;
+  HasFallthroughStmt = false;
   HasPotentialAvailabilityViolations = false;
   ObjCShouldCallSuper = false;
   ObjCIsDesignatedInit = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26476: [AMDGPU] Add support for f16 builtin functions for VI+

2016-11-09 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: tstellarAMD, arsenm.
kzhuravl added a subscriber: cfe-commits.
Herald added subscribers: tony-tye, yaxunl, nhaehnle, wdng.

https://reviews.llvm.org/D26476

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-class.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-cos.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-div-fixup.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-fract.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-frexp-exp.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-frexp-mant.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-ldexp.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-rcp.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-rsq.cl
  test/CodeGenOpenCL/builtins-amdgcn-error-f16-sin.cl
  test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  test/CodeGenOpenCL/builtins-amdgcn.cl

Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -166,14 +166,14 @@
 }
 
 // CHECK-LABEL: @test_frexp_exp_f32
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f32
+// CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f32
 void test_frexp_exp_f32(global int* out, float a)
 {
   *out = __builtin_amdgcn_frexp_expf(a);
 }
 
 // CHECK-LABEL: @test_frexp_exp_f64
-// CHECK: call i32 @llvm.amdgcn.frexp.exp.f64
+// CHECK: call i32 @llvm.amdgcn.frexp.exp.i32.f64
 void test_frexp_exp_f64(global int* out, double a)
 {
   *out = __builtin_amdgcn_frexp_exp(a);
Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -1,8 +1,79 @@
 // REQUIRES: amdgpu-registered-target
 // RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -S -emit-llvm -o - %s | FileCheck %s
 
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
 typedef unsigned long ulong;
 
+// CHECK-LABEL: @test_div_fixup_f16
+// CHECK: call half @llvm.amdgcn.div.fixup.f16
+void test_div_fixup_f16(global half* out, half a, half b, half c)
+{
+  *out = __builtin_amdgcn_div_fixuph(a, b, c);
+}
+
+// CHECK-LABEL: @test_rcp_f16
+// CHECK: call half @llvm.amdgcn.rcp.f16
+void test_rcp_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_rcph(a);
+}
+
+// CHECK-LABEL: @test_rsq_f16
+// CHECK: call half @llvm.amdgcn.rsq.f16
+void test_rsq_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_rsqh(a);
+}
+
+// CHECK-LABEL: @test_sin_f16
+// CHECK: call half @llvm.amdgcn.sin.f16
+void test_sin_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_sinh(a);
+}
+
+// CHECK-LABEL: @test_cos_f16
+// CHECK: call half @llvm.amdgcn.cos.f16
+void test_cos_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_cosh(a);
+}
+
+// CHECK-LABEL: @test_ldexp_f16
+// CHECK: call half @llvm.amdgcn.ldexp.f16
+void test_ldexp_f16(global half* out, half a, int b)
+{
+  *out = __builtin_amdgcn_ldexph(a, b);
+}
+
+// CHECK-LABEL: @test_frexp_mant_f16
+// CHECK: call half @llvm.amdgcn.frexp.mant.f16
+void test_frexp_mant_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_frexp_manth(a);
+}
+
+// CHECK-LABEL: @test_frexp_exp_f16
+// CHECK: call i16 @llvm.amdgcn.frexp.exp.i16.f16
+void test_frexp_exp_f16(global short* out, half a)
+{
+  *out = __builtin_amdgcn_frexp_exph(a);
+}
+
+// CHECK-LABEL: @test_fract_f16
+// CHECK: call half @llvm.amdgcn.fract.f16
+void test_fract_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_fracth(a);
+}
+
+// CHECK-LABEL: @test_class_f16
+// CHECK: call i1 @llvm.amdgcn.class.f16
+void test_class_f16(global half* out, half a, int b)
+{
+  *out = __builtin_amdgcn_classh(a, b);
+}
 
 // CHECK-LABEL: @test_s_memrealtime
 // CHECK: call i64 @llvm.amdgcn.s.memrealtime()
Index: test/CodeGenOpenCL/builtins-amdgcn-error-f16-sin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-error-f16-sin.cl
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -target-cpu tahiti -verify -S -o - %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+void test_sin_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_sinh(a); // expected-error {{'__builtin_amdgcn_sinh' needs target feature 16-bit-insts}}
+}
Index: test/CodeGenOpenCL/builtins-amdgcn-error-f16-rsq.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-error-f16-rsq.cl
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -target-cpu tahiti -verify -S -o - %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+void test_rsq_f16(global half* out, half a)
+{
+  *out = __builtin_amdgcn_rsqh(a); // expected-error {{'__builtin_amd

[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-09 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.



Comment at: lib/Driver/Tools.cpp:4903-4906
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {

rSerge wrote:
> dberris wrote:
> > I'm wondering whether it's worth turning this into a `switch` statement now 
> > that we have more than two supported architectures?
> I think that would lead to more awkward code: there wouldn't be a single 
> decision outcome point (like the current `else` block), so to avoid 
> duplicating the code which currently prints the message, a `bool` variable 
> would be needed. I think it's more neat to just enumerate all the OS&CPU 
> combinations in the `if` condition for now.
> This place is not performance-critical and the compiler should convert 
> appropriate `if`s into `switch`es anyway.
This is an issue of making it more readable, something like:

```
if (Triple.getOS() != llvm::Triple::Linux)
  D.Diag(...) << ...; // Unsupported OS.
switch (Triple.getArch()) {
  case llvm::Triple::arm:
  case llvm::Triple::x86_64:
  case llvm::Tripe::aarch64:
// Supported.
break;
  default:
D.Diag(...) << ...;
}
```

This way any new architectures become supported, they just get added to the 
list of cases that short-circuit.


https://reviews.llvm.org/D26415



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


[PATCH] D26461: Tread TSan LLVM flags to driver: add TSan controlling flags to clang.

2016-11-09 Thread Dmitry Vyukov via cfe-commits
dvyukov added inline comments.



Comment at: include/clang/Driver/Options.td:733
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable data race detection in 
ThreadSanitizer">;
+def fno_sanitize_thread_data_races : Flag<["-"], 
"fno-sanitize-thread-data-races">,

These descriptions may be confusing for users.
This does not disable data race detection in tsan. Even if all files are 
compiled with this flag, tsan can still report races. Same for traces and 
atomics.
Please make it clear that it only enables/disables source _instrumentation_.

Does user see what's the default value? If not, then I guess some users will 
add flags just because they do want data races detection and stack traces. We 
need to make it clear that all flags are enabled by default.


https://reviews.llvm.org/D26461



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


r286411 - Relax testcase so it also works on Windows.

2016-11-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Nov  9 17:05:16 2016
New Revision: 286411

URL: http://llvm.org/viewvc/llvm-project?rev=286411&view=rev
Log:
Relax testcase so it also works on Windows.

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=286411&r1=286410&r2=286411&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp Wed Nov  9 17:05:16 2016
@@ -13,7 +13,7 @@ struct C : A, B {
 };
 
 void C::f() { }
-// CHECK: define void @_ZThn{{[48]}}_N1C1fEv
+// CHECK: define {{.*}} void @_ZThn{{[48]}}_N1C1fEv
 // CHECK-SAME: !dbg ![[SP:[0-9]+]]
 // CHECK-NOT: {{ret }}
 // CHECK: = load{{.*}} !dbg ![[DBG:[0-9]+]]


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


[PATCH] D26479: [PowerPC] Implement remaining permute builtins in altivec.h - Clang portion

2016-11-09 Thread Nemanja Ivanovic via cfe-commits
nemanjai created this revision.
nemanjai added reviewers: hfinkel, kbarton, syzaara, lei, jtony, sfertile, 
amehsan.
nemanjai added subscribers: cfe-commits, echristo.
nemanjai set the repository for this revision to rL LLVM.

This adds the following signatures into altivec.h:

vector bool long long vec_mergee (vector bool long long, vector bool long long);
vector signed long long vec_mergee (vector signed long long, vector signed long 
long);
vector unsigned long long vec_mergee (vector unsigned long long, vector 
unsigned long long);
vector float vec_mergee (vector float, vector float);
vector double vec_mergee (vector double, vector double);
vector bool long long vec_mergeo (vector bool long long, vector bool long long);
vector signed long long vec_mergeo (vector signed long long, vector signed long 
long);
vector unsigned long long vec_mergeo (vector unsigned long long, vector 
unsigned long long);
vector double vec_mergeo (vector double, vector double);
vector float vec_mergeo (vector float, vector float);
vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
vector bool char vec_permxor (vector bool char, vector bool char, vector bool 
char);
vector unsigned char vec_permxor (vector signed char, vector signed char, 
vector signed char);
vector unsigned char vec_permxor (vector unsigned char, vector unsigned char, 
vector unsigned char);
vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int, vector 
unsigned int);
vector unsigned long long vec_rlmi (vector unsigned long long, vector unsigned 
long long, vector unsigned long long);
vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int, vector 
unsigned int);
vector double vec_unpackh (vector float);
vector double vec_unpackl (vector float);
vector float vec_pack (vector double, vector double);


Repository:
  rL LLVM

https://reviews.llvm.org/D26479

Files:
  include/clang/Basic/BuiltinsPPC.def
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-crypto.c
  test/CodeGen/builtins-ppc-p8vector.c
  test/CodeGen/builtins-ppc-p9vector.c

Index: test/CodeGen/builtins-ppc-p9vector.c
===
--- test/CodeGen/builtins-ppc-p9vector.c
+++ test/CodeGen/builtins-ppc-p9vector.c
@@ -827,4 +827,101 @@
 // CHECK-NEXT: ret <16 x i8>
   return vec_srv (vuca, vucb);
 }
-
+vector unsigned short test74(void) {
+// CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK-BE: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK-BE: @llvm.ppc.altivec.vperm
+// CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK: @llvm.ppc.vsx.xvcvsphp(<4 x float>
+// CHECK: @llvm.ppc.altivec.vperm
+  return vec_pack_to_short_fp32(vfa, vfb);
+}
+vector unsigned int test75(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrlwmi(<4 x i32
+// CHECK-BE-NEXT: ret <4 x i32>
+// CHECK: @llvm.ppc.altivec.vrlwmi(<4 x i32
+// CHECK-NEXT: ret <4 x i32>
+  return vec_rlmi(vuia, vuia, vuia);
+}
+vector unsigned long long test76(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrldmi(<2 x i64
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: @llvm.ppc.altivec.vrldmi(<2 x i64
+// CHECK-NEXT: ret <2 x i64>
+  return vec_rlmi(vula, vula, vula);
+}
+vector unsigned int test77(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrlwnm(<4 x i32
+// CHECK-BE: and <4 x i32
+// CHECK-BE: ret <4 x i32>
+// CHECK: @llvm.ppc.altivec.vrlwnm(<4 x i32
+// CHECK: and <4 x i32
+// CHECK: ret <4 x i32>
+  return vec_rlnm(vuia, vuia, vuia);
+}
+vector unsigned long long test78(void) {
+// CHECK-BE: @llvm.ppc.altivec.vrldnm(<2 x i64
+// CHECK-BE: and <2 x i64
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: @llvm.ppc.altivec.vrldnm(<2 x i64
+// CHECK: and <2 x i64
+// CHECK-NEXT: ret <2 x i64>
+  return vec_rlnm(vula, vula, vula);
+}
+vector double test79(void) {
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+  return vec_unpackh(vfa);
+}
+vector double test80(void) {
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK-BE: extractelement <4 x float>
+// CHECK-BE: fpext float
+// CHECK-BE: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+// CHECK: extractelement <4 x float>
+// CHECK: fpext float
+// CHECK: insertelement <2 x double>
+  return vec_unpackl(vfa);
+}
+vector double test81(void) {
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrunc double
+  // CHECK: insertelement <4 x float>
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrunc double
+  // CHECK: insertelement <4 x float>
+  // CHECK: extractelement <2 x double>
+  // CHECK: fptrun

r286412 - Remove extra whitespace

2016-11-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Nov  9 17:10:44 2016
New Revision: 286412

URL: http://llvm.org/viewvc/llvm-project?rev=286412&view=rev
Log:
Remove extra whitespace

Modified:
cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp

Modified: cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=286412&r1=286411&r2=286412&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp Wed Nov  9 17:10:44 2016
@@ -13,7 +13,7 @@ struct C : A, B {
 };
 
 void C::f() { }
-// CHECK: define {{.*}} void @_ZThn{{[48]}}_N1C1fEv
+// CHECK: define {{.*}}void @_ZThn{{[48]}}_N1C1fEv
 // CHECK-SAME: !dbg ![[SP:[0-9]+]]
 // CHECK-NOT: {{ret }}
 // CHECK: = load{{.*}} !dbg ![[DBG:[0-9]+]]


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


[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-09 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 77410.
bkramer added a comment.

Add extern "C++" test case.


https://reviews.llvm.org/D23130

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GlobalNamesCheck.cpp
  clang-tidy/google/GlobalNamesCheck.h
  clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-global-names-in-headers.rst
  docs/clang-tidy/checks/google-global-names.rst
  test/clang-tidy/google-global-names.cpp
  unittests/clang-tidy/GoogleModuleTest.cpp

Index: unittests/clang-tidy/GoogleModuleTest.cpp
===
--- unittests/clang-tidy/GoogleModuleTest.cpp
+++ unittests/clang-tidy/GoogleModuleTest.cpp
@@ -1,6 +1,6 @@
 #include "ClangTidyTest.h"
 #include "google/ExplicitConstructorCheck.h"
-#include "google/GlobalNamesInHeadersCheck.h"
+#include "google/GlobalNamesCheck.h"
 #include "gtest/gtest.h"
 
 using namespace clang::tidy::google;
@@ -56,7 +56,7 @@
   "A(Foo);"));
 }
 
-class GlobalNamesInHeadersCheckTest : public ::testing::Test {
+class GlobalNamesCheckTest : public ::testing::Test {
 protected:
   bool runCheckOnCode(const std::string &Code, const std::string &Filename) {
 static const char *const Header = "namespace std {\n"
@@ -69,7 +69,7 @@
 if (!StringRef(Filename).endswith(".cpp")) {
   Args.emplace_back("-xc++-header");
 }
-test::runCheckOnCode(
+test::runCheckOnCode(
 Header + Code, &Errors, Filename, Args);
 if (Errors.empty())
   return false;
@@ -81,7 +81,7 @@
   }
 };
 
-TEST_F(GlobalNamesInHeadersCheckTest, UsingDeclarations) {
+TEST_F(GlobalNamesCheckTest, UsingDeclarations) {
   EXPECT_TRUE(runCheckOnCode("using std::string;", "foo.h"));
   EXPECT_FALSE(runCheckOnCode("using std::string;", "foo.cpp"));
   EXPECT_FALSE(runCheckOnCode("namespace my_namespace {\n"
@@ -91,7 +91,7 @@
   EXPECT_FALSE(runCheckOnCode("SOME_MACRO(std::string);", "foo.h"));
 }
 
-TEST_F(GlobalNamesInHeadersCheckTest, UsingDirectives) {
+TEST_F(GlobalNamesCheckTest, UsingDirectives) {
   EXPECT_TRUE(runCheckOnCode("using namespace std;", "foo.h"));
   EXPECT_FALSE(runCheckOnCode("using namespace std;", "foo.cpp"));
   EXPECT_FALSE(runCheckOnCode("namespace my_namespace {\n"
@@ -101,7 +101,7 @@
   EXPECT_FALSE(runCheckOnCode("SOME_MACRO(namespace std);", "foo.h"));
 }
 
-TEST_F(GlobalNamesInHeadersCheckTest, RegressionAnonymousNamespace) {
+TEST_F(GlobalNamesCheckTest, RegressionAnonymousNamespace) {
   EXPECT_FALSE(runCheckOnCode("namespace {}", "foo.h"));
 }
 
Index: test/clang-tidy/google-global-names.cpp
===
--- /dev/null
+++ test/clang-tidy/google-global-names.cpp
@@ -0,0 +1,46 @@
+// RUN: %check_clang_tidy %s google-global-names %t
+
+void f();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: 'f' declared in the global namespace
+void f() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: 'f' declared in the global namespace
+class F;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'F' declared in the global namespace
+class F {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'F' declared in the global namespace
+int i;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'i' declared in the global namespace
+extern int ii = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'ii' declared in the global namespace
+
+// No warnings below.
+extern "C" void g();
+extern "C" void h() {}
+extern "C++" void h2() {}
+
+#define VAR(v) v
+VAR(int m);
+
+extern "C" {
+void j() {}
+}
+
+struct Clike {
+  int i;
+};
+
+extern "C" int ik;
+extern "C" { int il; }
+
+void *operator new(__SIZE_TYPE__, int) { return 0; }
+void operator delete(void *, int) {}
+
+static void l() {}
+namespace {
+void m() {}
+}
+namespace x {
+void n() {}
+}
+
+int main() {}
Index: docs/clang-tidy/checks/google-global-names.rst
===
--- docs/clang-tidy/checks/google-global-names.rst
+++ docs/clang-tidy/checks/google-global-names.rst
@@ -1,10 +1,12 @@
-.. title:: clang-tidy - google-global-names-in-headers
+.. title:: clang-tidy - google-global-names
 
-google-global-names-in-headers
-==
+google-global-names
+===
 
-Flag global namespace pollution in header files. Right now it only triggers on
-``using`` declarations and directives.
+Flag global namespace pollution in header files.
+Right now it only triggers on using declarations and directives in header files
+and declarations and definitions of functions, classes and variables in the
+global namespace.
 
 The relevant style guide section is
 https://google.github.io/styleguide/cppguide.html#Namespaces.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to c

[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-09 Thread Benjamin Kramer via cfe-commits
bkramer marked 2 inline comments as done.
bkramer added a comment.

In https://reviews.llvm.org/D23130#589643, @alexfh wrote:

> > and generally frowned upon in many codebases (e.g. LLVM)
>
> Should it still be a part of google/? The old check was enforcing a part of 
> the Google C++ style guide, but the new one seems to be somewhat broader. Am 
> I mistaken?


The google style guide has a rule that code should usually be placed in a 
namespace. The wording there is fuzzy, but I believe this check still belongs 
under google/




Comment at: clang-tidy/google/GlobalNamesCheck.cpp:77
+}
+diag(
+D->getLocStart(),

aaron.ballman wrote:
> Is this formatting that clang-format generates?
Yes. I clang-formatted the entire file.



Comment at: test/clang-tidy/google-global-names.cpp:13-14
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'i' declared in the global 
namespace
+extern int ii = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'ii' declared in the global 
namespace
+

aaron.ballman wrote:
> aaron.ballman wrote:
> > bkramer wrote:
> > > aaron.ballman wrote:
> > > > This strikes me as being intentional enough to warrant not diagnosing 
> > > > because of the `extern` keyword.
> > > The only case I see where this pattern is valuable is interfacing with C 
> > > code. Not sure yet if we want to allow that or enforce extern "C" 
> > > instead. Ideas?
> > > 
> > > an extern global in the global namespace still feels like something we 
> > > should warn on :|
> > Yet externs in the global namespace do happen for valid reasons (such as 
> > not breaking ABIs by putting the extern definition into a namespace or 
> > changing the language linkage) -- I'm trying to think of ways we can allow 
> > the user to silence this diagnostic in those cases. I feel like in cases 
> > where the user writes "extern", they're explicitly specifying their intent 
> > and that doesn't seem like a case to warn them about, in some regards. It 
> > would give us two ways to silence the diagnostic (well, three, but two are 
> > morally close enough):
> > 
> > 1) Put it into a namespace
> > 2) Slap `extern` on it if it is global for C++ compatibility (such as ABIs)
> > 3) Slap `extern "C"` on it if it global for C compatibility
> > 
> > I suppose we could require `extern "C++"` instead of `extern`, but I don't 
> > think that's a particularly common use of the language linkage specifier?
> I still think that a user explicitly writing 'extern' is expecting external 
> linkage and all that goes along with it.
I disagree. If this is a special variable to be accessed via dlopen it should 
be extern "C". If not it should be in a namespace.



Comment at: test/clang-tidy/google-global-names.cpp:18
+extern "C" void g();
+extern "C" void h() {}
+

aaron.ballman wrote:
> Can you also add a test:
> ```
> extern "C++" void h2() {}
> ```
> I believe this will diagnose, but whether it should diagnose or not, I'm less 
> certain of.
Test added, doesn't diagnose.


https://reviews.llvm.org/D23130



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


[PATCH] D26342: [analyzer] Add MutexChecker for the Magenta kernel

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

In https://reviews.llvm.org/D26342#590881, @khazem wrote:

> I think that it's sensible to try merging this with PthreadLockChecker. In 
> fact, I could also try merging the SpinLockChecker [1] that I've posted for 
> review with PthreadLockChecker also, since they all implement similar 
> functionality.


That'd be great!

In https://reviews.llvm.org/D26342#590881, @khazem wrote:

> Here is my proposal: I could try refactoring the PthreadLockChecker into a 
> LockChecker class, which would be instantiated as various subclasses (for 
> Pthread, XNU, Magenta, and others in the future). The common functionality 
> would be implemented in LockChecker, but the user would ask for a specific 
> checker using command-line flags. Using subclasses would hopefully prevent 
> the class from becoming a mess of if/switch statements, while allowing future 
> LockCheckers to be implemented for other lock APIs. Does this seem reasonable?


We usually go with the if/switch approach (in this case we instantly see what's 
the difference between the two APIs), and i think we don't do checker 
inheritance anywhere, but i don't have good reasons to instantly prefer one 
over the other, so it's be nice to know if inheritance is actually better here.

Note that if all you want is to enable/disable platform-specific checks 
separately with `-analyzer-checker` options, or have separate lines for the 
checks in `Checkers.td` (and auto-enable magenta checkers if the magenta target 
platform is detected), then you don't necessarily need to produce separate 
`Checker<>` classes/instances in your C++ code for that. We can have different 
checkers point to the same C++ checker object. See `unix.Malloc` and 
`cplusplus.NewDelete` as an example (they're essentially the same checker) - 
the tricks are in `registerChecker` procedure.


https://reviews.llvm.org/D26342



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


[PATCH] D26466: [clang-tidy] Fix NOLINT test

2016-11-09 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Thanks! LG


https://reviews.llvm.org/D26466



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


Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-09 Thread Alexander Kornienko via cfe-commits
Malcolm, does it work for you?

On Wed, Nov 9, 2016 at 10:56 AM, Devin Coughlin  wrote:

> + Anna, Alexander, and Artem.
>
> > On Nov 9, 2016, at 10:50 AM, Devin Coughlin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> >
> >> On Nov 8, 2016, at 9:44 AM, Malcolm Parsons 
> wrote:
> >>
> >> On 8 November 2016 at 16:59, Alexander Kornienko 
> wrote:
> >>> On Nov 8, 2016 2:11 AM, "Malcolm Parsons" 
> wrote:
>  Oh, I was using clang-analyzer-alpha.cplusplus.VirtualCall.
> 
>  Should clang-tidy have an option to enable experimental checks?
> >>>
> >>> I'd instead ask Static Analyzer folks if they can graduate this check.
> >
> > We agree that this is a valuable checker and are committed to getting it
> out of alpha. This check is in alpha because:
> >
> > a) The diagnostic experience is not very good. It reports a call path
> directly in the diagnostic message (for example “Call path: foo <— bar” for
> a call to foo() in bar()) rather than as a path diagnostic.
> >
> > b) The lack of path-sensitive reasoning may result in false positives
> when a called function uses a member variable flag to track whether
> initialization is complete and does not call the virtual member function
> during initialization.
> >
> > c) The check issues a warning for both calls to pure virtual functions
> (which is always an error) and non-pure virtual functions (which is more of
> a code smell and may be a false positive).
> >
> > From our perspective, the diagnostic experience is the primary blocker
> to moving this checker out of alpha and thus turning it on by default.
> >
> > Here is our plan to graduate the checker:
> >
> > Step 1) Modify the existing AST-based checker to only report on virtual
> calls in the constructor/destructor itself. This will result in false
> negatives but avoid the poor diagnostic experience in a). We’ll move the
> checker out of alpha, which will turn it on by default for all users, and
> add an -analyzer-config flag to to recover the old behavior.
> >
> > Step 2) Rewrite the checker to be path-sensitive. This will improve the
> diagnostic experience so that we can turn the inter-procedural case back on
> and also limit false positives from b).
> >
> > I’ll commit to doing Step 1) in the immediate future and Step 2)
> eventually. Once the checker is on by default we’ll need to assess whether
> the false positive rate from c) is too high — if so, we’ll need to turn the
> non-pure-virtual case off by default.
> >
> > Devin
> >
> > ___
> > 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


  1   2   >