Re: [PATCH] D16628: clang-cl: support __cdecl-on-struct anachronism

2016-03-21 Thread Stephan Bergmann via cfe-commits
sberg added a comment.

friendly ping


http://reviews.llvm.org/D16628



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


Re: [PATCH] D18276: [OpenMP] Allow reduction on pointer dereference

2016-03-21 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld abandoned this revision.


Comment at: lib/CodeGen/CGStmtOpenMP.cpp:913-929
@@ -912,9 +912,19 @@
 });
-  } else if (auto *ASE = dyn_cast(IRef)) {
-auto *Base = ASE->getBase()->IgnoreParenImpCasts();
-while (auto *TempASE = dyn_cast(Base))
-  Base = TempASE->getBase()->IgnoreParenImpCasts();
+  } else if (isa(IRef) || isa(IRef)) {
+const Expr *Array;
+const Expr *Base;
+if (auto* ASE = dyn_cast(IRef)) {
+  Array = ASE;
+  Base = ASE->getBase()->IgnoreParenImpCasts();
+  while (auto *TempASE = dyn_cast(Base))
+Base = TempASE->getBase()->IgnoreParenImpCasts();
+} else {
+  auto* UO = cast(IRef);
+  assert(UO->getOpcode() == UO_Deref && "should be a dereference");
+  Array = UO;
+  Base = UO->getSubExpr()->IgnoreParenImpCasts();
+}
 auto *DE = cast(Base);
 auto *OrigVD = cast(DE->getDecl());
-auto ASELValue = EmitLValue(ASE);
+auto ASELValue = EmitLValue(Array);
 auto OriginalBaseLValue = EmitLValue(DE);

ABataev wrote:
> This is not allowed by OpenMP standard. I added support for array subscripts 
> because they are very similar to array sections, but unary operations are 
> definitely not allowed
Ok, I'm fine with that and will close this revision.

(for me `*arr` is the same as `arr[0]` so I expected it to work as well)


http://reviews.llvm.org/D18276



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


Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target

2016-03-21 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen added inline comments.


Comment at: test/CodeGenOpenCL/spir_version.cl:15
@@ +14,2 @@
+// CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
+// CL20: [[SPIR]] = !{i32 2, i32 0}

Can you test 'spir64' too?


http://reviews.llvm.org/D17596



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


r263921 - [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

2016-03-21 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon Mar 21 04:25:37 2016
New Revision: 263921

URL: http://llvm.org/viewvc/llvm-project?rev=263921&view=rev
Log:
[Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)

Implement lambda capture of *this by copy.
For e.g.:
struct A {

  int d = 10;
  auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; }

};

auto L = A{}.foo(); // A{}'s lifetime is gone.

// Below is still ok, because *this was captured by value.
assert(L(10) == 20);
assert(L(100) == 120);

If the capture was implicit, or [this] (i.e. *this was captured by reference), 
this code would be otherwise undefined.

Implementation Strategy:
  - amend the parser to accept *this in the lambda introducer
  - add a new king of capture LCK_StarThis
  - teach Sema::CheckCXXThisCapture to handle by copy captures of the
enclosing object (i.e. *this)
  - when CheckCXXThisCapture does capture by copy, the corresponding 
initializer expression for the closure's data member 
direct-initializes it thus making a copy of '*this'.
  - in codegen, when assigning to CXXThisValue, if *this was captured by 
copy, make sure it points to the corresponding field member, and
not, unlike when captured by reference, what the field member points
to.
  - mark feature as implemented in svn

Much gratitude to Richard Smith for his carefully illuminating reviews!   

Added:
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp
cfe/trunk/test/SemaCXX/cxx1z-lambda-star-this.cpp
Modified:
cfe/trunk/include/clang/AST/LambdaCapture.h
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/Lambda.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/LambdaCapture.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/LambdaCapture.h?rev=263921&r1=263920&r2=263921&view=diff
==
--- cfe/trunk/include/clang/AST/LambdaCapture.h (original)
+++ cfe/trunk/include/clang/AST/LambdaCapture.h Mon Mar 21 04:25:37 2016
@@ -35,8 +35,18 @@ class LambdaCapture {
 /// This includes the case of a non-reference init-capture.
 Capture_ByCopy = 0x02
   };
+  struct LLVM_ALIGNAS(4) OpaqueCapturedEntity {};
+  static OpaqueCapturedEntity ThisSentinel;
+  static OpaqueCapturedEntity VLASentinel;
+  
+  // Captured Entity could represent:
+  // - a VarDecl* that represents the variable that was captured or the 
+  //   init-capture.
+  // - or, points to the ThisSentinel if this represents a capture of '*this'
+  //   by value or reference.
+  // - or, points to the VLASentinel if this represents a capture of a VLA 
type.
+  llvm::PointerIntPair CapturedEntityAndBits;
 
-  llvm::PointerIntPair DeclAndBits;
   SourceLocation Loc;
   SourceLocation EllipsisLoc;
 
@@ -69,20 +79,21 @@ public:
   /// \brief Determine whether this capture handles the C++ \c this
   /// pointer.
   bool capturesThis() const {
-return (DeclAndBits.getPointer() == nullptr) &&
-   !(DeclAndBits.getInt() & Capture_ByCopy);
+return CapturedEntityAndBits.getPointer() == &ThisSentinel;
   }
 
   /// \brief Determine whether this capture handles a variable.
   bool capturesVariable() const {
-return dyn_cast_or_null(DeclAndBits.getPointer());
+void *Ptr = CapturedEntityAndBits.getPointer();
+if (Ptr != &ThisSentinel && Ptr != &VLASentinel)
+  return dyn_cast_or_null(static_cast(Ptr));
+return false;
   }
 
   /// \brief Determine whether this captures a variable length array bound
   /// expression.
   bool capturesVLAType() const {
-return (DeclAndBits.getPointer() == nullptr) &&
-   (DeclAndBits.getInt() & Capture_ByCopy);
+return CapturedEntityAndBits.getPointer() == &VLASentinel;
   }
 
   /// \brief Retrieve the declaration of the local variable being
@@ -91,13 +102,15 @@ public:
   /// This operation is only valid if this capture is a variable capture
   /// (other than a capture of \c this).
   VarDecl *getCapturedVar() const {
-assert(capturesVariable() && "No variable available for 'this' capture");
-return cast(DeclAndBits.getPointer());
+assert(capturesVariable() && "No variable available for capture");
+return static_cast(Captur

Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-03-21 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

ping


http://reviews.llvm.org/D13126



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


[PATCH] D18309: sourceRange function for MemRegion

2016-03-21 Thread Alexander Droste via cfe-commits
Alexander_Droste created this revision.
Alexander_Droste added a reviewer: zaks.anna.
Alexander_Droste added subscribers: dcoughlin, xazax.hun, cfe-commits.

Retrieve source range from memory region. The range retrieval is based on the 
decl obtained from the memory region.


http://reviews.llvm.org/D18309

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Core/MemRegion.cpp

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,18 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Retrieve source range from memory region. The range retrieval
+  /// is based on the decl obtained from the memory region.
+  /// For a VarRegion the range of the base region is returned.
+  /// For a FieldRegion the range of the field is returned.
+  /// If no declaration is found, an empty source range is returned.
+  /// The client is responsible for checking if the returned range is valid.
+  ///
+  /// \param MR memory region to retrieve the source range for
+  ///
+  /// \returns source range for declaration retrieved from memory region
+  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,25 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+SourceRange MemRegion::sourceRange() const {
+  const VarRegion *const VR = dyn_cast(this->getBaseRegion());
+  const FieldRegion *const FR = dyn_cast(this);
+
+  // Check for more specific regions first.
+  // FieldRegion
+  if (FR) {
+return FR->getDecl()->getSourceRange();
+  }
+  // VarRegion
+  else if (VR) {
+return VR->getDecl()->getSourceRange();
+  }
+  // Return invalid source range (can be checked by client).
+  else {
+return SourceRange{};
+  }
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,18 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Retrieve source range from memory region. The range retrieval
+  /// is based on the decl obtained from the memory region.
+  /// For a VarRegion the range of the base region is returned.
+  /// For a FieldRegion the range of the field is returned.
+  /// If no declaration is found, an empty source range is returned.
+  /// The client is responsible for checking if the returned range is valid.
+  ///
+  /// \param MR memory region to retrieve the source range for
+  ///
+  /// \returns source range for declaration retrieved from memory region
+  clang::SourceRange sourceRange() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,25 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+SourceRange MemRegion::sourceRange() const {
+  const VarRegion *const VR = dyn_cast(this->getBaseRegion());
+  const FieldRegion *const FR = dyn_cast(this);
+
+  // Check for more specific regions first.
+  // FieldRegion
+  if (FR) {
+return FR->getDecl()->getSourceRange();
+  }
+  // VarRegion
+  else if (VR) {
+return VR->getDecl()->getSourceRange();
+  }
+  // Return invalid source range (can be checked by client).
+  else {
+return SourceRange{};
+  }
+}
+
 //===--===//
 // MemRegionManager methods.
 //===--===//
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-03-21 Thread Serge Pavlov via cfe-commits
With the latest changes unit tests are successfully passed on Windows!
You can go forward in completing the fix.

Thanks,
--Serge

2016-03-18 21:44 GMT+06:00 Aleksei Sidorin :

> a.sidorin updated this revision to Diff 51027.
> a.sidorin added a comment.
>
> Serge, thank you for help!
> GNUNullExpr was 'long' on my platform. I weakened a matcher to check only
> if it has integer type.
> ParenListExpr issue was also successfully reproduced with
> 'fdelayed-template-parsing' and fixed.
> I hope this version passes all the tests. Could you recheck? I cannot gain
> access to MSVC now.
>
>
> http://reviews.llvm.org/D14286
>
> Files:
>   include/clang/AST/Type.h
>   lib/AST/ASTImporter.cpp
>   unittests/AST/ASTImporterTest.cpp
>   unittests/AST/CMakeLists.txt
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263922 - Reorder data members to be consistent with member initializers, to silence warnings.

2016-03-21 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Mon Mar 21 05:37:42 2016
New Revision: 263922

URL: http://llvm.org/viewvc/llvm-project?rev=263922&view=rev
Log:
Reorder data members to be consistent with member initializers, to silence 
warnings.

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=263922&r1=263921&r2=263922&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Mon Mar 21 05:37:42 2016
@@ -422,11 +422,6 @@ public:
 enum CaptureKind {
   Cap_ByCopy, Cap_ByRef, Cap_Block, Cap_VLA
 };
-/// Expression to initialize a field of the given type, and the kind of
-/// capture (if this is a capture and not an init-capture). The expression
-/// is only required if we are capturing ByVal and the variable's type has
-/// a non-trivial copy constructor.
-llvm::PointerIntPair InitExprAndCaptureKind;
 enum {
   IsNestedCapture = 0x1,
   IsThisCaptured = 0x2
@@ -434,7 +429,12 @@ public:
 /// The variable being captured (if we are not capturing 'this') and 
whether
 /// this is a nested capture, and whether we are capturing 'this'
 llvm::PointerIntPair VarAndNestedAndThis;
-
+/// Expression to initialize a field of the given type, and the kind of
+/// capture (if this is a capture and not an init-capture). The expression
+/// is only required if we are capturing ByVal and the variable's type has
+/// a non-trivial copy constructor.
+llvm::PointerIntPair InitExprAndCaptureKind;
+
 /// \brief The source location at which the first capture occurred.
 SourceLocation Loc;
 


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


r263931 - clang/test/Frontend/plugin-annotate-functions.c requires the target examples/AnnotateFunctions.

2016-03-21 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Mar 21 06:03:39 2016
New Revision: 263931

URL: http://llvm.org/viewvc/llvm-project?rev=263931&view=rev
Log:
clang/test/Frontend/plugin-annotate-functions.c requires the target 
examples/AnnotateFunctions.

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=263931&r1=263930&r2=263931&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Mon Mar 21 06:03:39 2016
@@ -40,6 +40,7 @@ endif ()
 
 if (ENABLE_CLANG_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
+AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
 )


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


[PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Sam Parker via cfe-commits
samparker created this revision.
samparker added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

http://reviews.llvm.org/D18311

Files:
  test/CodeGen/arm-target-features.c
  test/Driver/arm-cortex-cpus.c
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -345,12 +345,14 @@
 // SWIFT-THUMB:#define __ARM_FEATURE_DSP
 // SWIFT-THUMB:#define __ARM_FP 0xE
 
-// Test whether predefines are as expected when targeting cortex-a53.
+// Test whether predefines are as expected when targeting ARMv8-A Cortex 
implementations
+// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck 
--check-prefix=A53-ARM %s
 // RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck 
--check-prefix=A53-ARM %s
 // A53-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
 // A53-ARM:#define __ARM_FEATURE_DSP
 // A53-ARM:#define __ARM_FP 0xE
 
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | 
FileCheck --check-prefix=A53-THUMB %s
 // RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | 
FileCheck --check-prefix=A53-THUMB %s
 // A53-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
 // A53-THUMB:#define __ARM_FEATURE_DSP
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -458,11 +458,13 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // CHECK-BE-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7r-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a32 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
@@ -470,11 +472,13 @@
 // RUN: %clang -target arm -mcpu=exynos-m1 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
+// RUN: %clang -target armeb -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a32 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
@@ -482,11 +486,13 @@
 // RUN: %clang -target arm -mcpu=exynos-m1 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // CHECK-BE-CPUV8A: "-cc1"{{.*}} "-triple" "armebv8-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a32 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -mthumb -### -c %s 2>&1 | 
FileCheck -check

Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: test/Preprocessor/arm-target-features.c:349
@@ -349,1 +348,3 @@
+// Test whether predefines are as expected when targeting ARMv8-A Cortex 
implementations
+// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck 
--check-prefix=A53-ARM %s
 // RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck 
--check-prefix=A53-ARM %s

The check-prefix here is misleading. Please change it.


http://reviews.llvm.org/D18311



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


Re: [PATCH] D18293: [clang-tidy] Fix redundant-string-init check with msvc 14 headers.

2016-03-21 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

The patch looks good to me.


http://reviews.llvm.org/D18293



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


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-03-21 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

I submitted the sourceRange patch here: http://reviews.llvm.org/D18309
If also this patch would get committed as part of the package, there would be 
no need for an incremental commit procedure.


http://reviews.llvm.org/D16044



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


r263934 - clang/test/CodeGenCXX/cxx1z-lambda-star-this.cpp: Satisfy -Asserts.

2016-03-21 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Mar 21 06:40:15 2016
New Revision: 263934

URL: http://llvm.org/viewvc/llvm-project?rev=263934&view=rev
Log:
clang/test/CodeGenCXX/cxx1z-lambda-star-this.cpp: Satisfy -Asserts.

Modified:
cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp

Modified: cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp?rev=263934&r1=263933&r2=263934&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp Mon Mar 21 06:40:15 
2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - 
| FileCheck %s
+// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - 
| tee /tmp/__.bak | FileCheck %s
 //CHECK: %[[A_LAMBDA:.*]] = type { %struct.A }
 //CHECK: %[[B_LAMBDA:.*]] = type { %struct.B* }
 struct A {
@@ -12,11 +12,11 @@ int X = A{}.foo()();
 
 //CHECK: @"\01?foo@A@@QAE?A?@@XZ"(%struct.A* %this, %class.anon* noalias 
sret %[[A_LAMBDA_RETVAL:.*]])
 // get the first object with the closure type, which is of type 'struct.A'
-//CHECK: %0 = getelementptr inbounds %[[A_LAMBDA]], %[[A_LAMBDA]]* 
%[[A_LAMBDA_RETVAL]], i32 0, i32 0
-//CHECK: %1 = bitcast %struct.A* %0 to i8*
-//CHECK: %2 = bitcast %struct.A* %this1 to i8*
+//CHECK: %[[I0:.+]] = getelementptr inbounds %[[A_LAMBDA]], %[[A_LAMBDA]]* 
%[[A_LAMBDA_RETVAL]], i32 0, i32 0
+//CHECK: %[[I1:.+]] = bitcast %struct.A* %[[I0]] to i8*
+//CHECK: %[[I2:.+]] = bitcast %struct.A* %this1 to i8*
 // copy the contents ...
-//CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* %2, i32 8, i32 8, i1 
false)
+//CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[I1]], i8* %[[I2]], i32 8, 
i32 8, i1 false)
 
 struct B {
   double b = 222;
@@ -27,5 +27,5 @@ namespace ns2 {
 int X = B{}.bar()();
 }
 //CHECK: @"\01?bar@B@@QAE?A?@@XZ"(%struct.B* %this, %class.anon.0* 
noalias sret %agg.result)
-//CHECK: %0 = getelementptr inbounds %class.anon.0, %class.anon.0* 
%agg.result, i32 0, i32 0
-//CHECK: store %struct.B* %this1, %struct.B** %0, align 4
\ No newline at end of file
+//CHECK: %[[I20:.+]] = getelementptr inbounds %class.anon.0, %class.anon.0* 
%agg.result, i32 0, i32 0
+//CHECK: store %struct.B* %this1, %struct.B** %[[I20]], align 4


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


r263936 - Remove debug output. Sorry for the noise.

2016-03-21 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Mar 21 06:44:05 2016
New Revision: 263936

URL: http://llvm.org/viewvc/llvm-project?rev=263936&view=rev
Log:
Remove debug output. Sorry for the noise.

Modified:
cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp

Modified: cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp?rev=263936&r1=263935&r2=263936&view=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx1z-lambda-star-this.cpp Mon Mar 21 06:44:05 
2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - 
| tee /tmp/__.bak | FileCheck %s
+// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - 
| FileCheck %s
 //CHECK: %[[A_LAMBDA:.*]] = type { %struct.A }
 //CHECK: %[[B_LAMBDA:.*]] = type { %struct.B* }
 struct A {


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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-21 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D18264



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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-21 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

I don't think this is a safe assumption to make -- for instance, DSLs tend to 
have operator overload return types that aren't necessarily the same as the 
class type.  Also, it's quite common for older code (pre C++11) to return void 
and make these functions private (with no definition) as an early form of 
deleting the operator.

How many additional diagnostics does this modification produce over some large 
code bases (particularly ones with DSLs if you can narrow the test field a bit)?


http://reviews.llvm.org/D18264



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


[PATCH] D18313: clang-format: Make include sorting's main include detection configurable.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper created this revision.
djasper added a reviewer: klimek.
djasper added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch adds a regular expression to configure suffixes of an included file 
to check whether it is the "main" include of the current file. Previously, 
clang-format has allowed arbitrary suffixes on the formatted file, which is 
still the case when no IncludeMainRegex is specified.

http://reviews.llvm.org/D18313

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -175,6 +175,7 @@
 }
 
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
+  Style.IncludeMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -188,7 +189,7 @@
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
- "a_main.cc"));
+ "a_test.cc"));
   EXPECT_EQ("#include \"llvm/input.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -197,6 +198,24 @@
  "#include \"b.h\"\n",
  "input.mm"));
 
