[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-15 Thread Taewook Oh via Phabricator via cfe-commits
twoh added a comment.

@eric_niebler I just tried it on Windows machine, and it just succeeded with no 
warnings/fix-it. Is that expected?


https://reviews.llvm.org/D3



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a subscriber: mgorny.
Hahnfeld added a comment.

Yes, that's the current state. We had some discussion on cfe-dev on that 
matter: http://lists.llvm.org/pipermail/cfe-dev/2017-January/052512.html

Could you slightly adapt your patch so that other runtime libraries can follow 
this idea in the future?


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-15 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D30015#678243, @Hahnfeld wrote:

> Why is this only for OpenMP? I imagine this should be done for **all** 
> runtime libraries


The other runtime libraries have the arch included in the library's name and 
the driver links the correct file.  cbergstrom preferred to look in an 
arch-specific directory rather 
(http://lists.llvm.org/pipermail/openmp-dev/2017-February/001659.html).  It 
makes sense for OpenMP because other toolchains may assume the standard library 
name (libomp.so).


https://reviews.llvm.org/D30015



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


r295293 - Revert r295284: Add better ODR checking for modules.

2017-02-15 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Feb 16 01:09:18 2017
New Revision: 295293

URL: http://llvm.org/viewvc/llvm-project?rev=295293&view=rev
Log:
Revert r295284: Add better ODR checking for modules.

Fix modules build bot.

Removed:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=295293&r1=295292&r2=295293&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Feb 16 01:09:18 2017
@@ -458,9 +458,6 @@ class CXXRecordDecl : public RecordDecl
 /// \brief Whether we are currently parsing base specifiers.
 unsigned IsParsingBaseSpecifiers : 1;
 
-/// \brief A hash of parts of the class to help in ODR checking.
-unsigned ODRHash;
-
 /// \brief The number of base class specifiers in Bases.
 unsigned NumBases;
 
@@ -706,9 +703,6 @@ public:
 return data().IsParsingBaseSpecifiers;
   }
 
-  void computeODRHash();
-  unsigned getODRHash() const { return data().ODRHash; }
-
   /// \brief Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
 

Removed: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=295292&view=auto
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h (removed)
@@ -1,82 +0,0 @@
-//===-- ODRHash.h - Hashing to diagnose ODR failures *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-/// \file
-/// This file contains the declaration of the ODRHash class, which calculates
-/// a hash based on AST nodes, which is stable across different runs.
-///
-//===--===//
-
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/TemplateBase.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/SmallVector.h"
-
-namespace clang {
-
-class Decl;
-class IdentifierInfo;
-class NestedNameSpecifer;
-class Stmt;
-class TemplateParameterList;
-
-// ODRHash is used to calculate a hash based on AST node contents that
-// does not rely on pointer addresses.  This allows the hash to not vary
-// between runs and is usable to detect ODR problems in modules.  To use,
-// construct an ODRHash object, then call Add* methods over the nodes that
-// need to be hashed.  Then call CalculateHash to get the hash value.
-// Typically, only one Add* call is needed.  clear can be called to reuse the
-// object.
-class ODRHash {
-  // Use DenseMaps to convert between Decl and Type pointers and an index 
value.
-  llvm::DenseMap DeclMap;
-  llvm::DenseMap TypeMap;
-
-  // Save space by processing bools at the end.
-  llvm::SmallVector Bools;
-
-  llvm::FoldingSetNodeID ID;
-
-public:
-  ODRHash() {}
-
-  // Use this for ODR checking classes between modules.  This method compares
-  // more information than the AddDecl class.
-  void AddCXXRecordDecl(const CXXRecordDecl *Record);
-
-  // Process SubDecls of the main Decl.  This method calls the DeclVisitor
-  // while AddDecl does not.
-  void AddSubDecl(const Decl *D);
-
-  // Reset the object for reuse.
-  void clear();
-
-  // Add booleans to ID and uses it to calculate the hash.
-  unsigned CalculateHash();
-
-  // Add AST nodes that need to be processed.
-  void AddDecl(const Decl *D);
-  void AddType(const Type *T);
-  void AddQualType(QualType T);
-  void AddStmt(const Stmt *S);
-  void AddIdentifierInfo(const IdentifierInfo *II);
-  void AddNestedNameSpecifier(const NestedNameSpecifier *NNS);
-  void AddTemplateName(TemplateName Name);
-  void AddDeclarationName(DeclarationName Name);
-  void AddTemplateArgument(TemplateArgument TA);
-  void AddTemplateParameterList(const TemplateParameterList *TPL);
-
-  // Save booleans until the end to lower the size of data to process.
-  void Add

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Why is this only for OpenMP? I imagine this should be done for **all** runtime 
libraries


https://reviews.llvm.org/D30015



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


[PATCH] D30025: [compiler-rt] [builtins] Fix building atomic.c with GCC

2017-02-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Make the use of #pragma redefine_extname and appropriate renames of
builtins conditional to using clang. GCC used not to support it outside
Solaris and currently seems to be very restrictive on applying it.
In other words, it does not work for me with GCC 5.4.0 and the built
libraries use the 'internal' names.

On the other hand, GCC does not have any restrictions on redefining
builtins. So instead of trying to figure out how to make the #pragma
work, it is simpler to make the rename conditional to clang.


Repository:
  rL LLVM

https://reviews.llvm.org/D30025

Files:
  lib/builtins/atomic.c


Index: lib/builtins/atomic.c
===
--- lib/builtins/atomic.c
+++ lib/builtins/atomic.c
@@ -30,12 +30,17 @@
 
 #include "assembly.h"
 
+#ifdef __clang__
 // Clang objects if you redefine a builtin.  This little hack allows us to
 // define a function with the same name as an intrinsic.
-#pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load)
-#pragma redefine_extname __atomic_store_c SYMBOL_NAME(__atomic_store)
-#pragma redefine_extname __atomic_exchange_c SYMBOL_NAME(__atomic_exchange)
-#pragma redefine_extname __atomic_compare_exchange_c 
SYMBOL_NAME(__atomic_compare_exchange)
+#define ATOMIC_IMPL_SYMBOL(x) x##_c
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_load) 
SYMBOL_NAME(__atomic_load)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_store) 
SYMBOL_NAME(__atomic_store)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_exchange) 
SYMBOL_NAME(__atomic_exchange)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange) 
SYMBOL_NAME(__atomic_compare_exchange)
+#else
+#define ATOMIC_IMPL_SYMBOL(x) SYMBOL_NAME(x)
+#endif
 
 /// Number of locks.  This allocates one page on 32-bit platforms, two on
 /// 64-bit.  This can be specified externally if a different trade between
@@ -159,7 +164,7 @@
 
 /// An atomic load operation.  This is atomic with respect to the source
 /// pointer only.
-void __atomic_load_c(int size, void *src, void *dest, int model) {
+void ATOMIC_IMPL_SYMBOL(__atomic_load)(int size, void *src, void *dest, int 
model) {
 #define LOCK_FREE_ACTION(type) \
 *((type*)dest) = __c11_atomic_load((_Atomic(type)*)src, model);\
 return;
@@ -173,7 +178,7 @@
 
 /// An atomic store operation.  This is atomic with respect to the destination
 /// pointer only.
-void __atomic_store_c(int size, void *dest, void *src, int model) {
+void ATOMIC_IMPL_SYMBOL(__atomic_store)(int size, void *dest, void *src, int 
model) {
 #define LOCK_FREE_ACTION(type) \
 __c11_atomic_store((_Atomic(type)*)dest, *(type*)dest, model);\
 return;
@@ -190,7 +195,7 @@
 /// they  are not, then this stores the current value from *ptr in *expected.
 ///
 /// This function returns 1 if the exchange takes place or 0 if it fails. 
-int __atomic_compare_exchange_c(int size, void *ptr, void *expected,
+int ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange)(int size, void *ptr, void 
*expected,
 void *desired, int success, int failure) {
 #define LOCK_FREE_ACTION(type) \
   return __c11_atomic_compare_exchange_strong((_Atomic(type)*)ptr, 
(type*)expected,\
@@ -211,7 +216,7 @@
 
 /// Performs an atomic exchange operation between two pointers.  This is atomic
 /// with respect to the target address.
-void __atomic_exchange_c(int size, void *ptr, void *val, void *old, int model) 
{
+void ATOMIC_IMPL_SYMBOL(__atomic_exchange)(int size, void *ptr, void *val, 
void *old, int model) {
 #define LOCK_FREE_ACTION(type) \
 *(type*)old = __c11_atomic_exchange((_Atomic(type)*)ptr, *(type*)val,\
 model);\


Index: lib/builtins/atomic.c
===
--- lib/builtins/atomic.c
+++ lib/builtins/atomic.c
@@ -30,12 +30,17 @@
 
 #include "assembly.h"
 
+#ifdef __clang__
 // Clang objects if you redefine a builtin.  This little hack allows us to
 // define a function with the same name as an intrinsic.
-#pragma redefine_extname __atomic_load_c SYMBOL_NAME(__atomic_load)
-#pragma redefine_extname __atomic_store_c SYMBOL_NAME(__atomic_store)
-#pragma redefine_extname __atomic_exchange_c SYMBOL_NAME(__atomic_exchange)
-#pragma redefine_extname __atomic_compare_exchange_c SYMBOL_NAME(__atomic_compare_exchange)
+#define ATOMIC_IMPL_SYMBOL(x) x##_c
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_load) SYMBOL_NAME(__atomic_load)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_store) SYMBOL_NAME(__atomic_store)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_exchange) SYMBOL_NAME(__atomic_exchange)
+#pragma redefine_extname ATOMIC_IMPL_SYMBOL(__atomic_compare_exchange) SYMBOL_NAME(__atomic_compare_exchange)
+#else
+#define ATOMIC_IMPL_SYMBOL(x) SYMBOL_NAME(x)
+#endif
 
 /// Number of locks.  This allocates one page on 32-bit platforms, two on
 /// 64-bit.  This can be specified externally if a different trade betw

r295291 - [AVX-512] Replace 512-bit masked packss/packus builtins and replace with new unmasked builtins.

2017-02-15 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Feb 16 00:32:07 2017
New Revision: 295291

URL: http://llvm.org/viewvc/llvm-project?rev=295291&view=rev
Log:
[AVX-512] Replace 512-bit masked packss/packus builtins and replace with new 
unmasked builtins.

These new unmasked builtins will enable us to easily support optimizing these 
builtins in InstCombine in the backend.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=295291&r1=295290&r2=295291&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Feb 16 00:32:07 2017
@@ -1068,10 +1068,10 @@ TARGET_BUILTIN(__builtin_ia32_ucmpw512_m
 
 TARGET_BUILTIN(__builtin_ia32_pabsb512_mask, "V64cV64cV64cULLi", "", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pabsw512_mask, "V32sV32sV32sUi", "", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_packssdw512_mask, "V32sV16iV16iV32sUi", "", 
"avx512bw")
-TARGET_BUILTIN(__builtin_ia32_packsswb512_mask, "V64cV32sV32sV64cULLi", "", 
"avx512bw")
-TARGET_BUILTIN(__builtin_ia32_packusdw512_mask, "V32sV16iV16iV32sUi", "", 
"avx512bw")
-TARGET_BUILTIN(__builtin_ia32_packuswb512_mask, "V64cV32sV32sV64cULLi", "", 
"avx512bw")
+TARGET_BUILTIN(__builtin_ia32_packssdw512, "V32sV16iV16i", "", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_packsswb512, "V64cV32sV32s", "", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_packusdw512, "V32sV16iV16i", "", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_packuswb512, "V64cV32sV32s", "", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddsb512_mask, "V64cV64cV64cV64cULLi", "", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddsw512_mask, "V32sV32sV32sV32sUi", "", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_paddusb512_mask, "V64cV64cV64cV64cULLi", "", 
"avx512bw")

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=295291&r1=295290&r2=295291&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Thu Feb 16 00:32:07 2017
@@ -504,115 +504,91 @@ _mm512_maskz_abs_epi16 (__mmask32 __U, _
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_packs_epi32 (__m512i __A, __m512i __B)
+_mm512_packs_epi32(__m512i __A, __m512i __B)
 {
-  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
-  (__v16si) __B,
-  (__v32hi) _mm512_setzero_hi(),
-  (__mmask32) -1);
+  return (__m512i)__builtin_ia32_packssdw512((__v16si)__A, (__v16si)__B);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_maskz_packs_epi32 (__mmask32 __M, __m512i __A, __m512i __B)
+_mm512_maskz_packs_epi32(__mmask32 __M, __m512i __A, __m512i __B)
 {
-  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
-  (__v16si) __B,
-  (__v32hi) _mm512_setzero_hi(),
-  __M);
+  return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M,
+   (__v32hi)_mm512_packs_epi32(__A, __B),
+   (__v32hi)_mm512_setzero_hi());
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_mask_packs_epi32 (__m512i __W, __mmask32 __M, __m512i __A,
-   __m512i __B)
+_mm512_mask_packs_epi32(__m512i __W, __mmask32 __M, __m512i __A, __m512i __B)
 {
-  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
-  (__v16si) __B,
-  (__v32hi) __W,
-  __M);
+  return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M,
+   (__v32hi)_mm512_packs_epi32(__A, __B),
+   (__v32hi)__W);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_packs_epi16 (__m512i __A, __m512i __B)
+_mm512_packs_epi16(__m512i __A, __m512i __B)
 {
-  return (__m512i) __builtin_ia32_packsswb512_mask ((__v32hi) __A,
-  (__v32hi) __B,
-  (__v64qi) _mm512_setzero_qi(),
-  (__mmask64) -1);
+  return (__m512i)__builtin_ia32_packsswb512((__v32hi)__A, (__v32hi) __B);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_mask_packs_epi16 (__m512i __W, __mmask64 __M, __m512i __A,
-   __m512i __B)
+_mm512_mask_packs_epi16(__m512i __W, __mmask64 __M, __m512i __A, __m512i __B)
 {
-  return (__m512i) __builtin_ia32_packsswb512_mask ((__v32hi) __A,
-  (__v32hi) __B,
-  (__v64qi) __W,
-  (__mmask64) __M);
+  return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M,
+(__v64qi)_mm512_packs_epi16(__A, __B),
+(__v64qi)__

Re: r295279 - [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.

2017-02-15 Thread Craig Topper via cfe-commits
The assert below is throwing a -Wsign-compare warning because std::distance
returns a signed type.

+  const size_t NumFields =
+  std::distance(ClosureClass->field_begin(),
ClosureClass->field_end());
+
+  assert(NumFields ==
+std::distance(E->capture_init_begin(), E->capture_init_end()) &&
+"The number of lambda capture initializers should equal the number of "
+"fields within the closure type");

~Craig

On Wed, Feb 15, 2017 at 8:12 PM, Faisal Vali via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: faisalv
> Date: Wed Feb 15 22:12:21 2017
> New Revision: 295279
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295279&view=rev
> Log:
> [cxx1z-constexpr-lambda] Implement captures - thus completing
> implementation of constexpr lambdas.
>
> Enable evaluation of captures within constexpr lambdas by using a strategy
> similar to that used in CodeGen:
>   - when starting evaluation of a lambda's call operator, create a map
> from VarDecl's to a closure's FieldDecls
>   - every time a VarDecl (or '*this) that represents a capture is
> encountered while evaluating the expression via the expression evaluator
> (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced by
> the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on this
> LValue representation then determines the right rvalue when needed).
>
> Thanks to Richard Smith and Hubert Tong for their review and feedback!
>
> https://reviews.llvm.org/D29748
>
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ExprConstant.cpp?rev=295279&r1=295278&r2=295279&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 15 22:12:21 2017
> @@ -425,6 +425,17 @@ namespace {
>  /// Index - The call index of this call.
>  unsigned Index;
>
> +// FIXME: Adding this to every 'CallStackFrame' may have a nontrivial
> impact
> +// on the overall stack usage of deeply-recursing constexpr
> evaluataions.
> +// (We should cache this map rather than recomputing it repeatedly.)
> +// But let's try this and see how it goes; we can look into caching
> the map
> +// as a later change.
> +
> +/// LambdaCaptureFields - Mapping from captured variables/this to
> +/// corresponding data members in the closure class.
> +llvm::DenseMap LambdaCaptureFields;
> +FieldDecl *LambdaThisCaptureField;
> +
>  CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
> const FunctionDecl *Callee, const LValue *This,
> APValue *Arguments);
> @@ -2279,6 +2290,10 @@ static bool HandleLValueComplexElement(E
>return true;
>  }
>
> +static bool handleLValueToRValueConversion(EvalInfo &Info, const Expr
> *Conv,
> +   QualType Type, const LValue
> &LVal,
> +   APValue &RVal);
> +
>  /// Try to evaluate the initializer for a variable declaration.
>  ///
>  /// \param Info   Information about the ongoing evaluation.
> @@ -2290,6 +2305,7 @@ static bool HandleLValueComplexElement(E
>  static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
>  const VarDecl *VD, CallStackFrame *Frame,
>  APValue *&Result) {
> +
>// If this is a parameter to an active constexpr function call, perform
>// argument substitution.
>if (const ParmVarDecl *PVD = dyn_cast(VD)) {
> @@ -4180,6 +4196,10 @@ static bool HandleFunctionCall(SourceLoc
>return false;
>  This->moveInto(Result);
>  return true;
> +  } else if (MD && isLambdaCallOperator(MD)) {
> +// We're in a lambda; determine the lambda capture field maps.
> +MD->getParent()->getCaptureFields(Frame.LambdaCaptureFields,
> +  Frame.LambdaThisCaptureField);
>}
>
>StmtResult Ret = {Result, ResultSlot};
> @@ -5041,6 +5061,33 @@ bool LValueExprEvaluator::VisitDeclRefEx
>
>
>  bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD)
> {
> +
> +  // If we are within a lambda's call operator, check whether the 'VD'
> referred
> +  // to within 'E' actually represents a lambda-capture that maps to a
> +  // data-member/field within the closure object, and if so, evaluate to
> the
> +  // field or what the field refers to.
> +  if (Info.CurrentCall && isLambdaCallOperator(Info.CurrentCall->Callee))
> {
> +if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
> +  if (Info.checkingPotentialConstantExpression())
> +return false;
> +  // Start with 'Result' referring to the complete closure object...
> +  Result = *Info.CurrentCall->This;
> +  // ... then update i

r295286 - Loosen a Type check ODR checking to try to fix the build bot.

2017-02-15 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Feb 15 23:48:25 2017
New Revision: 295286

URL: http://llvm.org/viewvc/llvm-project?rev=295286&view=rev
Log:
Loosen a Type check ODR checking to try to fix the build bot.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=295286&r1=295285&r2=295286&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Feb 15 23:48:25 2017
@@ -9396,7 +9396,8 @@ void ASTReader::diagnoseOdrViolations()
 break;
   }
 
-  if (FirstParam->getType() != SecondParam->getType()) {
+  if (!Context.hasSameType(FirstParam->getType(),
+   SecondParam->getType())) {
 ODRDiagError(FirstParam->getLocation(),
  FirstParam->getSourceRange(), MethodParamType)
 << SecondMD << i + 1 << FirstParam->getType();
@@ -9460,7 +9461,8 @@ void ASTReader::diagnoseOdrViolations()
 }
 
 // This case is handled elsewhere.
-if (FirstField->getType() != SecondField->getType()) {
+if (!Context.hasSameType(FirstField->getType(),
+ SecondField->getType())) {
   break;
 }
 


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


[libunwind] r295285 - [libunwind][CMake] Use libc++ headers when available

2017-02-15 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Feb 15 23:18:08 2017
New Revision: 295285

URL: http://llvm.org/viewvc/llvm-project?rev=295285&view=rev
Log:
[libunwind][CMake] Use libc++ headers when available

libunwind depends on C++ library headers. When building libunwind
as part of LLVM and libc++ is available, use its headers.

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

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=295285&r1=295284&r2=295285&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Feb 15 23:18:08 2017
@@ -282,4 +282,24 @@ endif()
 
 include_directories(include)
 
+find_path(
+  LIBUNWIND_LIBCXX_INCLUDES_INTERNAL
+  __libcpp_version
+  PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
+${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
+  NO_DEFAULT_PATH
+)
+if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
+IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
+  set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
+endif()
+
+set(LIBUNWIND_CXX_INCLUDE_PATHS "${LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT}" CACHE 
PATH
+"Paths to C++ header directories separated by ';'.")
+
+if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STREQUAL "")
+  list(APPEND LIBUNWIND_CXX_FLAGS -nostdinc++)
+  include_directories("${LIBUNWIND_CXX_INCLUDE_PATHS}")
+endif()
+
 add_subdirectory(src)


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


r295284 - Add better ODR checking for modules.

2017-02-15 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Feb 15 22:53:40 2017
New Revision: 295284

URL: http://llvm.org/viewvc/llvm-project?rev=295284&view=rev
Log:
Add better ODR checking for modules.

Recommit r293585 that was reverted in r293611 with new fixes.  The previous
issue was determined to be an overly aggressive AST visitor from forward
declared objects.  The visitor will now only deeply visit certain Decl's and
only do a shallow information extraction from all other Decl's.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

Added:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=295284&r1=295283&r2=295284&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Feb 15 22:53:40 2017
@@ -458,6 +458,9 @@ class CXXRecordDecl : public RecordDecl
 /// \brief Whether we are currently parsing base specifiers.
 unsigned IsParsingBaseSpecifiers : 1;
 
+/// \brief A hash of parts of the class to help in ODR checking.
+unsigned ODRHash;
+
 /// \brief The number of base class specifiers in Bases.
 unsigned NumBases;
 
@@ -703,6 +706,9 @@ public:
 return data().IsParsingBaseSpecifiers;
   }
 
+  void computeODRHash();
+  unsigned getODRHash() const { return data().ODRHash; }
+
   /// \brief Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
 

Added: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=295284&view=auto
==
--- cfe/trunk/include/clang/AST/ODRHash.h (added)
+++ cfe/trunk/include/clang/AST/ODRHash.h Wed Feb 15 22:53:40 2017
@@ -0,0 +1,82 @@
+//===-- ODRHash.h - Hashing to diagnose ODR failures *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the declaration of the ODRHash class, which calculates
+/// a hash based on AST nodes, which is stable across different runs.
+///
+//===--===//
+
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TemplateBase.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class IdentifierInfo;
+class NestedNameSpecifer;
+class Stmt;
+class TemplateParameterList;
+
+// ODRHash is used to calculate a hash based on AST node contents that
+// does not rely on pointer addresse

r295281 - Revert r295277 to fix buildbot.

2017-02-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 15 22:22:56 2017
New Revision: 295281

URL: http://llvm.org/viewvc/llvm-project?rev=295281&view=rev
Log:
Revert r295277 to fix buildbot.

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp
cfe/trunk/test/SemaTemplate/partial-order.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=295281&r1=295280&r2=295281&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Feb 15 22:22:56 2017
@@ -551,15 +551,13 @@ public:
   OverloadsShown getShowOverloads() const { return ShowOverloads; }
   
   /// \brief Pretend that the last diagnostic issued was ignored, so any
-  /// subsequent notes will be suppressed, or restore a prior ignoring
-  /// state after ignoring some diagnostics and their notes, possibly in
-  /// the middle of another diagnostic.
+  /// subsequent notes will be suppressed.
   ///
   /// This can be used by clients who suppress diagnostics themselves.
-  void setLastDiagnosticIgnored(bool Ignored = true) {
+  void setLastDiagnosticIgnored() {
 if (LastDiagLevel == DiagnosticIDs::Fatal)
   FatalErrorOccurred = true;
-LastDiagLevel = Ignored ? DiagnosticIDs::Ignored : DiagnosticIDs::Warning;
+LastDiagLevel = DiagnosticIDs::Ignored;
   }
 
   /// \brief Determine whether the previous diagnostic was ignored. This can

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=295281&r1=295280&r2=295281&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Feb 15 22:22:56 2017
@@ -7210,16 +7210,13 @@ public:
 unsigned PrevSFINAEErrors;
 bool PrevInNonInstantiationSFINAEContext;
 bool PrevAccessCheckingSFINAE;
-bool PrevLastDiagnosticIgnored;
 
   public:
 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
   : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
 PrevInNonInstantiationSFINAEContext(
   SemaRef.InNonInstantiationSFINAEContext),
-PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
-PrevLastDiagnosticIgnored(
-SemaRef.getDiagnostics().isLastDiagnosticIgnored())
+PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE)
 {
   if (!SemaRef.isSFINAEContext())
 SemaRef.InNonInstantiationSFINAEContext = true;
@@ -7231,8 +7228,6 @@ public:
   SemaRef.InNonInstantiationSFINAEContext
 = PrevInNonInstantiationSFINAEContext;
   SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
-  SemaRef.getDiagnostics().setLastDiagnosticIgnored(
-  PrevLastDiagnosticIgnored);
 }
 
 /// \brief Determine whether any SFINAE errors have been trapped.

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=295281&r1=295280&r2=295281&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Feb 15 22:22:56 2017
@@ -2242,7 +2242,7 @@ static Sema::TemplateDeductionResult Con
 SmallVectorImpl &Deduced,
 TemplateDeductionInfo &Info, SmallVectorImpl &Builder,
 LocalInstantiationScope *CurrentInstantiationScope = nullptr,
-unsigned NumAlreadyConverted = 0, bool SkipNonDeduced = false) {
+unsigned NumAlreadyConverted = 0, bool PartialOverloading = false) {
   TemplateParameterList *TemplateParams = Template->getTemplateParameters();
 
   for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) {
@@ -2330,14 +2330,11 @@ static Sema::TemplateDeductionResult Con
 
 // If there was no default argument, deduction is incomplete.
 if (DefArg.getArgument().isNull()) {
-  if (SkipNonDeduced) {
-Builder.push_back(TemplateArgument());
-continue;
-  }
-
   Info.Param = makeTemplateParameter(
   const_cast(TemplateParams->getParam(I)));
   Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder));
+  if (PartialOverloading) break;
+
   return HasDefaultArg ? Sema::TDK_SubstitutionFailure
: Sema::TDK_Incomplete;
 }
@@ -3298,9 +3295,9 @@ static bool AdjustFunctionParmAndArgType
   return false;
 }
 
-static bool hasDeducibleTemplateParameters(Se

Re: r295279 - [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.

2017-02-15 Thread Richard Smith via cfe-commits
On 15 February 2017 at 20:12, Faisal Vali via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: faisalv
> Date: Wed Feb 15 22:12:21 2017
> New Revision: 295279
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295279&view=rev
> Log:
> [cxx1z-constexpr-lambda] Implement captures - thus completing
> implementation of constexpr lambdas.
>
> Enable evaluation of captures within constexpr lambdas by using a strategy
> similar to that used in CodeGen:
>   - when starting evaluation of a lambda's call operator, create a map
> from VarDecl's to a closure's FieldDecls
>   - every time a VarDecl (or '*this) that represents a capture is
> encountered while evaluating the expression via the expression evaluator
> (specifically the LValueEvaluator) in ExprConstant.cpp - it is replaced by
> the corresponding FieldDecl LValue (an Lvalue-to-Rvalue conversion on this
> LValue representation then determines the right rvalue when needed).
>
> Thanks to Richard Smith and Hubert Tong for their review and feedback!
>

Awesome, thanks Faisal!

Want to bump our value for __cpp_constexpr to 201603 in C++1z mode to
advertise support for this?


> https://reviews.llvm.org/D29748
>
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCo
> nstant.cpp?rev=295279&r1=295278&r2=295279&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 15 22:12:21 2017
> @@ -425,6 +425,17 @@ namespace {
>  /// Index - The call index of this call.
>  unsigned Index;
>
> +// FIXME: Adding this to every 'CallStackFrame' may have a nontrivial
> impact
> +// on the overall stack usage of deeply-recursing constexpr
> evaluataions.
> +// (We should cache this map rather than recomputing it repeatedly.)
> +// But let's try this and see how it goes; we can look into caching
> the map
> +// as a later change.
> +
> +/// LambdaCaptureFields - Mapping from captured variables/this to
> +/// corresponding data members in the closure class.
> +llvm::DenseMap LambdaCaptureFields;
> +FieldDecl *LambdaThisCaptureField;
> +
>  CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
> const FunctionDecl *Callee, const LValue *This,
> APValue *Arguments);
> @@ -2279,6 +2290,10 @@ static bool HandleLValueComplexElement(E
>return true;
>  }
>
> +static bool handleLValueToRValueConversion(EvalInfo &Info, const Expr
> *Conv,
> +   QualType Type, const LValue
> &LVal,
> +   APValue &RVal);
> +
>  /// Try to evaluate the initializer for a variable declaration.
>  ///
>  /// \param Info   Information about the ongoing evaluation.
> @@ -2290,6 +2305,7 @@ static bool HandleLValueComplexElement(E
>  static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
>  const VarDecl *VD, CallStackFrame *Frame,
>  APValue *&Result) {
> +
>// If this is a parameter to an active constexpr function call, perform
>// argument substitution.
>if (const ParmVarDecl *PVD = dyn_cast(VD)) {
> @@ -4180,6 +4196,10 @@ static bool HandleFunctionCall(SourceLoc
>return false;
>  This->moveInto(Result);
>  return true;
> +  } else if (MD && isLambdaCallOperator(MD)) {
> +// We're in a lambda; determine the lambda capture field maps.
> +MD->getParent()->getCaptureFields(Frame.LambdaCaptureFields,
> +  Frame.LambdaThisCaptureField);
>}
>
>StmtResult Ret = {Result, ResultSlot};
> @@ -5041,6 +5061,33 @@ bool LValueExprEvaluator::VisitDeclRefEx
>
>
>  bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD)
> {
> +
> +  // If we are within a lambda's call operator, check whether the 'VD'
> referred
> +  // to within 'E' actually represents a lambda-capture that maps to a
> +  // data-member/field within the closure object, and if so, evaluate to
> the
> +  // field or what the field refers to.
> +  if (Info.CurrentCall && isLambdaCallOperator(Info.CurrentCall->Callee))
> {
> +if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
> +  if (Info.checkingPotentialConstantExpression())
> +return false;
> +  // Start with 'Result' referring to the complete closure object...
> +  Result = *Info.CurrentCall->This;
> +  // ... then update it to refer to the field of the closure object
> +  // that represents the capture.
> +  if (!HandleLValueMember(Info, E, Result, FD))
> +return false;
> +  // And if the field is of reference type, update 'Result' to refer
> to what
> +  // the field refers to.
> +  if (FD->g

r295279 - [cxx1z-constexpr-lambda] Implement captures - thus completing implementation of constexpr lambdas.

2017-02-15 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Feb 15 22:12:21 2017
New Revision: 295279

URL: http://llvm.org/viewvc/llvm-project?rev=295279&view=rev
Log:
[cxx1z-constexpr-lambda] Implement captures - thus completing implementation of 
constexpr lambdas.

Enable evaluation of captures within constexpr lambdas by using a strategy 
similar to that used in CodeGen:
  - when starting evaluation of a lambda's call operator, create a map from 
VarDecl's to a closure's FieldDecls
  - every time a VarDecl (or '*this) that represents a capture is encountered 
while evaluating the expression via the expression evaluator (specifically the 
LValueEvaluator) in ExprConstant.cpp - it is replaced by the corresponding 
FieldDecl LValue (an Lvalue-to-Rvalue conversion on this LValue representation 
then determines the right rvalue when needed).

Thanks to Richard Smith and Hubert Tong for their review and feedback!

https://reviews.llvm.org/D29748


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=295279&r1=295278&r2=295279&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Feb 15 22:12:21 2017
@@ -425,6 +425,17 @@ namespace {
 /// Index - The call index of this call.
 unsigned Index;
 
+// FIXME: Adding this to every 'CallStackFrame' may have a nontrivial 
impact
+// on the overall stack usage of deeply-recursing constexpr evaluataions.
+// (We should cache this map rather than recomputing it repeatedly.)
+// But let's try this and see how it goes; we can look into caching the map
+// as a later change.
+
+/// LambdaCaptureFields - Mapping from captured variables/this to
+/// corresponding data members in the closure class.
+llvm::DenseMap LambdaCaptureFields;
+FieldDecl *LambdaThisCaptureField;
+
 CallStackFrame(EvalInfo &Info, SourceLocation CallLoc,
const FunctionDecl *Callee, const LValue *This,
APValue *Arguments);
@@ -2279,6 +2290,10 @@ static bool HandleLValueComplexElement(E
   return true;
 }
 
+static bool handleLValueToRValueConversion(EvalInfo &Info, const Expr *Conv,
+   QualType Type, const LValue &LVal,
+   APValue &RVal);
+
 /// Try to evaluate the initializer for a variable declaration.
 ///
 /// \param Info   Information about the ongoing evaluation.
@@ -2290,6 +2305,7 @@ static bool HandleLValueComplexElement(E
 static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
 const VarDecl *VD, CallStackFrame *Frame,
 APValue *&Result) {
+
   // If this is a parameter to an active constexpr function call, perform
   // argument substitution.
   if (const ParmVarDecl *PVD = dyn_cast(VD)) {
@@ -4180,6 +4196,10 @@ static bool HandleFunctionCall(SourceLoc
   return false;
 This->moveInto(Result);
 return true;
+  } else if (MD && isLambdaCallOperator(MD)) {
+// We're in a lambda; determine the lambda capture field maps.
+MD->getParent()->getCaptureFields(Frame.LambdaCaptureFields,
+  Frame.LambdaThisCaptureField);
   }
 
   StmtResult Ret = {Result, ResultSlot};
@@ -5041,6 +5061,33 @@ bool LValueExprEvaluator::VisitDeclRefEx
 
 
 bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
+
+  // If we are within a lambda's call operator, check whether the 'VD' referred
+  // to within 'E' actually represents a lambda-capture that maps to a
+  // data-member/field within the closure object, and if so, evaluate to the
+  // field or what the field refers to.
+  if (Info.CurrentCall && isLambdaCallOperator(Info.CurrentCall->Callee)) {
+if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
+  if (Info.checkingPotentialConstantExpression())
+return false;
+  // Start with 'Result' referring to the complete closure object...
+  Result = *Info.CurrentCall->This;
+  // ... then update it to refer to the field of the closure object
+  // that represents the capture.
+  if (!HandleLValueMember(Info, E, Result, FD))
+return false;
+  // And if the field is of reference type, update 'Result' to refer to 
what
+  // the field refers to.
+  if (FD->getType()->isReferenceType()) {
+APValue RVal;
+if (!handleLValueToRValueConversion(Info, E, FD->getType(), Result,
+RVal))
+  return false;
+Result.setFrom(Info.Ctx, RVal);
+  }
+  return true;
+}
+  }
   CallStackFrame *Frame = nullptr;
   if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1) {
 // Only if a local variable was d

r295277 - Add missing "deduced A == A" check for function template partial ordering.

2017-02-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 15 21:49:44 2017
New Revision: 295277

URL: http://llvm.org/viewvc/llvm-project?rev=295277&view=rev
Log:
Add missing "deduced A == A" check for function template partial ordering.

This appears to be the only template argument deduction context where we were
missing this check. Surprisingly, other implementations also appear to miss
the check in this case; it may turn out that important code is relying on
the widespread non-conformance here, in which case we'll need to reconsider.

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp
cfe/trunk/test/SemaTemplate/partial-order.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=295277&r1=295276&r2=295277&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Feb 15 21:49:44 2017
@@ -551,13 +551,15 @@ public:
   OverloadsShown getShowOverloads() const { return ShowOverloads; }
   
   /// \brief Pretend that the last diagnostic issued was ignored, so any
-  /// subsequent notes will be suppressed.
+  /// subsequent notes will be suppressed, or restore a prior ignoring
+  /// state after ignoring some diagnostics and their notes, possibly in
+  /// the middle of another diagnostic.
   ///
   /// This can be used by clients who suppress diagnostics themselves.
-  void setLastDiagnosticIgnored() {
+  void setLastDiagnosticIgnored(bool Ignored = true) {
 if (LastDiagLevel == DiagnosticIDs::Fatal)
   FatalErrorOccurred = true;
-LastDiagLevel = DiagnosticIDs::Ignored;
+LastDiagLevel = Ignored ? DiagnosticIDs::Ignored : DiagnosticIDs::Warning;
   }
 
   /// \brief Determine whether the previous diagnostic was ignored. This can

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=295277&r1=295276&r2=295277&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Feb 15 21:49:44 2017
@@ -7210,13 +7210,16 @@ public:
 unsigned PrevSFINAEErrors;
 bool PrevInNonInstantiationSFINAEContext;
 bool PrevAccessCheckingSFINAE;
+bool PrevLastDiagnosticIgnored;
 
   public:
 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
   : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
 PrevInNonInstantiationSFINAEContext(
   SemaRef.InNonInstantiationSFINAEContext),
-PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE)
+PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE),
+PrevLastDiagnosticIgnored(
+SemaRef.getDiagnostics().isLastDiagnosticIgnored())
 {
   if (!SemaRef.isSFINAEContext())
 SemaRef.InNonInstantiationSFINAEContext = true;
@@ -7228,6 +7231,8 @@ public:
   SemaRef.InNonInstantiationSFINAEContext
 = PrevInNonInstantiationSFINAEContext;
   SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
+  SemaRef.getDiagnostics().setLastDiagnosticIgnored(
+  PrevLastDiagnosticIgnored);
 }
 
 /// \brief Determine whether any SFINAE errors have been trapped.

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=295277&r1=295276&r2=295277&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Feb 15 21:49:44 2017
@@ -2242,7 +2242,7 @@ static Sema::TemplateDeductionResult Con
 SmallVectorImpl &Deduced,
 TemplateDeductionInfo &Info, SmallVectorImpl &Builder,
 LocalInstantiationScope *CurrentInstantiationScope = nullptr,
-unsigned NumAlreadyConverted = 0, bool PartialOverloading = false) {
+unsigned NumAlreadyConverted = 0, bool SkipNonDeduced = false) {
   TemplateParameterList *TemplateParams = Template->getTemplateParameters();
 
   for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) {
@@ -2330,11 +2330,14 @@ static Sema::TemplateDeductionResult Con
 
 // If there was no default argument, deduction is incomplete.
 if (DefArg.getArgument().isNull()) {
+  if (SkipNonDeduced) {
+Builder.push_back(TemplateArgument());
+continue;
+  }
+
   Info.Param = makeTemplateParameter(
   const_cast(TemplateParams->getParam(I)));
   Info.re

[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-15 Thread David Herzka via Phabricator via cfe-commits
herzka updated this revision to Diff 88652.
herzka added a comment.

Rename selectors


https://reviews.llvm.org/D29967

Files:
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjC/objc-class-property.m


Index: test/SemaObjC/objc-class-property.m
===
--- test/SemaObjC/objc-class-property.m
+++ test/SemaObjC/objc-class-property.m
@@ -21,22 +21,31 @@
 @property (class) int c2; // expected-note {{property declared here}} \
   // expected-note {{property declared here}}
 @property (class) int x;
+@property (class, setter=customSet:) int customSetterProperty;
+@property (class, getter=customGet) int customGetterProperty;
 @end
 
 @implementation A // expected-warning {{class property 'c2' requires method 
'c2' to be defined}} \
   // expected-warning {{class property 'c2' requires method 
'setC2:' to be defined}}
 @dynamic x; // refers to the instance property
 @dynamic (class) x; // refers to the class property
 @synthesize z, c2; // expected-error {{@synthesize not allowed on a class 
property 'c2'}}
 @dynamic c; // refers to the class property
+@dynamic customSetterProperty;
+@dynamic customGetterProperty;
 @end
 
 int test() {
   A *a = [[A alloc] init];
   a.c; // expected-error {{property 'c' is a class property; did you mean to 
access it with class 'A'}}
   return a.x + A.c;
 }
 
+void customSelectors() {
+  A.customSetterProperty = 1;
+  (void)A.customGetterProperty;
+}
+
 void message_id(id me) {
   [me y];
 }
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1984,13 +1984,26 @@
 }
   }
 
+  Selector GetterSel;
+  Selector SetterSel;
+  if (auto PD = IFace->FindPropertyDeclaration(
+  &propertyName, ObjCPropertyQueryKind::OBJC_PR_query_class)) {
+GetterSel = PD->getGetterName();
+SetterSel = PD->getSetterName();
+  } else {
+GetterSel = PP.getSelectorTable().getNullarySelector(&propertyName);
+SetterSel =
+  SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
+ PP.getSelectorTable(),
+ &propertyName);
+  }
+
   // Search for a declared property first.
-  Selector Sel = PP.getSelectorTable().getNullarySelector(&propertyName);
-  ObjCMethodDecl *Getter = IFace->lookupClassMethod(Sel);
+  ObjCMethodDecl *Getter = IFace->lookupClassMethod(GetterSel);
 
   // If this reference is in an @implementation, check for 'private' methods.
   if (!Getter)
-Getter = IFace->lookupPrivateClassMethod(Sel);
+Getter = IFace->lookupPrivateClassMethod(GetterSel);
 
   if (Getter) {
 // FIXME: refactor/share with ActOnMemberReference().
@@ -2000,11 +2013,6 @@
   }
 
   // Look for the matching setter, in case it is needed.
-  Selector SetterSel =
-SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
-PP.getSelectorTable(),
-   &propertyName);
-
   ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
   if (!Setter) {
 // If this reference is in an @implementation, also check for 'private'


Index: test/SemaObjC/objc-class-property.m
===
--- test/SemaObjC/objc-class-property.m
+++ test/SemaObjC/objc-class-property.m
@@ -21,22 +21,31 @@
 @property (class) int c2; // expected-note {{property declared here}} \
   // expected-note {{property declared here}}
 @property (class) int x;
+@property (class, setter=customSet:) int customSetterProperty;
+@property (class, getter=customGet) int customGetterProperty;
 @end
 
 @implementation A // expected-warning {{class property 'c2' requires method 'c2' to be defined}} \
   // expected-warning {{class property 'c2' requires method 'setC2:' to be defined}}
 @dynamic x; // refers to the instance property
 @dynamic (class) x; // refers to the class property
 @synthesize z, c2; // expected-error {{@synthesize not allowed on a class property 'c2'}}
 @dynamic c; // refers to the class property
+@dynamic customSetterProperty;
+@dynamic customGetterProperty;
 @end
 
 int test() {
   A *a = [[A alloc] init];
   a.c; // expected-error {{property 'c' is a class property; did you mean to access it with class 'A'}}
   return a.x + A.c;
 }
 
+void customSelectors() {
+  A.customSetterProperty = 1;
+  (void)A.customGetterProperty;
+}
+
 void message_id(id me) {
   [me y];
 }
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1984,13 +1984,26 @@
 }
   }
 
+  Selector GetterSel;
+  Selector SetterSel;
+  if (auto PD = IFace->FindPropertyDeclaration(
+  &propertyName, ObjCPropertyQueryKind::OBJC_PR_query_class)) {
+G

[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-15 Thread David Herzka via Phabricator via cfe-commits
herzka updated this revision to Diff 88650.
herzka added a comment.

Added test, used auto


https://reviews.llvm.org/D29967

Files:
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjC/objc-class-property.m


Index: test/SemaObjC/objc-class-property.m
===
--- test/SemaObjC/objc-class-property.m
+++ test/SemaObjC/objc-class-property.m
@@ -21,22 +21,31 @@
 @property (class) int c2; // expected-note {{property declared here}} \
   // expected-note {{property declared here}}
 @property (class) int x;
+@property (class, setter=customSetA:) int customSetterProperty;
+@property (class, getter=customGetB) int customGetterProperty;
 @end
 
 @implementation A // expected-warning {{class property 'c2' requires method 
'c2' to be defined}} \
   // expected-warning {{class property 'c2' requires method 
'setC2:' to be defined}}
 @dynamic x; // refers to the instance property
 @dynamic (class) x; // refers to the class property
 @synthesize z, c2; // expected-error {{@synthesize not allowed on a class 
property 'c2'}}
 @dynamic c; // refers to the class property
+@dynamic customSetterProperty;
+@dynamic customGetterProperty;
 @end
 
 int test() {
   A *a = [[A alloc] init];
   a.c; // expected-error {{property 'c' is a class property; did you mean to 
access it with class 'A'}}
   return a.x + A.c;
 }
 
+void customSelectors() {
+  A.customSetterProperty = 1;
+  (void)A.customGetterProperty;
+}
+
 void message_id(id me) {
   [me y];
 }
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1984,13 +1984,26 @@
 }
   }
 
+  Selector GetterSel;
+  Selector SetterSel;
+  if (auto PD = IFace->FindPropertyDeclaration(
+  &propertyName, ObjCPropertyQueryKind::OBJC_PR_query_class)) {
+GetterSel = PD->getGetterName();
+SetterSel = PD->getSetterName();
+  } else {
+GetterSel = PP.getSelectorTable().getNullarySelector(&propertyName);
+SetterSel =
+  SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
+ PP.getSelectorTable(),
+ &propertyName);
+  }
+
   // Search for a declared property first.
-  Selector Sel = PP.getSelectorTable().getNullarySelector(&propertyName);
-  ObjCMethodDecl *Getter = IFace->lookupClassMethod(Sel);
+  ObjCMethodDecl *Getter = IFace->lookupClassMethod(GetterSel);
 
   // If this reference is in an @implementation, check for 'private' methods.
   if (!Getter)
-Getter = IFace->lookupPrivateClassMethod(Sel);
+Getter = IFace->lookupPrivateClassMethod(GetterSel);
 
   if (Getter) {
 // FIXME: refactor/share with ActOnMemberReference().
@@ -2000,11 +2013,6 @@
   }
 
   // Look for the matching setter, in case it is needed.
-  Selector SetterSel =
-SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
-PP.getSelectorTable(),
-   &propertyName);
-
   ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
   if (!Setter) {
 // If this reference is in an @implementation, also check for 'private'


Index: test/SemaObjC/objc-class-property.m
===
--- test/SemaObjC/objc-class-property.m
+++ test/SemaObjC/objc-class-property.m
@@ -21,22 +21,31 @@
 @property (class) int c2; // expected-note {{property declared here}} \
   // expected-note {{property declared here}}
 @property (class) int x;
+@property (class, setter=customSetA:) int customSetterProperty;
+@property (class, getter=customGetB) int customGetterProperty;
 @end
 
 @implementation A // expected-warning {{class property 'c2' requires method 'c2' to be defined}} \
   // expected-warning {{class property 'c2' requires method 'setC2:' to be defined}}
 @dynamic x; // refers to the instance property
 @dynamic (class) x; // refers to the class property
 @synthesize z, c2; // expected-error {{@synthesize not allowed on a class property 'c2'}}
 @dynamic c; // refers to the class property
+@dynamic customSetterProperty;
+@dynamic customGetterProperty;
 @end
 
 int test() {
   A *a = [[A alloc] init];
   a.c; // expected-error {{property 'c' is a class property; did you mean to access it with class 'A'}}
   return a.x + A.c;
 }
 
+void customSelectors() {
+  A.customSetterProperty = 1;
+  (void)A.customGetterProperty;
+}
+
 void message_id(id me) {
   [me y];
 }
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1984,13 +1984,26 @@
 }
   }
 
+  Selector GetterSel;
+  Selector SetterSel;
+  if (auto PD = IFace->FindPropertyDeclaration(
+  &propertyName, ObjCPropertyQueryKind::OBJC_PR_query_class))