+  // Don't allow prefixes.
+  EXPECT_EQ("#include \"b.h\"\n"
+"#include \"c.h\"\n"
+"#include \"llvm/not_a.h\"\n",
+sort("#include \"llvm/not_a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
+ "a.cc"));
+
+  // Don't do this for _main and other suffixes.
+  EXPECT_EQ("#include \"b.h\"\n"
+"#include \"c.h\"\n"
+"#include \"llvm/a.h\"\n",
+sort("#include \"llvm/a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
+ "a_main.cc"));
+
   // Don't do this in headers.
   EXPECT_EQ("#include \"b.h\"\n"
 "#include \"c.h\"\n"
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9941,6 +9941,7 @@
   SpacesBeforeTrailingComments, 1234u);
   CHECK_PARSE("IndentWidth: 32", IndentWidth, 32u);
   CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);
+  CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");
 
   Style.PointerAlignment = FormatStyle::PAS_Middle;
   CHECK_PARSE("PointerAlignment: Left", PointerAlignment,
@@ -10099,6 +10100,7 @@
   "  - Regex: .*\n"
   "Priority: 1",
   IncludeCategories, ExpectedCategories);
+  CHECK_PARSE("IncludeMainRegex: 'abc$'", IncludeMainRegex, "abc$");
 }
 
 TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -300,6 +300,7 @@
Style.ExperimentalAutoDetectBinPacking);
 IO.mapOptional("ForEachMacros", Style.ForEachMacros);
 IO.mapOptional("IncludeCategories", Style.IncludeCategories);
+IO.mapOptional("IncludeMainRegex", Style.IncludeMainRegex);
 IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
 IO.mapOptional("IndentWidth", Style.IndentWidth);
 IO.mapOptional("IndentWrappedFunctionNames",
@@ -517,6 +518,7 @@
   LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2},
  {"^(<|\"(gtest|isl|json)/)", 3},
  {".*", 1}};
+  LLVMStyle.IncludeMainRegex = "$";
   LLVMStyle.IndentCaseLabels = false;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
@@ -569,6 +571,7 @@
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
   GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
@@ -1961,8 +1964,12 @@
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem)) {
-Category = 0;
-MainIncludeFound = true;
+llvm::Regex MainFileRegex(
+(Twine(HeaderStem) + Style.IncludeMainRegex).str());
+if (MainFileRegex.match(FileStem)) {
+  Category = 0;
+  MainIncludeFound = true;
+}
   }
 }
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
Index: include/clang/Fo

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Eric Liu via cfe-commits
PING

On Mon, Mar 14, 2016 at 8:18 PM Eric Liu  wrote:

> ioeric updated this revision to Diff 50627.
> ioeric marked 10 inline comments as done.
> ioeric added a comment.
>
> - renamed calculateChangedRangesInFile to calculateChangedRanges; removed
> const from FileToReplacementsMap key type.
>
>
> http://reviews.llvm.org/D17852
>
> Files:
>   include/clang/Basic/SourceManager.h
>   include/clang/Format/Format.h
>   include/clang/Tooling/Core/Replacement.h
>   include/clang/Tooling/Refactoring.h
>   lib/Format/Format.cpp
>   lib/Tooling/CMakeLists.txt
>   lib/Tooling/Core/Replacement.cpp
>   lib/Tooling/Refactoring.cpp
>   unittests/Format/FormatTest.cpp
>   unittests/Tooling/CMakeLists.txt
>   unittests/Tooling/RefactoringTest.cpp
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18313: clang-format: Make include sorting's main include detection configurable.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper updated this revision to Diff 51154.

http://reviews.llvm.org/D18313

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -175,6 +175,7 @@
 }
 
 TEST_F(SortIncludesTest, LeavesMainHeaderFirst) {
+  Style.IncludeMainRegex = "([-_](test|unittest))?$";
   EXPECT_EQ("#include \"llvm/a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
@@ -188,15 +189,33 @@
 sort("#include \"llvm/a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
- "a_main.cc"));
+ "a_test.cc"));
   EXPECT_EQ("#include \"llvm/input.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n",
 sort("#include \"llvm/input.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n",
  "input.mm"));
 
+  // Don't allow prefixes.
+  EXPECT_EQ("#include \"b.h\"\n"
+"#include \"c.h\"\n"
+"#include \"llvm/not_a.h\"\n",
+sort("#include \"llvm/not_a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
+ "a.cc"));
+
+  // Don't do this for _main and other suffixes.
+  EXPECT_EQ("#include \"b.h\"\n"
+"#include \"c.h\"\n"
+"#include \"llvm/a.h\"\n",
+sort("#include \"llvm/a.h\"\n"
+ "#include \"c.h\"\n"
+ "#include \"b.h\"\n",
+ "a_main.cc"));
+
   // Don't do this in headers.
   EXPECT_EQ("#include \"b.h\"\n"
 "#include \"c.h\"\n"
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -9941,6 +9941,7 @@
   SpacesBeforeTrailingComments, 1234u);
   CHECK_PARSE("IndentWidth: 32", IndentWidth, 32u);
   CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);
+  CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");
 
   Style.PointerAlignment = FormatStyle::PAS_Middle;
   CHECK_PARSE("PointerAlignment: Left", PointerAlignment,
@@ -10099,6 +10100,7 @@
   "  - Regex: .*\n"
   "Priority: 1",
   IncludeCategories, ExpectedCategories);
+  CHECK_PARSE("IncludeMainRegex: 'abc$'", IncludeMainRegex, "abc$");
 }
 
 TEST_F(FormatTest, ParsesConfigurationWithLanguages) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -300,6 +300,7 @@
Style.ExperimentalAutoDetectBinPacking);
 IO.mapOptional("ForEachMacros", Style.ForEachMacros);
 IO.mapOptional("IncludeCategories", Style.IncludeCategories);
+IO.mapOptional("IncludeMainRegex", Style.IncludeMainRegex);
 IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
 IO.mapOptional("IndentWidth", Style.IndentWidth);
 IO.mapOptional("IndentWrappedFunctionNames",
@@ -517,6 +518,7 @@
   LLVMStyle.IncludeCategories = {{"^\"(llvm|llvm-c|clang|clang-c)/", 2},
  {"^(<|\"(gtest|isl|json)/)", 3},
  {".*", 1}};
+  LLVMStyle.IncludeMainRegex = "$";
   LLVMStyle.IndentCaseLabels = false;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
@@ -569,6 +571,7 @@
   GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
   GoogleStyle.DerivePointerAlignment = true;
   GoogleStyle.IncludeCategories = {{"^<.*\\.h>", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
@@ -1961,8 +1964,12 @@
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem)) {
-Category = 0;
-MainIncludeFound = true;
+llvm::Regex MainFileRegex(
+(Twine(HeaderStem) + Style.IncludeMainRegex).str());
+if (MainFileRegex.match(FileStem)) {
+  Category = 0;
+  MainIncludeFound = true;
+}
   }
 }
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -401,6 +401,19 @@
   /// \endcode
   std::vector IncludeCategories;
 
+  /// \brief Specify a regular expression of suffixes that are allowed in the
+  /// file-to

Re: [PATCH] D18313: clang-format: Make include sorting's main include detection configurable.

2016-03-21 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg



Comment at: include/clang/Format/Format.h:415
@@ +414,3 @@
+  /// as the "main" include in both a.cc and a_test.cc.
+  std::string IncludeMainRegex;
+

I'd probably call it MainIncludeRegex.


Comment at: lib/Format/Format.cpp:1967
@@ -1963,3 +1966,3 @@
   if (FileStem.startswith(HeaderStem)) {
-Category = 0;
-MainIncludeFound = true;
+llvm::Regex MainFileRegex(
+(Twine(HeaderStem) + Style.IncludeMainRegex).str());

Try to not set up the Regex in a loop.


Comment at: lib/Format/Format.cpp:1968
@@ +1967,3 @@
+llvm::Regex MainFileRegex(
+(Twine(HeaderStem) + Style.IncludeMainRegex).str());
+if (MainFileRegex.match(FileStem)) {

Twine() shouldn't be needed.


http://reviews.llvm.org/D18313



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:231
@@ +230,3 @@
+typedef std::map
+FileToReplacementsMap;
+

Honestly, I'd get rid of the typedef. Daniel, what do you think?


Comment at: lib/Tooling/Refactoring.cpp:90
@@ +89,3 @@
+
+// FIXME: duplicated code here. Any better way to overload?
+bool formatAndApplyAllReplacements(const Replacements &Replaces,

Just call the above with the format::getStyle("file", FilePath, "LLVM")?
(note that I think "Google" is a bad default style here)


Comment at: unittests/Tooling/RefactoringTest.cpp:206
@@ +205,3 @@
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"

Also use a ColumnLimit to make the test more readable?


http://reviews.llvm.org/D17852



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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

2016-03-21 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51155.

http://reviews.llvm.org/D17986

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5385,5 +5385,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -238,6 +238,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4841,6 +4841,22 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5385,5 +5385,11 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(StatementMatcher, HasReturnValue) {
+  StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
+  EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
+  EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -238,6 +238,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4841,6 +4841,22 @@
   return false;
 }
 
+/// \brief Matches the return value expression of a return statement
+///
+/// Given
+/// \code
+///   return a + b;
+/// \endcode
+/// hasReturnValue(binaryOperator())
+///   matches 'return a + b'
+/// with binaryOperator()
+///   matching 'a + b'
+AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
+  InnerMatcher) {
+  return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
+}
+
+
 /// \brief Matches CUDA kernel call expression.
 ///
 /// Example matches,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18294: clang-format: [JS] no space in union and intersection types.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/TokenAnnotator.cpp:526
@@ +525,3 @@
+case tok::amp:
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  !Contexts.back().IsExpression) {

Don't use braces and possibly pull the comment out of the if itself.


Comment at: lib/Format/TokenAnnotator.cpp:2154
@@ -2141,1 +2153,3 @@
 return Style.SpacesInAngles;
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  (Left.is(TT_JsTypeOperator) || Right.is(TT_JsTypeOperator)))

Can we put this into the JavaScript specific section above?


http://reviews.llvm.org/D18294



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


Re: [PATCH] D18313: clang-format: Make include sorting's main include detection configurable.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Format/Format.h:415
@@ +414,3 @@
+  /// as the "main" include in both a.cc and a_test.cc.
+  std::string IncludeMainRegex;
+

I chose this name for better alphabetical ordering. I don't strongly lean 
either way, WDYT?


Comment at: lib/Format/Format.cpp:1967
@@ -1963,3 +1966,3 @@
   if (FileStem.startswith(HeaderStem)) {
-Category = 0;
-MainIncludeFound = true;
+llvm::Regex MainFileRegex(
+(Twine(HeaderStem) + Style.IncludeMainRegex).str());

I believe this is more efficient. In many cases, no Regex will need to be 
formed at all and the cases where it is formed more than once are rare (many 
includes starting with HeaderStem, but not matching the regex).


http://reviews.llvm.org/D18313



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Tooling/Core/Replacement.h:231
@@ +230,3 @@
+typedef std::map
+FileToReplacementsMap;
+

klimek wrote:
> Honestly, I'd get rid of the typedef. Daniel, what do you think?
I agree. I don't think it carries its weight and actually makes the code harder 
to read. Plus all users can probably use auto :-).


http://reviews.llvm.org/D17852



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Tooling/Refactoring.cpp:90
@@ +89,3 @@
+
+// FIXME: duplicated code here. Any better way to overload?
+bool formatAndApplyAllReplacements(const Replacements &Replaces,

klimek wrote:
> Just call the above with the format::getStyle("file", FilePath, "LLVM")?
> (note that I think "Google" is a bad default style here)
But there could be more than one FilePath in Replaces? 


Comment at: unittests/Tooling/RefactoringTest.cpp:206
@@ +205,3 @@
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"

klimek wrote:
> Also use a ColumnLimit to make the test more readable?
We don't have access to the Style here? Any way to set ColumnLimit?


http://reviews.llvm.org/D17852



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


Re: [PATCH] D18313: clang-format: Make include sorting's main include detection configurable.

2016-03-21 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Format/Format.h:415
@@ +414,3 @@
+  /// as the "main" include in both a.cc and a_test.cc.
+  std::string IncludeMainRegex;
+

djasper wrote:
> I chose this name for better alphabetical ordering. I don't strongly lean 
> either way, WDYT?
I'd still lean slightly towards MainIncludeRegex... but feel free to keep.


Comment at: lib/Format/Format.cpp:1967
@@ -1963,3 +1966,3 @@
   if (FileStem.startswith(HeaderStem)) {
-Category = 0;
-MainIncludeFound = true;
+llvm::Regex MainFileRegex(
+(Twine(HeaderStem) + Style.IncludeMainRegex).str());

djasper wrote:
> I believe this is more efficient. In many cases, no Regex will need to be 
> formed at all and the cases where it is formed more than once are rare (many 
> includes starting with HeaderStem, but not matching the regex).
Ok, makes sense.


http://reviews.llvm.org/D18313



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


Re: [PATCH] D18294: clang-format: [JS] no space in union and intersection types.

2016-03-21 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 51159.
mprobst marked 2 inline comments as done.
mprobst added a comment.

- Address review comments.


http://reviews.llvm.org/D18294

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -847,6 +847,14 @@
getGoogleJSStyleWithColumns(60));
 }
 
+TEST_F(FormatTestJS, UnionIntersectionTypes) {
+  verifyFormat("let x: A|B = A | B;");
+  verifyFormat("let x: A&B|C = A & B;");
+  verifyFormat("let x: Foo = new Foo();");
+  verifyFormat("function(x: A|B): C&D {}");
+  verifyFormat("function(x: A|B = A | B): C&D {}");
+}
+
 TEST_F(FormatTestJS, ClassDeclarations) {
   verifyFormat("class C {\n  x: string = 12;\n}");
   verifyFormat("class C {\n  x(): string => 12;\n}");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -141,6 +141,9 @@
  Left->Previous->is(TT_BinaryOperator))) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
+} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous 
&&
+   Left->Previous->is(Keywords.kw_function)) {
+  Contexts.back().IsExpression = false;
 } else if (Left->Previous && Left->Previous->is(tok::r_square) &&
Left->Previous->MatchingParen &&
Left->Previous->MatchingParen->is(TT_LambdaLSquare)) {
@@ -518,6 +521,14 @@
 Tok->Type = TT_InlineASMColon;
   }
   break;
+case tok::pipe:
+case tok::amp:
+  // | and & in declarations/type expressions represent union and
+  // intersection types, respectively.
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  !Contexts.back().IsExpression)
+Tok->Type = TT_JsTypeOperator;
+  break;
 case tok::kw_if:
 case tok::kw_while:
   if (CurrentToken && CurrentToken->is(tok::l_paren)) {
@@ -2051,6 +2062,8 @@
   return true;
 if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
   return false;
+if (Left.is(TT_JsTypeOperator) || Right.is(TT_JsTypeOperator))
+  return false;
 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
 Line.First->isOneOf(Keywords.kw_import, tok::kw_export))
   return false;
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -54,6 +54,7 @@
   TYPE(JsComputedPropertyName) \
   TYPE(JsFatArrow) \
   TYPE(JsTypeColon) \
+  TYPE(JsTypeOperator) \
   TYPE(JsTypeOptionalQuestion) \
   TYPE(LambdaArrow) \
   TYPE(LambdaLSquare) \


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -847,6 +847,14 @@
getGoogleJSStyleWithColumns(60));
 }
 
+TEST_F(FormatTestJS, UnionIntersectionTypes) {
+  verifyFormat("let x: A|B = A | B;");
+  verifyFormat("let x: A&B|C = A & B;");
+  verifyFormat("let x: Foo = new Foo();");
+  verifyFormat("function(x: A|B): C&D {}");
+  verifyFormat("function(x: A|B = A | B): C&D {}");
+}
+
 TEST_F(FormatTestJS, ClassDeclarations) {
   verifyFormat("class C {\n  x: string = 12;\n}");
   verifyFormat("class C {\n  x(): string => 12;\n}");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -141,6 +141,9 @@
  Left->Previous->is(TT_BinaryOperator))) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
+} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous &&
+   Left->Previous->is(Keywords.kw_function)) {
+  Contexts.back().IsExpression = false;
 } else if (Left->Previous && Left->Previous->is(tok::r_square) &&
Left->Previous->MatchingParen &&
Left->Previous->MatchingParen->is(TT_LambdaLSquare)) {
@@ -518,6 +521,14 @@
 Tok->Type = TT_InlineASMColon;
   }
   break;
+case tok::pipe:
+case tok::amp:
+  // | and & in declarations/type expressions represent union and
+  // intersection types, respectively.
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  !Contexts.back().IsExpression)
+Tok->Type = TT_JsTypeOperator;
+  break;
 case tok::kw_if:
 case tok::kw_while:
   if (CurrentToken && CurrentToken->is(tok::l_paren)) {
@@ -2051,6 +2062,8 @@
   return true;
 if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
   return false;
+if 

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Tooling/Refactoring.cpp:90
@@ +89,3 @@
+
+// FIXME: duplicated code here. Any better way to overload?
+bool formatAndApplyAllReplacements(const Replacements &Replaces,

ioeric wrote:
> klimek wrote:
> > Just call the above with the format::getStyle("file", FilePath, "LLVM")?
> > (note that I think "Google" is a bad default style here)
> But there could be more than one FilePath in Replaces? 
Ah, right; In that case, we have 2 options:
1. hand in a callback FormatStyle(StringRef), so users can hand in 
format::getStyle if needed; adapt the fixed-style one to call the 
callback-based one with a callback that just returns the fixed style
2. refactor so the inner loop becomes trivial, something like this:
  for (auto &ReplacementsByFile : groupReplacementsByFile(Replaces)) {
Style = ...
Result = 
applyAllReplacements(formatReplacements(getCode(ReplacementsByFile.first, 
ReplacementsByFile.second, Style))) && Result;
  }
  return Result;


http://reviews.llvm.org/D17852



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

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


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:87
@@ +86,3 @@
+
+namespace {
+void recordFixes(const VarDecl &Var, ASTContext &Context,

I prefer to move the anonymous namespace under `namespace performance {` 
statement.


Comment at: test/clang-tidy/performance-unnecessary-copy-initialization.cpp:232
@@ +231,3 @@
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_1 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the 
variable 'orig' is never modified; consider avoiding the copy 
[performance-unnecessary-copy-initialization]

It would be nice to add a test case with `copy_2` like:

```
 ExpensiveToCopyType orig;
 ExpensiveToCopyType copy_1 = orig;
 ExpensiveToCopyType copy_2 = copy_1;
 copy_1.constMethod();
 copy_2.constMethod();
 orig.constMethod();
```


http://reviews.llvm.org/D18149



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


r263943 - clang-format: Make include sorting's main include detection configurable.

2016-03-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Mar 21 09:11:27 2016
New Revision: 263943

URL: http://llvm.org/viewvc/llvm-project?rev=263943&view=rev
Log:
clang-format: Make include sorting's main include detection configurable.

This patch adds a regular expression to configure suffixes of an
included file to check whether it is the "main" include of the current
file. Previously, clang-format has allowed arbitrary suffixes on the
formatted file, which is still the case when no IncludeMainRegex is
specified.

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/SortIncludesTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=263943&r1=263942&r2=263943&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Mar 21 09:11:27 2016
@@ -519,6 +519,19 @@ the configuration (without a prefix: ``A
   - Regex:   '.\*'
 Priority:1
 
+**IncludeIsMainRegex** (``std::string``)
+  Specify a regular expression of suffixes that are allowed in the
+  file-to-main-include mapping.
+
+  When guessing whether a #include is the "main" include (to assign
+  category 0, see above), use this regex of allowed suffixes to the header
+  stem. A partial match is done, so that:
+  - "" means "arbitrary suffix"
+  - "$" means "no suffix"
+
+  For example, if configured to "(_test)?$", then a header a.h would be seen
+  as the "main" include in both a.cc and a_test.cc.
+
 **IndentCaseLabels** (``bool``)
   Indent case labels one level from the switch statement.
 
@@ -532,6 +545,22 @@ the configuration (without a prefix: ``A
   Indent if a function definition or declaration is wrapped after the
   type.
 
+**JavaScriptQuotes** (``JavaScriptQuoteStyle``)
+  The JavaScriptQuoteStyle to use for JavaScript strings.
+
+  Possible values:
+
+  * ``JSQS_Leave`` (in configuration: ``Leave``)
+Leave string quotes as they are.
+
+  * ``JSQS_Single`` (in configuration: ``Single``)
+Always use single quotes.
+
+  * ``JSQS_Double`` (in configuration: ``Double``)
+Always use double quotes.
+
+
+
 **KeepEmptyLinesAtTheStartOfBlocks** (``bool``)
   If true, empty lines at the start of blocks are kept.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=263943&r1=263942&r2=263943&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Mar 21 09:11:27 2016
@@ -401,6 +401,19 @@ struct FormatStyle {
   /// \endcode
   std::vector IncludeCategories;
 
+  /// \brief Specify a regular expression of suffixes that are allowed in the
+  /// file-to-main-include mapping.
+  ///
+  /// When guessing whether a #include is the "main" include (to assign
+  /// category 0, see above), use this regex of allowed suffixes to the header
+  /// stem. A partial match is done, so that:
+  /// - "" means "arbitrary suffix"
+  /// - "$" means "no suffix"
+  ///
+  /// For example, if configured to "(_test)?$", then a header a.h would be 
seen
+  /// as the "main" include in both a.cc and a_test.cc.
+  std::string IncludeIsMainRegex;
+
   /// \brief Indent case labels one level from the switch statement.
   ///
   /// When ``false``, use the same indentation level as for the switch 
statement.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=263943&r1=263942&r2=263943&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Mar 21 09:11:27 2016
@@ -300,6 +300,7 @@ template <> struct MappingTraits", 1}, {"^<.*", 2}, {".*", 3}};
+  GoogleStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
   GoogleStyle.IndentCaseLabels = true;
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
   GoogleStyle.ObjCSpaceAfterProperty = false;
@@ -1961,8 +1964,12 @@ tooling::Replacements sortIncludes(const
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem)) {
-Category = 0;
-MainIncludeFound = true;
+llvm::Regex MainIncludeRegex(
+(HeaderStem + Style.IncludeIsMainRegex).str());
+if (MainIncludeRegex.match(FileStem)) {
+  Category = 0;
+  MainIncludeFound = true;
+}
   }
 }
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});

Modified:

Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-21 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D18264#379092, @aaron.ballman wrote:

> Also, it's quite common for older code (pre C++11) to return void and make 
> these functions private (with no definition) as an early form of deleting the 
> operator.


This checker will not warn on private methods.

About EDSLs, I think they are not the common case. In case it is important, it 
might make sense to make this configurable, but I think the minority of the C++ 
projects have EDSLs so it make more sense to warn on those cases by default. 
What do you think?


http://reviews.llvm.org/D18264



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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

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

In http://reviews.llvm.org/D18264#379159, @xazax.hun wrote:

> In http://reviews.llvm.org/D18264#379092, @aaron.ballman wrote:
>
> > Also, it's quite common for older code (pre C++11) to return void and make 
> > these functions private (with no definition) as an early form of deleting 
> > the operator.
>
>
> This checker will not warn on private methods.


Good deal.

> About EDSLs, I think they are not the common case. In case it is important, 
> it might make sense to make this configurable, but I think the minority of 
> the C++ projects have EDSLs so it make more sense to warn on those cases by 
> default. What do you think?


That's why I am wondering about how much this increases the false positive 
rate. I don't think DSLs are going to be a huge problem, but if it turns out 
they are, then a configuration option makes sense. If we don't see a large 
increase, then no need to waste the effort on an option.

Also, this appears to be changing the behavior of the 
cppcoreguidelines-c-copy-assignment-signature alias. If the core guidelines 
don't prohibit this behavior under that rule, we should not trigger the 
diagnostic if the user enabled the check via 
cppcoreguidelines-c-copy-assignment-signature instead of 
misc-assign-operator-signature. Check out MoveConstructorInitCheck as an 
example of how we have handled this before.


http://reviews.llvm.org/D18264



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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

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

Can you rerun the doc script (dump_ast_matchers.py)?


http://reviews.llvm.org/D17986



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


Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Sam Parker via cfe-commits
samparker updated this revision to Diff 51165.
samparker added a comment.

Changed A53-ARM and A53-THUMB test prefixes to ARMV8-ARM and ARMV8-THUMB.


http://reviews.llvm.org/D18311

Files:
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -346,17 +346,17 @@
 // SWIFT-THUMB:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting ARMv8-A Cortex 
implementations
-// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck 
--check-prefix=A53-ARM %s
-// RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck 
--check-prefix=A53-ARM %s
-// A53-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
-// A53-ARM:#define __ARM_FEATURE_DSP
-// A53-ARM:#define __ARM_FP 0xE
-
-// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | 
FileCheck --check-prefix=A53-THUMB %s
-// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | 
FileCheck --check-prefix=A53-THUMB %s
-// A53-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
-// A53-THUMB:#define __ARM_FEATURE_DSP
-// A53-THUMB:#define __ARM_FP 0xE
+// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck 
--check-prefix=ARMV8-ARM %s
+// RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck 
--check-prefix=ARMV8-ARM %s
+// ARMV8-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV8-ARM:#define __ARM_FEATURE_DSP
+// ARMV8-ARM:#define __ARM_FP 0xE
+
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | 
FileCheck --check-prefix=ARMV8-THUMB %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | 
FileCheck --check-prefix=ARMV8-THUMB %s
+// ARMV8-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV8-THUMB:#define __ARM_FEATURE_DSP
+// ARMV8-THUMB:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting cortex-r4.
 // RUN: %clang -target armv7 -mcpu=cortex-r4 -x c -E -dM %s -o - | FileCheck 
--check-prefix=R4-ARM %s


Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -346,17 +346,17 @@
 // SWIFT-THUMB:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting ARMv8-A Cortex implementations
-// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck --check-prefix=A53-ARM %s
-// RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=A53-ARM %s
-// A53-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
-// A53-ARM:#define __ARM_FEATURE_DSP
-// A53-ARM:#define __ARM_FP 0xE
-
-// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck --check-prefix=A53-THUMB %s
-// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=A53-THUMB %s
-// A53-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
-// A53-THUMB:#define __ARM_FEATURE_DSP
-// A53-THUMB:#define __ARM_FP 0xE
+// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-ARM %s
+// RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-ARM %s
+// ARMV8-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV8-ARM:#define __ARM_FEATURE_DSP
+// ARMV8-ARM:#define __ARM_FP 0xE
+
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-THUMB %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-THUMB %s
+// ARMV8-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV8-THUMB:#define __ARM_FEATURE_DSP
+// ARMV8-THUMB:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting cortex-r4.
 // RUN: %clang -target armv7 -mcpu=cortex-r4 -x c -E -dM %s -o - | FileCheck --check-prefix=R4-ARM %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Tooling/Refactoring.cpp:90
@@ +89,3 @@
+
+// FIXME: duplicated code here. Any better way to overload?
+bool formatAndApplyAllReplacements(const Replacements &Replaces,

klimek wrote:
> ioeric wrote:
> > klimek wrote:
> > > Just call the above with the format::getStyle("file", FilePath, "LLVM")?
> > > (note that I think "Google" is a bad default style here)
> > But there could be more than one FilePath in Replaces? 
> Ah, right; In that case, we have 2 options:
> 1. hand in a callback FormatStyle(StringRef), so users can hand in 
> format::getStyle if needed; adapt the fixed-style one to call the 
> callback-based one with a callback that just returns the fixed style
> 2. refactor so the inner loop becomes trivial, something like this:
>   for (auto &ReplacementsByFile : groupReplacementsByFile(Replaces)) {
> Style = ...
> Result = 
> applyAllReplacements(formatReplacements(getCode(ReplacementsByFile.first, 
> ReplacementsByFile.second, Style))) && Result;
>   }
>   return Result;
Adding a helper function seems to do the trick too. 


http://reviews.llvm.org/D17852



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 51166.
ioeric marked 8 inline comments as done.
ioeric added a comment.

- removed FileToReplacementsMap typedef; refactored formatAndApplyReplacements 
to reduce duplicated code.


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,71 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"
+ "g(iii, 0, "
+ "jjj,\n"
+ "  0, kkk, 0, "
+ "mmm);\n"
+ "int  bad = format   ;";
+  std::string Expected =
+  "auto a = new MyType012345678901234567890123456789();\n"
+  "g(iii, nullptr,\n"
+  "  jjj, nullptr,\n"
+  "  kkk, nullptr,\n"
+  "  mmm);\n"
+  "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  Replacements Replaces;
+  Replaces.insert(
+  Replacement(Context.Sources, Context.getLocation(ID, 1, 1), 38, "auto "));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 3, 40),
+  1, "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 3), 1,
+  "nullptr"));
+  Replaces.insert(Replacement(Context.Sources, Context.getLocation(ID, 4, 43),
+  1, "nullptr"));
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite));
+  EXPECT_EQ(Expected, Context.getRewrittenText(ID));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -426,7 +492,7 @@
   Replaces.insert(Replacement("foo", 10, 1, "zz"));
   Replaces.insert(Replacement("foo", 11, 0, ""));
 
-  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+  std::vector Ranges = calculateChangedRanges(Replaces);
 
   EXPECT_EQ(3ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -30,6 

Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a reviewer: rengolin.
rengolin added a comment.
This revision is now accepted and ready to land.

Hi Sam,

The patch looks good, thanks!

A few comments on the process:

1. When you send an update, send the whole patch again, not just the new diff. 
Either squash or diff master, doesn't matter. If you don't have commit access, 
people will have to download the patch from this page to commit, and they'll 
need the whole change set.

2. When you commit, don't commit the requested changes in separate. If the 
patch makes sense as one commit, it'll still need to be one commit after all 
code review changes. So, a git rebase squash will be necessary to bring the 
number of patches down to the original list before git svn dcommit.

3. When you send a patch to review on Phab, please use "git show -U999", so 
that the patch is uploaded with context. I wish Phab was smart enough to know 
where the patch is being applied to and checkout the context from git/SVN, but 
apparently, it isn't. You can help by showing the context via -U option.

If you don't have commit rights, please upload the full patch to this review 
again, so I can commit it all at once.

cheers,
--renato


http://reviews.llvm.org/D18311



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


clang-tidy modernize-use-override

2016-03-21 Thread Robert Bolter via cfe-commits
Hi,

First time poster here, Please advise...

Can I contribute these patches for clang-tidy modernize-use-override addressing 
two problems:

1: missing spaces on pure function decls

Orig:
void pure() const=0
Problem:
void pure() constoverride =0
Fixed:
void pure() const override =0

2: This is ms-extension specific, but possibly applies to other attribute types 
as I see incorrect placement of override for Inherited Attributes and atts 
located before the method

Orig:
class __declspec(dllexport) X : public Y
  {
void p(); //inherits decl att
  };
Problem:
class override __declspec(dllexport) class X : public Y
  {
  void p();
  };
Fixed:
class __declspec(dllexport) class X : public Y
  {
  void p() override;
  };

I added test/clang-tidy/modernize-use-override-ms.cpp and modified 
modernize-use-override.cpp to test these fixes.


I've also added a -quiet option to clang-tidy/tool/run-clang-tidy.py  and a 
progress countdown which I personally find useful :)


Thanks,
Rob.




Autodesk Limited
Registered Office: One Discovery Place, Columbus Drive, Farnborough, Hampshire 
GU14 0NZ
Registered in England and Wales, No. 1839239


0001-run-clang-tidy-Adding-a-quiet-option-to-suppress-out.patch
Description: 0001-run-clang-tidy-Adding-a-quiet-option-to-suppress-out.patch


0001-modernize-use-override-fix-for-const-0-without-space.patch
Description: 0001-modernize-use-override-fix-for-const-0-without-space.patch
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Sam Parker via cfe-commits
samparker added a comment.

Hi Renato,

Thanks for the tips, one patch makes much more sense. I'm currently in the 
process of obtaining commit access and this patch depends on 
http://reviews.llvm.org/D18239.

Thanks again,
sam


http://reviews.llvm.org/D18311



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


Re: [PATCH] D18294: clang-format: [JS] no space in union and intersection types.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Looks good.


http://reviews.llvm.org/D18294



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


Re: [PATCH] D16993: Add missing __builtin_bitreverse8

2016-03-21 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

ping


http://reviews.llvm.org/D16993



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


Re: [PATCH] D18294: clang-format: [JS] no space in union and intersection types.

2016-03-21 Thread Martin Probst via cfe-commits
mprobst added inline comments.


Comment at: lib/Format/TokenAnnotator.cpp:2154
@@ -2141,1 +2153,3 @@
 return Style.SpacesInAngles;
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  (Left.is(TT_JsTypeOperator) || Right.is(TT_JsTypeOperator)))

djasper wrote:
> Can we put this into the JavaScript specific section above?
Done, wasn't sure if this should go next to binary operators, or next to JS 
stuff...


http://reviews.llvm.org/D18294



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


Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-21 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51167.

http://reviews.llvm.org/D18243

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1628,10 +1628,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", 
ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2859,18 +2859,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
-if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, &Result)) {
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
   *Builder = std::move(Result);
   return true;
 }


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1628,10 +1628,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2859,18 +2859,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
-if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, &Result)) {
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
   *Builder = std::move(Result);
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: unittests/Tooling/RefactoringTest.cpp:206
@@ +205,3 @@
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"

I'd rely on the general case to be covered by the other test then, and just 
test that the style is picked up correctly (or falls back correctly to LLVM 
style).


http://reviews.llvm.org/D17852



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


Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Renato Golin via cfe-commits
rengolin added a comment.

Right, if you could update both reviews with the full patch, I could commit 
them for you, for now.


http://reviews.llvm.org/D18311



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


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

2016-03-21 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp:136
@@ +135,3 @@
+  auto NodeIt = G.eop_begin();
+  const auto NodeEndIt = G.eop_end();
+

Alexander_Droste wrote:
> zaks.anna wrote:
> > The analyzer does not do a good job tracking global variables. You might 
> > get false positives, specifically, where the variable is released in 
> > another translation unit or by calling function that the analyzer does not 
> > inline.
> > 
> So shall we remove or keep the function?
I think you will get false positives of the nature I describe above if you keep 
it. If so, you should remove it. The user experience is much better if you 
avoid false positives.


http://reviews.llvm.org/D12761



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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

2016-03-21 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

I can rerun the script, however it seems it was not executed before the last 
commit on the master branch, thus if I rerun it then changes will appear in my 
diff which are not related to my work. What is the exect policy about running 
this scipt? Should it be rerun before the commit (then it was forgotten by the 
last committer) or it is executed only before releases?


http://reviews.llvm.org/D17986



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


Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Sam Parker via cfe-commits
samparker updated this revision to Diff 51173.
samparker added a comment.

Combined the two diffs


http://reviews.llvm.org/D18311

Files:
  test/CodeGen/arm-target-features.c
  test/Driver/arm-cortex-cpus.c
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -345,16 +345,18 @@
 // SWIFT-THUMB:#define __ARM_FEATURE_DSP
 // SWIFT-THUMB:#define __ARM_FP 0xE
 
-// Test whether predefines are as expected when targeting cortex-a53.
-// RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=A53-ARM %s
-// A53-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
-// A53-ARM:#define __ARM_FEATURE_DSP
-// A53-ARM:#define __ARM_FP 0xE
-
-// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=A53-THUMB %s
-// A53-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
-// A53-THUMB:#define __ARM_FEATURE_DSP
-// A53-THUMB:#define __ARM_FP 0xE
+// Test whether predefines are as expected when targeting ARMv8-A Cortex implementations
+// RUN: %clang -target armv8 -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-ARM %s
+// RUN: %clang -target armv8 -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-ARM %s
+// ARMV8-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV8-ARM:#define __ARM_FEATURE_DSP
+// ARMV8-ARM:#define __ARM_FP 0xE
+
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a32 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-THUMB %s
+// RUN: %clang -target armv8 -mthumb -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=ARMV8-THUMB %s
+// ARMV8-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
+// ARMV8-THUMB:#define __ARM_FEATURE_DSP
+// ARMV8-THUMB:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting cortex-r4.
 // RUN: %clang -target armv7 -mcpu=cortex-r4 -x c -E -dM %s -o - | FileCheck --check-prefix=R4-ARM %s
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -463,11 +463,13 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // CHECK-BE-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7r-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a32 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
@@ -475,11 +477,13 @@
 // RUN: %clang -target arm -mcpu=exynos-m1 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
+// RUN: %clang -target armeb -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a32 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
@@ -487,11 +491,13 @@
 // RUN: %clang -target arm -mcpu=exynos-m1 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHEC

r263947 - clang-cl: support __cdecl-on-struct anachronism

2016-03-21 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Mar 21 11:08:49 2016
New Revision: 263947

URL: http://llvm.org/viewvc/llvm-project?rev=263947&view=rev
Log:
clang-cl: support __cdecl-on-struct anachronism

Summary:
The Microsoft compiler emits

  warning C4229: anachronism used : modifiers on data are ignored

for

  struct {} __cdecl s;

but ICU's gendict can generate such (and does when building
LibreOffice), so accepting this in clang-cl too would be useful.

Reviewers: rnk

Patch by Stephan Bergmann

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