[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-15 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D29778



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-15 Thread Stephen Hines via Phabricator via cfe-commits
srhines added inline comments.



Comment at: include/clang/Driver/ToolChain.h:304
+  // Returns /lib//.  When -fopenmp is specified,
+  // this directory is added to the linker search path if it exists
+  const std::string getOpenMPLibPath() const;

Add a period at the end of the sentence.


https://reviews.llvm.org/D30015



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


[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-02-15 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris created this revision.
Herald added a subscriber: mehdi_amini.

We define the `__xray_customeevent` builtin that gets translated to
IR calls to the correct intrinsic. The default implementation of this is
a no-op function. The codegen side of this follows the following logic:

- When `-fxray-instrument` is not provided in the driver, we elide all

calls to `__xray_customevent`.

- When `-fxray-instrument` is enabled and a function is marked as "never

instrumented", we elide all calls to `__xray_customevent` in that
function; if either marked as "always instrumented" or subject to
threshold-based instrumentation, we emit a call to the
`llvm.xray.customevent` intrinsic from LLVM for each
`__xray_customevent` occurrence in the function.

This change depends on https://reviews.llvm.org/D27503 (to land in LLVM first).


https://reviews.llvm.org/D30018

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/xrayintrin.h
  test/CodeGen/xray-customevent.cpp

Index: test/CodeGen/xray-customevent.cpp
===
--- /dev/null
+++ test/CodeGen/xray-customevent.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @_Z16alwaysInstrumentv
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "instrument";
+  __xray_customevent(kPhase, 10);
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i8 10)
+}
+
+// CHECK-LABEL: @_Z15neverInstrumentv
+[[clang::xray_never_instrument]] void neverInstrument() {
+  static constexpr char kPhase[] = "never";
+  __xray_customevent(kPhase, 5);
+  // CHECK-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i8 5)
+}
+
+// CHECK-LABEL: @_Z21conditionalInstrumenti
+[[clang::xray_always_instrument]] void conditionalInstrument(int v) {
+  static constexpr char kTrue[] = "true";
+  static constexpr char kUntrue[] = "untrue";
+  if (v % 2)
+__xray_customevent(kTrue, 4);
+  else
+__xray_customevent(kUntrue, 6);
+
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i8 4)
+  // CHECK: call void @llvm.xray.customevent(i8*{{.*}}, i8 6)
+}
Index: lib/Headers/xrayintrin.h
===
--- /dev/null
+++ lib/Headers/xrayintrin.h
@@ -0,0 +1,34 @@
+/*=== xrayintrin.h - XRay intrinsics ---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __XRAYINTRIN_H
+#define __XRAYINTRIN_H
+
+extern "C" {
+inline void __xray_customevent(const char*, size_t) {
+  // Does nothing by design. The intent is the compiler's back-end will handle
+  // this particular intrinsic as special, and code-gen this appropriately.
+}
+}
+
+#endif  // __XRAYINTRIN_H
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2741,6 +2741,38 @@
 return RValue::get(ConstantInt::get(ConvertType(E->getType()),
 Layout.size().getQuantity()));
   }
+  case Builtin::BI__xray_customevent: {
+if (!this->ShouldXRayInstrumentFunction())
+  return RValue::getIgnored();
+if (const auto *XRayAttr =
+this->CurFuncDecl->getAttr()) {
+  if (XRayAttr->neverXRayInstrument())
+return RValue::getIgnored();
+}
+Function *F = CGM.getIntrinsic(Intrinsic::xray_customevent);
+// FIXME: assert that the types of the arguments match the intrinsic's
+// specification.
+SmallVector Args;
+auto FTy = F->getFunctionType();
+auto Arg0 = E->getArg(0);
+auto Arg0Val = EmitScalarExpr(Arg0);
+auto Arg0Ty = Arg0->getType();
+auto PTy0 = FTy->getParamType(0);
+if (PTy0 != Arg0Val->get

Re: [PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-15 Thread Richard Smith via cfe-commits
On 15 February 2017 at 17:45, Hal Finkel via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> hfinkel added a comment.
>
> I don't understand why it only supports some attributes. Is there some
> handling that needs to take place (I don't see anything obvious in this
> patch)? If most attributes will "just work", I'd much rather opt-out the
> few exceptions (which we can then explicitly document), if any, than using
> this opt-in solution.


Only supporting attributes with a GNU spelling also seems a bit strange to
me.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28510: Reinstate CWG1607 restrictions on lambdas appearing inside certain constant-expressions

2017-02-15 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D28510#654821, @faisalv wrote:

> In https://reviews.llvm.org/D28510#653794, @rsmith wrote:
>
> > I don't think it's possible to check this in the way you're doing so here. 
> > In general, there's no way to know whether a constant expression will be 
> > part of a `typedef` declaration or function declaration until you've 
> > finished parsing it (when you're parsing the decl-specifiers in a 
> > declaration you don't know whether you're declaring a function or a 
> > variable, and the `typedef` keyword might appear later).
>
>
> 
>   
>
> I see.  The issue is that the current approach would forbid valid variable 
> declarations such as:
>
> void (*f)(int [([]{return 5;}())]) = 0;
>
> ... where lambdas can appear within the array declarators (I believe that's 
> the only syntactic neighborhood that can cause this problem, right?).


I think so, at least until Louis removes the restriction on lambdas in 
unevaluated operands. Then we have a whole host of new problems:

  decltype([]{}()) typedef x; // error, lambda in a typedef
  template decltype([]{}()) f(); // error, lambda in a function 
declaration
  template decltype([]{}()) x; // ok

If we want a forward-looking change which prepares us for that, we should be 
thinking about how to deal with deferring the check until we get to the end of 
the declaration and find out whether we declared a function or a typedef.

> Well lambda's can't appear in unevaluated operands yet, so your example would 
> be ill-formed?  If so, we don't have to worry about them showing up in 
> decl-specifiers?
>  The only Declarator where they could be well formed is within an array 
> declarator of a variable or a parameter of a function pointer variable (but 
> no where else, i.e typedefs and function declarations), right?

Right. But we should at least keep in mind the upcoming removal of the 
unevaluated operands restriction. Ideally, we would get some implementation 
experience with that now, so we can make sure that we standardize a reasonable 
set of rules.


https://reviews.llvm.org/D28510



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


r295267 - Add missing regexp quantifiers in a test.

2017-02-15 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Wed Feb 15 19:35:23 2017
New Revision: 295267

URL: http://llvm.org/viewvc/llvm-project?rev=295267&view=rev
Log:
Add missing regexp quantifiers in a test.

Modified:
cfe/trunk/test/CodeGen/sanitize-init-order.cpp

Modified: cfe/trunk/test/CodeGen/sanitize-init-order.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitize-init-order.cpp?rev=295267&r1=295266&r2=295267&view=diff
==
--- cfe/trunk/test/CodeGen/sanitize-init-order.cpp (original)
+++ cfe/trunk/test/CodeGen/sanitize-init-order.cpp Wed Feb 15 19:35:23 2017
@@ -36,13 +36,13 @@ const volatile PODWithCtor array[5][5];
 
 // Check that ASan init-order checking ignores structs with trivial default
 // constructor.
-// CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], 
![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]}
+// CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], 
![[GLOB_3:[0-9]+]], ![[GLOB_4:[0-9]+]]
 // CHECK: ![[GLOB_1]] = !{%struct.PODStruct* {{.*}}, i1 false, i1 false}
 // CHECK: ![[GLOB_2]] = !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false}
 // CHECK: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 true, i1 
false}
 // CHECK: ![[GLOB_4]] = !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 true, i1 false}
 
-// BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], 
![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]}
+// BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], 
![[GLOB_3:[0-9]+]], ![[GLOB_4:[0-9]+]]}
 // BLACKLIST: ![[GLOB_1]] = !{%struct.PODStruct* {{.*}}, i1 false, i1 false}
 // BLACKLIST: ![[GLOB_2]] = !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false}
 // BLACKLIST: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 false, i1 
false}


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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-15 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

I don't understand why it only supports some attributes. Is there some handling 
that needs to take place (I don't see anything obvious in this patch)? If most 
attributes will "just work", I'd much rather opt-out the few exceptions (which 
we can then explicitly document), if any, than using this opt-in solution.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-15 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.
This revision is now accepted and ready to land.

LGTM, but should probably get signoff from someone else as well.


https://reviews.llvm.org/D30015



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


Re: r295252 - [Modules] Consider enable_if attrs in isSameEntity.

2017-02-15 Thread Richard Smith via cfe-commits
On 15 February 2017 at 17:32, George Burgess IV  wrote:

> I remember that we wanted to pretend that pass_object_size isn't a part of
> the FunctionType during the review that added it, though.
>

I remember we wanted to not add extra fake "parameters" to the FunctionType
to model pass_object_size. I don't remember whether or why we wanted it to
not be part of the function type at all -- on reflection, it seems as much
a part of the type as, say, a calling convention (which it is, in some
sense).


> Do you think that would be better than serializing parameters before we
> serialize template info? AFAICT, we only do merging after we start reading
> the template info, so I can't immediately see why that wouldn't work.
>

I would be concerned about the possibility of that introducing dependency
cycles into the deserialization process. For instance, merging default
arguments for function parameters may require us to have already merged the
function itself into its redeclaration chain (we don't currently model that
quite correctly, so we probably won't hit it today).


> On Wed, Feb 15, 2017 at 4:55 PM, Richard Smith 
> wrote:
>
>> On 15 February 2017 at 14:43, George Burgess IV via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: gbiv
>>> Date: Wed Feb 15 16:43:27 2017
>>> New Revision: 295252
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=295252&view=rev
>>> Log:
>>> [Modules] Consider enable_if attrs in isSameEntity.
>>>
>>> Two functions that differ only in their enable_if attributes are
>>> considered overloads, so we should check for those when we're trying to
>>> figure out if two functions are mergeable.
>>>
>>> We need to do the same thing for pass_object_size, as well. Looks like
>>> that'll be a bit less trivial, since we sometimes do these merging
>>> checks before we have pass_object_size attributes available (see the
>>> merge checks in ASTDeclReader::VisitFunctionDecl that happen before we
>>> read parameters, and merge checks in calls to ReadDeclAs<>()).
>>>
>>
>> Perhaps the best way to tackle this would be to track the presence of
>> pass_object_size as part of the function type (in the ExtParameterInfo data
>> on the function type).
>>
>> Added:
>>> cfe/trunk/test/Modules/Inputs/overloadable-attrs/
>>> cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
>>> cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap
>>> cfe/trunk/test/Modules/overloadable-attrs.cpp
>>> Modified:
>>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>>
>>> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serializat
>>> ion/ASTReaderDecl.cpp?rev=295252&r1=295251&r2=295252&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
>>> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 15 16:43:27
>>> 2017
>>> @@ -2656,6 +2656,44 @@ static bool isSameTemplateParameterList(
>>>return true;
>>>  }
>>>
>>> +/// Determine whether the attributes we can overload on are identical
>>> for A and
>>> +/// B. Expects A and B to (otherwise) have the same type.
>>> +static bool hasSameOverloadableAttrs(const FunctionDecl *A,
>>> + const FunctionDecl *B) {
>>> +  SmallVector AEnableIfs;
>>> +  // Since this is an equality check, we can ignore that enable_if
>>> attrs show up
>>> +  // in reverse order.
>>> +  for (const auto *EIA : A->specific_attrs())
>>> +AEnableIfs.push_back(EIA);
>>> +
>>> +  SmallVector BEnableIfs;
>>> +  for (const auto *EIA : B->specific_attrs())
>>> +BEnableIfs.push_back(EIA);
>>> +
>>> +  // Two very common cases: either we have 0 enable_if attrs, or we
>>> have an
>>> +  // unequal number of enable_if attrs.
>>> +  if (AEnableIfs.empty() && BEnableIfs.empty())
>>> +return true;
>>> +
>>> +  if (AEnableIfs.size() != BEnableIfs.size())
>>> +return false;
>>> +
>>> +  llvm::FoldingSetNodeID Cand1ID, Cand2ID;
>>> +  for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) {
>>> +Cand1ID.clear();
>>> +Cand2ID.clear();
>>> +
>>> +AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(),
>>> true);
>>> +BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(),
>>> true);
>>> +if (Cand1ID != Cand2ID)
>>> +  return false;
>>> +  }
>>> +
>>> +  // FIXME: This doesn't currently consider pass_object_size
>>> attributes, since
>>> +  // we aren't guaranteed that A and B have valid parameter lists yet.
>>> +  return true;
>>> +}
>>> +
>>>  /// \brief Determine whether the two declarations refer to the same
>>> entity.
>>>  static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
>>>assert(X->getDeclName() == Y->getDeclName() && "Declaration name
>>> mismatch!");
>>> @@ -2711,8 +2749,10 @@ static bool isSameEntity(NamedDecl *X, N
>>>  CtorY->getInheritedConstructo
>>> r().getCons

Re: r295252 - [Modules] Consider enable_if attrs in isSameEntity.

2017-02-15 Thread George Burgess IV via cfe-commits
I remember that we wanted to pretend that pass_object_size isn't a part of
the FunctionType during the review that added it, though. Do you think that
would be better than serializing parameters before we serialize template
info? AFAICT, we only do merging after we start reading the template info,
so I can't immediately see why that wouldn't work.

On Wed, Feb 15, 2017 at 4:55 PM, Richard Smith 
wrote:

> On 15 February 2017 at 14:43, George Burgess IV via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: gbiv
>> Date: Wed Feb 15 16:43:27 2017
>> New Revision: 295252
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295252&view=rev
>> Log:
>> [Modules] Consider enable_if attrs in isSameEntity.
>>
>> Two functions that differ only in their enable_if attributes are
>> considered overloads, so we should check for those when we're trying to
>> figure out if two functions are mergeable.
>>
>> We need to do the same thing for pass_object_size, as well. Looks like
>> that'll be a bit less trivial, since we sometimes do these merging
>> checks before we have pass_object_size attributes available (see the
>> merge checks in ASTDeclReader::VisitFunctionDecl that happen before we
>> read parameters, and merge checks in calls to ReadDeclAs<>()).
>>
>
> Perhaps the best way to tackle this would be to track the presence of
> pass_object_size as part of the function type (in the ExtParameterInfo data
> on the function type).
>
> Added:
>> cfe/trunk/test/Modules/Inputs/overloadable-attrs/
>> cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
>> cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap
>> cfe/trunk/test/Modules/overloadable-attrs.cpp
>> Modified:
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>
>> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serializat
>> ion/ASTReaderDecl.cpp?rev=295252&r1=295251&r2=295252&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 15 16:43:27
>> 2017
>> @@ -2656,6 +2656,44 @@ static bool isSameTemplateParameterList(
>>return true;
>>  }
>>
>> +/// Determine whether the attributes we can overload on are identical
>> for A and
>> +/// B. Expects A and B to (otherwise) have the same type.
>> +static bool hasSameOverloadableAttrs(const FunctionDecl *A,
>> + const FunctionDecl *B) {
>> +  SmallVector AEnableIfs;
>> +  // Since this is an equality check, we can ignore that enable_if attrs
>> show up
>> +  // in reverse order.
>> +  for (const auto *EIA : A->specific_attrs())
>> +AEnableIfs.push_back(EIA);
>> +
>> +  SmallVector BEnableIfs;
>> +  for (const auto *EIA : B->specific_attrs())
>> +BEnableIfs.push_back(EIA);
>> +
>> +  // Two very common cases: either we have 0 enable_if attrs, or we have
>> an
>> +  // unequal number of enable_if attrs.
>> +  if (AEnableIfs.empty() && BEnableIfs.empty())
>> +return true;
>> +
>> +  if (AEnableIfs.size() != BEnableIfs.size())
>> +return false;
>> +
>> +  llvm::FoldingSetNodeID Cand1ID, Cand2ID;
>> +  for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) {
>> +Cand1ID.clear();
>> +Cand2ID.clear();
>> +
>> +AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(),
>> true);
>> +BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(),
>> true);
>> +if (Cand1ID != Cand2ID)
>> +  return false;
>> +  }
>> +
>> +  // FIXME: This doesn't currently consider pass_object_size attributes,
>> since
>> +  // we aren't guaranteed that A and B have valid parameter lists yet.
>> +  return true;
>> +}
>> +
>>  /// \brief Determine whether the two declarations refer to the same
>> entity.
>>  static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
>>assert(X->getDeclName() == Y->getDeclName() && "Declaration name
>> mismatch!");
>> @@ -2711,8 +2749,10 @@ static bool isSameEntity(NamedDecl *X, N
>>  CtorY->getInheritedConstructo
>> r().getConstructor()))
>>  return false;
>>  }
>> -return (FuncX->getLinkageInternal() == FuncY->getLinkageInternal())
>> &&
>> -  FuncX->getASTContext().hasSameType(FuncX->getType(),
>> FuncY->getType());
>> +return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
>> +   FuncX->getASTContext().hasSameType(FuncX->getType(),
>> +  FuncY->getType()) &&
>> +   hasSameOverloadableAttrs(FuncX, FuncY);
>>}
>>
>>// Variables with the same type and linkage match.
>>
>> Added: cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/I
>> nputs/overloadable-attrs/a.h?rev=295252&view=auto
>> 
>> ==
>> ---

[PATCH] D29723: [Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum

2017-02-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295266: [Sema] Add lvalue-to-rvalue cast in 
direct-list-initialization of enum (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29723?vs=87679&id=88632#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29723

Files:
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp


Index: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
===
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
@@ -150,35 +150,44 @@
 
 void f(T);
 f(T{0});
+
+char c;
+auto t3 = T{c};
   }
 #if __cplusplus <= 201402L
-  // expected-error@-15 5{{cannot initialize}}
-  // expected-error@-15 5{{cannot initialize}}
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  //
   //
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
   //
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  //
+  // expected-error@-18 5{{cannot initialize}}
 #else
-  // expected-error@-29 {{cannot initialize}}
-  // expected-error@-29 {{cannot initialize}}
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  //
   //
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
   //
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  //
+  // expected-error@-35 {{cannot initialize}}
 #endif
 
   template void bad() {
@@ -252,4 +261,12 @@
 (void)B{0.0}; // expected-error {{type 'double' cannot be narrowed}}
 #endif
   }
+
+#if __cplusplus > 201402L
+  enum class F : unsigned {};
+  F f1(unsigned x) { return F{x}; }
+  F f2(const unsigned x) { return F{x}; }
+  F f3(bool x) { return F{x}; }
+  F f4(const bool x) { return F{x}; }
+#endif
 }
Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -3981,6 +3981,8 @@
   ImplicitConversionSequence ICS;
   ICS.setStandard();
   ICS.Standard.setAsIdentityConversion();
+  if (!E->isRValue())
+ICS.Standard.First = ICK_Lvalue_To_Rvalue;
   // If E is of a floating-point type, then the conversion is ill-formed
   // due to narrowing, but go through the motions in order to produce the
   // right diagnostic.


Index: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
===
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
@@ -150,35 +150,44 @@
 
 void f(T);
 f(T{0});
+
+char c;
+auto t3 = T{c};
   }
 #if __cplusplus <= 201402L
-  // expected-error@-15 5{{cannot initialize}}
-  // expected-error@-15 5{{cannot initialize}}
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  //
   //
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
   //
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  //
+  // expected-error@-18 5{{cannot initialize}}
 #else
-  // expected-error@-29 {{cannot initialize}}
-  // expected-error@-29 {{cannot initialize}}
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  //
   //
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
   //
-  // 

r295266 - [Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum

2017-02-15 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Feb 15 19:20:00 2017
New Revision: 295266

URL: http://llvm.org/viewvc/llvm-project?rev=295266&view=rev
Log:
[Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum

After r264564, we allowed direct-list-initialization of an enum from an
integral value in C++1z mode, so long as that value can convert to the
enum's underlying type.

In this kind of initialization, we need a lvalue-to-rvalue conversion
for the initializer value if it is not a rvalue. This lets us accept the
following code:

  enum class A : unsigned {};
  A foo(unsigned x) { return A{x}; }

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

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=295266&r1=295265&r2=295266&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Feb 15 19:20:00 2017
@@ -3981,6 +3981,8 @@ static void TryListInitialization(Sema &
   ImplicitConversionSequence ICS;
   ICS.setStandard();
   ICS.Standard.setAsIdentityConversion();
+  if (!E->isRValue())
+ICS.Standard.First = ICK_Lvalue_To_Rvalue;
   // If E is of a floating-point type, then the conversion is ill-formed
   // due to narrowing, but go through the motions in order to produce the
   // right diagnostic.

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp?rev=295266&r1=295265&r2=295266&view=diff
==
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp Wed Feb 15 
19:20:00 2017
@@ -150,35 +150,44 @@ namespace cxx1z_direct_enum_init {
 
 void f(T);
 f(T{0});
+
+char c;
+auto t3 = T{c};
   }
 #if __cplusplus <= 201402L
-  // expected-error@-15 5{{cannot initialize}}
-  // expected-error@-15 5{{cannot initialize}}
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
+  //
   //
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
   //
+  // expected-error@-18 5{{cannot initialize}}
   //
-  // expected-error@-15 5{{cannot initialize}}
+  //
+  // expected-error@-18 5{{cannot initialize}}
 #else
-  // expected-error@-29 {{cannot initialize}}
-  // expected-error@-29 {{cannot initialize}}
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
+  //
   //
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
   //
+  // expected-error@-35 {{cannot initialize}}
   //
-  // expected-error@-29 {{cannot initialize}}
+  //
+  // expected-error@-35 {{cannot initialize}}
 #endif
 
   template void bad() {
@@ -252,4 +261,12 @@ namespace cxx1z_direct_enum_init {
 (void)B{0.0}; // expected-error {{type 'double' cannot be narrowed}}
 #endif
   }
+
+#if __cplusplus > 201402L
+  enum class F : unsigned {};
+  F f1(unsigned x) { return F{x}; }
+  F f2(const unsigned x) { return F{x}; }
+  F f3(bool x) { return F{x}; }
+  F f4(const bool x) { return F{x}; }
+#endif
 }


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


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-02-15 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D28404#675687, @chandlerc wrote:

> In https://reviews.llvm.org/D28404#675616, @mehdi_amini wrote:
>
> > We're still waiting for @rsmith to comment whether it'd be better to `have 
> > a LangOpts flag that basically means "pragma clang optimize off is always 
> > in effect."` and `Have Sema pretend the pragma is in effect at all times, 
> > at -O0`.
>
>
> FWIW, I have no real opinion about this side of it, I see it more as a detail 
> of how Clang wants to implement this kind of thing.


That was my suggestion as it seemed like this patch is essentially replicating 
the attribute-conflict detection logic that's in place for attributes specified 
in the source.  And we do like to say DRY.
But I won't insist; the patch can proceed as far as I'm concerned.


https://reviews.llvm.org/D28404



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


[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-15 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google marked an inline comment as done.
jgravelle-google added a comment.

Thanks, added a comment


https://reviews.llvm.org/D29778



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


Re: r295252 - [Modules] Consider enable_if attrs in isSameEntity.

2017-02-15 Thread Richard Smith via cfe-commits
On 15 February 2017 at 14:43, George Burgess IV via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Wed Feb 15 16:43:27 2017
> New Revision: 295252
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295252&view=rev
> Log:
> [Modules] Consider enable_if attrs in isSameEntity.
>
> Two functions that differ only in their enable_if attributes are
> considered overloads, so we should check for those when we're trying to
> figure out if two functions are mergeable.
>
> We need to do the same thing for pass_object_size, as well. Looks like
> that'll be a bit less trivial, since we sometimes do these merging
> checks before we have pass_object_size attributes available (see the
> merge checks in ASTDeclReader::VisitFunctionDecl that happen before we
> read parameters, and merge checks in calls to ReadDeclAs<>()).
>

Perhaps the best way to tackle this would be to track the presence of
pass_object_size as part of the function type (in the ExtParameterInfo data
on the function type).

Added:
> cfe/trunk/test/Modules/Inputs/overloadable-attrs/
> cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
> cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap
> cfe/trunk/test/Modules/overloadable-attrs.cpp
> Modified:
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>
> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Serialization/ASTReaderDecl.cpp?rev=295252&r1=295251&r2=295252&view=diff
> 
> ==
> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 15 16:43:27 2017
> @@ -2656,6 +2656,44 @@ static bool isSameTemplateParameterList(
>return true;
>  }
>
> +/// Determine whether the attributes we can overload on are identical for
> A and
> +/// B. Expects A and B to (otherwise) have the same type.
> +static bool hasSameOverloadableAttrs(const FunctionDecl *A,
> + const FunctionDecl *B) {
> +  SmallVector AEnableIfs;
> +  // Since this is an equality check, we can ignore that enable_if attrs
> show up
> +  // in reverse order.
> +  for (const auto *EIA : A->specific_attrs())
> +AEnableIfs.push_back(EIA);
> +
> +  SmallVector BEnableIfs;
> +  for (const auto *EIA : B->specific_attrs())
> +BEnableIfs.push_back(EIA);
> +
> +  // Two very common cases: either we have 0 enable_if attrs, or we have
> an
> +  // unequal number of enable_if attrs.
> +  if (AEnableIfs.empty() && BEnableIfs.empty())
> +return true;
> +
> +  if (AEnableIfs.size() != BEnableIfs.size())
> +return false;
> +
> +  llvm::FoldingSetNodeID Cand1ID, Cand2ID;
> +  for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) {
> +Cand1ID.clear();
> +Cand2ID.clear();
> +
> +AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(), true);
> +BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(), true);
> +if (Cand1ID != Cand2ID)
> +  return false;
> +  }
> +
> +  // FIXME: This doesn't currently consider pass_object_size attributes,
> since
> +  // we aren't guaranteed that A and B have valid parameter lists yet.
> +  return true;
> +}
> +
>  /// \brief Determine whether the two declarations refer to the same
> entity.
>  static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
>assert(X->getDeclName() == Y->getDeclName() && "Declaration name
> mismatch!");
> @@ -2711,8 +2749,10 @@ static bool isSameEntity(NamedDecl *X, N
>  CtorY->getInheritedConstructor().
> getConstructor()))
>  return false;
>  }
> -return (FuncX->getLinkageInternal() == FuncY->getLinkageInternal()) &&
> -  FuncX->getASTContext().hasSameType(FuncX->getType(),
> FuncY->getType());
> +return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
> +   FuncX->getASTContext().hasSameType(FuncX->getType(),
> +  FuncY->getType()) &&
> +   hasSameOverloadableAttrs(FuncX, FuncY);
>}
>
>// Variables with the same type and linkage match.
>
> Added: cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/overloadable-attrs/a.h?rev=295252&view=auto
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h (added)
> +++ cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h Wed Feb 15
> 16:43:27 2017
> @@ -0,0 +1,16 @@
> +namespace enable_if_attrs {
> +constexpr int fn1() __attribute__((enable_if(0, ""))) { return 0; }
> +constexpr int fn1() { return 1; }
> +
> +constexpr int fn2() { return 1; }
> +constexpr int fn2() __attribute__((enable_if(0, ""))) { return 0; }
> +
> +constexpr int fn3(int i) __attribute__((enable_if(!i, ""))) { return 0; }
> +constexpr int fn3(int i) __attribute_

[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-15 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google updated this revision to Diff 88629.
jgravelle-google added a comment.

- Add comment to lgamma builtins


https://reviews.llvm.org/D29778

Files:
  include/clang/Basic/Builtins.def
  test/CodeGen/libcall-declarations.c


Index: test/CodeGen/libcall-declarations.c
===
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHECK-ERRNO-SAME: nounwind{{.*}} }
 // CHECK-ERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1086,9 +1086,11 @@
 LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
 
-LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
-LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
+// POSIX math.h declares a global, signgam, that lgamma writes to, so these
+// shouldn't have "e" or "c" attributes
+LIBBUILTIN(lgamma, "dd", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
 
 LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
 LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)


Index: test/CodeGen/libcall-declarations.c
===
--- test/CodeGen/libcall-declarations.c
+++ test/CodeGen/libcall-declarations.c
@@ -402,9 +402,9 @@
 // CHECK-NOERRNO: declare i32 @ilogb(double) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbf(float) [[NUW]]
 // CHECK-NOERRNO: declare i32 @ilogbl(x86_fp80) [[NUW]]
-// CHECK-NOERRNO: declare double @lgamma(double) [[NUW]]
-// CHECK-NOERRNO: declare float @lgammaf(float) [[NUW]]
-// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NUW]]
+// CHECK-NOERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-NOERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-NOERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-NOERRNO: declare i64 @llrint(double) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintf(float) [[NUW]]
 // CHECK-NOERRNO: declare i64 @llrintl(x86_fp80) [[NUW]]
@@ -554,6 +554,9 @@
 // CHECK-ERRNO: declare double @fmin(double, double) [[NUW]]
 // CHECK-ERRNO: declare float @fminf(float, float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[NUW]]
+// CHECK-ERRNO: declare double @lgamma(double) [[NONCONST:#[0-9]+]]
+// CHECK-ERRNO: declare float @lgammaf(float) [[NONCONST]]
+// CHECK-ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NONCONST]]
 // CHECK-ERRNO: declare double @nearbyint(double) [[NUW]]
 // CHECK-ERRNO: declare float @nearbyintf(float) [[NUW]]
 // CHECK-ERRNO: declare x86_fp80 @nearbyintl(x86_fp80) [[NUW]]
@@ -612,5 +615,11 @@
 // CHECK-ERRNO: declare <2 x float> @ctanhf(<2 x float>) [[NUW]]
 
 // CHECK-NOERRNO: attributes [[NUW]] = { nounwind readnone{{.*}} }
+// CHECK-NOERRNO: attributes [[NONCONST]] = {
+// CHECK-NOERRNO-NOT: readnone
+// CHECK-NOERRNO-SAME: nounwind{{.*}} }
 
+// CHECK-ERRNO: attributes [[NONCONST]] = {
+// CHECK-ERRNO-NOT: readnone
+// CHE

r295264 - [c++1z] Diagnose non-deducible template parameters in deduction guide templates, per [temp.param]p11.

2017-02-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 15 18:36:47 2017
New Revision: 295264

URL: http://llvm.org/viewvc/llvm-project?rev=295264&view=rev
Log:
[c++1z] Diagnose non-deducible template parameters in deduction guide 
templates, per [temp.param]p11.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=295264&r1=295263&r2=295264&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Feb 15 18:36:47 
2017
@@ -2002,6 +2002,10 @@ def err_deduction_guide_explicit_mismatc
   "previous declaration was%select{ not|}0">;
 def err_deduction_guide_specialized : Error<"deduction guide cannot be "
   "%select{explicitly instantiated|explicitly specialized}0">;
+def err_deduction_guide_template_not_deducible : Error<
+"deduction guide template contains "
+"%select{a template parameter|template parameters}0 that cannot be "
+"deduced">;
 
 // C++1y deduced return types
 def err_auto_fn_deduction_failure : Error<
@@ -4146,7 +4150,7 @@ def ext_partial_specs_not_deducible : Ex
 "%select{a template parameter|template parameters}1 that cannot be "
 "deduced; this partial specialization will never be used">,
 DefaultError, InGroup>;
-def note_partial_spec_unused_parameter : Note<
+def note_non_deducible_parameter : Note<
 "non-deducible template parameter %0">;
 def err_partial_spec_ordering_ambiguous : Error<
 "ambiguous partial specializations of %0">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=295264&r1=295263&r2=295264&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Feb 15 18:36:47 2017
@@ -5624,6 +5624,7 @@ public:
   Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
   void CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
  StorageClass &SC);
+  void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD);
 
   void CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD);
   void CheckExplicitlyDefaultedMemberExceptionSpec(CXXMethodDecl *MD,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=295264&r1=295263&r2=295264&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 15 18:36:47 2017
@@ -9152,13 +9152,15 @@ bool Sema::CheckFunctionDeclaration(Scop
 } else if (CXXConversionDecl *Conversion
= dyn_cast(NewFD)) {
   ActOnConversionDeclarator(Conversion);
-} else if (NewFD->isDeductionGuide() &&
-   NewFD->getTemplateSpecializationKind() ==
-   TSK_ExplicitSpecialization) {
+} else if (NewFD->isDeductionGuide()) {
+  if (auto *TD = NewFD->getDescribedFunctionTemplate())
+CheckDeductionGuideTemplate(TD);
+
   // A deduction guide is not on the list of entities that can be
   // explicitly specialized.
-  Diag(NewFD->getLocStart(), diag::err_deduction_guide_specialized)
-<< /*explicit specialization*/ 1;
+  if (NewFD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+Diag(NewFD->getLocStart(), diag::err_deduction_guide_specialized)
+<< /*explicit specialization*/ 1;
 }
 
 // Find any virtual functions that this function overrides.

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=295264&r1=295263&r2=295264&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Feb 15 18:36:47 2017
@@ -3162,6 +3162,23 @@ static void checkMoreSpecializedThanPrim
   S.Diag(Template->getLocation(), diag::note_template_decl_here);
 }
 