Added:
cfe/trunk/test/Parser/ms-anachronism.c
Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=263947&r1=263946&r2=263947&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Mar 21 11:08:49 2016
@@ -1103,6 +1103,15 @@ bool Parser::isValidAfterTypeSpecifier(b
 return true;
   case tok::colon:
 return CouldBeBitfield; // enum E { ... }   : 2;
+  // Microsoft compatibility
+  case tok::kw___cdecl: // struct foo {...} __cdecl  x;
+  case tok::kw___fastcall:  // struct foo {...} __fastcall   x;
+  case tok::kw___stdcall:   // struct foo {...} __stdcallx;
+  case tok::kw___thiscall:  // struct foo {...} __thiscall   x;
+  case tok::kw___vectorcall:// struct foo {...} __vectorcall x;
+// We will diagnose these calling-convention specifiers on non-function
+// declarations later, so claim they are valid after a type specifier.
+return getLangOpts().MicrosoftExt;
   // Type qualifiers
   case tok::kw_const:   // struct foo {...} const x;
   case tok::kw_volatile:// struct foo {...} volatile  x;

Added: cfe/trunk/test/Parser/ms-anachronism.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/ms-anachronism.c?rev=263947&view=auto
==
--- cfe/trunk/test/Parser/ms-anachronism.c (added)
+++ cfe/trunk/test/Parser/ms-anachronism.c Mon Mar 21 11:08:49 2016
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -fsyntax-only 
-verify %s
+
+struct {} __cdecl s; // expected-warning {{'__cdecl' only applies to function 
types; type here is 'struct}}


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


Re: [PATCH] D16628: clang-cl: support __cdecl-on-struct anachronism

2016-03-21 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL263947: clang-cl: support __cdecl-on-struct anachronism 
(authored by rnk).

Changed prior to commit:
  http://reviews.llvm.org/D16628?vs=46228&id=51176#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16628

Files:
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/test/Parser/ms-anachronism.c

Index: cfe/trunk/test/Parser/ms-anachronism.c
===
--- cfe/trunk/test/Parser/ms-anachronism.c
+++ cfe/trunk/test/Parser/ms-anachronism.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -fsyntax-only 
-verify %s
+
+struct {} __cdecl s; // expected-warning {{'__cdecl' only applies to function 
types; type here is 'struct}}
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1103,6 +1103,15 @@
 return true;
   case tok::colon:
 return CouldBeBitfield; // enum E { ... }   : 2;
+  // Microsoft compatibility
+  case tok::kw___cdecl: // struct foo {...} __cdecl  x;
+  case tok::kw___fastcall:  // struct foo {...} __fastcall   x;
+  case tok::kw___stdcall:   // struct foo {...} __stdcallx;
+  case tok::kw___thiscall:  // struct foo {...} __thiscall   x;
+  case tok::kw___vectorcall:// struct foo {...} __vectorcall x;
+// We will diagnose these calling-convention specifiers on non-function
+// declarations later, so claim they are valid after a type specifier.
+return getLangOpts().MicrosoftExt;
   // Type qualifiers
   case tok::kw_const:   // struct foo {...} const x;
   case tok::kw_volatile:// struct foo {...} volatile  x;


Index: cfe/trunk/test/Parser/ms-anachronism.c
===
--- cfe/trunk/test/Parser/ms-anachronism.c
+++ cfe/trunk/test/Parser/ms-anachronism.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -fsyntax-only -verify %s
+
+struct {} __cdecl s; // expected-warning {{'__cdecl' only applies to function types; type here is 'struct}}
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1103,6 +1103,15 @@
 return true;
   case tok::colon:
 return CouldBeBitfield; // enum E { ... }   : 2;
+  // Microsoft compatibility
+  case tok::kw___cdecl: // struct foo {...} __cdecl  x;
+  case tok::kw___fastcall:  // struct foo {...} __fastcall   x;
+  case tok::kw___stdcall:   // struct foo {...} __stdcallx;
+  case tok::kw___thiscall:  // struct foo {...} __thiscall   x;
+  case tok::kw___vectorcall:// struct foo {...} __vectorcall x;
+// We will diagnose these calling-convention specifiers on non-function
+// declarations later, so claim they are valid after a type specifier.
+return getLangOpts().MicrosoftExt;
   // Type qualifiers
   case tok::kw_const:   // struct foo {...} const x;
   case tok::kw_volatile:// struct foo {...} volatile  x;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

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

Why is there such a large jump in the number of warnings reported in the last 
patch iteration?
It went from "1678 projects where scanned. In total I got 124 warnings" to "In 
2215 projects it found 875 warnings." Did the number of warnings in the initial 
1678 projects stay the same?

Is it possible to take a look at the nature of the false positives, as per 
NoQ's request above?

This checker would benefit greatly from explaining why the errors occur. For 
example, where the values of variables are being constrained. Other checkers 
use BugReporterVisitor to generate the rich diagnostic information. Dow you 
have plans on how to accomplish that for this checker?



Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:11
@@ +10,3 @@
+// This defines ConversionChecker that warns about dangerous conversions where
+// there is possible loss of precision.
+//

Please, make this more specific.
Would be useful to summarize which heuristics you used to bring the number of 
false positives down.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:29
@@ +28,3 @@
+public:
+  void checkPreStmt(const ImplicitCastExpr *Cast, CheckerContext &C) const {
+// TODO: For now we only warn about DeclRefExpr, to avoid noise. Warn for

nit: Please move the body out of the declaration.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:74
@@ +73,3 @@
+if (!BT)
+  BT.reset(new BuiltinBug(this, "Conversion", "loss of sign/precision."));
+

Please, capitalize the sentence.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:84
@@ +83,3 @@
+// Can E value be greater or equal than Val?
+static bool canBeGreaterEqual(CheckerContext &C, const Expr *E,
+  unsigned long long Val) {

This function returns true if the value "is" greater or equal, not "can be" 
greater or equal. The latter would be "return StGE".

Also, it's slightly better to return the StGE state and use it to report the 
bug. This way, our assumption is explicitly recorded in the error state.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:147
@@ +146,3 @@
+  if (canBeGreaterEqual(C, Cast->getSubExpr(), MaxVal))
+reportBug(C, "loss of precision in implicit conversion");
+}

Please, use capitalization and punctuation.


http://reviews.llvm.org/D13126



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


[PATCH] D18319: Add a PragmaHandler Registry for plugins to add PragmaHandlers to

2016-03-21 Thread John Brawn via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: bkramer, rsmith, rnk.
john.brawn added a subscriber: cfe-commits.
john.brawn set the repository for this revision to rL LLVM.

This allows plugins which add AST passes to also define pragmas to do things 
like only enable certain behaviour of the AST pass in files where a certain 
pragma is used.


Repository:
  rL LLVM

http://reviews.llvm.org/D18319

Files:
  docs/ClangPlugins.rst
  examples/AnnotateFunctions/AnnotateFunctions.cpp
  include/clang/Lex/Preprocessor.h
  lib/Lex/Pragma.cpp
  test/Frontend/plugin-annotate-functions.c

Index: test/Frontend/plugin-annotate-functions.c
===
--- test/Frontend/plugin-annotate-functions.c
+++ test/Frontend/plugin-annotate-functions.c
@@ -1,7 +1,25 @@
-// RUN: %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -S %s -o - | FileCheck %s
+// RUN: %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -DPRAGMA_ON -S %s -o - | FileCheck %s --check-prefix=PRAGMA
+// RUN: %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -S %s -o - | FileCheck %s --check-prefix=NOPRAGMA
+// RUN: not %clang -fplugin=%llvmshlibdir/AnnotateFunctions%pluginext -emit-llvm -DBAD_PRAGMA -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADPRAGMA
 // REQUIRES: plugins, examples
 
-// CHECK: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] c"example_annotation\00"
-// CHECK: @llvm.global.annotations = {{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
+#ifdef PRAGMA_ON
+#pragma enable_annotate
+#endif
+
+// BADPRAGMA: warning: extra tokens at end of #pragma directive
+#ifdef BAD_PRAGMA
+#pragma enable_annotate something
+#endif
+
+// PRAGMA: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] c"example_annotation\00"
+// PRAGMA: @llvm.global.annotations = {{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
+// NOPRAGMA-NOT: [[STR_VAR:@.+]] = private unnamed_addr constant [19 x i8] c"example_annotation\00"
+// NOPRAGMA-NOT: @llvm.global.annotations = {{.*}}@fn1{{.*}}[[STR_VAR]]{{.*}}@fn2{{.*}}[[STR_VAR]]
 void fn1() { }
 void fn2() { }
+
+// BADPRAGMA: error: #pragma enable_annotate not allowed after declarations
+#ifdef BAD_PRAGMA
+#pragma enable_annotate
+#endif
Index: lib/Lex/Pragma.cpp
===
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -1490,6 +1490,13 @@
 AddPragmaHandler(new PragmaRegionHandler("region"));
 AddPragmaHandler(new PragmaRegionHandler("endregion"));
   }
+
+  // Pragmas added by plugins
+  for (PragmaHandlerRegistry::iterator it = PragmaHandlerRegistry::begin(),
+   ie = PragmaHandlerRegistry::end();
+   it != ie; ++it) {
+AddPragmaHandler(it->instantiate().release());
+  }
 }
 
 /// Ignore all pragmas, useful for modes such as -Eonly which would otherwise
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -32,6 +32,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Registry.h"
 #include 
 #include 
 
@@ -1937,6 +1938,9 @@
   virtual bool HandleComment(Preprocessor &PP, SourceRange Comment) = 0;
 };
 
+/// \brief Registry of pragma handlers added by plugins
+typedef llvm::Registry PragmaHandlerRegistry;
+
 }  // end namespace clang
 
 #endif
Index: examples/AnnotateFunctions/AnnotateFunctions.cpp
===
--- examples/AnnotateFunctions/AnnotateFunctions.cpp
+++ examples/AnnotateFunctions/AnnotateFunctions.cpp
@@ -7,20 +7,29 @@
 //
 //===--===//
 //
-// Example clang plugin which adds an annotation to every function.
+// Example clang plugin which adds an annotation to every function in
+// translation units that start with #pragma enable_annotate.
 //
 //===--===//
 
 #include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/AST/AST.h"
 #include "clang/AST/ASTConsumer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/LexDiagnostic.h"
 using namespace clang;
 
 namespace {
 
+static bool EnableAnnotate = false;
+static bool HandledDecl = false;
+
 class AnnotateFunctionsConsumer : public ASTConsumer {
 public:
   bool HandleTopLevelDecl(DeclGroupRef DG) override {
+HandledDecl = true;
+if (!EnableAnnotate)
+  return true;
 for (auto D : DG)
   if (FunctionDecl *FD = dyn_cast(D))
 FD->addAttr(AnnotateAttr::CreateImplicit(FD->getASTContext(),
@@ -46,7 +55,34 @@
   }
 };
 
+class PragmaAnnotateHandler : public PragmaHandler {
+public:
+  PragmaAnnotateHandler() : PragmaHandler("enable_annotate") { }
+
+  void HandlePragma

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

2016-03-21 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 51179.
Alexander_Droste added a comment.

- remove `checkMissingWaitsGlobals` to prevent potential false positives


http://reviews.llvm.org/D12761

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.h
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.cpp
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPIFunctionClassifier.h
  lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h
  test/Analysis/MPIChecker.cpp

Index: test/Analysis/MPIChecker.cpp
===
--- test/Analysis/MPIChecker.cpp
+++ test/Analysis/MPIChecker.cpp
@@ -0,0 +1,225 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.mpi.MPI-Checker -verify %s
+
+// MPI-Checker makes no assumptions about details of an MPI implementation.
+// Typedefs and constants are compared as strings.
+
+#include "MPIMock.h"
+
+//integration tests
+
+void matchedWait1() {
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  if (rank >= 0) {
+MPI_Request sendReq1, recvReq1;
+MPI_Isend(&buf, 1, MPI_DOUBLE, rank + 1, 3, MPI_COMM_WORLD, &sendReq1);
+MPI_Irecv(&buf, 1, MPI_DOUBLE, rank - 1, 3, MPI_COMM_WORLD, &recvReq1);
+
+MPI_Wait(&sendReq1, MPI_STATUS_IGNORE);
+MPI_Wait(&recvReq1, MPI_STATUS_IGNORE);
+  }
+} // no error
+
+void matchedWait2() {
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  if (rank >= 0) {
+MPI_Request sendReq1, recvReq1;
+MPI_Isend(&buf, 1, MPI_DOUBLE, rank + 1, 4, MPI_COMM_WORLD, &sendReq1);
+MPI_Irecv(&buf, 1, MPI_DOUBLE, rank - 1, 4, MPI_COMM_WORLD, &recvReq1);
+MPI_Wait(&sendReq1, MPI_STATUS_IGNORE);
+MPI_Wait(&recvReq1, MPI_STATUS_IGNORE);
+  }
+} // no error
+
+void matchedWait3() {
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  if (rank >= 0) {
+MPI_Request sendReq1, recvReq1;
+MPI_Isend(&buf, 1, MPI_DOUBLE, rank + 1, 5, MPI_COMM_WORLD, &sendReq1);
+MPI_Irecv(&buf, 1, MPI_DOUBLE, rank - 1, 5, MPI_COMM_WORLD, &recvReq1);
+
+if (rank > 1000) {
+  MPI_Wait(&sendReq1, MPI_STATUS_IGNORE);
+  MPI_Wait(&recvReq1, MPI_STATUS_IGNORE);
+} else {
+  MPI_Wait(&sendReq1, MPI_STATUS_IGNORE);
+  MPI_Wait(&recvReq1, MPI_STATUS_IGNORE);
+}
+  }
+} // no error
+
+void missingWait1() { // Check missing wait for dead region.
+  int rank = 0;
+  double buf = 0;
+  MPI_Request sendReq1;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD,
+  &sendReq1); // expected-note{{Request is previously used by nonblocking call here.}}
+} // expected-warning{{Request 'sendReq1' has no matching wait.}}
+
+void missingWait2() {
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  if (rank == 0) {
+  } else {
+MPI_Request sendReq1, recvReq1;
+
+MPI_Isend(&buf, 1, MPI_DOUBLE, rank + 1, 2, MPI_COMM_WORLD, &sendReq1);
+MPI_Irecv(&buf, 1, MPI_DOUBLE, rank - 1, 2, MPI_COMM_WORLD, &recvReq1); // expected-warning{{Request 'sendReq1' has no matching wait.}}
+MPI_Wait(&recvReq1, MPI_STATUS_IGNORE);
+  }
+}
+
+void doubleNonblocking() {
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+  if (rank == 1) {
+  } else {
+MPI_Request sendReq1;
+
+MPI_Isend(&buf, 1, MPI_DOUBLE, rank + 1, 6, MPI_COMM_WORLD, &sendReq1); // expected-note{{Request is previously used by nonblocking call here. }}
+MPI_Irecv(&buf, 1, MPI_DOUBLE, rank - 1, 6, MPI_COMM_WORLD, &sendReq1); // expected-warning{{Double nonblocking on request 'sendReq1'.}}
+MPI_Wait(&sendReq1, MPI_STATUS_IGNORE);
+  }
+}
+
+void doubleNonblocking2() {
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+  MPI_Request req;
+  MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, &req); // expected-note{{Request is previously used by nonblocking call here.}}
+  MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, &req); // expected-warning{{Double nonblocking on request 'req'.}}
+  MPI_Wait(&req, MPI_STATUS_IGNORE);
+}
+
+void doubleNonblocking3() {
+  typedef struct { MPI_Request req; } ReqStruct;
+
+  ReqStruct rs;
+  int rank = 0;
+  double buf = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+  MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, &rs.req); // expected-note{{Request is previously used by nonblocking call here.}}
+  MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD, &rs.req); // expected-warning{{Double nonblocking on request 'rs.req'.}}
+  MPI_Wait(&rs.req, MPI_STATUS_IGNORE);
+}
+
+void doubleNonb

Re: [PATCH] D18319: Add a PragmaHandler Registry for plugins to add PragmaHandlers to

2016-03-21 Thread Reid Kleckner via cfe-commits
rnk added a comment.

This seems reasonable.


Repository:
  rL LLVM

http://reviews.llvm.org/D18319



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


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

2016-03-21 Thread Alexander Droste via cfe-commits
Alexander_Droste marked 6 inline comments as done.


Comment at: lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp:39
@@ +38,3 @@
+
+  if (Range.isValid())
+Report->addRange(Range);

`sourceRange` patch -> http://reviews.llvm.org/D18309


Comment at: lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp:136
@@ +135,3 @@
+  auto NodeIt = G.eop_begin();
+  const auto NodeEndIt = G.eop_end();
+

zaks.anna wrote:
> Alexander_Droste wrote:
> > zaks.anna wrote:
> > > The analyzer does not do a good job tracking global variables. You might 
> > > get false positives, specifically, where the variable is released in 
> > > another translation unit or by calling function that the analyzer does 
> > > not inline.
> > > 
> > So shall we remove or keep the function?
> I think you will get false positives of the nature I describe above if you 
> keep it. If so, you should remove it. The user experience is much better if 
> you avoid false positives.
I removed the function.


http://reviews.llvm.org/D12761



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-03-21 Thread Martin Probst via cfe-commits
mprobst marked an inline comment as done.
mprobst added a comment.

As discussed offline, this matches existing very similar behaviour for 
destructured goog.require calls:

  js
  const {X, Y, Z} = goog.require('a'); // won't ever wrap
  import {X, Y, Z} from 'a';  // Shouldn't ever wrap

It also has the nice side effect that it prevents IWYU comments of the form:

  js
  import {X, Y, Z} from 'a';  // from //some/location

... from wrapping.


http://reviews.llvm.org/D17440



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


r263953 - clang-cl: Move /FC from "Unsupported" to "Ignored" list.

2016-03-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Mar 21 12:19:31 2016
New Revision: 263953

URL: http://llvm.org/viewvc/llvm-project?rev=263953&view=rev
Log:
clang-cl: Move /FC from "Unsupported" to "Ignored" list.

/FC affects if diagnostics print with full paths and if __FILE__ expands with a
full path.  clang-cl does both of these two by default.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=263953&r1=263952&r2=263953&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Mar 21 12:19:31 2016
@@ -273,6 +273,7 @@ def _SLASH_cgthreads : CLIgnoredJoined<"
 def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">;
 def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
 def _SLASH_Fd : CLIgnoredJoined<"Fd">;
+def _SLASH_FC : CLIgnoredFlag<"FC">;
 def _SLASH_FS : CLIgnoredFlag<"FS">, HelpText<"Force synchronous PDB writes">;
 def _SLASH_Gd : CLIgnoredFlag<"Gd">;
 def _SLASH_GF : CLIgnoredFlag<"GF">;
@@ -304,7 +305,6 @@ def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_FA_joined : CLJoined<"FA">;
 def _SLASH_favor : CLJoined<"favor">;
-def _SLASH_FC : CLFlag<"FC">;
 def _SLASH_F : CLFlag<"F">;
 def _SLASH_Fm : CLJoined<"Fm">;
 def _SLASH_Fr : CLJoined<"Fr">;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=263953&r1=263952&r2=263953&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Mar 21 12:19:31 2016
@@ -249,6 +249,7 @@
 // RUN:/cgthreads8 \
 // RUN:/d2Zi+ \
 // RUN:/errorReport:foo \
+// RUN:/FC \
 // RUN:/Fdfoo \
 // RUN:/FS \
 // RUN:/Gd \


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


r263955 - NFC: wrap Availability-related data in its own struct in AttributeList.

2016-03-21 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Mar 21 12:26:40 2016
New Revision: 263955

URL: http://llvm.org/viewvc/llvm-project?rev=263955&view=rev
Log:
NFC: wrap Availability-related data in its own struct in AttributeList.

This makes it easy to add more data into Availability.

Modified:
cfe/trunk/include/clang/Sema/AttributeList.h

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=263955&r1=263954&r2=263955&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Mon Mar 21 12:26:40 2016
@@ -46,6 +46,27 @@ struct AvailabilityChange {
   bool isValid() const { return !Version.empty(); }
 };
 
+namespace {
+enum AvailabilitySlot {
+  IntroducedSlot, DeprecatedSlot, ObsoletedSlot, NumAvailabilitySlots
+};
+
+/// Describes the trailing object for Availability attribute in AttributeList.
+struct AvailabilityData {
+  AvailabilityChange Changes[NumAvailabilitySlots];
+  SourceLocation StrictLoc;
+  AvailabilityData(const AvailabilityChange &Introduced,
+   const AvailabilityChange &Deprecated,
+   const AvailabilityChange &Obsoleted,
+   SourceLocation Strict)
+: StrictLoc(Strict) {
+Changes[IntroducedSlot] = Introduced;
+Changes[DeprecatedSlot] = Deprecated;
+Changes[ObsoletedSlot] = Obsoleted;
+  }
+};
+}
+
 /// \brief Wraps an identifier and optional source location for the identifier.
 struct IdentifierLoc {
   SourceLocation Loc;
@@ -148,30 +169,13 @@ private:
 return reinterpret_cast(this + 1);
   }
 
-  enum AvailabilitySlot {
-IntroducedSlot, DeprecatedSlot, ObsoletedSlot
-  };
-
   /// Availability information is stored immediately following the arguments,
   /// if any, at the end of the object.