+static void
+noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams,
+   const llvm::SmallBitVector &DeducibleParams) {
+  for (unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) {
+if (!DeducibleParams[I]) {
+  NamedDecl *Param = cast(TemplateParams->getParam(I));
+  if (Param->getDeclName())
+S.Diag(Param->getLocation(), diag::note_non_deducible_parameter)
+  

Re: r291905 - [Sema] Add warning for unused lambda captures

2017-02-15 Thread Richard Smith via cfe-commits
https://bugs.llvm.org/show_bug.cgi?id=31977 makes the good point that this
is warning on a certain idiomatic use of capture-by-value to extend the
lifetime of an RAII object; consider:

  shared_ptr p = /*...*/;
  int *q = &p->n;
  return [=, p] { return *q++; }

Here, we'll warn that the capture of p is unused, but it's not -- the "use"
is to hold a reference to keep the Foo object alive.

I'd suggest suppressing the warning for a by-copy capture of a variable
with a non-trivial destructor (this mirrors what we do for
-Wunused-variable).

On 13 January 2017 at 07:01, Malcolm Parsons via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: malcolm.parsons
> Date: Fri Jan 13 09:01:06 2017
> New Revision: 291905
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291905&view=rev
> Log:
> [Sema] Add warning for unused lambda captures
>
> Summary:
> Warn when a lambda explicitly captures something that is not used in its
> body.
>
> The warning is part of -Wunused and can be enabled with
> -Wunused-lambda-capture.
>
> Reviewers: rsmith, arphaman, jbcoe, aaron.ballman
>
> Subscribers: Quuxplusone, arphaman, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D28467
>
> Added:
> cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/ScopeInfo.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaLambda.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
> cfe/trunk/test/SemaCXX/uninitialized.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/DiagnosticGroups.td?rev=291905&r1=291904&r2=291905&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 13 09:01:06
> 2017
> @@ -480,6 +480,7 @@ def UnusedFunction : DiagGroup<"unused-f
>  def UnusedMemberFunction : DiagGroup<"unused-member-function",
>   [UnneededMemberFunction]>;
>  def UnusedLabel : DiagGroup<"unused-label">;
> +def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
>  def UnusedParameter : DiagGroup<"unused-parameter">;
>  def UnusedResult : DiagGroup<"unused-result">;
>  def PotentiallyEvaluatedExpression : DiagGroup<"potentially-
> evaluated-expression">;
> @@ -617,8 +618,9 @@ def Unused : DiagGroup<"unused",
> [UnusedArgument, UnusedFunction, UnusedLabel,
>  // UnusedParameter, (matches GCC's behavior)
>  // UnusedMemberFunction, (clean-up llvm before
> enabling)
> -UnusedPrivateField, UnusedLocalTypedef,
> -UnusedValue, UnusedVariable, UnusedPropertyIvar]>,
> +UnusedPrivateField, UnusedLambdaCapture,
> +UnusedLocalTypedef, UnusedValue, UnusedVariable,
> +UnusedPropertyIvar]>,
>  DiagCategory<"Unused Entity Issue">;
>
>  // Format settings.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=291905&r1=291904&r2=291905&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
> 09:01:06 2017
> @@ -316,6 +316,9 @@ def warn_unneeded_member_function : Warn
>InGroup, DefaultIgnore;
>  def warn_unused_private_field: Warning<"private field %0 is not used">,
>InGroup, DefaultIgnore;
> +def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
> +  "%select{used|required to be captured for use in an unevaluated
> context}1">,
> +  InGroup, DefaultIgnore;
>
>  def warn_parameter_size: Warning<
>"%0 is a large (%1 bytes) pass-by-value argument; "
>
> Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/ScopeInfo.h?rev=291905&r1=291904&r2=291905&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
> +++ cfe/trunk/include/clang/Sema/ScopeInfo.h Fri Jan 13 09:01:06 2017
> @@ -452,6 +452,14 @@ public:
>  /// non-static d