-  AvailabilityChange &getAvailabilitySlot(AvailabilitySlot index) {
-return reinterpret_cast(getArgsBuffer()
- + NumArgs)[index];
-  }
-  const AvailabilityChange &getAvailabilitySlot(AvailabilitySlot index) const {
-return reinterpret_cast(getArgsBuffer()
-   + NumArgs)[index];
+  AvailabilityData *getAvailabilityData() {
+return reinterpret_cast(getArgsBuffer() + NumArgs);
   }
-
-  /// The location of the 'strict' keyword in an availability attribute.
-  SourceLocation *getStrictSlot() {
-return reinterpret_cast(
-   &getAvailabilitySlot(ObsoletedSlot) + 1);
-  }
-
-  SourceLocation const *getStrictSlot() const {
-return reinterpret_cast(
-   &getAvailabilitySlot(ObsoletedSlot) + 1);
+  const AvailabilityData *getAvailabilityData() const {
+return reinterpret_cast(getArgsBuffer() + 
NumArgs);
   }
 
 public:
@@ -260,10 +264,8 @@ private:
   MessageExpr(messageExpr), NextInPosition(nullptr), NextInPool(nullptr) {
 ArgsUnion PVal(Parm);
 memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
-new (&getAvailabilitySlot(IntroducedSlot)) AvailabilityChange(introduced);
-new (&getAvailabilitySlot(DeprecatedSlot)) AvailabilityChange(deprecated);
-new (&getAvailabilitySlot(ObsoletedSlot)) AvailabilityChange(obsoleted);
-memcpy(getStrictSlot(), &strict, sizeof(SourceLocation));
+new (getAvailabilityData()) AvailabilityData(
+introduced, deprecated, obsoleted, strict);
 AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
   }
 
@@ -428,22 +430,22 @@ public:
 
   const AvailabilityChange &getAvailabilityIntroduced() const {
 assert(getKind() == AT_Availability && "Not an availability attribute");
-return getAvailabilitySlot(IntroducedSlot);
+return getAvailabilityData()->Changes[IntroducedSlot];
   }
 
   const AvailabilityChange &getAvailabilityDeprecated() const {
 assert(getKind() == AT_Availability && "Not an availability attribute");
-return getAvailabilitySlot(DeprecatedSlot);
+return getAvailabilityData()->Changes[DeprecatedSlot];
   }
 
   const AvailabilityChange &getAvailabilityObsoleted() const {
 assert(getKind() == AT_Availability && "Not an availability attribute");
-return getAvailabilitySlot(ObsoletedSlot);
+return getAvailabilityData()->Changes[ObsoletedSlot];
   }
 
   SourceLocation getStrictLoc() const {
 assert(getKind() == AT_Availability && "Not an availability attribute");
-return *getStrictSlot();
+return getAvailabilityData()->StrictLoc;
   }
 
   SourceLocation getUnavailableLoc() const {
@@ -522,8 +524,7 @@ public:
 /// which we want to ensure is a multiple of sizeof(void*).
 AvailabilityAllocSize =
   sizeof(AttributeList)
-  + ((3 * sizeof(AvailabilityChange) + sizeof(void*) +
- sizeof(ArgsUnion) + sizeof(SourceLocation) - 1)
+  + ((sizeof(AvailabilityData) + sizeof(void*) + sizeof(ArgsUnion) - 1)
  / sizeof(void*) * siz

Re: [PATCH] D18311: Clang tests for ARM Cortex-A32 support.

2016-03-21 Thread Renato Golin via cfe-commits
rengolin closed this revision.
rengolin added a comment.

Committed in r263957.


http://reviews.llvm.org/D18311



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


r263957 - [ARM] Clang tests for ARM Cortex-A32 support

2016-03-21 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Mon Mar 21 12:29:51 2016
New Revision: 263957

URL: http://llvm.org/viewvc/llvm-project?rev=263957&view=rev
Log:
[ARM] Clang tests for ARM Cortex-A32 support

Patch by Sam Parker.

Modified:
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=263957&r1=263956&r2=263957&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Mon Mar 21 12:29:51 2016
@@ -22,6 +22,7 @@
 
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a32 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a35 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8

Modified: cfe/trunk/test/Driver/arm-cortex-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-cortex-cpus.c?rev=263957&r1=263956&r2=263957&view=diff
==
--- cfe/trunk/test/Driver/arm-cortex-cpus.c (original)
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c Mon Mar 21 12:29:51 2016
@@ -463,11 +463,13 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r8 -mbig-endian -mthumb 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // CHECK-BE-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7r-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a32 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
@@ -475,11 +477,13 @@
 // RUN: %clang -target arm -mcpu=exynos-m1 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
+// RUN: %clang -target armeb -mcpu=cortex-a32 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a32 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
@@ -487,11 +491,13 @@
 // RUN: %clang -target arm -mcpu=exynos-m1 -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // CHECK-BE-CPUV8A: "-cc1"{{.*}} "-triple" "armebv8-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a32 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cortex-a35 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV8A-THUMB %s
 // RUN: %clang -target arm -mcpu=cort

Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: unittests/Tooling/RefactoringTest.cpp:206
@@ +205,3 @@
+TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
+  std::string Code = "MyType012345678901234567890123456789 *a =\n"
+ "new MyType012345678901234567890123456789();\n"

klimek wrote:
> I'd rely on the general case to be covered by the other test then, and just 
> test that the style is picked up correctly (or falls back correctly to LLVM 
> style).
You are right. Shall I remove this test case for now and add general test 
cases(I mean non-unit test) for format::getStyle in the future?


http://reviews.llvm.org/D17852



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


r263958 - Add replacement = "xxx" to AvailabilityAttr.

2016-03-21 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Mar 21 12:30:55 2016
New Revision: 263958

URL: http://llvm.org/viewvc/llvm-project?rev=263958&view=rev
Log:
Add replacement = "xxx" to AvailabilityAttr.

This commit adds a named argument to AvailabilityAttr, while r263652 adds an
optional string argument to __attribute__((deprecated)).

This was commited in r263687 and reverted in 263752 due to misaligned
access.

rdar://20588929

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/attr-deprecated-replacement-fixit.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=263958&r1=263957&r2=263958&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Mar 21 12:30:55 2016
@@ -467,7 +467,7 @@ def Availability : InheritableAttr {
   let Args = [IdentifierArgument<"platform">, VersionArgument<"introduced">,
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
-  BoolArgument<"strict">];
+  BoolArgument<"strict">, StringArgument<"replacement">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=263958&r1=263957&r2=263958&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Mar 21 12:30:55 2016
@@ -661,6 +661,11 @@ message=\ *string-literal*
   error about use of a deprecated or obsoleted declaration.  Useful to direct
   users to replacement APIs.
 
+replacement=\ *string-literal*
+  Additional message text that Clang will use to provide Fix-It when emitting
+  a warning about use of a deprecated declaration. The Fix-It will replace
+  the deprecated declaration with the new declaration specified.
+
 Multiple availability attributes can be placed on a declaration, which may
 correspond to different platforms.  Only the availability attribute with the
 platform corresponding to the target platform will be used; any others will be

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=263958&r1=263957&r2=263958&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Mar 21 12:30:55 2016
@@ -137,6 +137,9 @@ class Parser : public CodeCompletionHand
   /// \brief Identifier for "strict".
   IdentifierInfo *Ident_strict;
 
+  /// \brief Identifier for "replacement".
+  IdentifierInfo *Ident_replacement;
+
   /// C++0x contextual keywords.
   mutable IdentifierInfo *Ident_final;
   mutable IdentifierInfo *Ident_override;

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=263958&r1=263957&r2=263958&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Mon Mar 21 12:30:55 2016
@@ -55,11 +55,12 @@ enum AvailabilitySlot {
 struct AvailabilityData {
   AvailabilityChange Changes[NumAvailabilitySlots];
   SourceLocation StrictLoc;
+  const Expr *Replacement;
   AvailabilityData(const AvailabilityChange &Introduced,
const AvailabilityChange &Deprecated,
const AvailabilityChange &Obsoleted,
-   SourceLocation Strict)
-: StrictLoc(Strict) {
+   SourceLocation Strict, const Expr *ReplaceExpr)
+: StrictLoc(Strict), Replacement(ReplaceExpr) {
 Changes[IntroducedSlot] = Introduced;
 Changes[DeprecatedSlot] = Deprecated;
 Changes[ObsoletedSlot] = Obsoleted;
@@ -255,7 +256,8 @@ private:
 const AvailabilityChange &obsoleted,
 SourceLocation unavailable, 
 const Expr *messageExpr,
-Syntax syntaxUsed, SourceLocation strict)
+Syntax syntaxUsed, SourceLocation strict,
+const Expr *replacementExpr)
 : AttrName(attrName), ScopeName(scopeName), At

r263961 - clang-format: [JS] no space in union and intersection types.

2016-03-21 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Mar 21 12:57:31 2016
New Revision: 263961

URL: http://llvm.org/viewvc/llvm-project?rev=263961&view=rev
Log:
clang-format: [JS] no space in union and intersection types.

The operators | and & in types, as opposed to the bitwise operators,
should not have whitespace around them (e.g. `Foo`).

Patch by Martin Probst. Thank you.

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

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=263961&r1=263960&r2=263961&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Mon Mar 21 12:57:31 2016
@@ -54,6 +54,7 @@ namespace format {
   TYPE(JsComputedPropertyName) \
   TYPE(JsFatArrow) \
   TYPE(JsTypeColon) \
+  TYPE(JsTypeOperator) \
   TYPE(JsTypeOptionalQuestion) \
   TYPE(LambdaArrow) \
   TYPE(LambdaLSquare) \

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=263961&r1=263960&r2=263961&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Mar 21 12:57:31 2016
@@ -141,6 +141,9 @@ private:
  Left->Previous->is(TT_BinaryOperator))) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
+} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous 
&&
+   Left->Previous->is(Keywords.kw_function)) {
+  Contexts.back().IsExpression = false;
 } else if (Left->Previous && Left->Previous->is(tok::r_square) &&
Left->Previous->MatchingParen &&
Left->Previous->MatchingParen->is(TT_LambdaLSquare)) {
@@ -518,6 +521,14 @@ private:
 Tok->Type = TT_InlineASMColon;
   }
   break;
+case tok::pipe:
+case tok::amp:
+  // | and & in declarations/type expressions represent union and
+  // intersection types, respectively.
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  !Contexts.back().IsExpression)
+Tok->Type = TT_JsTypeOperator;
+  break;
 case tok::kw_if:
 case tok::kw_while:
   if (CurrentToken && CurrentToken->is(tok::l_paren)) {
@@ -2051,6 +2062,8 @@ bool TokenAnnotator::spaceRequiredBefore
   return true;
 if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
   return false;
+if (Left.is(TT_JsTypeOperator) || Right.is(TT_JsTypeOperator))
+  return false;
 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
 Line.First->isOneOf(Keywords.kw_import, tok::kw_export))
   return false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=263961&r1=263960&r2=263961&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Mar 21 12:57:31 2016
@@ -847,6 +847,14 @@ TEST_F(FormatTestJS, TypeAnnotations) {
getGoogleJSStyleWithColumns(60));
 }
 
+TEST_F(FormatTestJS, UnionIntersectionTypes) {
+  verifyFormat("let x: A|B = A | B;");
+  verifyFormat("let x: A&B|C = A & B;");
+  verifyFormat("let x: Foo = new Foo();");
+  verifyFormat("function(x: A|B): C&D {}");
+  verifyFormat("function(x: A|B = A | B): C&D {}");
+}
+
 TEST_F(FormatTestJS, ClassDeclarations) {
   verifyFormat("class C {\n  x: string = 12;\n}");
   verifyFormat("class C {\n  x(): string => 12;\n}");


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


Re: [PATCH] D18294: clang-format: [JS] no space in union and intersection types.

2016-03-21 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r263961.


http://reviews.llvm.org/D18294



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


[clang-tools-extra] r263963 - [clang-tidy] Fix check broken in rL263822.

2016-03-21 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Mon Mar 21 13:00:43 2016
New Revision: 263963

URL: http://llvm.org/viewvc/llvm-project?rev=263963&view=rev
Log:
[clang-tidy] Fix check broken in rL263822.

Add names missing from rL263822 and add tests to prevent future omissions.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp?rev=263963&r1=263962&r2=263963&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp Mon 
Mar 21 13:00:43 2016
@@ -38,7 +38,8 @@ void InefficientAlgorithmCheck::register
  "::std::lower_bound", "::std::upper_bound");
   const auto ContainerMatcher = classTemplateSpecializationDecl(hasAnyName(
   "::std::set", "::std::map", "::std::multiset", "::std::multimap",
-  "::std::unordered_set", "::std::unordered_map"));
+  "::std::unordered_set", "::std::unordered_map",
+  "::std::unordered_multiset", "::std::unordered_multimap"));
 
   const auto Matcher =
   callExpr(

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp?rev=263963&r1=263962&r2=263963&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp Mon 
Mar 21 13:00:43 2016
@@ -35,7 +35,11 @@ template  struct multimap : map {};
 template  struct unordered_set : set {};
+template  struct unordered_map : map {};
+template  struct unordered_multiset : set {};
+template  struct unordered_multimap : map {};
 
 template > struct multiset : set {};
 
@@ -114,10 +118,30 @@ int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
   // CHECK-FIXES: {{^  }}us.find(10);{{$}}
 
+  std::unordered_multiset ums;
+  find(ums.begin(), ums.end(), 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+  // CHECK-FIXES: {{^  }}ums.find(10);{{$}}
+
   std::map intmap;
   find(intmap.begin(), intmap.end(), 46);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
   // CHECK-FIXES: {{^  }}find(intmap.begin(), intmap.end(), 46);{{$}}
+
+  std::multimap intmmap;
+  find(intmmap.begin(), intmmap.end(), 46);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+  // CHECK-FIXES: {{^  }}find(intmmap.begin(), intmmap.end(), 46);{{$}}
+
+  std::unordered_map umap;
+  find(umap.begin(), umap.end(), 46);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+  // CHECK-FIXES: {{^  }}find(umap.begin(), umap.end(), 46);{{$}}
+
+  std::unordered_multimap ummap;
+  find(ummap.begin(), ummap.end(), 46);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
+  // CHECK-FIXES: {{^  }}find(ummap.begin(), ummap.end(), 46);{{$}}
 }
 
 struct Value {


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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-21 Thread Etienne Bergeron via cfe-commits
etienneb added a subscriber: etienneb.


Comment at: clang-tidy/misc/AssignOperatorSignatureCheck.cpp:39
@@ -37,1 +38,3 @@
+  const auto IsSelfAssign =
+cxxMethodDecl(IsAssign,
 hasParameter(0, parmVarDecl(hasType(IsSelf

nit: could you +2 the line to be consistent with the rest of the code


http://reviews.llvm.org/D18264



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


Re: [PATCH] D16749: [OpenMP] Map clause codegeneration.

2016-03-21 Thread Samuel Antao via cfe-commits
sfantao added a comment.

In http://reviews.llvm.org/D16749#378969, @ABataev wrote:

> Samuel, this is true for device part of codegen. But what about host? If 
>  this code must be executed on host, will it be handled correctly?


Hi Alexey,

Yes, it will be handled correctly. The map clause doesn't change the way 
codegen is done for the host. The host always takes the original references 
regardless the map clause and its modifiers. Even for the device side, map 
clause won't have any effect in the code generation of the outlined target 
function. This behavior is what ensures that everything works seamlessly in a 
system that has a shared address space for host and device.

In any case, I added a new regression tests (CK25) that ensures that the lambda 
gets the same captures regardless the map clause.


http://reviews.llvm.org/D16749



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


Re: [PATCH] D17986: [ASTMatchers] New matcher hasReturnValue added

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

In http://reviews.llvm.org/D17986#379271, @baloghadamsoftware wrote:

> I can rerun the script, however it seems it was not executed before the last 
> commit on the master branch, thus if I rerun it then changes will appear in 
> my diff which are not related to my work. What is the exect policy about 
> running this scipt? Should it be rerun before the commit (then it was 
> forgotten by the last committer) or it is executed only before releases?


I don't think there is a specific policy here. We try to keep it up to date, 
but some changes forget to do it.
We can do it in a separate patch if you feel the extra diff should not be on 
this one.


http://reviews.llvm.org/D17986



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


Fwd: r202683 - Introduce '-fmodules-user-build-path' which accepts the "canonical" path to a user workspace build.

2016-03-21 Thread Richard Smith via cfe-commits
[Resend to new ML]

What is this option for? This seems, in effect, to provide a way to
use a distinct module cache. Why would someone use this rather than
specifying a module cache path?

On Mon, Mar 3, 2014 at 12:12 AM, Argyrios Kyrtzidis  wrote:
> Author: akirtzidis
> Date: Mon Mar  3 02:12:05 2014
> New Revision: 202683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=202683&view=rev
> Log:
> Introduce '-fmodules-user-build-path' which accepts the "canonical" path to a 
> user workspace build.
>
> This is used to avoid conflicts with user modules with the same name from 
> different workspaces.
>
> rdar://16042513
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=202683&r1=202682&r2=202683&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Mar  3 02:12:05 2014
> @@ -575,6 +575,9 @@ def fms_memptr_rep_EQ : Joined<["-"], "f
>  def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, 
> Group,
>Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
>HelpText<"Specify the module cache path">;
> +def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, 
> Group,
> +  Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
> +  HelpText<"Specify the module user build path">;
>  def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, 
> Group,
>Flags<[CC1Option]>, MetaVarName<"">,
>HelpText<"Specify the interval (in seconds) between attempts to prune the 
> module cache">;
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=202683&r1=202682&r2=202683&view=diff
> ==
> --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Mar  3 02:12:05 2014
> @@ -89,6 +89,9 @@ public:
>/// \brief The directory used for the module cache.
>std::string ModuleCachePath;
>
> +  /// \brief The directory used for a user build.
> +  std::string ModuleUserBuildPath;
> +
>/// \brief Whether we should disable the use of the hash string within the
>/// module cache.
>///
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=202683&r1=202682&r2=202683&view=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar  3 02:12:05 2014
> @@ -3366,6 +3366,13 @@ void Clang::ConstructJob(Compilation &C,
>  CmdArgs.push_back(Args.MakeArgString(DefaultModuleCache));
>}
>
> +  if (Arg *A = Args.getLastArg(options::OPT_fmodules_user_build_path)) {
> +A->claim();
> +if (HaveModules) {
> +  A->render(Args, CmdArgs);
> +}
> +  }
> +
>// Pass through all -fmodules-ignore-macro arguments.
>Args.AddAllArgs(CmdArgs, options::OPT_fmodules_ignore_macro);
>Args.AddLastArg(CmdArgs, options::OPT_fmodules_prune_interval);
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=202683&r1=202682&r2=202683&view=diff
> ==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar  3 02:12:05 2014
> @@ -918,6 +918,7 @@ static void ParseHeaderSearchArgs(Header
>  Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
>Opts.ResourceDir = Args.getLastArgValue(OPT_resource_dir);
>Opts.ModuleCachePath = Args.getLastArgValue(OPT_fmodules_cache_path);
> +  Opts.ModuleUserBuildPath = 
> Args.getLastArgValue(OPT_fmodules_user_build_path);
>Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
>// -fmodules implies -fmodule-maps
>Opts.ModuleMaps = Args.hasArg(OPT_fmodule_maps) || 
> Args.hasArg(OPT_fmodules);
> @@ -1821,6 +1822,9 @@ std::string CompilerInvocation::getModul
>hsOpts.UseStandardCXXIncludes,
>hsOpts.UseLibcxx);
>
> +  // Extend the signature with the user build path.
> +  code = hash_combine(code, hsOpts.ModuleUserBuildPath);
> +
>// Darwin-specific hack: if we have a sysroot, use the contents and
>// modification time of
>//   $sysroot/System/Lib

r263970 - [modules] Don't invent a module cache path unless implicit module builds are enabled.

2016-03-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar 21 14:06:06 2016
New Revision: 263970

URL: http://llvm.org/viewvc/llvm-project?rev=263970&view=rev
Log:
[modules] Don't invent a module cache path unless implicit module builds are 
enabled.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Modules/no-implicit-builds.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263970&r1=263969&r2=263970&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 21 14:06:06 2016
@@ -5016,28 +5016,12 @@ void Clang::ConstructJob(Compilation &C,
   if (!Args.hasFlag(options::OPT_fimplicit_modules,
 options::OPT_fno_implicit_modules)) {
 CmdArgs.push_back("-fno-implicit-modules");
-  }
-
-  // -fmodule-name specifies the module that is currently being built (or
-  // used for header checking by -fmodule-maps).
-  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
-
-  // -fmodule-map-file can be used to specify files containing module
-  // definitions.
-  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-  // -fmodule-file can be used to specify files containing precompiled modules.
-  if (HaveModules)
-Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
-  else
-Args.ClaimAllArgs(options::OPT_fmodule_file);
-
-  // -fmodule-cache-path specifies where our implicitly-built module files
-  // should be written.
-  SmallString<128> Path;
-  if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
-Path = A->getValue();
-  if (HaveModules) {
+  } else if (HaveModules) {
+// -fmodule-cache-path specifies where our implicitly-built module files
+// should be written.
+SmallString<128> Path;
+if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
+  Path = A->getValue();
 if (C.isForDiagnostics()) {
   // When generating crash reports, we want to emit the modules along with
   // the reproduction sources, so we ignore any provided module path.
@@ -5056,6 +5040,20 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back(Args.MakeArgString(Path));
   }
 
+  // -fmodule-name specifies the module that is currently being built (or
+  // used for header checking by -fmodule-maps).
+  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+  // -fmodule-map-file can be used to specify files containing module
+  // definitions.
+  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+  // -fmodule-file can be used to specify files containing precompiled modules.
+  if (HaveModules)
+Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
+  else
+Args.ClaimAllArgs(options::OPT_fmodule_file);
+
   // When building modules and generating crashdumps, we need to dump a module
   // dependency VFS alongside the output.
   if (HaveModules && C.isForDiagnostics()) {

Modified: cfe/trunk/test/Modules/no-implicit-builds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/no-implicit-builds.cpp?rev=263970&r1=263969&r2=263970&view=diff
==
--- cfe/trunk/test/Modules/no-implicit-builds.cpp (original)
+++ cfe/trunk/test/Modules/no-implicit-builds.cpp Mon Mar 21 14:06:06 2016
@@ -1,5 +1,9 @@
 // RUN: rm -rf %t
 
+// RUN: %clang -x c++ -std=c++11 -fmodules -fno-implicit-modules /dev/null 
-### \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-MODULE-CACHE %s
+// CHECK-NO-MODULE-CACHE-NOT: -fmodules-cache-path
+
 // Produce an error if a module is needed, but not found.
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t \
 // RUN: -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \


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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-21 Thread James Y Knight via cfe-commits
jyknight added a comment.

> Changed to what you suggested. Much nicer. I don't remember why I thought it 
> was a bad idea.


Thanks, great! I don't have any opinion on what remains in this patch; someone 
else should review now.


http://reviews.llvm.org/D17950



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


Re: [PATCH] D18110: [OpenMP] Fix SEMA bug in the capture of global variables in template functions.

2016-03-21 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Ping!


http://reviews.llvm.org/D18110



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


Re: [PATCH] D18268: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo

2016-03-21 Thread Akira Hatanaka via cfe-commits
Jordan,Does the attached patch look OK?On Mar 18, 2016, at 1:19 PM, Jordan Rose  wrote:No, that case worked already. The case you fixed is the one where Base is 'foo' and Property is 'prop'…and actually, thinking more about it, this should not be considered "exact". *sigh* The point of "exact" is "if you see this Base and Property again, are you sure it's really the same Base?". I thought the answer was yes because the receiver is a class and the property identifies the class, but unfortunately it could be a subclass (i.e. "NSResponder.classProp.prop" vs. "NSView.classProp.prop"). These might use the same declaration (and even definition) for 'classProp' but nonetheless return different values.We could ignore this whole thing if we stored an arbitrary-length key, but there's diminishing returns there and this is already not a cheap check.Please change it to set IsExact to false (and update the table).JordanOn Mar 18, 2016, at 12:21 , Akira Hatanaka  wrote:Thanks Jordan. I’ve committed the patch in r263818.I didn’t understand your comment on WeakObjectProfileTy’s table (I’m assuming you are talking about the table in ScopeInfo.h:183). It looks like the entry MyClass.prop in the table already covers the case this patch fixed (in the test case I added, Base is NSBundle and Property is the method “foo”)?On Mar 18, 2016, at 9:55 AM, Jordan Rose via cfe-commits  wrote:jordan_rose accepted this revision.jordan_rose added a comment.This revision is now accepted and ready to land.Ah, of course! Thanks for catching this, Akira. Can you add this case to the table in the doc comment for WeakObjectProfileTy? (That's how I convinced myself it was correct.)http://reviews.llvm.org/D18268___cfe-commits mailing listcfe-commits@lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

p1.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r263974 - clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.

2016-03-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Mar 21 14:44:18 2016
New Revision: 263974

URL: http://llvm.org/viewvc/llvm-project?rev=263974&view=rev
Log:
clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
cfe/trunk/test/Misc/diag-format.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263974&r1=263973&r2=263974&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 21 14:44:18 2016
@@ -3257,6 +3257,7 @@ VersionTuple visualstudio::getMSVCVersio
 if (Major || Minor || Micro)
   return VersionTuple(Major, Minor, Micro);
 
+// FIXME: Consider bumping this to 19 (MSVC2015) soon.
 return VersionTuple(18);
   }
   return VersionTuple();

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=263974&r1=263973&r2=263974&view=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Mon Mar 21 14:44:18 2016
@@ -819,7 +819,15 @@ void TextDiagnostic::emitDiagnosticLoc(S
   switch (DiagOpts->getFormat()) {
   case DiagnosticOptions::Clang:
   case DiagnosticOptions::Vi:OS << ':';break;
-  case DiagnosticOptions::MSVC:  OS << ") : "; break;
+  case DiagnosticOptions::MSVC:
+// MSVC2013 and before print 'file(4) : error'. MSVC2015 gets rid of the
+// space and prints 'file(4): error'.
+OS << ')';
+if (LangOpts.MSCompatibilityVersion &&
+!LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
+  OS << ' ';
+OS << ": ";
+break;
   }
 
   if (DiagOpts->ShowSourceRanges && !Ranges.empty()) {

Modified: cfe/trunk/test/Misc/diag-format.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-format.c?rev=263974&r1=263973&r2=263974&view=diff
==
--- cfe/trunk/test/Misc/diag-format.c (original)
+++ cfe/trunk/test/Misc/diag-format.c Mon Mar 21 14:44:18 2016
@@ -4,13 +4,15 @@
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300  %s 
2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
-fms-compatibility-version=13.00  %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc  %s 2>&1 | FileCheck %s 
-check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc  %s 2>&1 | FileCheck %s 
-check-prefix=MSVCNOTRIPLE
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
-target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
-fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 
%s 2>&1 | FileCheck %s -check-prefix=MSVC
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
-target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
-fms-compatibility-version=13.00 -target x86_64-pc-win32 -fshow-column %s 2>&1 
| FileCheck %s -check-prefix=MSVC2010
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 
-fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1800 
-target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2013
+// RN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 
-fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1900 
-target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2015
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=vi%s 2>&1 | FileCheck %s 
-check-prefix=VI
 //
@@ -20,11 +22,9 @@
 //
 // RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback 
-fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK
 // RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback 
-fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2010-FALLBACK
-// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback %s 
2>&1 | FileCheck %s -check-prefix=MSVC-FALLBACK
-
-
-
-
+// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback %s 
-fmsc-version=1800 2>&1 | FileCheck %s -check-prefix=MSVC2013-FALLBACK
+// RN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback %s 
2>&1 | FileCheck %s -check

Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-21 Thread Matt Kulukundis via cfe-commits
fowles updated this revision to Diff 51215.
fowles marked 2 inline comments as done.

http://reviews.llvm.org/D18149

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -1,28 +1,33 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
-  ExpensiveToCopyType() {}
-  virtual ~ExpensiveToCopyType() {}
-  const ExpensiveToCopyType &reference() const { return *this; }
-  void nonConstMethod() {}
+  ExpensiveToCopyType();
+  virtual ~ExpensiveToCopyType();
+  const ExpensiveToCopyType &reference() const;
+  void nonConstMethod();
+  bool constMethod() const;
 };
 
 struct TrivialToCopyType {
-  const TrivialToCopyType &reference() const { return *this; }
+  const TrivialToCopyType &reference() const;
 };
 
-const ExpensiveToCopyType &ExpensiveTypeReference() {
-  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
-  return *Type;
-}
+struct WeirdCopyCtorType {
+  WeirdCopyCtorType();
+  WeirdCopyCtorType(const WeirdCopyCtorType &w, bool oh_yes = true);
 
-const TrivialToCopyType &TrivialTypeReference() {
-  static const TrivialToCopyType *Type = new TrivialToCopyType();
-  return *Type;
-}
+  void nonConstMethod();
+  bool constMethod() const;
+};
+
+ExpensiveToCopyType global_expensive_to_copy_type;
+
+const ExpensiveToCopyType &ExpensiveTypeReference();
+const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
 void mutate(ExpensiveToCopyType *);
+void useAsConstPointer(const ExpensiveToCopyType *);
 void useAsConstReference(const ExpensiveToCopyType &);
 void useByValue(ExpensiveToCopyType);
 
@@ -203,23 +208,133 @@
   ExpensiveToCopyType Obj;
 };
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)	\
-  void functionWith##TYPE(const TYPE& T) {		\
-auto AssignedInMacro = T.reference();		\
-  }			\
+#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)  \
+  void functionWith##TYPE(const TYPE &T) { \
+auto AssignedInMacro = T.reference();  \
+  }\
 // Ensure fix is not applied.
 // CHECK-FIXES: auto AssignedInMacro = T.reference();
 
-
 UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT)	\
-  ARGUMENT
+#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT) ARGUMENT
 
 void PositiveMacroArgument(const ExpensiveToCopyType &Obj) {
   UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(auto CopyInMacroArg = Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:48: warning: the variable 'CopyInMacroArg' is copy-constructed
   // Ensure fix is not applied.
   // CHECK-FIXES: auto CopyInMacroArg = Obj.reference()
 }
+
+void PositiveLocalCopyConstMethodInvoked() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_1 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_1 = orig;
+  copy_1.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyUsingExplicitCopyCtor() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_2(orig);
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_2'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_2(orig);
+  copy_2.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyCopyIsArgument(const ExpensiveToCopyType &orig) {
+  ExpensiveToCopyType copy_3 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_3'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_3 = orig;
+  copy_3.constMethod();
+}
+
+void PositiveLocalCopyUsedAsConstRef() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_4 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_4'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_4 = orig;
+  useAsConstReference(orig);
+}
+
+void PositiveLocalCopyTwice() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_5 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_5'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_5 = orig;
+  ExpensiveToCopyType copy_6 = copy_5;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_6'
+  // CHECK-FIXES: const ExpensiveToCo

[PATCH] D18325: export additional header modules from xmmintrin

2016-03-21 Thread John Thompson via cfe-commits
jtsoftware created this revision.
jtsoftware added reviewers: silvas, probinson.
jtsoftware added a subscriber: cfe-commits.

If someone only includes xmmintrin.h, but references any definitions from 
stdlib.h (included via mm_malloc.h), if module are enabled it will fail, but if 
modules are not enable, it will not fail to compile.  This will fix this (if 
__STDC_HOSTED__ is defined).


http://reviews.llvm.org/D18325

Files:
  lib/Headers/module.modulemap
  test/Headers/xmmintrin.c

Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -23,3 +23,7 @@
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -44,14 +44,17 @@
 }
 
 explicit module sse {
-  export mmx
-  export sse2 // note: for hackish  dependency
   header "xmmintrin.h"
+  export mm_malloc
+  export mmx
+  export sse2
 }
 
 explicit module sse2 {
-  export sse
   header "emmintrin.h"
+  export mm_malloc
+  export mmx
+  export sse
 }
 
 explicit module sse3 {


Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -23,3 +23,7 @@
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -44,14 +44,17 @@
 }
 
 explicit module sse {
-  export mmx
-  export sse2 // note: for hackish  dependency
   header "xmmintrin.h"
+  export mm_malloc
+  export mmx
+  export sse2
 }
 
 explicit module sse2 {
-  export sse
   header "emmintrin.h"
+  export mm_malloc
+  export mmx
+  export sse
 }
 
 explicit module sse3 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18268: [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo

2016-03-21 Thread Jordan Rose via cfe-commits
Yes, that looks good. For bonus points, add a similar test using the new 
property syntax

@property (class) NSBundle *foo2;

instead of the method. (I expect that version to behave nearly the same, 
including the "may" in the diagnostic.)

Jordan


> On Mar 21, 2016, at 12:36, Akira Hatanaka  wrote:
> 
> Jordan,
> 
> Does the attached patch look OK?
> 
>> On Mar 18, 2016, at 1:19 PM, Jordan Rose > > wrote:
>> 
>> No, that case worked already. The case you fixed is the one where Base is 
>> 'foo' and Property is 'prop'…and actually, thinking more about it, this 
>> should not be considered "exact". *sigh* The point of "exact" is "if you see 
>> this Base and Property again, are you sure it's really the same Base?". I 
>> thought the answer was yes because the receiver is a class and the property 
>> identifies the class, but unfortunately it could be a subclass (i.e. 
>> "NSResponder.classProp.prop" vs. "NSView.classProp.prop"). These might use 
>> the same declaration (and even definition) for 'classProp' but nonetheless 
>> return different values.
>> 
>> We could ignore this whole thing if we stored an arbitrary-length key, but 
>> there's diminishing returns there and this is already not a cheap check.
>> 
>> Please change it to set IsExact to false (and update the table).
>> 
>> Jordan
>> 
>> 
>>> On Mar 18, 2016, at 12:21 , Akira Hatanaka >> > wrote:
>>> 
>>> Thanks Jordan. I’ve committed the patch in r263818.
>>> 
>>> I didn’t understand your comment on WeakObjectProfileTy’s table (I’m 
>>> assuming you are talking about the table in ScopeInfo.h:183). It looks like 
>>> the entry MyClass.prop in the table already covers the case this patch 
>>> fixed (in the test case I added, Base is NSBundle and Property is the 
>>> method “foo”)?
>>> 
 On Mar 18, 2016, at 9:55 AM, Jordan Rose via cfe-commits 
 mailto:cfe-commits@lists.llvm.org>> wrote:
 
 jordan_rose accepted this revision.
 jordan_rose added a comment.
 This revision is now accepted and ready to land.
 
 Ah, of course! Thanks for catching this, Akira. Can you add this case to 
 the table in the doc comment for WeakObjectProfileTy? (That's how I 
 convinced myself it was correct.)
 
 
 http://reviews.llvm.org/D18268 
 
 
 
 ___
 cfe-commits mailing list
 cfe-commits@lists.llvm.org 
 http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>> 
>> 
> 

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


Re: [PATCH] D9557: Remove duplicate type definitions from f16cintrin.h

2016-03-21 Thread John Thompson via cfe-commits
jtsoftware abandoned this revision.
jtsoftware added a comment.

It looks like this has already been addressed.


http://reviews.llvm.org/D9557



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


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Manuel Klimek via cfe-commits
On Mon, Mar 21, 2016 at 6:36 PM Eric Liu  wrote:

> ioeric added inline comments.
>
> 
> Comment at: unittests/Tooling/RefactoringTest.cpp:206
> @@ +205,3 @@
> +TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
> +  std::string Code = "MyType012345678901234567890123456789 *a =\n"
> + "new MyType012345678901234567890123456789();\n"
> 
> klimek wrote:
> > I'd rely on the general case to be covered by the other test then, and
> just test that the style is picked up correctly (or falls back correctly to
> LLVM style).
> You are right. Shall I remove this test case for now and add general test
> cases(I mean non-unit test) for format::getStyle in the future?
>

Any reason to not add this now?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-21 Thread Eric Liu via cfe-commits
Just wanted to check if there are existing test cases for format::getStyle.
If there is no test for it, I'll add test cases for sure :=)

On Mon, Mar 21, 2016, 21:20 Manuel Klimek  wrote:

> On Mon, Mar 21, 2016 at 6:36 PM Eric Liu  wrote:
>
>> ioeric added inline comments.
>>
>> 
>> Comment at: unittests/Tooling/RefactoringTest.cpp:206
>> @@ +205,3 @@
>> +TEST_F(ReplacementTest, ReplaceAndFormatNoStyle) {
>> +  std::string Code = "MyType012345678901234567890123456789 *a =\n"
>> + "new MyType012345678901234567890123456789();\n"
>> 
>> klimek wrote:
>> > I'd rely on the general case to be covered by the other test then, and
>> just test that the style is picked up correctly (or falls back correctly to
>> LLVM style).
>> You are right. Shall I remove this test case for now and add general test
>> cases(I mean non-unit test) for format::getStyle in the future?
>>
>
> Any reason to not add this now?
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18327: [sema] [CUDA] Use std algorithms in EraseUnwantedCUDAMatchesImpl.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

NFC

http://reviews.llvm.org/D18327

Files:
  lib/Sema/SemaCUDA.cpp

Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -210,31 +210,28 @@
   return false;
 }
 
-template 
-static void EraseUnwantedCUDAMatchesImpl(Sema &S, const FunctionDecl *Caller,
- llvm::SmallVectorImpl &Matches,
- FetchDeclFn FetchDecl) {
+template 
+static void EraseUnwantedCUDAMatchesImpl(
+Sema &S, const FunctionDecl *Caller, llvm::SmallVectorImpl &Matches,
+std::function FetchDecl) {
   assert(S.getLangOpts().CUDATargetOverloads &&
  "Should not be called w/o enabled target overloads.");
   if (Matches.size() <= 1)
 return;
 
+  // Gets the CUDA function preference for a call from Caller to Match.
+  auto GetCFP = [&](const T &Match) {
+return S.IdentifyCUDAPreference(Caller, FetchDecl(Match));
+  };
+
   // Find the best call preference among the functions in Matches.
-  Sema::CUDAFunctionPreference P, BestCFP = Sema::CFP_Never;
-  for (auto const &Match : Matches) {
-P = S.IdentifyCUDAPreference(Caller, FetchDecl(Match));
-if (P > BestCFP)
-  BestCFP = P;
-  }
+  Sema::CUDAFunctionPreference BestCFP = GetCFP(*std::max_element(
+  Matches.begin(), Matches.end(),
+  [&](const T &M1, const T &M2) { return GetCFP(M1) < GetCFP(M2); }));
 
   // Erase all functions with lower priority.
-  for (unsigned I = 0, N = Matches.size(); I != N;)
-if (S.IdentifyCUDAPreference(Caller, FetchDecl(Matches[I])) < BestCFP) {
-  Matches[I] = Matches[--N];
-  Matches.resize(N);
-} else {
-  ++I;
-}
+  Matches.erase(llvm::remove_if(
+  Matches, [&](const T &Match) { return GetCFP(Match) < BestCFP; }));
 }
 
 void Sema::EraseUnwantedCUDAMatches(const FunctionDecl *Caller,


Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -210,31 +210,28 @@
   return false;
 }
 
-template 
-static void EraseUnwantedCUDAMatchesImpl(Sema &S, const FunctionDecl *Caller,
- llvm::SmallVectorImpl &Matches,
- FetchDeclFn FetchDecl) {
+template 
+static void EraseUnwantedCUDAMatchesImpl(
+Sema &S, const FunctionDecl *Caller, llvm::SmallVectorImpl &Matches,
+std::function FetchDecl) {
   assert(S.getLangOpts().CUDATargetOverloads &&
  "Should not be called w/o enabled target overloads.");
   if (Matches.size() <= 1)
 return;
 
+  // Gets the CUDA function preference for a call from Caller to Match.
+  auto GetCFP = [&](const T &Match) {
+return S.IdentifyCUDAPreference(Caller, FetchDecl(Match));
+  };
+
   // Find the best call preference among the functions in Matches.
-  Sema::CUDAFunctionPreference P, BestCFP = Sema::CFP_Never;
-  for (auto const &Match : Matches) {
-P = S.IdentifyCUDAPreference(Caller, FetchDecl(Match));
-if (P > BestCFP)
-  BestCFP = P;
-  }
+  Sema::CUDAFunctionPreference BestCFP = GetCFP(*std::max_element(
+  Matches.begin(), Matches.end(),
+  [&](const T &M1, const T &M2) { return GetCFP(M1) < GetCFP(M2); }));
 
   // Erase all functions with lower priority.
-  for (unsigned I = 0, N = Matches.size(); I != N;)
-if (S.IdentifyCUDAPreference(Caller, FetchDecl(Matches[I])) < BestCFP) {
-  Matches[I] = Matches[--N];
-  Matches.resize(N);
-} else {
-  ++I;
-}
+  Matches.erase(llvm::remove_if(
+  Matches, [&](const T &Match) { return GetCFP(Match) < BestCFP; }));
 }
 
 void Sema::EraseUnwantedCUDAMatches(const FunctionDecl *Caller,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added reviewers: tra, rnk.
jlebar added subscribers: cfe-commits, jhen.

clang --cuda-allow-std-complex translates into cc1
-fcuda-allow-std-complex.  With this flag, we will mark all functions
inside  within namespace std as host+device, other than
operator>> and operator<<, which use ostreams, which are not supported
in CUDA device code.

http://reviews.llvm.org/D18328

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  include/clang/Sema/Sema.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  test/Driver/cuda-complex.cu
  test/SemaCUDA/Inputs/complex
  test/SemaCUDA/complex.cu

Index: test/SemaCUDA/complex.cu
===
--- /dev/null
+++ test/SemaCUDA/complex.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-allow-std-complex -fcuda-is-device -isystem "%S/Inputs" -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -fcuda-allow-std-complex -isystem "%S/Inputs" -verify %s
+
+// Checks that functions inside a system header named  are marked as
+// host+device.
+
+#include 
+#include 
+
+using std::complex;
+using std::real;
+
+void __device__ foo() {
+  complex x;
+  complex y(x);
+  y += x;
+  x + y;
+  real(complex(1, 2));
+
+  // Our  header defines complex-to-complex operator<< and operator>>,
+  // but these are not implicitly marked as host+device.
+
+  x << y; // expected-error {{invalid operands to binary expression}}
+  // expected-note@complex:* {{call to __host__ function from __device__ function}}
+  x >> y; // expected-error {{invalid operands to binary expression}}
+  // expected-note@complex:* {{call to __host__ function from __device__ function}}
+}
Index: test/SemaCUDA/Inputs/complex
===
--- /dev/null
+++ test/SemaCUDA/Inputs/complex
@@ -0,0 +1,30 @@
+// Incomplete stub of  used to check that we properly annotate these
+// functions as host+device.
+
+namespace std {
+
+template 
+class complex {
+ public:
+  complex(const T &re = T(), const T &im = T());
+  complex &operator+=(const complex &);
+
+ private:
+  T real;
+  T imag;
+};
+
+template 
+complex operator+(const complex &, const complex &);
+
+template 
+T real(const complex &);
+
+// Stream operators are not marked as host+device.
+template 
+void operator<<(const complex &, const complex &);
+
+template 
+void operator>>(const complex &, const complex &);
+
+} // namespace std
Index: test/Driver/cuda-complex.cu
===
--- /dev/null
+++ test/Driver/cuda-complex.cu
@@ -0,0 +1,15 @@
+// Tests CUDA compilation pipeline construction in Driver.
+// REQUIRES: clang-driver
+
+// Check that --cuda-allow-std-complex passes -fcuda-allow-std-complex to cc1.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-allow-std-complex -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ALLOW-COMPLEX %s
+
+// ALLOW-COMPLEX: -fcuda-allow-std-complex
+
+// But if we don't pass --cuda-allow-std-complex, we don't pass
+// -fcuda-allow-std-complex to cc1.
+// RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix NO-ALLOW-COMPLEX %s
+
+// NO-ALLOW-COMPLEX-NOT: -fcuda-allow-std-complex
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8340,6 +8340,12 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  // CUDA: Some decls in system headers get an implicit __host__ __device__.
+  if (getLangOpts().CUDA && declShouldBeCUDAHostDevice(*NewFD)) {
+NewFD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+NewFD->addAttr(CUDAHostAttr::CreateImplicit(Context));
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -14,11 +14,13 @@
 #include "clang/Sema/Sema.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringSet.h"
 using namespace clang;
 
 ExprResult Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation oc,
@@ -450,3 +452,44 @@
 
   return true;
 }
+
+// Everything within namespace std inside  should be host+device,
+// except operator<< and operator>> (ostreams aren't supported in CUDA device
+// code).  Whitelisting the functions we want, rather than blacklisting the
+// stream operators, is a tempting alternative, but libstdc++ us

r263984 - Revert "Convert some ObjC msgSends to runtime calls."

2016-03-21 Thread Pete Cooper via cfe-commits
Author: pete
Date: Mon Mar 21 15:50:03 2016
New Revision: 263984

URL: http://llvm.org/viewvc/llvm-project?rev=263984&view=rev
Log:
Revert "Convert some ObjC msgSends to runtime calls."

This reverts commit r263607.

This change caused more objc_retain/objc_release calls in the IR but those
are then incorrectly optimized by the ARC optimizer.  Work is going to have
to be done to ensure the ARC optimizer doesn't optimize user written RR, but
that should land before this change.

This change will also need to be updated to take account for any changes 
required
to ensure that user written calls to RR are distinct from those inserted by ARC.

Removed:
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
cfe/trunk/test/Driver/objc-convert-messages-to-runtime-calls.m
Modified:
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/ObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ObjCRuntime.h?rev=263984&r1=263983&r2=263984&view=diff
==
--- cfe/trunk/include/clang/Basic/ObjCRuntime.h (original)
+++ cfe/trunk/include/clang/Basic/ObjCRuntime.h Mon Mar 21 15:50:03 2016
@@ -171,79 +171,6 @@ public:
 llvm_unreachable("bad kind");
   }
 
-  /// Does this runtime provide ARC entrypoints that are likely to be faster
-  /// than an ordinary message send of the appropriate selector?
-  ///
-  /// The ARC entrypoints are guaranteed to be equivalent to just sending the
-  /// corresponding message.  If the entrypoint is implemented naively as just 
a
-  /// message send, using it is a trade-off: it sacrifices a few cycles of
-  /// overhead to save a small amount of code.  However, it's possible for
-  /// runtimes to detect and special-case classes that use "standard"
-  /// retain/release behavior; if that's dynamically a large proportion of all
-  /// retained objects, using the entrypoint will also be faster than using a
-  /// message send.
-  ///
-  /// When this method returns true, Clang will turn non-super message sends of
-  /// certain selectors into calls to the correspond entrypoint:
-  ///   retain => objc_retain
-  ///   release => objc_release
-  bool shouldUseARCFunctionsForRetainRelease() const {
-switch (getKind()) {
-case FragileMacOSX:
-  return false;
-case MacOSX:
-  return getVersion() >= VersionTuple(10, 10);
-case iOS:
-  return getVersion() >= VersionTuple(8);
-case WatchOS:
-  return true;
-
-case GCC:
-  return false;
-case GNUstep:
-  return false;
-case ObjFW:
-  return false;
-}
-llvm_unreachable("bad kind");
-  }
-
-  /// Does this runtime provide entrypoints that are likely to be faster
-  /// than an ordinary message send of the "alloc" selector?
-  ///
-  /// The "alloc" entrypoint is guaranteed to be equivalent to just sending the
-  /// corresponding message.  If the entrypoint is implemented naively as just 
a
-  /// message send, using it is a trade-off: it sacrifices a few cycles of
-  /// overhead to save a small amount of code.  However, it's possible for
-  /// runtimes to detect and special-case classes that use "standard"
-  /// alloc behavior; if that's dynamically a large proportion of all
-  /// objects, using the entrypoint will also be faster than using a message
-  /// send.
-  ///
-  /// When this method returns true, Clang will turn non-super message sends of
-  /// certain selectors into calls to the correspond entrypoint:
-  ///   alloc => objc_alloc
-  bool shouldUseRuntimeFunctionsForAlloc() const {
-switch (getKind()) {
-case FragileMacOSX:
-  return false;
-case MacOSX:
-  return getVersion() >= VersionTuple(10, 10);
-case iOS:
-  return getVersion() >= VersionTuple(8);
-case WatchOS:
-  return true;
-
-case GCC:
-  return false;
-case GNUstep:
-  return false;
-case ObjFW:
-  return false;
-}
-llvm_unreachable("bad kind");
-  }
-
   /// \brief Does this runtime supports optimized setter entrypoints?
   bool hasOptimizedSetter() const {
 switch (getKind()) {

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=263984&r1=263983&r2=263984&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Mar 21 15:50:03 2016
@@ -933,10 +933,6 @@ def fno_zero_initialized_in_bss : Flag<[
 def fobjc_arc : Flag<["-"], "fobjc-arc">, Group, Flags<[CC1Op

Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

One minor question, LGTM otherwise.



Comment at: lib/Sema/SemaCUDA.cpp:474
@@ +473,3 @@
+  SourceLocation Loc = FD.getLocation();
+  if (!SM.isInSystemHeader(Loc))
+return false;

Can C++ library headers ever be non-system? I.e. can someone use libc++ via -I ?



http://reviews.llvm.org/D18328



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-21 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

In http://reviews.llvm.org/D17741#374725, @weimingz wrote:

> In http://reviews.llvm.org/D17741#372098, @weimingz wrote:
>
> > rebased
>
>
> ping~


HI,

Any comments/suggestions?


http://reviews.llvm.org/D17741



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


r263989 - [modules] Renumber DECL_UPDATES from 30 to 50, so it no longer collides with

2016-03-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar 21 16:16:01 2016
New Revision: 263989

URL: http://llvm.org/viewvc/llvm-project?rev=263989&view=rev
Log:
[modules] Renumber DECL_UPDATES from 30 to 50, so it no longer collides with
TYPE_TEMPLATE_SPECIALIZATION. This was fine in practice because both record
kinds are only ever found by offset, but made the llvm-bcanalyzer -dump output
very confusing.

Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=263989&r1=263988&r2=263989&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Mar 21 16:16:01 2016
@@ -484,9 +484,8 @@ namespace clang {
   /// that were modified after being deserialized and need updates.
   DECL_UPDATE_OFFSETS = 29,
 
-  /// \brief Record of updates for a declaration that was modified after
-  /// being deserialized.
-  DECL_UPDATES = 30,
+  // ID 30 used to be a decl update record. These are now in the DECLTYPES
+  // block.
   
   /// \brief Record code for the table of offsets to CXXBaseSpecifier
   /// sets.
@@ -833,7 +832,7 @@ namespace clang {
 /// These constants describe the type records that can occur within a
 /// block identified by DECLTYPES_BLOCK_ID in the AST file. Each
 /// constant describes a record for a specific type class in the
-/// AST.
+/// AST. Note that DeclCode values share this code space.
 enum TypeCode {
   /// \brief An ExtQualType record.
   TYPE_EXT_QUAL = 1,
@@ -1010,15 +1009,20 @@ namespace clang {
 /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
 const unsigned int NUM_PREDEF_DECL_IDS = 16;
 
+/// \brief Record of updates for a declaration that was modified after
+/// being deserialized. This can occur within DECLTYPES_BLOCK_ID.
+const unsigned int DECL_UPDATES = 49;
+
 /// \brief Record code for a list of local redeclarations of a declaration.
+/// This can occur within DECLTYPES_BLOCK_ID.
 const unsigned int LOCAL_REDECLARATIONS = 50;
 
 /// \brief Record codes for each kind of declaration.
 ///
 /// These constants describe the declaration records that can occur within
-/// a declarations block (identified by DECLS_BLOCK_ID). Each
+/// a declarations block (identified by DECLTYPES_BLOCK_ID). Each
 /// constant describes a record for a specific declaration class
-/// in the AST.
+/// in the AST. Note that TypeCode values share this code space.
 enum DeclCode {
   /// \brief A TypedefDecl record.
   DECL_TYPEDEF = 51,


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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Sema/SemaCUDA.cpp:474
@@ +473,3 @@
+  SourceLocation Loc = FD.getLocation();
+  if (!SM.isInSystemHeader(Loc))
+return false;

tra wrote:
> Can C++ library headers ever be non-system? I.e. can someone use libc++ via 
> -I ?
> 
Good question, I have no idea if that's supposed to work.  Reid, do you know?


http://reviews.llvm.org/D18328



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


LLVM buildmaster will be restarted tonight

2016-03-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

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

Thanks

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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

I would much prefer for us to, say, provide a  header that wraps the 
system one and does something like

  // 
  #pragma clang cuda_implicit_host_device {
  #include_next 
  #pragma clang cuda_implicit_host_device }

or to provide an explicit list of the functions that we're promoting to 
`__host__` `__device__`, or to require people to use a CUDA-compatible standard 
library if they want CUDA-compatible standard library behaviour.



Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

I don't think it's reasonable to have something this hacky / arbitrary in the 
stable Clang driver interface.


Comment at: lib/Sema/SemaCUDA.cpp:479-481
@@ +478,5 @@
+return false;
+  StringRef Filename = FE->getName();
+  if (Filename != "complex" && !Filename.endswith("/complex"))
+return false;
+

I don't think this works: the standard library might factor parts of  
out into separate header files. For instance, libstdc++ 4.4 includes the TR1 
pieces of  in that way.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/Sema/SemaCUDA.cpp:474
@@ +473,3 @@
+  SourceLocation Loc = FD.getLocation();
+  if (!SM.isInSystemHeader(Loc))
+return false;

jlebar wrote:
> tra wrote:
> > Can C++ library headers ever be non-system? I.e. can someone use libc++ via 
> > -I ?
> > 
> Good question, I have no idea if that's supposed to work.  Reid, do you know?
libc++ complex has this pragma in it:
  #pragma GCC system_header
So we should be safe regardless of the flags used to find it.


Comment at: lib/Sema/SemaCUDA.cpp:483-488
@@ +482,8 @@
+
+  bool IsInStd = FD.isInStdNamespace();
+  if (const auto *Method = dyn_cast(&FD))
+if (const auto *Parent = Method->getParent())
+  IsInStd |= Parent->isInStdNamespace();
+  if (!IsInStd)
+return false;
+

I'd do this check after the system header test and before the "complex" test, 
since it's probably faster.


Comment at: lib/Sema/SemaCUDA.cpp:485
@@ +484,3 @@
+  if (const auto *Method = dyn_cast(&FD))
+if (const auto *Parent = Method->getParent())
+  IsInStd |= Parent->isInStdNamespace();

There's no cast on the RHS, so I'd spell out `CXXRecordDecl` here to make 
things more obvious.


Comment at: lib/Sema/SemaDecl.cpp:8344
@@ +8343,3 @@
+  // CUDA: Some decls in system headers get an implicit __host__ __device__.
+  if (getLangOpts().CUDA && declShouldBeCUDAHostDevice(*NewFD)) {
+NewFD->addAttr(CUDADeviceAttr::CreateImplicit(Context));

Do you want this to apply to declarations as well as definitions? Your test 
uses that functionality.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Thanks for the suggestions, Richard.  I'm not sure any of them will work, but I 
don't defend this patch as anything other than a hack, so if we can come up 
with something that works for what we need to accomplish and is cleaner, that's 
great.

In http://reviews.llvm.org/D18328#379824, @rsmith wrote:

> I would much prefer for us to, say, provide a  header that wraps the 
> system one and does something like
>
>   // 
>   #pragma clang cuda_implicit_host_device {
>   #include_next 
>   #pragma clang cuda_implicit_host_device }


We considered this and ruled it out for two reasons:

1. We'd have to exclude operator>> and operator<<, presumably with additional 
pragmas, and
2. We'd have to exclude everything included by .

Of course with enough pragmas anything is possible, but at this point it seemed 
to become substantially more complicated than this (admittedly awful) hack.

> or to provide an explicit list of the functions that we're promoting to 
> `__host__` `__device__`


The problem with that is that libstdc++ uses many helper functions, which we'd 
also have to enumerate.  Baking those kinds of implementation details into 
clang seemed worse than this hack.

> or to require people to use a CUDA-compatible standard library if they want 
> CUDA-compatible standard library behaviour.


I think asking people to use a custom standard library is a nonstarter for e.g. 
OSS tensorflow, and I suspect it would be a considerable amount of work to 
accomplish in google3.  (Not to suggest that two wrongs make a right, but we 
already have many similar hacks in place to match nvcc's behavior with standard 
library functions -- the main difference here is that we're spelling the hack 
in clang's C++ as opposed to in __clang_cuda_runtime_wrapper.h.)


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Artem Belevich via cfe-commits
tra added a comment.

In http://reviews.llvm.org/D18328#379824, @rsmith wrote:

> I would much prefer for us to, say, provide a  header that wraps the 
> system one and does something like
>
>   // 
>   #pragma clang cuda_implicit_host_device {
>   #include_next 
>   #pragma clang cuda_implicit_host_device }
>   
>
> or to provide an explicit list of the functions that we're promoting to 
> `__host__` `__device__`, or to require people to use a CUDA-compatible 
> standard library if they want CUDA-compatible standard library behaviour.


We'll still need some filtering as not everything inside  should be 
`__host__` `__device__`.



Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

rsmith wrote:
> I don't think it's reasonable to have something this hacky / arbitrary in the 
> stable Clang driver interface.
What would be a better way to enable this 'feature'? I guess we could live with 
-Xclang -fcuda-allow-std-complex for now, but that does not seem to be 
particularly good way to give user control, either.

Perhaps we should have some sort of --cuda-enable-extension=foo option to 
control CUDA hacks.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Here are two other approaches we considered and rejected, for the record:

1. Copy-paste a  implementation from e.g. libc++ into 
__clang_cuda_runtime_wrapper.h, and edit it appropriately.  Then #define the 
real 's include guards.

  Main problem with this is the obvious one: We're copying a big chunk of the 
standard library into the compiler, where it doesn't belong, and now we have 
two divergent copies of this code to maintain.  In addition, we can't 
necessarily use libc++, since we need to support pre-c++11 and AIUI libc++ does 
not.



2. Provide `__device__` overrides for all the functions defined in .  
This almost works, except that we do not (currently) have a way to let you 
inject new overloads for member functions into classes we don't own.  E.g. we 
can add a `__device__` overload `std::real(const complex&)`, just like we 
could override `std::real` in any other way, but we can't add a new 
`__device__` overload to `std::complex::real()`.

  This approach also has a similar problem to (1), which is that we'd end up 
copy/pasting almost all of  into the compiler.



Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

tra wrote:
> rsmith wrote:
> > I don't think it's reasonable to have something this hacky / arbitrary in 
> > the stable Clang driver interface.
> What would be a better way to enable this 'feature'? I guess we could live 
> with -Xclang -fcuda-allow-std-complex for now, but that does not seem to be 
> particularly good way to give user control, either.
> 
> Perhaps we should have some sort of --cuda-enable-extension=foo option to 
> control CUDA hacks.
> I don't think it's reasonable to have something this hacky / arbitrary in the 
> stable Clang driver interface.

This is an important feature for a lot of projects, including tensorflow and 
eigen.  No matter how we define the flag, I suspect people are going to use it 
en masse.  (Most projects I've seen pass the equivalent flag to nvcc.)  At the 
point that many or even most projects are relying on it, I'd suspect we'll have 
difficulty changing this flag, regardless of whether or not it is officially 
part of our stable API.

There's also the issue of discoverability.  nvcc actually gives a nice error 
message when you try to use std::complex -- it seems pretty unfriendly not to 
even list the relevant flag in clang --help.

I don't feel particularly strongly about this, though -- I'm more concerned 
about getting something that works.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

jlebar wrote:
> tra wrote:
> > rsmith wrote:
> > > I don't think it's reasonable to have something this hacky / arbitrary in 
> > > the stable Clang driver interface.
> > What would be a better way to enable this 'feature'? I guess we could live 
> > with -Xclang -fcuda-allow-std-complex for now, but that does not seem to be 
> > particularly good way to give user control, either.
> > 
> > Perhaps we should have some sort of --cuda-enable-extension=foo option to 
> > control CUDA hacks.
> > I don't think it's reasonable to have something this hacky / arbitrary in 
> > the stable Clang driver interface.
> 
> This is an important feature for a lot of projects, including tensorflow and 
> eigen.  No matter how we define the flag, I suspect people are going to use 
> it en masse.  (Most projects I've seen pass the equivalent flag to nvcc.)  At 
> the point that many or even most projects are relying on it, I'd suspect 
> we'll have difficulty changing this flag, regardless of whether or not it is 
> officially part of our stable API.
> 
> There's also the issue of discoverability.  nvcc actually gives a nice error 
> message when you try to use std::complex -- it seems pretty unfriendly not to 
> even list the relevant flag in clang --help.
> 
> I don't feel particularly strongly about this, though -- I'm more concerned 
> about getting something that works.
An alternative wrt the flag is to enable it by default.  This would be somewhat 
consistent with existing behavior, wherein we make most std math functions 
available without a special flag, even though they're not technically 
host-device.  The main difference here is that there we're matching nvcc's 
default behavior, whereas here we're actually going further than nvcc -- nvcc 
by default doesn't let you touch std::complex from device code at all, and with 
a flag, you can touch its *constexpr* functions.  Which is not actually very 
much.

Nonetheless, since the user-visible effect is consistent with our approach of 
making std math stuff available, and since this shouldn't make us reject code 
nvcc accepts, I'd be more OK hiding the flag to turn it off.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D18328#379824, @rsmith wrote:

> I would much prefer for us to, say, provide a  header that wraps the 
> system one and does something like
>
>   // 
>   #pragma clang cuda_implicit_host_device {
>   #include_next 
>   #pragma clang cuda_implicit_host_device }
>   
>
> or to provide an explicit list of the functions that we're promoting to 
> `__host__` `__device__`, or to require people to use a CUDA-compatible 
> standard library if they want CUDA-compatible standard library behaviour.


I don't really like include_next wrapper headers, but adding a pragma spelling 
of the cuda device attributes might be nice. There would still be issues with 
the streaming operators, though.



Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

jlebar wrote:
> tra wrote:
> > rsmith wrote:
> > > I don't think it's reasonable to have something this hacky / arbitrary in 
> > > the stable Clang driver interface.
> > What would be a better way to enable this 'feature'? I guess we could live 
> > with -Xclang -fcuda-allow-std-complex for now, but that does not seem to be 
> > particularly good way to give user control, either.
> > 
> > Perhaps we should have some sort of --cuda-enable-extension=foo option to 
> > control CUDA hacks.
> > I don't think it's reasonable to have something this hacky / arbitrary in 
> > the stable Clang driver interface.
> 
> This is an important feature for a lot of projects, including tensorflow and 
> eigen.  No matter how we define the flag, I suspect people are going to use 
> it en masse.  (Most projects I've seen pass the equivalent flag to nvcc.)  At 
> the point that many or even most projects are relying on it, I'd suspect 
> we'll have difficulty changing this flag, regardless of whether or not it is 
> officially part of our stable API.
> 
> There's also the issue of discoverability.  nvcc actually gives a nice error 
> message when you try to use std::complex -- it seems pretty unfriendly not to 
> even list the relevant flag in clang --help.
> 
> I don't feel particularly strongly about this, though -- I'm more concerned 
> about getting something that works.
What if we had a catchall nvcc quirks mode flag similar to -fms-compatibility? 
We probably don't want a super fine grained LangOpt like this.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

jlebar wrote:
> rnk wrote:
> > jlebar wrote:
> > > tra wrote:
> > > > rsmith wrote:
> > > > > I don't think it's reasonable to have something this hacky / 
> > > > > arbitrary in the stable Clang driver interface.
> > > > What would be a better way to enable this 'feature'? I guess we could 
> > > > live with -Xclang -fcuda-allow-std-complex for now, but that does not 
> > > > seem to be particularly good way to give user control, either.
> > > > 
> > > > Perhaps we should have some sort of --cuda-enable-extension=foo option 
> > > > to control CUDA hacks.
> > > > I don't think it's reasonable to have something this hacky / arbitrary 
> > > > in the stable Clang driver interface.
> > > 
> > > This is an important feature for a lot of projects, including tensorflow 
> > > and eigen.  No matter how we define the flag, I suspect people are going 
> > > to use it en masse.  (Most projects I've seen pass the equivalent flag to 
> > > nvcc.)  At the point that many or even most projects are relying on it, 
> > > I'd suspect we'll have difficulty changing this flag, regardless of 
> > > whether or not it is officially part of our stable API.
> > > 
> > > There's also the issue of discoverability.  nvcc actually gives a nice 
> > > error message when you try to use std::complex -- it seems pretty 
> > > unfriendly not to even list the relevant flag in clang --help.
> > > 
> > > I don't feel particularly strongly about this, though -- I'm more 
> > > concerned about getting something that works.
> > What if we had a catchall nvcc quirks mode flag similar to 
> > -fms-compatibility? We probably don't want a super fine grained LangOpt 
> > like this.
> An alternative wrt the flag is to enable it by default.  This would be 
> somewhat consistent with existing behavior, wherein we make most std math 
> functions available without a special flag, even though they're not 
> technically host-device.  The main difference here is that there we're 
> matching nvcc's default behavior, whereas here we're actually going further 
> than nvcc -- nvcc by default doesn't let you touch std::complex from device 
> code at all, and with a flag, you can touch its *constexpr* functions.  Which 
> is not actually very much.
> 
> Nonetheless, since the user-visible effect is consistent with our approach of 
> making std math stuff available, and since this shouldn't make us reject code 
> nvcc accepts, I'd be more OK hiding the flag to turn it off.
> What if we had a catchall nvcc quirks mode flag similar to -fms-compatibility?

I think we midair'ed on this.  See above comment about turning this flag on by 
default -- calling this "nvcc compat" wouldn't quite be right.  We could 
certainly have a broader flag, but I'm not sure at the moment what else would 
reasonably go in with this one.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-21 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Driver/Options.td:383-384
@@ -382,2 +382,4 @@
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def cuda_allow_std_complex : Flag<["--"], "cuda-allow-std-complex">,
+  HelpText<"Allow CUDA device code to use definitions from , other 
than operator>> and operator<<.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,

jlebar wrote:
> jlebar wrote:
> > rnk wrote:
> > > jlebar wrote:
> > > > tra wrote:
> > > > > rsmith wrote:
> > > > > > I don't think it's reasonable to have something this hacky / 
> > > > > > arbitrary in the stable Clang driver interface.
> > > > > What would be a better way to enable this 'feature'? I guess we could 
> > > > > live with -Xclang -fcuda-allow-std-complex for now, but that does not 
> > > > > seem to be particularly good way to give user control, either.
> > > > > 
> > > > > Perhaps we should have some sort of --cuda-enable-extension=foo 
> > > > > option to control CUDA hacks.
> > > > > I don't think it's reasonable to have something this hacky / 
> > > > > arbitrary in the stable Clang driver interface.
> > > > 
> > > > This is an important feature for a lot of projects, including 
> > > > tensorflow and eigen.  No matter how we define the flag, I suspect 
> > > > people are going to use it en masse.  (Most projects I've seen pass the 
> > > > equivalent flag to nvcc.)  At the point that many or even most projects 
> > > > are relying on it, I'd suspect we'll have difficulty changing this 
> > > > flag, regardless of whether or not it is officially part of our stable 
> > > > API.
> > > > 
> > > > There's also the issue of discoverability.  nvcc actually gives a nice 
> > > > error message when you try to use std::complex -- it seems pretty 
> > > > unfriendly not to even list the relevant flag in clang --help.
> > > > 
> > > > I don't feel particularly strongly about this, though -- I'm more 
> > > > concerned about getting something that works.
> > > What if we had a catchall nvcc quirks mode flag similar to 
> > > -fms-compatibility? We probably don't want a super fine grained LangOpt 
> > > like this.
> > An alternative wrt the flag is to enable it by default.  This would be 
> > somewhat consistent with existing behavior, wherein we make most std math 
> > functions available without a special flag, even though they're not 
> > technically host-device.  The main difference here is that there we're 
> > matching nvcc's default behavior, whereas here we're actually going further 
> > than nvcc -- nvcc by default doesn't let you touch std::complex from device 
> > code at all, and with a flag, you can touch its *constexpr* functions.  
> > Which is not actually very much.
> > 
> > Nonetheless, since the user-visible effect is consistent with our approach 
> > of making std math stuff available, and since this shouldn't make us reject 
> > code nvcc accepts, I'd be more OK hiding the flag to turn it off.
> > What if we had a catchall nvcc quirks mode flag similar to 
> > -fms-compatibility?
> 
> I think we midair'ed on this.  See above comment about turning this flag on 
> by default -- calling this "nvcc compat" wouldn't quite be right.  We could 
> certainly have a broader flag, but I'm not sure at the moment what else would 
> reasonably go in with this one.
I'd find either of these suggestions (-fnvcc-compatibility or a cc1-only flag 
to turn this behaviour off) more palatable than the current approach.

I'd also be a lot happier about this if we can view it as a short-term 
workaround, with the longer-term fix being to get the host/device attributes 
added to standard library implementations (even if it turns out we can never 
actually remove this workaround in practice). If we can legitimately claim that 
this is the way that CUDA is intended to work, and the missing attributes in 
 are a bug in that header (in CUDA mode), then that provides a solid 
justification for having this complexity in Clang.


Comment at: lib/Sema/SemaCUDA.cpp:464-465
@@ +463,4 @@
+//  without passing -fcuda-allow-std-complex.
+// TODO: Output a nvcc-compat warning if you try to use a non-constexpr 
function
+// from  -- nvcc only lets you use constexpr functions.
+bool Sema::declShouldBeCUDAHostDevice(const FunctionDecl &FD) {

Does nvcc do this "`constexpr` implies `__host__ __device__`" thing only for 
functions declared within , or for all functions?

Another alternative strategy: a wrapper `` header that does this:

#include // ... union of includes from libc++ and libstdc++ 
#define constexpr __host__ __device__ constexpr
#include_next 
#undef constexpr


Comment at: lib/Sema/SemaCUDA.cpp:485
@@ +484,3 @@
+  if (const auto *Method = dyn_cast(&FD))
+if (const auto *Parent = Method->getParent())
+  IsInStd |= Parent->isInStdNamespace();

rnk wrote:
> There's no cast

r263996 - [modules] Store mangling numbers in a deterministic order so they don't cause the resulting .pcm files to be nondeterministic.

2016-03-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Mar 21 17:33:02 2016
New Revision: 263996

URL: http://llvm.org/viewvc/llvm-project?rev=263996&view=rev
Log:
[modules] Store mangling numbers in a deterministic order so they don't cause 
the resulting .pcm files to be nondeterministic.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=263996&r1=263995&r2=263996&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Mar 21 17:33:02 2016
@@ -36,6 +36,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Support/Allocator.h"
@@ -393,8 +394,8 @@ private:
 
   /// \brief Side-table of mangling numbers for declarations which rarely
   /// need them (like static local vars).
-  llvm::DenseMap MangleNumbers;
-  llvm::DenseMap StaticLocalNumbers;
+  llvm::MapVector MangleNumbers;
+  llvm::MapVector StaticLocalNumbers;
 
   /// \brief Mapping that stores parameterIndex values for ParmVarDecls when
   /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=263996&r1=263995&r2=263996&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Mar 21 17:33:02 2016
@@ -8684,8 +8684,7 @@ void ASTContext::setManglingNumber(const
 }
 
 unsigned ASTContext::getManglingNumber(const NamedDecl *ND) const {
-  llvm::DenseMap::const_iterator I =
-MangleNumbers.find(ND);
+  auto I = MangleNumbers.find(ND);
   return I != MangleNumbers.end() ? I->second : 1;
 }
 
@@ -8695,8 +8694,7 @@ void ASTContext::setStaticLocalNumber(co
 }
 
 unsigned ASTContext::getStaticLocalNumber(const VarDecl *VD) const {
-  llvm::DenseMap::const_iterator I =
-  StaticLocalNumbers.find(VD);
+  auto I = StaticLocalNumbers.find(VD);
   return I != StaticLocalNumbers.end() ? I->second : 1;
 }
 


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


  1   2   >