[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

efriedma wrote:
> I'm wondering if we can tweak the approach so that we don't have to 
> separately define how this works for each attribute; for example, `#pragma 
> clang attribute_function_declaration push(...)` would apply to each function 
> declaration, `#pragma clang attribute_global_variable_declaration push(...)` 
> would apply to each global variable declaration, etc.
I agree with this idea, I think it would be useful to have the ability to 
specify the target declarations. I do think it would be better to use the 
'clang attribute' umbrella pragma, and maybe add an extra argument to the 
'push', e.g.:

```
#pragma attribute push (annotate("functions-only"), applicable_to=function) // 
or maybe received_by=?
#pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
applicable_to=enum)
```


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 88627.
smeenai edited the summary of this revision.
smeenai removed a reviewer: dexonsmith.
smeenai removed a subscriber: dexonsmith.
smeenai added a comment.

Guarding behind ABI macro


https://reviews.llvm.org/D27387

Files:
  include/__config
  include/functional
  lib/CMakeLists.txt
  src/functional.cpp


Index: src/functional.cpp
===
--- /dev/null
+++ src/functional.cpp
@@ -0,0 +1,29 @@
+//===--- functional.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "__config"
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+
+#include "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -178,7 +178,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects
Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1388,6 +1388,12 @@
 class _LIBCPP_EXCEPTION_ABI bad_function_call
 : public exception
 {
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+
+virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -59,6 +59,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using that class define their own copies.
+#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
 #elif _LIBCPP_ABI_VERSION == 1
 #if !defined(_WIN32)
 // Enable compiling copies of now inline methods into the dylib to support


Index: src/functional.cpp
===
--- /dev/null
+++ src/functional.cpp
@@ -0,0 +1,29 @@
+//===--- functional.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "__config"
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+
+#include "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -178,7 +178,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects
Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1388,6 +1388,12 @@
 class _LIBCPP_EXCEPTION_ABI bad_function_call
 : public exception
 {
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+
+virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -59,6 +59,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the libra

[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases

2017-02-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I'm quite surprised by the fact that we have to change so many diagnostics in 
tests. Do these diagnostics have the full qualifiers for errors that occur with 
record types instead of typedefs?


https://reviews.llvm.org/D29944



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: docs/LanguageExtensions.rst:2344
+declaration failed to receive the attribute because of a compilation error. The
+attributes that aren't applied to any declaration are not verified 
semantically.
+

I think "to each declaration individually" needs to expanded on a bit here.  
It's not clear how this interacts with namespaces, or classes, or function 
declarations, or function definitions, or templates.  For example, if you 
declare a function inside of a `#pragma clang attribute 
push(annotate("custom"))`, does that add an attribute to each parameter of the 
function?



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

I'm wondering if we can tweak the approach so that we don't have to separately 
define how this works for each attribute; for example, `#pragma clang 
attribute_function_declaration push(...)` would apply to each function 
declaration, `#pragma clang attribute_global_variable_declaration push(...)` 
would apply to each global variable declaration, etc.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29723: [Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum

2017-02-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

(Resigning as a reviewer; I don't know enough about standard conversion 
sequences off the top of my head to review this properly.)


https://reviews.llvm.org/D29723



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


[PATCH] D29723: [Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enum

2017-02-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Ping.


https://reviews.llvm.org/D29723



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


r295258 - [dllimport] Check for dtor references in functions

2017-02-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb 15 17:28:10 2017
New Revision: 295258

URL: http://llvm.org/viewvc/llvm-project?rev=295258&view=rev
Log:
[dllimport] Check for dtor references in functions

Destructor references are not modelled explicitly in the AST. This adds
checks for destructor calls due to variable definitions and temporaries.

If a dllimport function references a non-dllimport destructor, it must
not be emitted available_externally, as the referenced destructor might
live across the DLL boundary and isn't exported.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=295258&r1=295257&r2=295258&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb 15 17:28:10 2017
@@ -1693,6 +1693,16 @@ void CodeGenModule::EmitGlobal(GlobalDec
   }
 }
 
+// Check if T is a class type with a destructor that's not dllimport.
+static bool HasNonDllImportDtor(QualType T) {
+  if (const auto *RT = T->getBaseElementTypeUnsafe()->getAs())
+if (CXXRecordDecl *RD = dyn_cast(RT->getDecl()))
+  if (RD->getDestructor() && 
!RD->getDestructor()->hasAttr())
+return true;
+
+  return false;
+}
+
 namespace {
   struct FunctionIsDirectlyRecursive :
 public RecursiveASTVisitor {
@@ -1726,6 +1736,7 @@ namespace {
 }
   };
 
+  // Make sure we're not referencing non-imported vars or functions.
   struct DLLImportFunctionVisitor
   : public RecursiveASTVisitor {
 bool SafeToInline = true;
@@ -1733,12 +1744,25 @@ namespace {
 bool shouldVisitImplicitCode() const { return true; }
 
 bool VisitVarDecl(VarDecl *VD) {
-  // A thread-local variable cannot be imported.
-  SafeToInline = !VD->getTLSKind();
+  if (VD->getTLSKind()) {
+// A thread-local variable cannot be imported.
+SafeToInline = false;
+return SafeToInline;
+  }
+
+  // A variable definition might imply a destructor call.
+  if (VD->isThisDeclarationADefinition())
+SafeToInline = !HasNonDllImportDtor(VD->getType());
+
+  return SafeToInline;
+}
+
+bool VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
+  if (const auto *D = E->getTemporary()->getDestructor())
+SafeToInline = D->hasAttr();
   return SafeToInline;
 }
 
-// Make sure we're not referencing non-imported vars or functions.
 bool VisitDeclRefExpr(DeclRefExpr *E) {
   ValueDecl *VD = E->getDecl();
   if (isa(VD))
@@ -1747,10 +1771,12 @@ namespace {
 SafeToInline = !V->hasGlobalStorage() || V->hasAttr();
   return SafeToInline;
 }
+
 bool VisitCXXConstructExpr(CXXConstructExpr *E) {
   SafeToInline = E->getConstructor()->hasAttr();
   return SafeToInline;
 }
+
 bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
   CXXMethodDecl *M = E->getMethodDecl();
   if (!M) {
@@ -1761,10 +1787,12 @@ namespace {
   }
   return SafeToInline;
 }
+
 bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
   SafeToInline = E->getOperatorDelete()->hasAttr();
   return SafeToInline;
 }
+
 bool VisitCXXNewExpr(CXXNewExpr *E) {
   SafeToInline = E->getOperatorNew()->hasAttr();
   return SafeToInline;
@@ -1793,16 +1821,6 @@ CodeGenModule::isTriviallyRecursive(cons
   return Walker.Result;
 }
 
-// Check if T is a class type with a destructor that's not dllimport.
-static bool HasNonDllImportDtor(QualType T) {
-  if (const auto *RT = T->getBaseElementTypeUnsafe()->getAs())
-if (CXXRecordDecl *RD = dyn_cast(RT->getDecl()))
-  if (RD->getDestructor() && 
!RD->getDestructor()->hasAttr())
-return true;
-
-  return false;
-}
-
 bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
   if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage)
 return true;

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=295258&r1=295257&r2=295258&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Wed Feb 15 17:28:10 2017
@@ -368,6 +368,13 @@ struct ClassWithCtor { ClassWithCtor() {
 struct __declspec(dllimport) ClassWithNonDllImportFieldWithCtor { 
ClassWithCtor t; };
 USECLASS(ClassWithNonDllImportFieldWithCtor);
 // MO1-DAG: declare dllimport x86_thiscallcc 
%struct.ClassWithNonDllImportFieldWithCtor* 
@"\01??0ClassWithNonDllImportFieldWithCtor@@QAE@XZ"(%struct.ClassWithNonDllImportFieldWithCtor*
 returned)
+struct ClassWithImplicitDtor { __declspec(dllimport) ClassWithImplicitDtor(); 
ClassWithDtor member; };
+__declspec(dllimport) inline void ReferencingDtorThroughDefinitio

r295257 - [dllimport] Look through typedefs and arrays in HasNonDllImportDtor

2017-02-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb 15 17:28:07 2017
New Revision: 295257

URL: http://llvm.org/viewvc/llvm-project?rev=295257&view=rev
Log:
[dllimport] Look through typedefs and arrays in HasNonDllImportDtor

The function is used to check whether a type is a class with
non-dllimport destructor. It needs to look through typedefs and array
types.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=295257&r1=295256&r2=295257&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Feb 15 17:28:07 2017
@@ -1795,7 +1795,7 @@ CodeGenModule::isTriviallyRecursive(cons
 
 // Check if T is a class type with a destructor that's not dllimport.
 static bool HasNonDllImportDtor(QualType T) {
-  if (const RecordType *RT = dyn_cast(T))
+  if (const auto *RT = T->getBaseElementTypeUnsafe()->getAs())
 if (CXXRecordDecl *RD = dyn_cast(RT->getDecl()))
   if (RD->getDestructor() && 
!RD->getDestructor()->hasAttr())
 return true;

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=295257&r1=295256&r2=295257&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Wed Feb 15 17:28:07 2017
@@ -358,7 +358,7 @@ __declspec(dllimport) inline int *Refere
 USE(ReferencingImportedNew)
 USE(ReferencingImportedDelete)
 struct ClassWithDtor { ~ClassWithDtor() {} };
-struct __declspec(dllimport) ClassWithNonDllImportField { ClassWithDtor t; };
+struct __declspec(dllimport) ClassWithNonDllImportField { using X = 
ClassWithDtor; X t[2]; };
 struct __declspec(dllimport) ClassWithNonDllImportBase : public ClassWithDtor 
{ };
 USECLASS(ClassWithNonDllImportField);
 USECLASS(ClassWithNonDllImportBase);


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


r295256 - [Docs] Add missing space to an option doc

2017-02-15 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Feb 15 17:24:15 2017
New Revision: 295256

URL: http://llvm.org/viewvc/llvm-project?rev=295256&view=rev
Log:
[Docs] Add missing space to an option doc

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=295256&r1=295255&r2=295256&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 15 17:24:15 2017
@@ -1448,8 +1448,8 @@ def fno_unique_section_names : Flag <["-
 
 def fstrict_return : Flag<["-"], "fstrict-return">, Group,
   Flags<[CC1Option]>,
-  HelpText<"Always treat control flow paths that fall off the end of a 
non-void"
-   "function as unreachable">;
+  HelpText<"Always treat control flow paths that fall off the end of a "
+   "non-void function as unreachable">;
 def fno_strict_return : Flag<["-"], "fno-strict-return">, Group,
   Flags<[CC1Option]>;
 


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


[PATCH] D24812: Lit C++11 Compatibility Patch #11

2017-02-15 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 88617.
tigerleapgorge added a comment.

Changed "CHECK11" to "CHECK11-NEXT".


https://reviews.llvm.org/D24812

Files:
  test/CodeGenCXX/mangle-unnamed.cpp
  test/CodeGenCXX/static-init.cpp
  test/CodeGenCXX/volatile-1.cpp
  test/CodeGenCXX/volatile.cpp
  test/PCH/macro-undef.cpp

Index: test/PCH/macro-undef.cpp
===
--- test/PCH/macro-undef.cpp
+++ test/PCH/macro-undef.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
-// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
 
 #ifndef HEADER
 #define HEADER
Index: test/CodeGenCXX/volatile.cpp
===
--- test/CodeGenCXX/volatile.cpp
+++ test/CodeGenCXX/volatile.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -std=c++98 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // Check that IR gen doesn't try to do an lvalue-to-rvalue conversion
 // on a volatile reference result.  rdar://problem/8338198
@@ -27,6 +28,7 @@
   // CHECK-LABEL: define void @_ZN5test14testEv()
   void test() {
 // CHECK:  [[TMP:%.*]] = load i32*, i32** @_ZN5test11xE, align 8
+// CHECK11-NEXT: {{%.*}} = load volatile i32, i32* [[TMP]], align 4
 // CHECK-NEXT: ret void
 *x;
   }
Index: test/CodeGenCXX/volatile-1.cpp
===
--- test/CodeGenCXX/volatile-1.cpp
+++ test/CodeGenCXX/volatile-1.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -std=c++98 -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // CHECK: @i = global [[INT:i[0-9]+]] 0
 volatile int i, j, k;
@@ -22,18 +23,22 @@
 
   asm("nop"); // CHECK: call void asm
 
-  // should not load
+  // should not load in C++98
   i;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @i
 
   (float)(ci);
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
   // CHECK-NEXT: sitofp [[INT]]
 
-  // These are not uses in C++:
+  // These are not uses in C++98:
   //   [expr.static.cast]p6:
   // The lvalue-to-rvalue . . . conversions are not applied to the expression.
   (void)ci;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
+
   (void)a;
 
   (void)(ci=ci);
@@ -126,7 +131,8 @@
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: sitofp
 
-  (void)i;
+  (void)i; // This is now a load in C++11
+  // CHECK11-NEXT: load volatile
 
   i=i;
   // CHECK-NEXT: load volatile
@@ -155,25 +161,30 @@
   // CHECK-NEXT: br label
   // CHECK:  phi
 
-  (void)(i,(i=i));
+  (void)(i,(i=i)); // first i is also a load in C++11
+  // CHECK11-NEXT: load volatile
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: store volatile
 
-  i=i,k;
+  i=i,k; // k is also a load in C++11
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @i
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @k
 
   (i=j,k=j);
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @j
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @j
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @k
 
-  (i=j,k);
+  (i=j,k); // k is also a load in C++11
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @j
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @k
 
-  (i,j);
+  (i,j); // i and j both are loads in C++11
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @j
 
   // Extra load in C++.
   i=c=k;
@@ -190,7 +201,9 @@
   // CHECK-NEXT: add nsw [[INT]]
   // CHECK-NEXT: store volatile
 
-  ci;
+  ci; // ci is a load in C++11
+  // CHECK11-NEXT: load volatile {{.*}} @ci, i32 0, i32 0
+  // C

[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.

Please add a test for this.




Comment at: lib/Sema/SemaExprObjC.cpp:1989
+  Selector SetterSel;
+  if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(
+  &propertyName, ObjCPropertyQueryKind::OBJC_PR_query_class)) {

Use `auto`.


https://reviews.llvm.org/D29967



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


[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2017-02-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Thanks for all your work on these!


Repository:
  rL LLVM

https://reviews.llvm.org/D26654



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-15 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch adds support for the `#pragma clang attribute` directive that was 
proposed recently at 
http://lists.llvm.org/pipermail/cfe-dev/2017-February/052689.html.

Initially it supports the `annotate`, `require_constant_initialization` and 
`objc_subclassing_restricted` attribute (I added support for the last two to 
verify that only those declarations that are specified in the Attr.td subject 
list can receive the attribute). The attributes are parsed immediately and are 
applied individually to each relevant declaration. The attribute application 
errors aren't reported more than once. The `annotate` attribute, which doesn't 
have the subject list, is applied only to those declarations that can receive 
explicit GNU-style attributes.

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D30009

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/AttributeList.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/Parser/pragma-attribute.cpp
  test/Sema/pragma-attribute.c
  test/SemaCXX/pragma-attribute.cpp
  test/SemaObjC/pragma-attribute.m
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1522,6 +1522,20 @@
   OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n";
 }
 
+// Emits the SupportsPragmaAttribute property for attributes.
+static void emitClangAttrPragmaAttributeSupportList(RecordKeeper &Records,
+raw_ostream &OS) {
+  OS << "#if defined(CLANG_ATTR_PRAGMA_ATTRIBUTE_SUPPORT_LIST)\n";
+  for (const auto *Attr : Records.getAllDerivedDefinitions("Attr")) {
+if (!Attr->getValueAsBit("SupportsPragmaAttribute"))
+  continue;
+std::vector Spellings = GetFlattenedSpellings(*Attr);
+for (const auto &I : Spellings)
+  OS << ".Case(\"" << I.name() << "\", 1)\n";
+  }
+  OS << "#endif // CLANG_ATTR_PRAGMA_ATTRIBUTE_SUPPORT_LIST\n\n";
+}
+
 template 
 static void forEachUniqueSpelling(const Record &Attr, Fn &&F) {
   std::vector Spellings = GetFlattenedSpellings(Attr);
@@ -2692,9 +2706,13 @@
   return B + "Decl";
 }
 
+static std::string functionNameForCustomAppertainsTo(const Record &Subject) {
+  return "is" + Subject.getName().str();
+}
+
 static std::string GenerateCustomAppertainsTo(const Record &Subject,
   raw_ostream &OS) {
-  std::string FnName = "is" + Subject.getName().str();
+  std::string FnName = functionNameForCustomAppertainsTo(Subject);
 
   // If this code has already been generated, simply return the previous
   // instance of it.
@@ -2779,6 +2797,51 @@
   return FnName;
 }
 
+static void GenerateDefaultAppliesTo(raw_ostream &OS) {
+  OS << "static bool defaultAttributeAppliesTo(Sema &, const Decl *) {\n";
+  OS << "  return true;\n";
+  OS << "}\n\n";
+}
+
+static std::string GenerateAppliesTo(const Record &Attr, raw_ostream &OS) {
+  // If the attribute doesn't support '#pragma clang attribute' or if it doesn't
+  // contain a subjects definition, then use the default appliedTo logic.
+  if (!Attr.getValueAsBit("SupportsPragmaAttribute") ||
+  Attr.isValueUnset("Subjects"))
+return "defaultAttributeAppliesTo";
+
+  const Record *SubjectObj = Attr.getValueAsDef("Subjects");
+  std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
+
+  // If the list of subjects is empty, it is assumed that the attribute applies
+  // to everything.
+  if (Subjects.empty())
+return "defaultAttributeAppliesTo";
+
+  // Otherwise, generate an appliesTo check specific to this attribute which
+  // checks all of the given subjects against the Decl passed in. Return the
+  // name of that check to the caller.
+  std::string FnName = "check" + Attr.getName().str() + "AttributeAppliesTo";
+  std::stringstream SS;
+  SS << "static bool " << FnName << "(Sema &S, const Decl *D) {\n";
+  SS << "  return ";
+  for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
+// If the subject has custom code associated with it, use the function
+// that was generated for GenerateAppertainsTo to check if the declaration
+// is valid.
+if ((*I)->isSubClassOf("SubsetSubject"))
+  SS << functionNameForCustomAppertainsTo(**I) << "(D)";
+else
+  SS << "isa<" << GetSubjectWithSuffix(*I) << ">(D)";
+
+if (I + 1 != E)
+  SS << " || ";
+  }
+  SS << ";\n}\n\n";
+  OS << SS.str();
+  return FnName;
+}
+
 static void Generate

r295252 - [Modules] Consider enable_if attrs in isSameEntity.

2017-02-15 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Feb 15 16:43:27 2017
New Revision: 295252

URL: http://llvm.org/viewvc/llvm-project?rev=295252&view=rev
Log:
[Modules] Consider enable_if attrs in isSameEntity.

Two functions that differ only in their enable_if attributes are
considered overloads, so we should check for those when we're trying to
figure out if two functions are mergeable.

We need to do the same thing for pass_object_size, as well. Looks like
that'll be a bit less trivial, since we sometimes do these merging
checks before we have pass_object_size attributes available (see the
merge checks in ASTDeclReader::VisitFunctionDecl that happen before we
read parameters, and merge checks in calls to ReadDeclAs<>()).

Added:
cfe/trunk/test/Modules/Inputs/overloadable-attrs/
cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap
cfe/trunk/test/Modules/overloadable-attrs.cpp
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=295252&r1=295251&r2=295252&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 15 16:43:27 2017
@@ -2656,6 +2656,44 @@ static bool isSameTemplateParameterList(
   return true;
 }
 
+/// Determine whether the attributes we can overload on are identical for A and
+/// B. Expects A and B to (otherwise) have the same type.
+static bool hasSameOverloadableAttrs(const FunctionDecl *A,
+ const FunctionDecl *B) {
+  SmallVector AEnableIfs;
+  // Since this is an equality check, we can ignore that enable_if attrs show 
up
+  // in reverse order.
+  for (const auto *EIA : A->specific_attrs())
+AEnableIfs.push_back(EIA);
+
+  SmallVector BEnableIfs;
+  for (const auto *EIA : B->specific_attrs())
+BEnableIfs.push_back(EIA);
+
+  // Two very common cases: either we have 0 enable_if attrs, or we have an
+  // unequal number of enable_if attrs.
+  if (AEnableIfs.empty() && BEnableIfs.empty())
+return true;
+
+  if (AEnableIfs.size() != BEnableIfs.size())
+return false;
+
+  llvm::FoldingSetNodeID Cand1ID, Cand2ID;
+  for (unsigned I = 0, E = AEnableIfs.size(); I != E; ++I) {
+Cand1ID.clear();
+Cand2ID.clear();
+
+AEnableIfs[I]->getCond()->Profile(Cand1ID, A->getASTContext(), true);
+BEnableIfs[I]->getCond()->Profile(Cand2ID, B->getASTContext(), true);
+if (Cand1ID != Cand2ID)
+  return false;
+  }
+
+  // FIXME: This doesn't currently consider pass_object_size attributes, since
+  // we aren't guaranteed that A and B have valid parameter lists yet.
+  return true;
+}
+
 /// \brief Determine whether the two declarations refer to the same entity.
 static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
   assert(X->getDeclName() == Y->getDeclName() && "Declaration name mismatch!");
@@ -2711,8 +2749,10 @@ static bool isSameEntity(NamedDecl *X, N
 CtorY->getInheritedConstructor().getConstructor()))
 return false;
 }
-return (FuncX->getLinkageInternal() == FuncY->getLinkageInternal()) &&
-  FuncX->getASTContext().hasSameType(FuncX->getType(), FuncY->getType());
+return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() &&
+   FuncX->getASTContext().hasSameType(FuncX->getType(),
+  FuncY->getType()) &&
+   hasSameOverloadableAttrs(FuncX, FuncY);
   }
 
   // Variables with the same type and linkage match.

Added: cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h?rev=295252&view=auto
==
--- cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/overloadable-attrs/a.h Wed Feb 15 16:43:27 
2017
@@ -0,0 +1,16 @@
+namespace enable_if_attrs {
+constexpr int fn1() __attribute__((enable_if(0, ""))) { return 0; }
+constexpr int fn1() { return 1; }
+
+constexpr int fn2() { return 1; }
+constexpr int fn2() __attribute__((enable_if(0, ""))) { return 0; }
+
+constexpr int fn3(int i) __attribute__((enable_if(!i, ""))) { return 0; }
+constexpr int fn3(int i) __attribute__((enable_if(i, ""))) { return 1; }
+
+constexpr int fn4(int i) { return 0; }
+constexpr int fn4(int i) __attribute__((enable_if(i, ""))) { return 1; }
+
+constexpr int fn5(int i) __attribute__((enable_if(i, ""))) { return 1; }
+constexpr int fn5(int i) { return 0; }
+}

Added: cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/overloadable-attrs/module.modulemap?rev=295252&view=auto

r295245 - Fix the static build.

2017-02-15 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Feb 15 16:19:04 2017
New Revision: 295245

URL: http://llvm.org/viewvc/llvm-project?rev=295245&view=rev
Log:
Fix the static build.

Modified:
cfe/trunk/tools/c-index-test/CMakeLists.txt

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=295245&r1=295244&r2=295245&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Wed Feb 15 16:19:04 2017
@@ -17,6 +17,7 @@ endif()
 if (LLVM_BUILD_STATIC)
   target_link_libraries(c-index-test
 libclang_static
+clangCodeGen
 clangIndex
   )
 else()


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


[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds

2017-02-15 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Does the code you added detects array out of bounds cases without false 
positives? Is it an option to just have this checkers produce a more precise 
error message in the specific case.

A lot of work will probably need to be done to implement a proper array out of 
bounds checking and no-one is working on that.


Repository:
  rL LLVM

https://reviews.llvm.org/D28278



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


[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker

2017-02-15 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Please, make sure future reviews go through cfg-dev list. See 
http://llvm.org/docs/Phabricator.html.


Repository:
  rL LLVM

https://reviews.llvm.org/D28297



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


[PATCH] D24812: Lit C++11 Compatibility Patch #11

2017-02-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: test/CodeGenCXX/static-init.cpp:14
+// CHECK98: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global 
%"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK11: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global { i8** } 
{ i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN5test49HasVTableE, i32 0, inrange i32 0, i32 2) }, comdat, align 8
 

rjmccall wrote:
> Interesting.  It looks to me like the C++11 IR pattern is actually the only 
> one that would've exposed the bug that Reid was fixing in r242704.  Reid, do 
> you agree?
I'm not sure I follow exactly, but I think what's going on here is that, in 
C++11, the implicit default constructor is constexpr. I'm not sure how that 
feeds into what type we choose to use for the global.


https://reviews.llvm.org/D24812



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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-15 Thread Eric Niebler via Phabricator via cfe-commits
eric_niebler added a comment.

My question was more about whether the code is correct for absolute paths on 
Windows, not about whether this particular test would pass or fail. Have you 
tested an incorrectly-cased absolute path on a Windows machine?


https://reviews.llvm.org/D3



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


[PATCH] D29599: Clang Changes for alloc_align

2017-02-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 88602.
erichkeane added a comment.

I was able to get the templated versions working in response to the discussion 
with Akira.  Note the added test file which shows off all of the combos I could 
think of.

It required a little bit of surgery inside the SemaDeclAttr.cpp, since the 
SemaTemplateInstatiateDecl.cpp no longer has "AttributeList" info anymore, so 
getting the error messages in the existing functions required a little 
template-writing of my own!

I decided to explicitly forbid the following case, because I cannot see a valid 
usecase for this, or for making 'Which' below a dependent value.

  template
  void* foo(int a, int b, int c, int d) __attribute__((alloc_align(Which)));


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c
  test/SemaCXX/alloc-align-attr.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4225,7 +4225,11 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal = IRCallArgs[AA->getParamIndex() - 1];
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
+
   }
 
   return Ret;
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2412,6 +2412,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -168,6 +168,16 @@
 Aligned->getSpellingListIndex());
 }
 
+static void instantiateDependentAllocAlignAttr(
+Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
+const AllocAlignAttr *Align, Decl *New) {
+  Expr *Param = IntegerLiteral::Create(
+  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext().UnsignedLongLongTy, Align->getLocation());
+  S.AddAllocAlignAttr(Align->getLocation(), New, Param,
+  Align->getSpellingListIndex());
+}
+
 static Expr *instantiateDependentFunctionAttrCondition(
 Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
 const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) {
@@ -352,6 +362,12 @@
   continue;
 }
 
+if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
+  instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New);
+  continue;
+}
+
+
 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
   instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl,
cast(New));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -218,21 +218,42 @@
std::greater());
 }
 
+/// \brief A helper function to provide Attribute Location for the Attr types
+/// AND the AttributeList
+template  static typename
+std::enable_if::value, SourceLocation>::type
+getAttrLoc(const AttrInfo& Attr) {
+  return Attr.getLocation();
+}
+static SourceLocation getAttrLoc(const clang::AttributeList& Attr) {
+  return Attr.getLoc();
+}
+/// \brief A helper function to provide Attribute Name for the Attr types
+/// AND the AttributeList
+template  static typename
+std::enable_if::value, const AttrInfo*>::type
+getAttrName(const AttrInfo& Attr) {
+  return &Attr;
+}
+const IdentifierInfo* getAttrName(const clang::AttributeList &Attr) {
+  return Attr.getName();
+}
+
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-static bool checkUInt32Argument(Sema &S, const AttributeList &Attr,
-

Patch for Bug 30413, including test case

2017-02-15 Thread Lobron, David via cfe-commits
Hi All,

I am re-submitting my patch for Bug 30413, this time with a test case included 
as well (ivar-type-encoding.m).  The test case file should be added to 
clang/test/CodeGenObjC.  The test verifies that correct metadata is emitted by 
clang for an object-valued instance variable.  I've verified that the test 
passes when the patch has been applied to ASTContext.cpp, and fails otherwise.

Please let me know if this looks OK, or if any additional information is needed.

Thanks,

David



ivar-type-encoding.m
Description: ivar-type-encoding.m


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


Re: r295150 - [Sema] Disallow returning a __block variable via a move.

2017-02-15 Thread Hans Wennborg via cfe-commits
On Wed, Feb 15, 2017 at 12:17 PM, Richard Smith  wrote:
> On 15 February 2017 at 11:50, Hans Wennborg  wrote:
>>
>> +Richard for risk/reward analysis.
>
>
> This is an extremely safe change, and fixes what amounts to a subtle
> miscompile. I think we should take it.

Very good; merged in r295234.

>
>>
>> r274291 was also in 3.9, so this isn't strictly speaking a regression.
>>
>> On Wed, Feb 15, 2017 at 11:43 AM, Akira Hatanaka 
>> wrote:
>> > Hans,
>> >
>> > Can this be merged to 4.0 too?
>> >
>> >> On Feb 14, 2017, at 9:15 PM, Akira Hatanaka via cfe-commits
>> >>  wrote:
>> >>
>> >> Author: ahatanak
>> >> Date: Tue Feb 14 23:15:28 2017
>> >> New Revision: 295150
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=295150&view=rev
>> >> Log:
>> >> [Sema] Disallow returning a __block variable via a move.
>> >>
>> >> r274291 made changes to prefer calling a move constructor to calling a
>> >> copy constructor when returning from a function. This caused programs
>> >> to
>> >> crash when a __block variable in the heap was moved out and used later.
>> >>
>> >> This commit fixes the bug by disallowing moving out of __block
>> >> variables
>> >> implicitly.
>> >>
>> >> rdar://problem/28181080
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D29908
>> >>
>> >> Modified:
>> >>cfe/trunk/lib/Sema/SemaStmt.cpp
>> >>cfe/trunk/test/SemaObjCXX/blocks.mm
>> >>
>> >> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=295150&r1=295149&r2=295150&view=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> >> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Feb 14 23:15:28 2017
>> >> @@ -2743,15 +2743,17 @@ bool Sema::isCopyElisionCandidate(QualTy
>> >>   // ...automatic...
>> >>   if (!VD->hasLocalStorage()) return false;
>> >>
>> >> +  // Return false if VD is a __block variable. We don't want to
>> >> implicitly move
>> >> +  // out of a __block variable during a return because we cannot
>> >> assume the
>> >> +  // variable will no longer be used.
>> >> +  if (VD->hasAttr()) return false;
>> >> +
>> >>   if (AllowParamOrMoveConstructible)
>> >> return true;
>> >>
>> >>   // ...non-volatile...
>> >>   if (VD->getType().isVolatileQualified()) return false;
>> >>
>> >> -  // __block variables can't be allocated in a way that permits NRVO.
>> >> -  if (VD->hasAttr()) return false;
>> >> -
>> >>   // Variables with higher required alignment than their type's ABI
>> >>   // alignment cannot use NRVO.
>> >>   if (!VD->getType()->isDependentType() && VD->hasAttr()
>> >> &&
>> >>
>> >> Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/blocks.mm?rev=295150&r1=295149&r2=295150&view=diff
>> >>
>> >> ==
>> >> --- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
>> >> +++ cfe/trunk/test/SemaObjCXX/blocks.mm Tue Feb 14 23:15:28 2017
>> >> @@ -1,4 +1,4 @@
>> >> -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class
>> >> %s
>> >> +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class
>> >> -std=c++11 %s
>> >> @protocol NSObject;
>> >>
>> >> void bar(id(^)(void));
>> >> @@ -144,3 +144,17 @@ namespace DependentReturn {
>> >>
>> >>   template void f(X);
>> >> }
>> >> +
>> >> +namespace MoveBlockVariable {
>> >> +struct B0 {
>> >> +};
>> >> +
>> >> +struct B1 { // expected-note 2 {{candidate constructor (the implicit}}
>> >> +  B1(B0&&); // expected-note {{candidate constructor not viable}}
>> >> +};
>> >> +
>> >> +B1 test_move() {
>> >> +  __block B0 b;
>> >> +  return b; // expected-error {{no viable conversion from returned
>> >> value of type 'MoveBlockVariable::B0' to function return type
>> >> 'MoveBlockVariable::B1'}}
>> >> +}
>> >> +}
>> >>
>> >>
>> >> ___
>> >> 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: r295149 - Fix assertion failure due to implicit special member lookup lacking a source location.

2017-02-15 Thread Hans Wennborg via cfe-commits
On Wed, Feb 15, 2017 at 12:14 PM, Richard Smith  wrote:
> On 15 February 2017 at 11:39, Hans Wennborg  wrote:
>>
>> IIUC, this is a follow-up to r291955, which was merged to 4.0. Should
>> this one be merged also?
>
>
> Yes, please.

r295233.

>
>>
>> Cheers,
>> Hans
>>
>> On Tue, Feb 14, 2017 at 8:18 PM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Tue Feb 14 22:18:23 2017
>> > New Revision: 295149
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=295149&view=rev
>> > Log:
>> > Fix assertion failure due to implicit special member lookup lacking a
>> > source location.
>> >
>> > Modified:
>> > cfe/trunk/lib/Sema/SemaLookup.cpp
>> > cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
>> >
>> > Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=295149&r1=295148&r2=295149&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
>> > +++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Feb 14 22:18:23 2017
>> > @@ -2838,6 +2838,9 @@ Sema::SpecialMemberOverloadResult *Sema:
>> >  assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
>> > "parameter-less special members can't have qualified
>> > arguments");
>> >
>> > +  // FIXME: Get the caller to pass in a location for the lookup.
>> > +  SourceLocation LookupLoc = RD->getLocation();
>> > +
>> >llvm::FoldingSetNodeID ID;
>> >ID.AddPointer(RD);
>> >ID.AddInteger(SM);
>> > @@ -2919,7 +2922,7 @@ Sema::SpecialMemberOverloadResult *Sema:
>> >VK = VK_RValue;
>> >}
>> >
>> > -  OpaqueValueExpr FakeArg(SourceLocation(), ArgType, VK);
>> > +  OpaqueValueExpr FakeArg(LookupLoc, ArgType, VK);
>> >
>> >if (SM != CXXDefaultConstructor) {
>> >  NumArgs = 1;
>> > @@ -2933,13 +2936,13 @@ Sema::SpecialMemberOverloadResult *Sema:
>> >if (VolatileThis)
>> >  ThisTy.addVolatile();
>> >Expr::Classification Classification =
>> > -OpaqueValueExpr(SourceLocation(), ThisTy,
>> > +OpaqueValueExpr(LookupLoc, ThisTy,
>> >  RValueThis ? VK_RValue :
>> > VK_LValue).Classify(Context);
>> >
>> >// Now we perform lookup on the name we computed earlier and do
>> > overload
>> >// resolution. Lookup is only performed directly into the class since
>> > there
>> >// will always be a (possibly implicit) declaration to shadow any
>> > others.
>> > -  OverloadCandidateSet OCS(RD->getLocation(),
>> > OverloadCandidateSet::CSK_Normal);
>> > +  OverloadCandidateSet OCS(LookupLoc,
>> > OverloadCandidateSet::CSK_Normal);
>> >DeclContext::lookup_result R = RD->lookup(Name);
>> >
>> >if (R.empty()) {
>> > @@ -2994,7 +2997,7 @@ Sema::SpecialMemberOverloadResult *Sema:
>> >}
>> >
>> >OverloadCandidateSet::iterator Best;
>> > -  switch (OCS.BestViableFunction(*this, SourceLocation(), Best)) {
>> > +  switch (OCS.BestViableFunction(*this, LookupLoc, Best)) {
>> >  case OR_Success:
>> >Result->setMethod(cast(Best->Function));
>> >Result->setKind(SpecialMemberOverloadResult::Success);
>> >
>> > Modified: cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp?rev=295149&r1=295148&r2=295149&view=diff
>> >
>> > ==
>> > --- cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp (original)
>> > +++ cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp Tue Feb 14
>> > 22:18:23 2017
>> > @@ -105,3 +105,31 @@ namespace PR31606 {
>> >// Note, we do *not* allow operator=='s argument to use the inherited
>> > A::A(Base&&) constructor to construct from B{}.
>> >bool b = A{} == B{}; // expected-error {{invalid operands}}
>> >  }
>> > +
>> > +namespace implicit_member_srcloc {
>> > +  template
>> > +  struct S3 {
>> > +  };
>> > +
>> > +  template
>> > +  struct S2 {
>> > +S2(S3 &&);
>> > +  };
>> > +
>> > +  template
>> > +  struct S1 : S2 {
>> > +using S2::S2;
>> > +S1();
>> > +  };
>> > +
>> > +  template
>> > +  struct S0 {
>> > +S0();
>> > +S0(S0&&) = default;
>> > +S1 m1;
>> > +  };
>> > +
>> > +  void foo1() {
>> > +S0 s0;
>> > +  }
>> > +}
>> >
>> >
>> > ___
>> > 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: r295150 - [Sema] Disallow returning a __block variable via a move.

2017-02-15 Thread Richard Smith via cfe-commits
On 15 February 2017 at 11:50, Hans Wennborg  wrote:

> +Richard for risk/reward analysis.
>

This is an extremely safe change, and fixes what amounts to a subtle
miscompile. I think we should take it.


> r274291 was also in 3.9, so this isn't strictly speaking a regression.
>
> On Wed, Feb 15, 2017 at 11:43 AM, Akira Hatanaka 
> wrote:
> > Hans,
> >
> > Can this be merged to 4.0 too?
> >
> >> On Feb 14, 2017, at 9:15 PM, Akira Hatanaka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: ahatanak
> >> Date: Tue Feb 14 23:15:28 2017
> >> New Revision: 295150
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=295150&view=rev
> >> Log:
> >> [Sema] Disallow returning a __block variable via a move.
> >>
> >> r274291 made changes to prefer calling a move constructor to calling a
> >> copy constructor when returning from a function. This caused programs to
> >> crash when a __block variable in the heap was moved out and used later.
> >>
> >> This commit fixes the bug by disallowing moving out of __block variables
> >> implicitly.
> >>
> >> rdar://problem/28181080
> >>
> >> Differential Revision: https://reviews.llvm.org/D29908
> >>
> >> Modified:
> >>cfe/trunk/lib/Sema/SemaStmt.cpp
> >>cfe/trunk/test/SemaObjCXX/blocks.mm
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaStmt.cpp?rev=295150&r1=295149&r2=295150&view=diff
> >> 
> ==
> >> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Feb 14 23:15:28 2017
> >> @@ -2743,15 +2743,17 @@ bool Sema::isCopyElisionCandidate(QualTy
> >>   // ...automatic...
> >>   if (!VD->hasLocalStorage()) return false;
> >>
> >> +  // Return false if VD is a __block variable. We don't want to
> implicitly move
> >> +  // out of a __block variable during a return because we cannot
> assume the
> >> +  // variable will no longer be used.
> >> +  if (VD->hasAttr()) return false;
> >> +
> >>   if (AllowParamOrMoveConstructible)
> >> return true;
> >>
> >>   // ...non-volatile...
> >>   if (VD->getType().isVolatileQualified()) return false;
> >>
> >> -  // __block variables can't be allocated in a way that permits NRVO.
> >> -  if (VD->hasAttr()) return false;
> >> -
> >>   // Variables with higher required alignment than their type's ABI
> >>   // alignment cannot use NRVO.
> >>   if (!VD->getType()->isDependentType() && VD->hasAttr()
> &&
> >>
> >> Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaObjCXX/blocks.mm?rev=295150&r1=295149&r2=295150&view=diff
> >> 
> ==
> >> --- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
> >> +++ cfe/trunk/test/SemaObjCXX/blocks.mm Tue Feb 14 23:15:28 2017
> >> @@ -1,4 +1,4 @@
> >> -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class
> %s
> >> +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class
> -std=c++11 %s
> >> @protocol NSObject;
> >>
> >> void bar(id(^)(void));
> >> @@ -144,3 +144,17 @@ namespace DependentReturn {
> >>
> >>   template void f(X);
> >> }
> >> +
> >> +namespace MoveBlockVariable {
> >> +struct B0 {
> >> +};
> >> +
> >> +struct B1 { // expected-note 2 {{candidate constructor (the implicit}}
> >> +  B1(B0&&); // expected-note {{candidate constructor not viable}}
> >> +};
> >> +
> >> +B1 test_move() {
> >> +  __block B0 b;
> >> +  return b; // expected-error {{no viable conversion from returned
> value of type 'MoveBlockVariable::B0' to function return type
> 'MoveBlockVariable::B1'}}
> >> +}
> >> +}
> >>
> >>
> >> ___
> >> 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: r295224 - PR24440: Do not silently discard a fold-expression appearing as the operand of a cast-expression.

2017-02-15 Thread Richard Smith via cfe-commits
Hans, this would be a good candidate for Clang 4. The bug in question is
not a regression, but it is an accepts-invalid / wrong-code bug.

On 15 February 2017 at 11:57, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed Feb 15 13:57:10 2017
> New Revision: 295224
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295224&view=rev
> Log:
> PR24440: Do not silently discard a fold-expression appearing as the
> operand of a cast-expression.
>
> Modified:
> cfe/trunk/lib/Parse/ParseExpr.cpp
> cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
>
> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
> ParseExpr.cpp?rev=295224&r1=295223&r2=295224&view=diff
> 
> ==
> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 15 13:57:10 2017
> @@ -2409,7 +2409,7 @@ Parser::ParseParenExpression(ParenParseO
>// fold-expressions, we'll need to allow multiple ArgExprs here.
>if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
>NextToken().is(tok::ellipsis))
> -return ParseFoldExpression(Result, T);
> +return ParseFoldExpression(ArgExprs[0], T);
>
>ExprType = SimpleExpr;
>Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
>
> Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaTemplateVariadic.cpp?rev=295224&r1=295223&r2=295224&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Wed Feb 15 13:57:10 2017
> @@ -1015,6 +1015,11 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>CheckFoldOperand(*this, LHS);
>CheckFoldOperand(*this, RHS);
>
> +  auto DiscardOperands = [&] {
> +CorrectDelayedTyposInExpr(LHS);
> +CorrectDelayedTyposInExpr(RHS);
> +  };
> +
>// [expr.prim.fold]p3:
>//   In a binary fold, op1 and op2 shall be the same fold-operator, and
>//   either e1 shall contain an unexpanded parameter pack or e2 shall
> contain
> @@ -1022,6 +1027,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>if (LHS && RHS &&
>LHS->containsUnexpandedParameterPack() ==
>RHS->containsUnexpandedParameterPack()) {
> +DiscardOperands();
>  return Diag(EllipsisLoc,
>  LHS->containsUnexpandedParameterPack()
>  ? diag::err_fold_expression_packs_both_sides
> @@ -1035,6 +1041,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>if (!LHS || !RHS) {
>  Expr *Pack = LHS ? LHS : RHS;
>  assert(Pack && "fold expression with neither LHS nor RHS");
> +DiscardOperands();
>  if (!Pack->containsUnexpandedParameterPack())
>return Diag(EllipsisLoc, diag::err_pack_expansion_
> without_parameter_packs)
>   << Pack->getSourceRange();
>
> Modified: cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/
> cxx1z-fold-expressions.cpp?rev=295224&r1=295223&r2=295224&view=diff
> 
> ==
> --- cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp (original)
> +++ cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Wed Feb 15 13:57:10
> 2017
> @@ -34,3 +34,12 @@ template int bad9() { return (
>  template int bad10() { return (3 ? ... : N); } //
> expected-error +{{}} expected-note {{to match}}
>  template int bad11() { return (N + ... 0); } // expected-error
> {{expected a foldable binary operator}} expected-error {{expected
> expression}}
>  template int bad12() { return (... N); } // expected-error
> {{expected expression}}
> +
> +template void as_operand_of_cast(int a, T ...t) {
> +  return
> +(int)(a + ... + undeclared_junk) + // expected-error {{undeclared}}
> expected-error {{does not contain any unexpanded}}
> +(int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
> +(int)(... + undeclared_junk) + // expected-error {{undeclared}}
> expected-error {{does not contain any unexpanded}}
> +(int)(undeclared_junk + ...) + // expected-error {{undeclared}}
> +(int)(a + ...); // expected-error {{does not contain any unexpanded}}
> +}
>
>
> ___
> 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: r295149 - Fix assertion failure due to implicit special member lookup lacking a source location.

2017-02-15 Thread Richard Smith via cfe-commits
On 15 February 2017 at 11:39, Hans Wennborg  wrote:

> IIUC, this is a follow-up to r291955, which was merged to 4.0. Should
> this one be merged also?
>

Yes, please.


> Cheers,
> Hans
>
> On Tue, Feb 14, 2017 at 8:18 PM, Richard Smith via cfe-commits
>  wrote:
> > Author: rsmith
> > Date: Tue Feb 14 22:18:23 2017
> > New Revision: 295149
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=295149&view=rev
> > Log:
> > Fix assertion failure due to implicit special member lookup lacking a
> source location.
> >
> > Modified:
> > cfe/trunk/lib/Sema/SemaLookup.cpp
> > cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaLookup.cpp?rev=295149&r1=295148&r2=295149&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Feb 14 22:18:23 2017
> > @@ -2838,6 +2838,9 @@ Sema::SpecialMemberOverloadResult *Sema:
> >  assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
> > "parameter-less special members can't have qualified
> arguments");
> >
> > +  // FIXME: Get the caller to pass in a location for the lookup.
> > +  SourceLocation LookupLoc = RD->getLocation();
> > +
> >llvm::FoldingSetNodeID ID;
> >ID.AddPointer(RD);
> >ID.AddInteger(SM);
> > @@ -2919,7 +2922,7 @@ Sema::SpecialMemberOverloadResult *Sema:
> >VK = VK_RValue;
> >}
> >
> > -  OpaqueValueExpr FakeArg(SourceLocation(), ArgType, VK);
> > +  OpaqueValueExpr FakeArg(LookupLoc, ArgType, VK);
> >
> >if (SM != CXXDefaultConstructor) {
> >  NumArgs = 1;
> > @@ -2933,13 +2936,13 @@ Sema::SpecialMemberOverloadResult *Sema:
> >if (VolatileThis)
> >  ThisTy.addVolatile();
> >Expr::Classification Classification =
> > -OpaqueValueExpr(SourceLocation(), ThisTy,
> > +OpaqueValueExpr(LookupLoc, ThisTy,
> >  RValueThis ? VK_RValue :
> VK_LValue).Classify(Context);
> >
> >// Now we perform lookup on the name we computed earlier and do
> overload
> >// resolution. Lookup is only performed directly into the class since
> there
> >// will always be a (possibly implicit) declaration to shadow any
> others.
> > -  OverloadCandidateSet OCS(RD->getLocation(), OverloadCandidateSet::CSK_
> Normal);
> > +  OverloadCandidateSet OCS(LookupLoc, OverloadCandidateSet::CSK_
> Normal);
> >DeclContext::lookup_result R = RD->lookup(Name);
> >
> >if (R.empty()) {
> > @@ -2994,7 +2997,7 @@ Sema::SpecialMemberOverloadResult *Sema:
> >}
> >
> >OverloadCandidateSet::iterator Best;
> > -  switch (OCS.BestViableFunction(*this, SourceLocation(), Best)) {
> > +  switch (OCS.BestViableFunction(*this, LookupLoc, Best)) {
> >  case OR_Success:
> >Result->setMethod(cast(Best->Function));
> >Result->setKind(SpecialMemberOverloadResult::Success);
> >
> > Modified: cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/cxx11-inheriting-ctors.cpp?rev=295149&r1=
> 295148&r2=295149&view=diff
> > 
> ==
> > --- cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp (original)
> > +++ cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp Tue Feb 14
> 22:18:23 2017
> > @@ -105,3 +105,31 @@ namespace PR31606 {
> >// Note, we do *not* allow operator=='s argument to use the inherited
> A::A(Base&&) constructor to construct from B{}.
> >bool b = A{} == B{}; // expected-error {{invalid operands}}
> >  }
> > +
> > +namespace implicit_member_srcloc {
> > +  template
> > +  struct S3 {
> > +  };
> > +
> > +  template
> > +  struct S2 {
> > +S2(S3 &&);
> > +  };
> > +
> > +  template
> > +  struct S1 : S2 {
> > +using S2::S2;
> > +S1();
> > +  };
> > +
> > +  template
> > +  struct S0 {
> > +S0();
> > +S0(S0&&) = default;
> > +S1 m1;
> > +  };
> > +
> > +  void foo1() {
> > +S0 s0;
> > +  }
> > +}
> >
> >
> > ___
> > 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


r295224 - PR24440: Do not silently discard a fold-expression appearing as the operand of a cast-expression.

2017-02-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 15 13:57:10 2017
New Revision: 295224

URL: http://llvm.org/viewvc/llvm-project?rev=295224&view=rev
Log:
PR24440: Do not silently discard a fold-expression appearing as the operand of 
a cast-expression.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=295224&r1=295223&r2=295224&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 15 13:57:10 2017
@@ -2409,7 +2409,7 @@ Parser::ParseParenExpression(ParenParseO
   // fold-expressions, we'll need to allow multiple ArgExprs here.
   if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
   NextToken().is(tok::ellipsis))
-return ParseFoldExpression(Result, T);
+return ParseFoldExpression(ArgExprs[0], T);
 
   ExprType = SimpleExpr;
   Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),

Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=295224&r1=295223&r2=295224&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Wed Feb 15 13:57:10 2017
@@ -1015,6 +1015,11 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
   CheckFoldOperand(*this, LHS);
   CheckFoldOperand(*this, RHS);
 
+  auto DiscardOperands = [&] {
+CorrectDelayedTyposInExpr(LHS);
+CorrectDelayedTyposInExpr(RHS);
+  };
+
   // [expr.prim.fold]p3:
   //   In a binary fold, op1 and op2 shall be the same fold-operator, and
   //   either e1 shall contain an unexpanded parameter pack or e2 shall contain
@@ -1022,6 +1027,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
   if (LHS && RHS &&
   LHS->containsUnexpandedParameterPack() ==
   RHS->containsUnexpandedParameterPack()) {
+DiscardOperands();
 return Diag(EllipsisLoc,
 LHS->containsUnexpandedParameterPack()
 ? diag::err_fold_expression_packs_both_sides
@@ -1035,6 +1041,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
   if (!LHS || !RHS) {
 Expr *Pack = LHS ? LHS : RHS;
 assert(Pack && "fold expression with neither LHS nor RHS");
+DiscardOperands();
 if (!Pack->containsUnexpandedParameterPack())
   return Diag(EllipsisLoc, 
diag::err_pack_expansion_without_parameter_packs)
  << Pack->getSourceRange();

Modified: cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp?rev=295224&r1=295223&r2=295224&view=diff
==
--- cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp (original)
+++ cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Wed Feb 15 13:57:10 2017
@@ -34,3 +34,12 @@ template int bad9() { return (
 template int bad10() { return (3 ? ... : N); } // expected-error 
+{{}} expected-note {{to match}}
 template int bad11() { return (N + ... 0); } // expected-error 
{{expected a foldable binary operator}} expected-error {{expected expression}}
 template int bad12() { return (... N); } // expected-error 
{{expected expression}}
+
+template void as_operand_of_cast(int a, T ...t) {
+  return
+(int)(a + ... + undeclared_junk) + // expected-error {{undeclared}} 
expected-error {{does not contain any unexpanded}}
+(int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
+(int)(... + undeclared_junk) + // expected-error {{undeclared}} 
expected-error {{does not contain any unexpanded}}
+(int)(undeclared_junk + ...) + // expected-error {{undeclared}}
+(int)(a + ...); // expected-error {{does not contain any unexpanded}}
+}


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


Re: r295150 - [Sema] Disallow returning a __block variable via a move.

2017-02-15 Thread Hans Wennborg via cfe-commits
+Richard for risk/reward analysis.

r274291 was also in 3.9, so this isn't strictly speaking a regression.

On Wed, Feb 15, 2017 at 11:43 AM, Akira Hatanaka  wrote:
> Hans,
>
> Can this be merged to 4.0 too?
>
>> On Feb 14, 2017, at 9:15 PM, Akira Hatanaka via cfe-commits 
>>  wrote:
>>
>> Author: ahatanak
>> Date: Tue Feb 14 23:15:28 2017
>> New Revision: 295150
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295150&view=rev
>> Log:
>> [Sema] Disallow returning a __block variable via a move.
>>
>> r274291 made changes to prefer calling a move constructor to calling a
>> copy constructor when returning from a function. This caused programs to
>> crash when a __block variable in the heap was moved out and used later.
>>
>> This commit fixes the bug by disallowing moving out of __block variables
>> implicitly.
>>
>> rdar://problem/28181080
>>
>> Differential Revision: https://reviews.llvm.org/D29908
>>
>> Modified:
>>cfe/trunk/lib/Sema/SemaStmt.cpp
>>cfe/trunk/test/SemaObjCXX/blocks.mm
>>
>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=295150&r1=295149&r2=295150&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Feb 14 23:15:28 2017
>> @@ -2743,15 +2743,17 @@ bool Sema::isCopyElisionCandidate(QualTy
>>   // ...automatic...
>>   if (!VD->hasLocalStorage()) return false;
>>
>> +  // Return false if VD is a __block variable. We don't want to implicitly 
>> move
>> +  // out of a __block variable during a return because we cannot assume the
>> +  // variable will no longer be used.
>> +  if (VD->hasAttr()) return false;
>> +
>>   if (AllowParamOrMoveConstructible)
>> return true;
>>
>>   // ...non-volatile...
>>   if (VD->getType().isVolatileQualified()) return false;
>>
>> -  // __block variables can't be allocated in a way that permits NRVO.
>> -  if (VD->hasAttr()) return false;
>> -
>>   // Variables with higher required alignment than their type's ABI
>>   // alignment cannot use NRVO.
>>   if (!VD->getType()->isDependentType() && VD->hasAttr() &&
>>
>> Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/blocks.mm?rev=295150&r1=295149&r2=295150&view=diff
>> ==
>> --- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
>> +++ cfe/trunk/test/SemaObjCXX/blocks.mm Tue Feb 14 23:15:28 2017
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
>> +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
>> -std=c++11 %s
>> @protocol NSObject;
>>
>> void bar(id(^)(void));
>> @@ -144,3 +144,17 @@ namespace DependentReturn {
>>
>>   template void f(X);
>> }
>> +
>> +namespace MoveBlockVariable {
>> +struct B0 {
>> +};
>> +
>> +struct B1 { // expected-note 2 {{candidate constructor (the implicit}}
>> +  B1(B0&&); // expected-note {{candidate constructor not viable}}
>> +};
>> +
>> +B1 test_move() {
>> +  __block B0 b;
>> +  return b; // expected-error {{no viable conversion from returned value of 
>> type 'MoveBlockVariable::B0' to function return type 
>> 'MoveBlockVariable::B1'}}
>> +}
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-15 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 88584.
twoh added a comment.

Make it explicit that the test doesn't support windows. @eric_niebler, my 
original intention was avoiding use of platform-dependent path separator, but 
now made it explicit that the test is not for windows, it should be okay to use 
'/'. Thanks for the comments!


https://reviews.llvm.org/D3

Files:
  lib/Lex/PPDirectives.cpp
  test/Lexer/case-insensitive-include-pr31836.sh


Index: test/Lexer/case-insensitive-include-pr31836.sh
===
--- /dev/null
+++ test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-SAME: /case-insensitive-include-pr31836.h
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :


Index: test/Lexer/case-insensitive-include-pr31836.sh
===
--- /dev/null
+++ test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+// UNSUPPORTED: system-windows
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 -E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-SAME: /case-insensitive-include-pr31836.h
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r295150 - [Sema] Disallow returning a __block variable via a move.

2017-02-15 Thread Akira Hatanaka via cfe-commits
Hans,

Can this be merged to 4.0 too?

> On Feb 14, 2017, at 9:15 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> Author: ahatanak
> Date: Tue Feb 14 23:15:28 2017
> New Revision: 295150
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=295150&view=rev
> Log:
> [Sema] Disallow returning a __block variable via a move.
> 
> r274291 made changes to prefer calling a move constructor to calling a
> copy constructor when returning from a function. This caused programs to
> crash when a __block variable in the heap was moved out and used later.
> 
> This commit fixes the bug by disallowing moving out of __block variables
> implicitly.
> 
> rdar://problem/28181080
> 
> Differential Revision: https://reviews.llvm.org/D29908
> 
> Modified:
>cfe/trunk/lib/Sema/SemaStmt.cpp
>cfe/trunk/test/SemaObjCXX/blocks.mm
> 
> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=295150&r1=295149&r2=295150&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Feb 14 23:15:28 2017
> @@ -2743,15 +2743,17 @@ bool Sema::isCopyElisionCandidate(QualTy
>   // ...automatic...
>   if (!VD->hasLocalStorage()) return false;
> 
> +  // Return false if VD is a __block variable. We don't want to implicitly 
> move
> +  // out of a __block variable during a return because we cannot assume the
> +  // variable will no longer be used.
> +  if (VD->hasAttr()) return false;
> +
>   if (AllowParamOrMoveConstructible)
> return true;
> 
>   // ...non-volatile...
>   if (VD->getType().isVolatileQualified()) return false;
> 
> -  // __block variables can't be allocated in a way that permits NRVO.
> -  if (VD->hasAttr()) return false;
> -
>   // Variables with higher required alignment than their type's ABI
>   // alignment cannot use NRVO.
>   if (!VD->getType()->isDependentType() && VD->hasAttr() &&
> 
> Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/blocks.mm?rev=295150&r1=295149&r2=295150&view=diff
> ==
> --- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
> +++ cfe/trunk/test/SemaObjCXX/blocks.mm Tue Feb 14 23:15:28 2017
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
> +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
> -std=c++11 %s
> @protocol NSObject;
> 
> void bar(id(^)(void));
> @@ -144,3 +144,17 @@ namespace DependentReturn {
> 
>   template void f(X);
> }
> +
> +namespace MoveBlockVariable {
> +struct B0 {
> +};
> +
> +struct B1 { // expected-note 2 {{candidate constructor (the implicit}}
> +  B1(B0&&); // expected-note {{candidate constructor not viable}}
> +};
> +
> +B1 test_move() {
> +  __block B0 b;
> +  return b; // expected-error {{no viable conversion from returned value of 
> type 'MoveBlockVariable::B0' to function return type 'MoveBlockVariable::B1'}}
> +}
> +}
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[PATCH] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-15 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/2437 is 
broken by this revision.


Repository:
  rL LLVM

https://reviews.llvm.org/D29886



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


Re: r295149 - Fix assertion failure due to implicit special member lookup lacking a source location.

2017-02-15 Thread Hans Wennborg via cfe-commits
IIUC, this is a follow-up to r291955, which was merged to 4.0. Should
this one be merged also?

Cheers,
Hans

On Tue, Feb 14, 2017 at 8:18 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Tue Feb 14 22:18:23 2017
> New Revision: 295149
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295149&view=rev
> Log:
> Fix assertion failure due to implicit special member lookup lacking a source 
> location.
>
> Modified:
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=295149&r1=295148&r2=295149&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Feb 14 22:18:23 2017
> @@ -2838,6 +2838,9 @@ Sema::SpecialMemberOverloadResult *Sema:
>  assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
> "parameter-less special members can't have qualified arguments");
>
> +  // FIXME: Get the caller to pass in a location for the lookup.
> +  SourceLocation LookupLoc = RD->getLocation();
> +
>llvm::FoldingSetNodeID ID;
>ID.AddPointer(RD);
>ID.AddInteger(SM);
> @@ -2919,7 +2922,7 @@ Sema::SpecialMemberOverloadResult *Sema:
>VK = VK_RValue;
>}
>
> -  OpaqueValueExpr FakeArg(SourceLocation(), ArgType, VK);
> +  OpaqueValueExpr FakeArg(LookupLoc, ArgType, VK);
>
>if (SM != CXXDefaultConstructor) {
>  NumArgs = 1;
> @@ -2933,13 +2936,13 @@ Sema::SpecialMemberOverloadResult *Sema:
>if (VolatileThis)
>  ThisTy.addVolatile();
>Expr::Classification Classification =
> -OpaqueValueExpr(SourceLocation(), ThisTy,
> +OpaqueValueExpr(LookupLoc, ThisTy,
>  RValueThis ? VK_RValue : VK_LValue).Classify(Context);
>
>// Now we perform lookup on the name we computed earlier and do overload
>// resolution. Lookup is only performed directly into the class since there
>// will always be a (possibly implicit) declaration to shadow any others.
> -  OverloadCandidateSet OCS(RD->getLocation(), 
> OverloadCandidateSet::CSK_Normal);
> +  OverloadCandidateSet OCS(LookupLoc, OverloadCandidateSet::CSK_Normal);
>DeclContext::lookup_result R = RD->lookup(Name);
>
>if (R.empty()) {
> @@ -2994,7 +2997,7 @@ Sema::SpecialMemberOverloadResult *Sema:
>}
>
>OverloadCandidateSet::iterator Best;
> -  switch (OCS.BestViableFunction(*this, SourceLocation(), Best)) {
> +  switch (OCS.BestViableFunction(*this, LookupLoc, Best)) {
>  case OR_Success:
>Result->setMethod(cast(Best->Function));
>Result->setKind(SpecialMemberOverloadResult::Success);
>
> Modified: cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp?rev=295149&r1=295148&r2=295149&view=diff
> ==
> --- cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp Tue Feb 14 22:18:23 2017
> @@ -105,3 +105,31 @@ namespace PR31606 {
>// Note, we do *not* allow operator=='s argument to use the inherited 
> A::A(Base&&) constructor to construct from B{}.
>bool b = A{} == B{}; // expected-error {{invalid operands}}
>  }
> +
> +namespace implicit_member_srcloc {
> +  template
> +  struct S3 {
> +  };
> +
> +  template
> +  struct S2 {
> +S2(S3 &&);
> +  };
> +
> +  template
> +  struct S1 : S2 {
> +using S2::S2;
> +S1();
> +  };
> +
> +  template
> +  struct S0 {
> +S0();
> +S0(S0&&) = default;
> +S1 m1;
> +  };
> +
> +  void foo1() {
> +S0 s0;
> +  }
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29778: Declare lgamma library builtins as never being const

2017-02-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: include/clang/Basic/Builtins.def:1091
+LIBBUILTIN(lgammaf, "ff", "fn", "math.h", ALL_LANGUAGES)
+LIBBUILTIN(lgammal, "LdLd", "fn", "math.h", ALL_LANGUAGES)
 

Please add a comment explaining why this doesn't have an "e" marking.


https://reviews.llvm.org/D29778



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


[PATCH] D30002: [clang-tidy] Fix handling of methods with try-statement as a body in modernize-use-override

2017-02-15 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode created this revision.
idlecode added a project: clang-tools-extra.
Herald added a subscriber: JDevlieghere.

Fix generated by modernize-use-override caused syntax error when method
used try-statement as a body. `override` keyword was inserted after last
declaration token which happened to be a `try` keyword.

This fixes PR27119.


https://reviews.llvm.org/D30002

Files:
  clang-tidy/modernize/UseOverrideCheck.cpp
  test/clang-tidy/modernize-use-override.cpp


Index: test/clang-tidy/modernize-use-override.cpp
===
--- test/clang-tidy/modernize-use-override.cpp
+++ test/clang-tidy/modernize-use-override.cpp
@@ -288,3 +288,17 @@
 };
 template <> void MembersOfSpecializations<3>::a() {}
 void ff() { MembersOfSpecializations<3>().a(); };
+
+// In case try statement is used as a method body,
+// make sure that override fix is placed before try keyword.
+struct TryStmtAsBody : public Base {
+  void a() try
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
+  // CHECK-FIXES: {{^}}  void a() override try
+  { b(); } catch(...) { c(); }
+
+  virtual void d() try
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void d() override try
+  { e(); } catch(...) { f(); }
+};
Index: clang-tidy/modernize/UseOverrideCheck.cpp
===
--- clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tidy/modernize/UseOverrideCheck.cpp
@@ -147,14 +147,13 @@
   // end of the declaration of the function, but prefer to put it on the
   // same line as the declaration if the beginning brace for the start of
   // the body falls on the next line.
-  Token LastNonCommentToken;
-  for (Token T : Tokens) {
-if (!T.is(tok::comment)) {
-  LastNonCommentToken = T;
-}
-  }
-  InsertLoc = LastNonCommentToken.getEndLoc();
   ReplacementText = " override";
+  auto LastTokenIter = std::prev(Tokens.end());
+  // When try statement is used instead of compound statement as
+  // method body - insert override keyword before it.
+  if (LastTokenIter->is(tok::kw_try))
+LastTokenIter = std::prev(LastTokenIter);
+  InsertLoc = LastTokenIter->getEndLoc();
 }
 
 if (!InsertLoc.isValid()) {


Index: test/clang-tidy/modernize-use-override.cpp
===
--- test/clang-tidy/modernize-use-override.cpp
+++ test/clang-tidy/modernize-use-override.cpp
@@ -288,3 +288,17 @@
 };
 template <> void MembersOfSpecializations<3>::a() {}
 void ff() { MembersOfSpecializations<3>().a(); };
+
+// In case try statement is used as a method body,
+// make sure that override fix is placed before try keyword.
+struct TryStmtAsBody : public Base {
+  void a() try
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
+  // CHECK-FIXES: {{^}}  void a() override try
+  { b(); } catch(...) { c(); }
+
+  virtual void d() try
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void d() override try
+  { e(); } catch(...) { f(); }
+};
Index: clang-tidy/modernize/UseOverrideCheck.cpp
===
--- clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tidy/modernize/UseOverrideCheck.cpp
@@ -147,14 +147,13 @@
   // end of the declaration of the function, but prefer to put it on the
   // same line as the declaration if the beginning brace for the start of
   // the body falls on the next line.
-  Token LastNonCommentToken;
-  for (Token T : Tokens) {
-if (!T.is(tok::comment)) {
-  LastNonCommentToken = T;
-}
-  }
-  InsertLoc = LastNonCommentToken.getEndLoc();
   ReplacementText = " override";
+  auto LastTokenIter = std::prev(Tokens.end());
+  // When try statement is used instead of compound statement as
+  // method body - insert override keyword before it.
+  if (LastTokenIter->is(tok::kw_try))
+LastTokenIter = std::prev(LastTokenIter);
+  InsertLoc = LastTokenIter->getEndLoc();
 }
 
 if (!InsertLoc.isValid()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-15 Thread Eric Niebler via Phabricator via cfe-commits
eric_niebler added a subscriber: karies.
eric_niebler added inline comments.



Comment at: lib/Lex/PPDirectives.cpp:1983
+  isLeadingSeparator = false;
+else
+  Path.append(Component);

What happens on Windows for an absolute path like "C:/hello/world.h", I wonder? 
Does this correctly generate the fixit? @karies?



Comment at: test/Lexer/case-insensitive-include-pr31836.sh:8
+// CHECK: warning: non-portable path to file
+// CHECK-NOT: Ccase-insensitive-include-pr31836.h
+// CHECK: {{$}}

@twoh I'm curious why you chose to check that the output was not a specific 
incorrect answer instead of checking that the output was the correct answer.


https://reviews.llvm.org/D3



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


[PATCH] D23421: [Clang-tidy] CERT-DCL58-CPP (checker for std namespace modification)

2017-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for working on this!


https://reviews.llvm.org/D23421



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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-15 Thread Taewook Oh via Phabricator via cfe-commits
twoh created this revision.

This is a patch for PR31836. As the bug replaces the path separators in the 
included file name with the characters following them, the test script makes 
sure that there's no "Ccase-insensitive-include-pr31836.h" in the warning 
message.


https://reviews.llvm.org/D3

Files:
  lib/Lex/PPDirectives.cpp
  test/Lexer/case-insensitive-include-pr31836.sh


Index: test/Lexer/case-insensitive-include-pr31836.sh
===
--- /dev/null
+++ test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-NOT: Ccase-insensitive-include-pr31836.h
+// CHECK: {{$}}
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :


Index: test/Lexer/case-insensitive-include-pr31836.sh
===
--- /dev/null
+++ test/Lexer/case-insensitive-include-pr31836.sh
@@ -0,0 +1,9 @@
+// REQUIRES: case-insensitive-filesystem
+
+// RUN: mkdir -p %T
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 -E - 2>&1 | FileCheck %s
+
+// CHECK: warning: non-portable path to file
+// CHECK-NOT: Ccase-insensitive-include-pr31836.h
+// CHECK: {{$}}
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1976,8 +1976,12 @@
   SmallString<128> Path;
   Path.reserve(Name.size()+2);
   Path.push_back(isAngled ? '<' : '"');
+  bool isLeadingSeparator = llvm::sys::path::is_absolute(Name);
   for (auto Component : Components) {
-Path.append(Component);
+if (isLeadingSeparator)
+  isLeadingSeparator = false;
+else
+  Path.append(Component);
 // Append the separator the user used, or the close quote
 Path.push_back(
   Path.size() <= Filename.size() ? Filename[Path.size()-1] :
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r294431 - [test] Fix hard_link_count test to account for fs with dir nlink==1

2017-02-15 Thread Hans Wennborg via cfe-commits
Michal requested this to be merged in PR31965, it seems fine to me,
and Marshall OK'd it in an email to me. Merged in r295214.

On Wed, Feb 8, 2017 at 1:57 AM, Michal Gorny via cfe-commits
 wrote:
> Author: mgorny
> Date: Wed Feb  8 03:57:32 2017
> New Revision: 294431
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294431&view=rev
> Log:
> [test] Fix hard_link_count test to account for fs with dir nlink==1
>
> Filesystems are not required to maintain a hard link count consistent
> with number of subdirectories. For example, on btrfs all directories
> have nlink==1. Account for that in the test.
>
> Differential Revision: https://reviews.llvm.org/D29706
>
> Modified:
> 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
>
> Modified: 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp?rev=294431&r1=294430&r2=294431&view=diff
> ==
> --- 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
>  Wed Feb  8 03:57:32 2017
> @@ -57,15 +57,19 @@ TEST_CASE(hard_link_count_for_directory)
>  Dir3Expect = 3; // .  ..  file5
>  #endif
>  TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
> -   hard_link_count(StaticEnv::Dir) == DirExpectAlt);
> +   hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
> +   hard_link_count(StaticEnv::Dir) == 1);
>  TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
> -   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt);
> +   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
> +   hard_link_count(StaticEnv::Dir3) == 1);
>
>  std::error_code ec;
>  TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
> -   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt);
> +   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
> +   hard_link_count(StaticEnv::Dir) == 1);
>  TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
> -   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt);
> +   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
> +   hard_link_count(StaticEnv::Dir3) == 1);
>  }
>  TEST_CASE(hard_link_count_increments_test)
>  {
>
>
> ___
> 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


[libcxx] r295214 - Merging r294431:

2017-02-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb 15 12:40:52 2017
New Revision: 295214

URL: http://llvm.org/viewvc/llvm-project?rev=295214&view=rev
Log:
Merging r294431:

r294431 | mgorny | 2017-02-08 01:57:32 -0800 (Wed, 08 Feb 2017) | 7 lines

[test] Fix hard_link_count test to account for fs with dir nlink==1

Filesystems are not required to maintain a hard link count consistent
with number of subdirectories. For example, on btrfs all directories
have nlink==1. Account for that in the test.

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


Modified:
libcxx/branches/release_40/   (props changed)

libcxx/branches/release_40/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp

Propchange: libcxx/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 15 12:40:52 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:292013,292091,292607,292990,293154,293197,293581,294133,294142
+/libcxx/trunk:292013,292091,292607,292990,293154,293197,293581,294133,294142,294431

Modified: 
libcxx/branches/release_40/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp?rev=295214&r1=295213&r2=295214&view=diff
==
--- 
libcxx/branches/release_40/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
 (original)
+++ 
libcxx/branches/release_40/test/std/experimental/filesystem/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
 Wed Feb 15 12:40:52 2017
@@ -57,15 +57,19 @@ TEST_CASE(hard_link_count_for_directory)
 Dir3Expect = 3; // .  ..  file5
 #endif
 TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
-   hard_link_count(StaticEnv::Dir) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 
 std::error_code ec;
 TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
-   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt);
+   hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
+   hard_link_count(StaticEnv::Dir) == 1);
 TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
-   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt);
+   hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
+   hard_link_count(StaticEnv::Dir3) == 1);
 }
 TEST_CASE(hard_link_count_increments_test)
 {


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


[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2017-02-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 88575.

Repository:
  rL LLVM

https://reviews.llvm.org/D26654

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake

Index: cmake/caches/Fuchsia.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia.cmake
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,64 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;AArch64 CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+endif()
+
+#set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
+
+#set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  lldb
+  LTO
+  clang-format
+  clang-headers
+  builtins-x86_64-fuchsia-none
+  builtins-aarch64-fuchsia-none
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29990: [clangd] Implement format on type

2017-02-15 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: clangd/ProtocolHandlers.cpp:117
+  // starting from there.
+  StringRef Code = Store.getDocument(DOTFP->textDocument.uri);
+  size_t CursorPos = positionToOffset(Code, DOTFP->position);

This should be a std::string in trunk, StringRef gives you a use after free.



Comment at: clangd/ProtocolHandlers.cpp:119
+  size_t CursorPos = positionToOffset(Code, DOTFP->position);
+  size_t PreviousLBracePos = Code.find_last_of("{", CursorPos);
+  if (PreviousLBracePos == StringRef::npos)

nit: use the character overload of this function (`Code.find_last_of('{'...`)


https://reviews.llvm.org/D29990



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


[clang-tools-extra] r295207 - [clang-tidy] Fix test modernize-return-braced-init-list

2017-02-15 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Feb 15 11:37:58 2017
New Revision: 295207

URL: http://llvm.org/viewvc/llvm-project?rev=295207&view=rev
Log:
[clang-tidy] Fix test modernize-return-braced-init-list

Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp?rev=295207&r1=295206&r2=295207&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp 
Wed Feb 15 11:37:58 2017
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
-// -std=c++14
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- -- 
-std=c++14
 
 namespace std {
 typedef decltype(sizeof(int)) size_t;


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


[clang-tools-extra] r295205 - Fixed indentation issue in release notes

2017-02-15 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Feb 15 11:19:44 2017
New Revision: 295205

URL: http://llvm.org/viewvc/llvm-project?rev=295205&view=rev
Log:
Fixed indentation issue in release notes

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=295205&r1=295204&r2=295205&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Feb 15 11:19:44 2017
@@ -68,7 +68,7 @@ Improvements to clang-tidy
   Finds uses of inline assembler.
 
 - New `modernize-return-braced-init-list
-
`_
 check
+  
`_
 check
 
   Finds and replaces explicit calls to the constructor in a return statement by
   a braced initializer list so that the return type is not needlessly repeated.


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


[libunwind] r295202 - Revert "[libunwind][CMake] Use libc++ headers when available"

2017-02-15 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Feb 15 11:15:41 2017
New Revision: 295202

URL: http://llvm.org/viewvc/llvm-project?rev=295202&view=rev
Log:
Revert "[libunwind][CMake] Use libc++ headers when available"

This causing build failure on sanitizer bots because of the unused
argument '-nostdinc++' during linking of libunwind.

This reverts commit 0e14fd1a1d37b9c6d55a2d3bc7649e5b39ce74d3.

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=295202&r1=295201&r2=295202&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Feb 15 11:15:41 2017
@@ -282,24 +282,4 @@ endif()
 
 include_directories(include)
 
-find_path(
-  LIBUNWIND_LIBCXX_INCLUDES_INTERNAL
-  __libcpp_version
-  PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
-${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
-  NO_DEFAULT_PATH
-)
-if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
-IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
-  set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
-endif()
-
-set(LIBUNWIND_CXX_INCLUDE_PATHS "${LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT}" CACHE 
PATH
-"Paths to C++ header directories separated by ';'.")
-
-if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STREQUAL "")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
-  include_directories("${LIBUNWIND_CXX_INCLUDE_PATHS}")
-endif()
-
 add_subdirectory(src)


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


[PATCH] D29032: [mips] Define macros related to -mabicalls in the preprocessor

2017-02-15 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ok, I'll have `__mips_abicalls` unconditionally defined for everyone, The other 
two BSD's will have the traditional macro defined as well.


https://reviews.llvm.org/D29032



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


[clang-tools-extra] r295199 - [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-02-15 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Wed Feb 15 11:06:06 2017
New Revision: 295199

URL: http://llvm.org/viewvc/llvm-project?rev=295199&view=rev
Log:
[clang-tidy] Add check 'modernize-return-braced-init-list'

Summary:
Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
return type and the return statement.

```
Foo bar() {
  Baz baz;
  return Foo(baz);
}

// transforms to:

Foo bar() {
  Baz baz;
  return {baz};
}
```

Reviewers: hokein, Prazek, aaron.ballman, alexfh

Reviewed By: Prazek, aaron.ballman, alexfh

Subscribers: malcolm.parsons, mgorny, cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-return-braced-init-list.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=295199&r1=295198&r2=295199&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 15 
11:06:06 2017
@@ -13,6 +13,7 @@ add_clang_library(clangTidyModernizeModu
   RawStringLiteralCheck.cpp
   RedundantVoidArgCheck.cpp
   ReplaceAutoPtrCheck.cpp
+  ReturnBracedInitListCheck.cpp
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=295199&r1=295198&r2=295199&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Wed 
Feb 15 11:06:06 2017
@@ -19,6 +19,7 @@
 #include "RawStringLiteralCheck.h"
 #include "RedundantVoidArgCheck.h"
 #include "ReplaceAutoPtrCheck.h"
+#include "ReturnBracedInitListCheck.h"
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
@@ -53,6 +54,8 @@ public:
 "modernize-redundant-void-arg");
 CheckFactories.registerCheck(
 "modernize-replace-auto-ptr");
+CheckFactories.registerCheck(
+"modernize-return-braced-init-list");
 CheckFactories.registerCheck("modernize-shrink-to-fit");
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp?rev=295199&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ReturnBracedInitListCheck.cpp 
Wed Feb 15 11:06:06 2017
@@ -0,0 +1,97 @@
+//===--- ReturnBracedInitListCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ReturnBracedInitListCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) {
+  // Only register the matchers for C++.
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  // Skip list initialization and constructors with an initializer list.
+  auto ConstructExpr =
+  cxxConstructExpr(
+  unless(anyOf(hasDeclaration(cxxConstructorDecl(isExplicit())),
+   isListInitialization(), hasDescendant(initListExpr()),
+   isInTemplateInstantiation(
+  .bind("ctor");
+
+  auto CtorAsArgument = materializeTemporaryExpr(anyOf(
+  has(ConstructExpr), has(cxxFunctionalCastExpr(has(ConstructExpr);
+
+  Finder->addMatc

[clang-tools-extra] r295198 - [clangd] Fix another use after free that I missed because COW strings.

2017-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Feb 15 11:04:57 2017
New Revision: 295198

URL: http://llvm.org/viewvc/llvm-project?rev=295198&view=rev
Log:
[clangd] Fix another use after free that I missed because COW strings.

Modified:
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=295198&r1=295197&r2=295198&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Wed Feb 15 11:04:57 2017
@@ -113,7 +113,7 @@ void TextDocumentFormattingHandler::hand
   }
 
   // Format everything.
-  StringRef Code = Store.getDocument(DFP->textDocument.uri);
+  std::string Code = Store.getDocument(DFP->textDocument.uri);
   writeMessage(formatCode(Code, DFP->textDocument.uri,
   {clang::tooling::Range(0, Code.size())}, ID));
 }


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


[clang-tools-extra] r295196 - [clangd] Silence GCC warning about falling off a fully covered switch.

2017-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Feb 15 10:58:44 2017
New Revision: 295196

URL: http://llvm.org/viewvc/llvm-project?rev=295196&view=rev
Log:
[clangd] Silence GCC warning about falling off a fully covered switch.

Modified:
clang-tools-extra/trunk/clangd/ASTManager.cpp

Modified: clang-tools-extra/trunk/clangd/ASTManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ASTManager.cpp?rev=295196&r1=295195&r2=295196&view=diff
==
--- clang-tools-extra/trunk/clangd/ASTManager.cpp (original)
+++ clang-tools-extra/trunk/clangd/ASTManager.cpp Wed Feb 15 10:58:44 2017
@@ -51,6 +51,7 @@ static int getSeverity(DiagnosticsEngine
   case DiagnosticsEngine::Ignored:
 return 0;
   }
+  llvm_unreachable("Unknown diagnostic level!");
 }
 
 ASTManager::ASTManager(JSONOutput &Output, DocumentStore &Store)


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


[PATCH] D29599: Clang Changes for alloc_align

2017-02-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ah, I see!  Sorry for missing that.  I don't see a reason why we cannot support 
that, but I wasn't really considering it.  In general, this attribute is a 
compiler hint for some C standard library stuff in glibc.

I've been playing with it a few hours now, and it seems that GCC ONLY complains 
about the attribute parameter being in range (same error for the type of the 
parameter as well!), so we DO a bit extra SEMA here, though I think that is 
correct.  I'll dig into this a bit more and see if I can get the template 
return type working correctly.


https://reviews.llvm.org/D29599



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


[clang-tools-extra] r295194 - [clangd] Synchronize logs access.

2017-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Feb 15 10:44:11 2017
New Revision: 295194

URL: http://llvm.org/viewvc/llvm-project?rev=295194&view=rev
Log:
[clangd] Synchronize logs access.

I don't think that this is necessary for correctness, but makes tsan
much more useful.

Modified:
clang-tools-extra/trunk/clangd/ASTManager.cpp
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/ASTManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ASTManager.cpp?rev=295194&r1=295193&r2=295194&view=diff
==
--- clang-tools-extra/trunk/clangd/ASTManager.cpp (original)
+++ clang-tools-extra/trunk/clangd/ASTManager.cpp Wed Feb 15 10:44:11 2017
@@ -150,7 +150,7 @@ ASTManager::getOrCreateCompilationDataba
 
   std::string Error;
   I = tooling::CompilationDatabase::autoDetectFromSource(Uri, Error);
-  Output.logs() << "Failed to load compilation database: " << Error << '\n';
+  Output.log("Failed to load compilation database: " + Twine(Error) + "\n");
   return I.get();
 }
 

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=295194&r1=295193&r2=295194&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Wed Feb 15 10:44:11 2017
@@ -88,12 +88,11 @@ int main(int argc, char *argv[]) {
 if (Len > 0) {
   llvm::StringRef JSONRef(JSON.data(), Len);
   // Log the message.
-  Logs << "<-- " << JSONRef << '\n';
-  Logs.flush();
+  Out.log("<-- " + JSONRef + "\n");
 
   // Finally, execute the action for this JSON message.
   if (!Dispatcher.call(JSONRef))
-Logs << "JSON dispatch failed!\n";
+Out.log("JSON dispatch failed!\n");
 
   // If we're done, exit the loop.
   if (ShutdownHandler->isDone())

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=295194&r1=295193&r2=295194&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Wed Feb 15 10:44:11 
2017
@@ -29,8 +29,14 @@ void JSONOutput::writeMessage(const Twin
   Outs.flush();
 }
 
+void JSONOutput::log(const Twine &Message) {
+  std::lock_guard Guard(StreamMutex);
+  Logs << Message;
+  Logs.flush();
+}
+
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
-  Output.logs() << "Method ignored.\n";
+  Output.log("Method ignored.\n");
   // Return that this method is unsupported.
   writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
@@ -38,7 +44,7 @@ void Handler::handleMethod(llvm::yaml::M
 }
 
 void Handler::handleNotification(llvm::yaml::MappingNode *Params) {
-  Output.logs() << "Notification ignored.\n";
+  Output.log("Notification ignored.\n");
 }
 
 void JSONRPCDispatcher::registerHandler(StringRef Method,

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=295194&r1=295193&r2=295194&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Wed Feb 15 10:44:11 2017
@@ -28,8 +28,8 @@ public:
   /// Emit a JSONRPC message.
   void writeMessage(const Twine &Message);
 
-  /// Get the logging stream.
-  llvm::raw_ostream &logs() { return Logs; }
+  /// Write to the logging stream.
+  void log(const Twine &Message);
 
 private:
   llvm::raw_ostream &Outs;

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=295194&r1=295193&r2=295194&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Wed Feb 15 10:44:11 2017
@@ -17,7 +17,7 @@ void TextDocumentDidOpenHandler::handleN
 llvm::yaml::MappingNode *Params) {
   auto DOTDP = DidOpenTextDocumentParams::parse(Params);
   if (!DOTDP) {
-Output.logs() << "Failed to decode DidOpenTextDocumentParams!\n";
+Output.log("Failed to decode DidOpenTextDocumentParams!\n");
 return;
   }
   Store.addDocument(DOTDP->textDocument.uri, DOTDP->textDocument.text);
@@ -27,7 +27,7 @@ void TextDocumentDidChangeHandler::handl
 llvm::yaml::Mapp

[clang-tools-extra] r295193 - [clangd] Initialize the thread after the mutex.

2017-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Feb 15 10:34:58 2017
New Revision: 295193

URL: http://llvm.org/viewvc/llvm-project?rev=295193&view=rev
Log:
[clangd] Initialize the thread after the mutex.

Otherwise locking the mutex yields a racy assertion failure on picky
implementations.

Modified:
clang-tools-extra/trunk/clangd/ASTManager.h

Modified: clang-tools-extra/trunk/clangd/ASTManager.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ASTManager.h?rev=295193&r1=295192&r2=295193&view=diff
==
--- clang-tools-extra/trunk/clangd/ASTManager.h (original)
+++ clang-tools-extra/trunk/clangd/ASTManager.h Wed Feb 15 10:34:58 2017
@@ -57,9 +57,6 @@ private:
   CompilationDatabases;
   std::shared_ptr PCHs;
 
-  /// We run parsing on a separate thread. This thread looks into 
PendingRequest
-  /// as a 'one element work queue' as long as RequestIsPending is true.
-  std::thread ClangWorker;
   /// Queue of requests.
   std::deque RequestQueue;
   /// Setting Done to true will make the worker thread terminate.
@@ -68,6 +65,10 @@ private:
   std::condition_variable ClangRequestCV;
   /// Lock for accesses to RequestQueue and Done.
   std::mutex RequestLock;
+
+  /// We run parsing on a separate thread. This thread looks into 
PendingRequest
+  /// as a 'one element work queue' as the queue is non-empty.
+  std::thread ClangWorker;
 };
 
 } // namespace clangd


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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-02-15 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 88550.
JDevlieghere added a comment.

Fixed latest comment from @aaron.ballman before landing.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,199 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
+// -std=c++14
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+// libc++'s implementation
+template 
+class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b),
+__size_(__s) {}
+
+public:
+  typedef _E value_type;
+  typedef const _E &reference;
+  typedef const _E &const_reference;
+  typedef size_t size_type;
+
+  typedef const _E *iterator;
+  typedef const _E *const_iterator;
+
+  initializer_list() : __begin_(nullptr), __size_(0) {}
+
+  size_t size() const { return __size_; }
+  const _E *begin() const { return __begin_; }
+  const _E *end() const { return __begin_ + __size_; }
+};
+
+template 
+class vector {
+public:
+  vector(T) {}
+  vector(std::initializer_list) {}
+};
+}
+
+class Bar {};
+
+Bar b0;
+
+class Foo {
+public:
+  Foo(Bar) {}
+  explicit Foo(Bar, unsigned int) {}
+  Foo(unsigned int) {}
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar bm;
+return Foo(bm);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
+// CHECK-FIXES: return {bm};
+  }
+};
+
+class Quux : public Foo {
+public:
+  Quux(Bar bar) : Foo(bar) {}
+  Quux(unsigned, unsigned, unsigned k = 0) : Foo(k) {}
+};
+
+Foo f() {
+  Bar b1;
+  return Foo(b1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {b1};
+}
+
+Foo f2() {
+  Bar b2;
+  return {b2};
+}
+
+auto f3() {
+  Bar b3;
+  return Foo(b3);
+}
+
+#define A(b) Foo(b)
+
+Foo f4() {
+  Bar b4;
+  return A(b4);
+}
+
+Foo f5() {
+  Bar b5;
+  return Quux(b5);
+}
+
+Foo f6() {
+  Bar b6;
+  return Foo(b6, 1);
+}
+
+std::vector f7() {
+  int i7 = 1;
+  return std::vector(i7);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+}
+
+Bar f8() {
+  return {};
+}
+
+Bar f9() {
+  return Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+}
+
+Bar f10() {
+  return Bar{};
+}
+
+Foo f11(Bar b11) {
+  return Foo(b11);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {b11};
+}
+
+Foo f12() {
+  return f11(Bar());
+}
+
+Foo f13() {
+  return Foo(Bar()); // 13
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {Bar()}; // 13
+}
+
+Foo f14() {
+  // FIXME: Type narrowing should not occur!
+  return Foo(-1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {-1};
+}
+
+Foo f15() {
+  return Foo(f10());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {f10()};
+}
+
+Quux f16() {
+  return Quux(1, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {1, 2};
+}
+
+Quux f17() {
+  return Quux(1, 2, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
+  // CHECK-FIXES: return {1, 2, 3};
+}
+
+template 
+T f19() {
+  return T();
+}
+
+Bar i1 = f19();
+Baz i2 = f19();
+
+template 
+Foo f20(T t) {
+  return Foo(t);
+}
+
+Foo i3 = f20(b0);
+
+template 
+class BazT {
+public:
+  T m() {
+Bar b;
+return T(b);
+  }
+
+  Foo m2(T t) {
+return Foo(t);
+  }
+};
+
+BazT bazFoo;
+Foo i4 = bazFoo.m();
+Foo i5 = bazFoo.m2(b0);
+
+BazT bazQuux;
+Foo i6 = bazQuux.m();
+Foo i7 = bazQuux.m2(b0);
+
+auto v1 = []() { return std::vector({1, 2}); }();
+auto v2 = []() -> std::vector { return std::vector({1, 2}); }();
Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-return-braced-init-list.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - modernize-return-braced-init-list
+
+modernize-return-braced-init-list
+=
+
+Replaces explicit calls to the constructor in a return with a braced
+initializer list. This way the return type is not n

[clang-tools-extra] r295192 - [clang-tidy] Don't delay parsing of templates in test for misc-unconventional-assign-operator

2017-02-15 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Feb 15 10:32:55 2017
New Revision: 295192

URL: http://llvm.org/viewvc/llvm-project?rev=295192&view=rev
Log:
[clang-tidy] Don't delay parsing of templates in test for 
misc-unconventional-assign-operator

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp?rev=295192&r1=295191&r2=295192&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
Wed Feb 15 10:32:55 2017
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
 
 namespace std {
 template 


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


[PATCH] D29884: [analyzer] Proper caching in CallDescription objects.

2017-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:73
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 

xazax.hun wrote:
> NoQ wrote:
> > Maybe `assert(FuncName.size() > 0)` here?
> Oh, I see now. Yeah, that would make sense :) Do you want me to commit that 
> or will you?
Because C++ checkers are receiving a lot of attention recently, i'd probably be 
looking into modifying this class to work with qualified names and overloads. 
You can commit though if you want it sooner :)


Repository:
  rL LLVM

https://reviews.llvm.org/D29884



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


r295191 - [index] USR generation: use getTemplateArgs() instead of getTemplateInstantiationArgs()

2017-02-15 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Wed Feb 15 10:16:27 2017
New Revision: 295191

URL: http://llvm.org/viewvc/llvm-project?rev=295191&view=rev
Log:
[index] USR generation: use getTemplateArgs() instead of 
getTemplateInstantiationArgs()

Otherwise we may end up creating a different USR for the definition of a 
function, vs its declaration.

Modified:
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=295191&r1=295190&r2=295191&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Wed Feb 15 10:16:27 2017
@@ -310,7 +310,7 @@ void USRGenerator::VisitVarDecl(const Va
   // For a template specialization, mangle the template arguments.
   if (const VarTemplateSpecializationDecl *Spec
   = dyn_cast(D)) {
-const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs();
+const TemplateArgumentList &Args = Spec->getTemplateArgs();
 Out << '>';
 for (unsigned I = 0, N = Args.size(); I != N; ++I) {
   Out << '#';
@@ -521,7 +521,7 @@ void USRGenerator::VisitTagDecl(const Ta
   // For a class template specialization, mangle the template arguments.
   if (const ClassTemplateSpecializationDecl *Spec
   = dyn_cast(D)) {
-const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs();
+const TemplateArgumentList &Args = Spec->getTemplateArgs();
 Out << '>';
 for (unsigned I = 0, N = Args.size(); I != N; ++I) {
   Out << '#';

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=295191&r1=295190&r2=295191&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Wed Feb 15 10:16:27 2017
@@ -23,6 +23,16 @@ public:
 TemplCls gtv(0);
 // CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | 
 | Ref,RelCont | rel: 1
 
+template
+class Wrapper {};
+template
+class Wrapper {};
+
+// CHECK: [[@LINE+1]]:6 | function/C | test1 | [[TEST1_USR:.*]] | 
[[TEST1_CG:.*]] | Decl | rel: 0
+void test1(Wrapper f);
+// CHECK: [[@LINE+1]]:6 | function/C | test1 | [[TEST1_USR]] | [[TEST1_CG]] | 
Def | rel: 0
+void test1(Wrapper f) {}
+
 template 
 class BT {
   struct KLR {


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


[PATCH] D29884: [analyzer] Proper caching in CallDescription objects.

2017-02-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:73
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 

NoQ wrote:
> Maybe `assert(FuncName.size() > 0)` here?
Oh, I see now. Yeah, that would make sense :) Do you want me to commit that or 
will you?


Repository:
  rL LLVM

https://reviews.llvm.org/D29884



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


[PATCH] D29884: [analyzer] Proper caching in CallDescription objects.

2017-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:73
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 

Maybe `assert(FuncName.size() > 0)` here?


Repository:
  rL LLVM

https://reviews.llvm.org/D29884



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


[PATCH] D29884: [analyzer] Proper caching in CallDescription objects.

2017-02-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D29884#677387, @NoQ wrote:

> Yep, seems that somebody has missed these issues :)
>
> I guess there's no way to test the operator case, because nobody made a 
> CallDescription with an empty name for us (maybe we should even assert that).


Thank you for the review! :) Unfortunately, I did not get where would you put 
that assert. But in case you think it is important, I would be happy to review 
a patch :)


Repository:
  rL LLVM

https://reviews.llvm.org/D29884



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


[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:54
+// FIXME use DiagnosticIDs::Level::Note
+diag(NoExceptRange.getBegin(), "in a function declared no-throw here:", 
DiagnosticIDs::Note)
+<< FixItHint::CreateRemoval(NoExceptRange);

Prazek wrote:
> sbarzowski wrote:
> > Prazek wrote:
> > > sbarzowski wrote:
> > > > alexfh wrote:
> > > > > nit: `nothrow` (without a dash), no colon needed (it will look weird, 
> > > > > since the location is mentioned _before_ the message, not after it)
> > > > No, it's after the message now. When I changed the level to note the 
> > > > order of messages changed as well.
> > > > 
> > > > It looks like that:
> > > > ```
> > > > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:5:5:
> > > >  warning: 'throw' expression in a function declared with a non-throwing 
> > > > exception specification [misc-throw-with-noexcept]
> > > > throw 5;
> > > > ^
> > > > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
> > > >  note: FIX-IT applied suggested code changes
> > > > void f_throw_with_ne() noexcept(true) {
> > > >^
> > > > /Users/uland/clang-new/build/tools/clang/tools/extra/test/clang-tidy/Output/misc-throw-with-noexcept.cpp.tmp.cpp:3:24:
> > > >  note: in a function declared nothrow here:
> > > > void f_throw_with_ne() noexcept(true) {
> > > >^
> > > > 
> > > > ```
> > > > 
> > > > So, should I leave the colon or remove it anyway?
> > > I think that the best way would be to have warnings in order:
> > > 
> > > warning function declared nothrow here have throw statement inside:
> > > Note: throw statement here
> > > 
> > > Note: Fixit applied for every other declaration
> > > 
> > > What do you think Alex?
> > > 
> > > 
> > > 
> > @Prazek 
> > So, do you suggest that we don't emit anything for additional declarations 
> > (without -fix)?
> > 
> > BTW (in the current version) I don't know if I can control if FIX-IT goes 
> > first or the location message. As you can see in the code the FIX-IT goes 
> > after the location.
> Yep, there is no need for user to know all the locations if he doesn't want 
> to perform fixit. This way it is easier to read the warning.
The `FIX-IT applied suggested code changes` notes are shown by clang-tidy 
itself and only when the user passes -fix flag. There's no way to control them 
from the check (apart from removing fixes or attaching them to a different 
warning).


https://reviews.llvm.org/D19201



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


[PATCH] D23421: [Clang-tidy] CERT-DCL58-CPP (checker for std namespace modification)

2017-02-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 88541.
xazax.hun added a comment.

- Do not warn for function specializations within the std namespace.
- Add a test case for swap.


https://reviews.llvm.org/D23421

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
  clang-tidy/cert/DontModifyStdNamespaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl58-cpp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/Headers/system.h
  test/clang-tidy/cert-dcl58-cpp.cpp

Index: test/clang-tidy/cert-dcl58-cpp.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-dcl58-cpp.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s cert-dcl58-cpp %t -- -- -std=c++1z -I %S/Inputs/Headers
+
+#include "system.h"
+
+namespace A {
+  namespace B {
+int b;
+  }
+}
+
+namespace A {
+  namespace B {
+int c;
+  }
+}
+
+namespace posix {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'posix' namespace can result in undefined behavior [cert-dcl58-cpp]
+  namespace vmi {
+  }
+}
+
+namespace std {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'std' namespace can
+  int stdInt;
+}
+
+namespace foobar {
+  namespace std {
+int bar;
+  }
+}
+
+namespace posix::a {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'posix' namespace 
+}
+
+enum class MyError {
+  ErrorA,
+  ErrorB
+};
+
+namespace std {
+template <>
+struct is_error_code_enum : std::true_type {};
+
+template<>
+void swap(MyError &a, MyError &b);
+}
+
+enum class MyError2 {
+  Error2A,
+  Error2B
+};
+
+namespace std {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: modification of 'std' namespace 
+template <>
+struct is_error_code_enum : std::true_type {};
+
+int foobar;
+}
+
+using namespace std;
+
+int x;
+
Index: test/clang-tidy/Inputs/Headers/system.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/Headers/system.h
@@ -0,0 +1,24 @@
+#pragma clang system_header
+
+namespace std {
+
+template
+struct integral_constant {
+static constexpr T value = v;
+typedef T value_type;
+typedef integral_constant type;
+constexpr operator value_type() const noexcept { return value; }
+};
+
+template 
+using bool_constant = integral_constant;
+using true_type = bool_constant;
+using false_type = bool_constant;
+
+template
+struct is_error_code_enum : false_type {};
+
+template
+void swap(T &a, T &b);
+}
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -8,6 +8,7 @@
cert-dcl03-c (redirects to misc-static-assert) 
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
+   cert-dcl58-cpp
cert-dcl59-cpp (redirects to google-build-namespaces) 
cert-env33-c
cert-err09-cpp (redirects to misc-throw-by-value-catch-by-reference) 
Index: docs/clang-tidy/checks/cert-dcl58-cpp.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-dcl58-cpp.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - cert-dcl58-cpp
+
+cert-dcl58-cpp
+==
+
+Modification of the ``std`` or ``posix`` namespace can result in undefined
+behavior.
+This check warns for such modifications.
+
+Examples:
+
+.. code-block:: c++
+
+  namespace std {
+int x; // May cause undefined behavior.
+  }
+
+
+This check corresponds to the CERT C++ Coding Standard rule
+`DCL58-CPP. Do not modify the standard namespaces
+`_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `cert-dcl58-cpp
+  `_ check
+
+  Finds modification of the ``std`` or ``posix`` namespace.
+
 - New `safety-no-assembler
   `_ check
 
Index: clang-tidy/cert/DontModifyStdNamespaceCheck.h
===
--- /dev/null
+++ clang-tidy/cert/DontModifyStdNamespaceCheck.h
@@ -0,0 +1,36 @@
+//===--- DontModifyStdNamespaceCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
+
+

[clang-tools-extra] r295187 - [clangd] Fix use after free.

2017-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Feb 15 09:56:14 2017
New Revision: 295187

URL: http://llvm.org/viewvc/llvm-project?rev=295187&view=rev
Log:
[clangd] Fix use after free.

Modified:
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=295187&r1=295186&r2=295187&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Wed Feb 15 09:56:14 2017
@@ -95,7 +95,7 @@ void TextDocumentRangeFormattingHandler:
 return;
   }
 
-  StringRef Code = Store.getDocument(DRFP->textDocument.uri);
+  std::string Code = Store.getDocument(DRFP->textDocument.uri);
 
   size_t Begin = positionToOffset(Code, DRFP->range.start);
   size_t Len = positionToOffset(Code, DRFP->range.end) - Begin;


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


[PATCH] D29884: [analyzer] Proper caching in CallDescription objects.

2017-02-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295186: [analyzer] Proper caching in CallDescription 
objects. (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D29884?vs=88166&id=88537#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29884

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -212,9 +212,12 @@
 
 bool CallEvent::isCalled(const CallDescription &CD) const {
   assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
-  if (!CD.II)
+  if (!CD.IsLookupDone) {
+CD.IsLookupDone = true;
 CD.II = 
&getState()->getStateManager().getContext().Idents.get(CD.FuncName);
-  if (getCalleeIdentifier() != CD.II)
+  }
+  const IdentifierInfo *II = getCalleeIdentifier();
+  if (!II || II != CD.II)
 return false;
   return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
   CD.RequiredArgs == getNumArgs());
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -55,6 +55,7 @@
 class CallDescription {
   friend CallEvent;
   mutable IdentifierInfo *II;
+  mutable bool IsLookupDone;
   StringRef FuncName;
   unsigned RequiredArgs;
 
@@ -68,7 +69,8 @@
   /// call. Omit this parameter to match every occurance of call with a given
   /// name regardless the number of arguments.
   CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
-  : II(nullptr), FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 
   /// \brief Get the name of the function that this object matches.
   StringRef getFunctionName() const { return FuncName; }


Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -212,9 +212,12 @@
 
 bool CallEvent::isCalled(const CallDescription &CD) const {
   assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
-  if (!CD.II)
+  if (!CD.IsLookupDone) {
+CD.IsLookupDone = true;
 CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName);
-  if (getCalleeIdentifier() != CD.II)
+  }
+  const IdentifierInfo *II = getCalleeIdentifier();
+  if (!II || II != CD.II)
 return false;
   return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
   CD.RequiredArgs == getNumArgs());
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -55,6 +55,7 @@
 class CallDescription {
   friend CallEvent;
   mutable IdentifierInfo *II;
+  mutable bool IsLookupDone;
   StringRef FuncName;
   unsigned RequiredArgs;
 
@@ -68,7 +69,8 @@
   /// call. Omit this parameter to match every occurance of call with a given
   /// name regardless the number of arguments.
   CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
-  : II(nullptr), FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 
   /// \brief Get the name of the function that this object matches.
   StringRef getFunctionName() const { return FuncName; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295186 - [analyzer] Proper caching in CallDescription objects.

2017-02-15 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed Feb 15 09:35:56 2017
New Revision: 295186

URL: http://llvm.org/viewvc/llvm-project?rev=295186&view=rev
Log:
[analyzer] Proper caching in CallDescription objects.

During the review of D29567 it turned out the caching in CallDescription is not 
implemented properly. In case an identifier does not exist in a translation 
unit, repeated identifier lookups will be done which might have bad impact on 
the performance. This patch guarantees that the lookup is only executed once. 
Moreover this patch fixes a corner case when the identifier of CallDescription 
does not exist in the translation unit and the called function does not have an 
identifier (e.g.: overloaded operator in C++).

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


Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=295186&r1=295185&r2=295186&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Wed 
Feb 15 09:35:56 2017
@@ -55,6 +55,7 @@ class CallEventManager;
 class CallDescription {
   friend CallEvent;
   mutable IdentifierInfo *II;
+  mutable bool IsLookupDone;
   StringRef FuncName;
   unsigned RequiredArgs;
 
@@ -68,7 +69,8 @@ public:
   /// call. Omit this parameter to match every occurance of call with a given
   /// name regardless the number of arguments.
   CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
-  : II(nullptr), FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 
   /// \brief Get the name of the function that this object matches.
   StringRef getFunctionName() const { return FuncName; }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=295186&r1=295185&r2=295186&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Wed Feb 15 09:35:56 2017
@@ -212,9 +212,12 @@ ProgramPoint CallEvent::getProgramPoint(
 
 bool CallEvent::isCalled(const CallDescription &CD) const {
   assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
-  if (!CD.II)
+  if (!CD.IsLookupDone) {
+CD.IsLookupDone = true;
 CD.II = 
&getState()->getStateManager().getContext().Idents.get(CD.FuncName);
-  if (getCalleeIdentifier() != CD.II)
+  }
+  const IdentifierInfo *II = getCalleeIdentifier();
+  if (!II || II != CD.II)
 return false;
   return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
   CD.RequiredArgs == getNumArgs());


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


[clang-tools-extra] r295184 - [clangd] Add missing include.

2017-02-15 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Feb 15 09:19:13 2017
New Revision: 295184

URL: http://llvm.org/viewvc/llvm-project?rev=295184&view=rev
Log:
[clangd] Add missing include.

Modified:
clang-tools-extra/trunk/clangd/DocumentStore.h

Modified: clang-tools-extra/trunk/clangd/DocumentStore.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/DocumentStore.h?rev=295184&r1=295183&r2=295184&view=diff
==
--- clang-tools-extra/trunk/clangd/DocumentStore.h (original)
+++ clang-tools-extra/trunk/clangd/DocumentStore.h Wed Feb 15 09:19:13 2017
@@ -14,6 +14,7 @@
 #include "llvm/ADT/StringMap.h"
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {


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


[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker

2017-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I sometimes wish ASTContext methods just didn't crash :)
Oh well, let's just see if more problems show up.




Comment at: lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp:93
 
 // Warn when there is widening cast.
 unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width;

I think we should move the check here then. That'd avoid double-checking if 
`ToPointeeTy` is a record type (we could `cast<>` directly on this branch).


Repository:
  rL LLVM

https://reviews.llvm.org/D28297



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


  1   2   >